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;
2345 cmdline_parse_token_string_t cmd_config_rss_port =
2346 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2347 cmdline_parse_token_string_t cmd_config_rss_keyword =
2348 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2349 cmdline_parse_token_string_t cmd_config_rss_all =
2350 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2351 cmdline_parse_token_string_t cmd_config_rss_name =
2352 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2353 cmdline_parse_token_string_t cmd_config_rss_value =
2354 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2356 cmdline_parse_inst_t cmd_config_rss = {
2357 .f = cmd_config_rss_parsed,
2359 .help_str = "port config all rss "
2360 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2362 (void *)&cmd_config_rss_port,
2363 (void *)&cmd_config_rss_keyword,
2364 (void *)&cmd_config_rss_all,
2365 (void *)&cmd_config_rss_name,
2366 (void *)&cmd_config_rss_value,
2371 /* *** configure rss hash key *** */
2372 struct cmd_config_rss_hash_key {
2373 cmdline_fixed_string_t port;
2374 cmdline_fixed_string_t config;
2376 cmdline_fixed_string_t rss_hash_key;
2377 cmdline_fixed_string_t rss_type;
2378 cmdline_fixed_string_t key;
2382 hexa_digit_to_value(char hexa_digit)
2384 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2385 return (uint8_t) (hexa_digit - '0');
2386 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2387 return (uint8_t) ((hexa_digit - 'a') + 10);
2388 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2389 return (uint8_t) ((hexa_digit - 'A') + 10);
2390 /* Invalid hexa digit */
2395 parse_and_check_key_hexa_digit(char *key, int idx)
2399 hexa_v = hexa_digit_to_value(key[idx]);
2401 printf("invalid key: character %c at position %d is not a "
2402 "valid hexa digit\n", key[idx], idx);
2407 cmd_config_rss_hash_key_parsed(void *parsed_result,
2408 __rte_unused struct cmdline *cl,
2409 __rte_unused void *data)
2411 struct cmd_config_rss_hash_key *res = parsed_result;
2412 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2416 struct rte_eth_dev_info dev_info;
2417 uint8_t hash_key_size;
2421 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2425 if (dev_info.hash_key_size > 0 &&
2426 dev_info.hash_key_size <= sizeof(hash_key))
2427 hash_key_size = dev_info.hash_key_size;
2429 printf("dev_info did not provide a valid hash key size\n");
2432 /* Check the length of the RSS hash key */
2433 key_len = strlen(res->key);
2434 if (key_len != (hash_key_size * 2)) {
2435 printf("key length: %d invalid - key must be a string of %d"
2436 " hexa-decimal numbers\n",
2437 (int) key_len, hash_key_size * 2);
2440 /* Translate RSS hash key into binary representation */
2441 for (i = 0; i < hash_key_size; i++) {
2442 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2445 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2448 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2450 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2454 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2455 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2456 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2457 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2459 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2460 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2461 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2462 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2463 rss_hash_key, "rss-hash-key");
2464 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2465 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2466 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2467 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2468 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2469 "ipv6-tcp-ex#ipv6-udp-ex#"
2470 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only");
2471 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2472 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2474 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2475 .f = cmd_config_rss_hash_key_parsed,
2477 .help_str = "port config <port_id> rss-hash-key "
2478 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2479 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2480 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2481 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only "
2482 "<string of hex digits (variable length, NIC dependent)>",
2484 (void *)&cmd_config_rss_hash_key_port,
2485 (void *)&cmd_config_rss_hash_key_config,
2486 (void *)&cmd_config_rss_hash_key_port_id,
2487 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2488 (void *)&cmd_config_rss_hash_key_rss_type,
2489 (void *)&cmd_config_rss_hash_key_value,
2494 /* *** configure port rxq/txq ring size *** */
2495 struct cmd_config_rxtx_ring_size {
2496 cmdline_fixed_string_t port;
2497 cmdline_fixed_string_t config;
2499 cmdline_fixed_string_t rxtxq;
2501 cmdline_fixed_string_t rsize;
2506 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2507 __rte_unused struct cmdline *cl,
2508 __rte_unused void *data)
2510 struct cmd_config_rxtx_ring_size *res = parsed_result;
2511 struct rte_port *port;
2514 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2517 if (res->portid == (portid_t)RTE_PORT_ALL) {
2518 printf("Invalid port id\n");
2522 port = &ports[res->portid];
2524 if (!strcmp(res->rxtxq, "rxq"))
2526 else if (!strcmp(res->rxtxq, "txq"))
2529 printf("Unknown parameter\n");
2533 if (isrx && rx_queue_id_is_invalid(res->qid))
2535 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2538 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2539 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2545 port->nb_rx_desc[res->qid] = res->size;
2547 port->nb_tx_desc[res->qid] = res->size;
2549 cmd_reconfig_device_queue(res->portid, 0, 1);
2552 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2553 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2555 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2556 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2558 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2559 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2561 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2562 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2564 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2565 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2567 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2568 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2569 rsize, "ring_size");
2570 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2571 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2574 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2575 .f = cmd_config_rxtx_ring_size_parsed,
2577 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2579 (void *)&cmd_config_rxtx_ring_size_port,
2580 (void *)&cmd_config_rxtx_ring_size_config,
2581 (void *)&cmd_config_rxtx_ring_size_portid,
2582 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2583 (void *)&cmd_config_rxtx_ring_size_qid,
2584 (void *)&cmd_config_rxtx_ring_size_rsize,
2585 (void *)&cmd_config_rxtx_ring_size_size,
2590 /* *** configure port rxq/txq start/stop *** */
2591 struct cmd_config_rxtx_queue {
2592 cmdline_fixed_string_t port;
2594 cmdline_fixed_string_t rxtxq;
2596 cmdline_fixed_string_t opname;
2600 cmd_config_rxtx_queue_parsed(void *parsed_result,
2601 __rte_unused struct cmdline *cl,
2602 __rte_unused void *data)
2604 struct cmd_config_rxtx_queue *res = parsed_result;
2609 if (test_done == 0) {
2610 printf("Please stop forwarding first\n");
2614 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2617 if (port_is_started(res->portid) != 1) {
2618 printf("Please start port %u first\n", res->portid);
2622 if (!strcmp(res->rxtxq, "rxq"))
2624 else if (!strcmp(res->rxtxq, "txq"))
2627 printf("Unknown parameter\n");
2631 if (isrx && rx_queue_id_is_invalid(res->qid))
2633 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2636 if (!strcmp(res->opname, "start"))
2638 else if (!strcmp(res->opname, "stop"))
2641 printf("Unknown parameter\n");
2645 if (isstart && isrx)
2646 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2647 else if (!isstart && isrx)
2648 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2649 else if (isstart && !isrx)
2650 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2652 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2654 if (ret == -ENOTSUP)
2655 printf("Function not supported in PMD driver\n");
2658 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2659 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2660 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2661 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2662 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2663 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2664 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2665 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2666 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2667 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2670 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2671 .f = cmd_config_rxtx_queue_parsed,
2673 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2675 (void *)&cmd_config_rxtx_queue_port,
2676 (void *)&cmd_config_rxtx_queue_portid,
2677 (void *)&cmd_config_rxtx_queue_rxtxq,
2678 (void *)&cmd_config_rxtx_queue_qid,
2679 (void *)&cmd_config_rxtx_queue_opname,
2684 /* *** configure port rxq/txq deferred start on/off *** */
2685 struct cmd_config_deferred_start_rxtx_queue {
2686 cmdline_fixed_string_t port;
2688 cmdline_fixed_string_t rxtxq;
2690 cmdline_fixed_string_t opname;
2691 cmdline_fixed_string_t state;
2695 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2696 __rte_unused struct cmdline *cl,
2697 __rte_unused void *data)
2699 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2700 struct rte_port *port;
2703 uint8_t needreconfig = 0;
2705 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2708 if (port_is_started(res->port_id) != 0) {
2709 printf("Please stop port %u first\n", res->port_id);
2713 port = &ports[res->port_id];
2715 isrx = !strcmp(res->rxtxq, "rxq");
2717 if (isrx && rx_queue_id_is_invalid(res->qid))
2719 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2722 ison = !strcmp(res->state, "on");
2724 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2725 port->rx_conf[res->qid].rx_deferred_start = ison;
2727 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2728 port->tx_conf[res->qid].tx_deferred_start = ison;
2733 cmd_reconfig_device_queue(res->port_id, 0, 1);
2736 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2737 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2739 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2740 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2742 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2743 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2745 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2746 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2748 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2749 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2750 opname, "deferred_start");
2751 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2752 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2755 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2756 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2758 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2760 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2761 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2762 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2763 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2764 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2765 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2770 /* *** configure port rxq/txq setup *** */
2771 struct cmd_setup_rxtx_queue {
2772 cmdline_fixed_string_t port;
2774 cmdline_fixed_string_t rxtxq;
2776 cmdline_fixed_string_t setup;
2779 /* Common CLI fields for queue setup */
2780 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2781 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2782 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2783 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2784 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2785 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2786 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2787 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2788 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2789 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2792 cmd_setup_rxtx_queue_parsed(
2793 void *parsed_result,
2794 __rte_unused struct cmdline *cl,
2795 __rte_unused void *data)
2797 struct cmd_setup_rxtx_queue *res = parsed_result;
2798 struct rte_port *port;
2799 struct rte_mempool *mp;
2800 unsigned int socket_id;
2804 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2807 if (res->portid == (portid_t)RTE_PORT_ALL) {
2808 printf("Invalid port id\n");
2812 if (!strcmp(res->rxtxq, "rxq"))
2814 else if (!strcmp(res->rxtxq, "txq"))
2817 printf("Unknown parameter\n");
2821 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2822 printf("Invalid rx queue\n");
2824 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2825 printf("Invalid tx queue\n");
2829 port = &ports[res->portid];
2831 socket_id = rxring_numa[res->portid];
2832 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2833 socket_id = port->socket_id;
2835 mp = mbuf_pool_find(socket_id);
2837 printf("Failed to setup RX queue: "
2838 "No mempool allocation"
2839 " on the socket %d\n",
2840 rxring_numa[res->portid]);
2843 ret = rte_eth_rx_queue_setup(res->portid,
2845 port->nb_rx_desc[res->qid],
2847 &port->rx_conf[res->qid],
2850 printf("Failed to setup RX queue\n");
2852 socket_id = txring_numa[res->portid];
2853 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2854 socket_id = port->socket_id;
2856 ret = rte_eth_tx_queue_setup(res->portid,
2858 port->nb_tx_desc[res->qid],
2860 &port->tx_conf[res->qid]);
2862 printf("Failed to setup TX queue\n");
2866 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2867 .f = cmd_setup_rxtx_queue_parsed,
2869 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2871 (void *)&cmd_setup_rxtx_queue_port,
2872 (void *)&cmd_setup_rxtx_queue_portid,
2873 (void *)&cmd_setup_rxtx_queue_rxtxq,
2874 (void *)&cmd_setup_rxtx_queue_qid,
2875 (void *)&cmd_setup_rxtx_queue_setup,
2881 /* *** Configure RSS RETA *** */
2882 struct cmd_config_rss_reta {
2883 cmdline_fixed_string_t port;
2884 cmdline_fixed_string_t keyword;
2886 cmdline_fixed_string_t name;
2887 cmdline_fixed_string_t list_name;
2888 cmdline_fixed_string_t list_of_items;
2892 parse_reta_config(const char *str,
2893 struct rte_eth_rss_reta_entry64 *reta_conf,
2894 uint16_t nb_entries)
2898 uint16_t hash_index, idx, shift;
2901 const char *p, *p0 = str;
2908 unsigned long int_fld[_NUM_FLD];
2909 char *str_fld[_NUM_FLD];
2911 while ((p = strchr(p0,'(')) != NULL) {
2913 if((p0 = strchr(p,')')) == NULL)
2917 if(size >= sizeof(s))
2920 snprintf(s, sizeof(s), "%.*s", size, p);
2921 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2923 for (i = 0; i < _NUM_FLD; i++) {
2925 int_fld[i] = strtoul(str_fld[i], &end, 0);
2926 if (errno != 0 || end == str_fld[i] ||
2931 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2932 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2934 if (hash_index >= nb_entries) {
2935 printf("Invalid RETA hash index=%d\n", hash_index);
2939 idx = hash_index / RTE_RETA_GROUP_SIZE;
2940 shift = hash_index % RTE_RETA_GROUP_SIZE;
2941 reta_conf[idx].mask |= (1ULL << shift);
2942 reta_conf[idx].reta[shift] = nb_queue;
2949 cmd_set_rss_reta_parsed(void *parsed_result,
2950 __rte_unused struct cmdline *cl,
2951 __rte_unused void *data)
2954 struct rte_eth_dev_info dev_info;
2955 struct rte_eth_rss_reta_entry64 reta_conf[8];
2956 struct cmd_config_rss_reta *res = parsed_result;
2958 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2962 if (dev_info.reta_size == 0) {
2963 printf("Redirection table size is 0 which is "
2964 "invalid for RSS\n");
2967 printf("The reta size of port %d is %u\n",
2968 res->port_id, dev_info.reta_size);
2969 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2970 printf("Currently do not support more than %u entries of "
2971 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2975 memset(reta_conf, 0, sizeof(reta_conf));
2976 if (!strcmp(res->list_name, "reta")) {
2977 if (parse_reta_config(res->list_of_items, reta_conf,
2978 dev_info.reta_size)) {
2979 printf("Invalid RSS Redirection Table "
2980 "config entered\n");
2983 ret = rte_eth_dev_rss_reta_update(res->port_id,
2984 reta_conf, dev_info.reta_size);
2986 printf("Bad redirection table parameter, "
2987 "return code = %d \n", ret);
2991 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2992 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2993 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2994 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2995 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2996 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2997 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2998 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2999 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3000 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3001 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3002 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3004 cmdline_parse_inst_t cmd_config_rss_reta = {
3005 .f = cmd_set_rss_reta_parsed,
3007 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3009 (void *)&cmd_config_rss_reta_port,
3010 (void *)&cmd_config_rss_reta_keyword,
3011 (void *)&cmd_config_rss_reta_port_id,
3012 (void *)&cmd_config_rss_reta_name,
3013 (void *)&cmd_config_rss_reta_list_name,
3014 (void *)&cmd_config_rss_reta_list_of_items,
3019 /* *** SHOW PORT RETA INFO *** */
3020 struct cmd_showport_reta {
3021 cmdline_fixed_string_t show;
3022 cmdline_fixed_string_t port;
3024 cmdline_fixed_string_t rss;
3025 cmdline_fixed_string_t reta;
3027 cmdline_fixed_string_t list_of_items;
3031 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3032 uint16_t nb_entries,
3036 const char *p, *p0 = str;
3041 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3042 RTE_RETA_GROUP_SIZE;
3045 p = strchr(p0, '(');
3049 p0 = strchr(p, ')');
3053 if (size >= sizeof(s)) {
3054 printf("The string size exceeds the internal buffer size\n");
3057 snprintf(s, sizeof(s), "%.*s", size, p);
3058 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3059 if (ret <= 0 || ret != num) {
3060 printf("The bits of masks do not match the number of "
3061 "reta entries: %u\n", num);
3064 for (i = 0; i < ret; i++)
3065 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3071 cmd_showport_reta_parsed(void *parsed_result,
3072 __rte_unused struct cmdline *cl,
3073 __rte_unused void *data)
3075 struct cmd_showport_reta *res = parsed_result;
3076 struct rte_eth_rss_reta_entry64 reta_conf[8];
3077 struct rte_eth_dev_info dev_info;
3078 uint16_t max_reta_size;
3081 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3085 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3086 if (res->size == 0 || res->size > max_reta_size) {
3087 printf("Invalid redirection table size: %u (1-%u)\n",
3088 res->size, max_reta_size);
3092 memset(reta_conf, 0, sizeof(reta_conf));
3093 if (showport_parse_reta_config(reta_conf, res->size,
3094 res->list_of_items) < 0) {
3095 printf("Invalid string: %s for reta masks\n",
3096 res->list_of_items);
3099 port_rss_reta_info(res->port_id, reta_conf, res->size);
3102 cmdline_parse_token_string_t cmd_showport_reta_show =
3103 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3104 cmdline_parse_token_string_t cmd_showport_reta_port =
3105 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3106 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3107 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3108 cmdline_parse_token_string_t cmd_showport_reta_rss =
3109 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3110 cmdline_parse_token_string_t cmd_showport_reta_reta =
3111 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3112 cmdline_parse_token_num_t cmd_showport_reta_size =
3113 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3114 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3115 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3116 list_of_items, NULL);
3118 cmdline_parse_inst_t cmd_showport_reta = {
3119 .f = cmd_showport_reta_parsed,
3121 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3123 (void *)&cmd_showport_reta_show,
3124 (void *)&cmd_showport_reta_port,
3125 (void *)&cmd_showport_reta_port_id,
3126 (void *)&cmd_showport_reta_rss,
3127 (void *)&cmd_showport_reta_reta,
3128 (void *)&cmd_showport_reta_size,
3129 (void *)&cmd_showport_reta_list_of_items,
3134 /* *** Show RSS hash configuration *** */
3135 struct cmd_showport_rss_hash {
3136 cmdline_fixed_string_t show;
3137 cmdline_fixed_string_t port;
3139 cmdline_fixed_string_t rss_hash;
3140 cmdline_fixed_string_t rss_type;
3141 cmdline_fixed_string_t key; /* optional argument */
3144 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3145 __rte_unused struct cmdline *cl,
3148 struct cmd_showport_rss_hash *res = parsed_result;
3150 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3153 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3154 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3155 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3156 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3157 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3158 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3159 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3160 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3162 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3163 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3165 cmdline_parse_inst_t cmd_showport_rss_hash = {
3166 .f = cmd_showport_rss_hash_parsed,
3168 .help_str = "show port <port_id> rss-hash",
3170 (void *)&cmd_showport_rss_hash_show,
3171 (void *)&cmd_showport_rss_hash_port,
3172 (void *)&cmd_showport_rss_hash_port_id,
3173 (void *)&cmd_showport_rss_hash_rss_hash,
3178 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3179 .f = cmd_showport_rss_hash_parsed,
3181 .help_str = "show port <port_id> rss-hash key",
3183 (void *)&cmd_showport_rss_hash_show,
3184 (void *)&cmd_showport_rss_hash_port,
3185 (void *)&cmd_showport_rss_hash_port_id,
3186 (void *)&cmd_showport_rss_hash_rss_hash,
3187 (void *)&cmd_showport_rss_hash_rss_key,
3192 /* *** Configure DCB *** */
3193 struct cmd_config_dcb {
3194 cmdline_fixed_string_t port;
3195 cmdline_fixed_string_t config;
3197 cmdline_fixed_string_t dcb;
3198 cmdline_fixed_string_t vt;
3199 cmdline_fixed_string_t vt_en;
3201 cmdline_fixed_string_t pfc;
3202 cmdline_fixed_string_t pfc_en;
3206 cmd_config_dcb_parsed(void *parsed_result,
3207 __rte_unused struct cmdline *cl,
3208 __rte_unused void *data)
3210 struct cmd_config_dcb *res = parsed_result;
3211 portid_t port_id = res->port_id;
3212 struct rte_port *port;
3216 port = &ports[port_id];
3217 /** Check if the port is not started **/
3218 if (port->port_status != RTE_PORT_STOPPED) {
3219 printf("Please stop port %d first\n", port_id);
3223 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3224 printf("The invalid number of traffic class,"
3225 " only 4 or 8 allowed.\n");
3229 if (nb_fwd_lcores < res->num_tcs) {
3230 printf("nb_cores shouldn't be less than number of TCs.\n");
3233 if (!strncmp(res->pfc_en, "on", 2))
3238 /* DCB in VT mode */
3239 if (!strncmp(res->vt_en, "on", 2))
3240 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3241 (enum rte_eth_nb_tcs)res->num_tcs,
3244 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3245 (enum rte_eth_nb_tcs)res->num_tcs,
3250 printf("Cannot initialize network ports.\n");
3254 cmd_reconfig_device_queue(port_id, 1, 1);
3257 cmdline_parse_token_string_t cmd_config_dcb_port =
3258 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3259 cmdline_parse_token_string_t cmd_config_dcb_config =
3260 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3261 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3262 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3263 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3264 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3265 cmdline_parse_token_string_t cmd_config_dcb_vt =
3266 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3267 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3268 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3269 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3270 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3271 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3272 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3273 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3274 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3276 cmdline_parse_inst_t cmd_config_dcb = {
3277 .f = cmd_config_dcb_parsed,
3279 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3281 (void *)&cmd_config_dcb_port,
3282 (void *)&cmd_config_dcb_config,
3283 (void *)&cmd_config_dcb_port_id,
3284 (void *)&cmd_config_dcb_dcb,
3285 (void *)&cmd_config_dcb_vt,
3286 (void *)&cmd_config_dcb_vt_en,
3287 (void *)&cmd_config_dcb_num_tcs,
3288 (void *)&cmd_config_dcb_pfc,
3289 (void *)&cmd_config_dcb_pfc_en,
3294 /* *** configure number of packets per burst *** */
3295 struct cmd_config_burst {
3296 cmdline_fixed_string_t port;
3297 cmdline_fixed_string_t keyword;
3298 cmdline_fixed_string_t all;
3299 cmdline_fixed_string_t name;
3304 cmd_config_burst_parsed(void *parsed_result,
3305 __rte_unused struct cmdline *cl,
3306 __rte_unused void *data)
3308 struct cmd_config_burst *res = parsed_result;
3309 struct rte_eth_dev_info dev_info;
3310 uint16_t rec_nb_pkts;
3313 if (!all_ports_stopped()) {
3314 printf("Please stop all ports first\n");
3318 if (!strcmp(res->name, "burst")) {
3319 if (res->value == 0) {
3320 /* If user gives a value of zero, query the PMD for
3321 * its recommended Rx burst size. Testpmd uses a single
3322 * size for all ports, so assume all ports are the same
3323 * NIC model and use the values from Port 0.
3325 ret = eth_dev_info_get_print_err(0, &dev_info);
3329 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3331 if (rec_nb_pkts == 0) {
3332 printf("PMD does not recommend a burst size.\n"
3333 "User provided value must be between"
3334 " 1 and %d\n", MAX_PKT_BURST);
3336 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3337 printf("PMD recommended burst size of %d"
3338 " exceeds maximum value of %d\n",
3339 rec_nb_pkts, MAX_PKT_BURST);
3342 printf("Using PMD-provided burst value of %d\n",
3344 nb_pkt_per_burst = rec_nb_pkts;
3345 } else if (res->value > MAX_PKT_BURST) {
3346 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3349 nb_pkt_per_burst = res->value;
3351 printf("Unknown parameter\n");
3357 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3360 cmdline_parse_token_string_t cmd_config_burst_port =
3361 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3362 cmdline_parse_token_string_t cmd_config_burst_keyword =
3363 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3364 cmdline_parse_token_string_t cmd_config_burst_all =
3365 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3366 cmdline_parse_token_string_t cmd_config_burst_name =
3367 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3368 cmdline_parse_token_num_t cmd_config_burst_value =
3369 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3371 cmdline_parse_inst_t cmd_config_burst = {
3372 .f = cmd_config_burst_parsed,
3374 .help_str = "port config all burst <value>",
3376 (void *)&cmd_config_burst_port,
3377 (void *)&cmd_config_burst_keyword,
3378 (void *)&cmd_config_burst_all,
3379 (void *)&cmd_config_burst_name,
3380 (void *)&cmd_config_burst_value,
3385 /* *** configure rx/tx queues *** */
3386 struct cmd_config_thresh {
3387 cmdline_fixed_string_t port;
3388 cmdline_fixed_string_t keyword;
3389 cmdline_fixed_string_t all;
3390 cmdline_fixed_string_t name;
3395 cmd_config_thresh_parsed(void *parsed_result,
3396 __rte_unused struct cmdline *cl,
3397 __rte_unused void *data)
3399 struct cmd_config_thresh *res = parsed_result;
3401 if (!all_ports_stopped()) {
3402 printf("Please stop all ports first\n");
3406 if (!strcmp(res->name, "txpt"))
3407 tx_pthresh = res->value;
3408 else if(!strcmp(res->name, "txht"))
3409 tx_hthresh = res->value;
3410 else if(!strcmp(res->name, "txwt"))
3411 tx_wthresh = res->value;
3412 else if(!strcmp(res->name, "rxpt"))
3413 rx_pthresh = res->value;
3414 else if(!strcmp(res->name, "rxht"))
3415 rx_hthresh = res->value;
3416 else if(!strcmp(res->name, "rxwt"))
3417 rx_wthresh = res->value;
3419 printf("Unknown parameter\n");
3425 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3428 cmdline_parse_token_string_t cmd_config_thresh_port =
3429 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3430 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3431 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3432 cmdline_parse_token_string_t cmd_config_thresh_all =
3433 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3434 cmdline_parse_token_string_t cmd_config_thresh_name =
3435 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3436 "txpt#txht#txwt#rxpt#rxht#rxwt");
3437 cmdline_parse_token_num_t cmd_config_thresh_value =
3438 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3440 cmdline_parse_inst_t cmd_config_thresh = {
3441 .f = cmd_config_thresh_parsed,
3443 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3445 (void *)&cmd_config_thresh_port,
3446 (void *)&cmd_config_thresh_keyword,
3447 (void *)&cmd_config_thresh_all,
3448 (void *)&cmd_config_thresh_name,
3449 (void *)&cmd_config_thresh_value,
3454 /* *** configure free/rs threshold *** */
3455 struct cmd_config_threshold {
3456 cmdline_fixed_string_t port;
3457 cmdline_fixed_string_t keyword;
3458 cmdline_fixed_string_t all;
3459 cmdline_fixed_string_t name;
3464 cmd_config_threshold_parsed(void *parsed_result,
3465 __rte_unused struct cmdline *cl,
3466 __rte_unused void *data)
3468 struct cmd_config_threshold *res = parsed_result;
3470 if (!all_ports_stopped()) {
3471 printf("Please stop all ports first\n");
3475 if (!strcmp(res->name, "txfreet"))
3476 tx_free_thresh = res->value;
3477 else if (!strcmp(res->name, "txrst"))
3478 tx_rs_thresh = res->value;
3479 else if (!strcmp(res->name, "rxfreet"))
3480 rx_free_thresh = res->value;
3482 printf("Unknown parameter\n");
3488 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3491 cmdline_parse_token_string_t cmd_config_threshold_port =
3492 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3493 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3494 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3496 cmdline_parse_token_string_t cmd_config_threshold_all =
3497 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3498 cmdline_parse_token_string_t cmd_config_threshold_name =
3499 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3500 "txfreet#txrst#rxfreet");
3501 cmdline_parse_token_num_t cmd_config_threshold_value =
3502 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3504 cmdline_parse_inst_t cmd_config_threshold = {
3505 .f = cmd_config_threshold_parsed,
3507 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3509 (void *)&cmd_config_threshold_port,
3510 (void *)&cmd_config_threshold_keyword,
3511 (void *)&cmd_config_threshold_all,
3512 (void *)&cmd_config_threshold_name,
3513 (void *)&cmd_config_threshold_value,
3519 struct cmd_stop_result {
3520 cmdline_fixed_string_t stop;
3523 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3524 __rte_unused struct cmdline *cl,
3525 __rte_unused void *data)
3527 stop_packet_forwarding();
3530 cmdline_parse_token_string_t cmd_stop_stop =
3531 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3533 cmdline_parse_inst_t cmd_stop = {
3534 .f = cmd_stop_parsed,
3536 .help_str = "stop: Stop packet forwarding",
3538 (void *)&cmd_stop_stop,
3543 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3546 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3547 unsigned int *parsed_items, int check_unique_values)
3549 unsigned int nb_item;
3557 * First parse all items in the list and store their value.
3562 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3564 if ((c >= '0') && (c <= '9')) {
3565 value = (unsigned int) (value * 10 + (c - '0'));
3570 printf("character %c is not a decimal digit\n", c);
3574 printf("No valid value before comma\n");
3577 if (nb_item < max_items) {
3578 parsed_items[nb_item] = value;
3584 if (nb_item >= max_items) {
3585 printf("Number of %s = %u > %u (maximum items)\n",
3586 item_name, nb_item + 1, max_items);
3589 parsed_items[nb_item++] = value;
3590 if (! check_unique_values)
3594 * Then, check that all values in the list are differents.
3595 * No optimization here...
3597 for (i = 0; i < nb_item; i++) {
3598 for (j = i + 1; j < nb_item; j++) {
3599 if (parsed_items[j] == parsed_items[i]) {
3600 printf("duplicated %s %u at index %u and %u\n",
3601 item_name, parsed_items[i], i, j);
3609 struct cmd_set_list_result {
3610 cmdline_fixed_string_t cmd_keyword;
3611 cmdline_fixed_string_t list_name;
3612 cmdline_fixed_string_t list_of_items;
3615 static void cmd_set_list_parsed(void *parsed_result,
3616 __rte_unused struct cmdline *cl,
3617 __rte_unused void *data)
3619 struct cmd_set_list_result *res;
3621 unsigned int lcorelist[RTE_MAX_LCORE];
3622 unsigned int portlist[RTE_MAX_ETHPORTS];
3624 unsigned int nb_item;
3626 if (test_done == 0) {
3627 printf("Please stop forwarding first\n");
3631 res = parsed_result;
3632 if (!strcmp(res->list_name, "corelist")) {
3633 nb_item = parse_item_list(res->list_of_items, "core",
3635 parsed_items.lcorelist, 1);
3637 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3642 if (!strcmp(res->list_name, "portlist")) {
3643 nb_item = parse_item_list(res->list_of_items, "port",
3645 parsed_items.portlist, 1);
3647 set_fwd_ports_list(parsed_items.portlist, nb_item);
3653 cmdline_parse_token_string_t cmd_set_list_keyword =
3654 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3656 cmdline_parse_token_string_t cmd_set_list_name =
3657 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3658 "corelist#portlist");
3659 cmdline_parse_token_string_t cmd_set_list_of_items =
3660 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3663 cmdline_parse_inst_t cmd_set_fwd_list = {
3664 .f = cmd_set_list_parsed,
3666 .help_str = "set corelist|portlist <list0[,list1]*>",
3668 (void *)&cmd_set_list_keyword,
3669 (void *)&cmd_set_list_name,
3670 (void *)&cmd_set_list_of_items,
3675 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3677 struct cmd_setmask_result {
3678 cmdline_fixed_string_t set;
3679 cmdline_fixed_string_t mask;
3683 static void cmd_set_mask_parsed(void *parsed_result,
3684 __rte_unused struct cmdline *cl,
3685 __rte_unused void *data)
3687 struct cmd_setmask_result *res = parsed_result;
3689 if (test_done == 0) {
3690 printf("Please stop forwarding first\n");
3693 if (!strcmp(res->mask, "coremask")) {
3694 set_fwd_lcores_mask(res->hexavalue);
3696 } else if (!strcmp(res->mask, "portmask")) {
3697 set_fwd_ports_mask(res->hexavalue);
3702 cmdline_parse_token_string_t cmd_setmask_set =
3703 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3704 cmdline_parse_token_string_t cmd_setmask_mask =
3705 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3706 "coremask#portmask");
3707 cmdline_parse_token_num_t cmd_setmask_value =
3708 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3710 cmdline_parse_inst_t cmd_set_fwd_mask = {
3711 .f = cmd_set_mask_parsed,
3713 .help_str = "set coremask|portmask <hexadecimal value>",
3715 (void *)&cmd_setmask_set,
3716 (void *)&cmd_setmask_mask,
3717 (void *)&cmd_setmask_value,
3723 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3725 struct cmd_set_result {
3726 cmdline_fixed_string_t set;
3727 cmdline_fixed_string_t what;
3731 static void cmd_set_parsed(void *parsed_result,
3732 __rte_unused struct cmdline *cl,
3733 __rte_unused void *data)
3735 struct cmd_set_result *res = parsed_result;
3736 if (!strcmp(res->what, "nbport")) {
3737 set_fwd_ports_number(res->value);
3739 } else if (!strcmp(res->what, "nbcore")) {
3740 set_fwd_lcores_number(res->value);
3742 } else if (!strcmp(res->what, "burst"))
3743 set_nb_pkt_per_burst(res->value);
3744 else if (!strcmp(res->what, "verbose"))
3745 set_verbose_level(res->value);
3748 cmdline_parse_token_string_t cmd_set_set =
3749 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3750 cmdline_parse_token_string_t cmd_set_what =
3751 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3752 "nbport#nbcore#burst#verbose");
3753 cmdline_parse_token_num_t cmd_set_value =
3754 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3756 cmdline_parse_inst_t cmd_set_numbers = {
3757 .f = cmd_set_parsed,
3759 .help_str = "set nbport|nbcore|burst|verbose <value>",
3761 (void *)&cmd_set_set,
3762 (void *)&cmd_set_what,
3763 (void *)&cmd_set_value,
3768 /* *** SET LOG LEVEL CONFIGURATION *** */
3770 struct cmd_set_log_result {
3771 cmdline_fixed_string_t set;
3772 cmdline_fixed_string_t log;
3773 cmdline_fixed_string_t type;
3778 cmd_set_log_parsed(void *parsed_result,
3779 __rte_unused struct cmdline *cl,
3780 __rte_unused void *data)
3782 struct cmd_set_log_result *res;
3785 res = parsed_result;
3786 if (!strcmp(res->type, "global"))
3787 rte_log_set_global_level(res->level);
3789 ret = rte_log_set_level_regexp(res->type, res->level);
3791 printf("Unable to set log level\n");
3795 cmdline_parse_token_string_t cmd_set_log_set =
3796 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3797 cmdline_parse_token_string_t cmd_set_log_log =
3798 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3799 cmdline_parse_token_string_t cmd_set_log_type =
3800 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3801 cmdline_parse_token_num_t cmd_set_log_level =
3802 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3804 cmdline_parse_inst_t cmd_set_log = {
3805 .f = cmd_set_log_parsed,
3807 .help_str = "set log global|<type> <level>",
3809 (void *)&cmd_set_log_set,
3810 (void *)&cmd_set_log_log,
3811 (void *)&cmd_set_log_type,
3812 (void *)&cmd_set_log_level,
3817 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3819 struct cmd_set_txpkts_result {
3820 cmdline_fixed_string_t cmd_keyword;
3821 cmdline_fixed_string_t txpkts;
3822 cmdline_fixed_string_t seg_lengths;
3826 cmd_set_txpkts_parsed(void *parsed_result,
3827 __rte_unused struct cmdline *cl,
3828 __rte_unused void *data)
3830 struct cmd_set_txpkts_result *res;
3831 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3832 unsigned int nb_segs;
3834 res = parsed_result;
3835 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3836 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3838 set_tx_pkt_segments(seg_lengths, nb_segs);
3841 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3842 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3843 cmd_keyword, "set");
3844 cmdline_parse_token_string_t cmd_set_txpkts_name =
3845 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3847 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3848 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3851 cmdline_parse_inst_t cmd_set_txpkts = {
3852 .f = cmd_set_txpkts_parsed,
3854 .help_str = "set txpkts <len0[,len1]*>",
3856 (void *)&cmd_set_txpkts_keyword,
3857 (void *)&cmd_set_txpkts_name,
3858 (void *)&cmd_set_txpkts_lengths,
3863 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3865 struct cmd_set_txsplit_result {
3866 cmdline_fixed_string_t cmd_keyword;
3867 cmdline_fixed_string_t txsplit;
3868 cmdline_fixed_string_t mode;
3872 cmd_set_txsplit_parsed(void *parsed_result,
3873 __rte_unused struct cmdline *cl,
3874 __rte_unused void *data)
3876 struct cmd_set_txsplit_result *res;
3878 res = parsed_result;
3879 set_tx_pkt_split(res->mode);
3882 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3883 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3884 cmd_keyword, "set");
3885 cmdline_parse_token_string_t cmd_set_txsplit_name =
3886 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3887 txsplit, "txsplit");
3888 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3889 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3892 cmdline_parse_inst_t cmd_set_txsplit = {
3893 .f = cmd_set_txsplit_parsed,
3895 .help_str = "set txsplit on|off|rand",
3897 (void *)&cmd_set_txsplit_keyword,
3898 (void *)&cmd_set_txsplit_name,
3899 (void *)&cmd_set_txsplit_mode,
3904 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3905 struct cmd_rx_vlan_filter_all_result {
3906 cmdline_fixed_string_t rx_vlan;
3907 cmdline_fixed_string_t what;
3908 cmdline_fixed_string_t all;
3913 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3914 __rte_unused struct cmdline *cl,
3915 __rte_unused void *data)
3917 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3919 if (!strcmp(res->what, "add"))
3920 rx_vlan_all_filter_set(res->port_id, 1);
3922 rx_vlan_all_filter_set(res->port_id, 0);
3925 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3926 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3927 rx_vlan, "rx_vlan");
3928 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3929 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3931 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3932 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3934 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3935 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3938 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3939 .f = cmd_rx_vlan_filter_all_parsed,
3941 .help_str = "rx_vlan add|rm all <port_id>: "
3942 "Add/Remove all identifiers to/from the set of VLAN "
3943 "identifiers filtered by a port",
3945 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3946 (void *)&cmd_rx_vlan_filter_all_what,
3947 (void *)&cmd_rx_vlan_filter_all_all,
3948 (void *)&cmd_rx_vlan_filter_all_portid,
3953 /* *** VLAN OFFLOAD SET ON A PORT *** */
3954 struct cmd_vlan_offload_result {
3955 cmdline_fixed_string_t vlan;
3956 cmdline_fixed_string_t set;
3957 cmdline_fixed_string_t vlan_type;
3958 cmdline_fixed_string_t what;
3959 cmdline_fixed_string_t on;
3960 cmdline_fixed_string_t port_id;
3964 cmd_vlan_offload_parsed(void *parsed_result,
3965 __rte_unused struct cmdline *cl,
3966 __rte_unused void *data)
3969 struct cmd_vlan_offload_result *res = parsed_result;
3972 portid_t port_id = 0;
3976 len = strnlen(str, STR_TOKEN_SIZE);
3978 /* Get port_id first */
3986 tmp = strtoul(str, NULL, 0);
3987 /* If port_id greater that what portid_t can represent, return */
3988 if(tmp >= RTE_MAX_ETHPORTS)
3990 port_id = (portid_t)tmp;
3992 if (!strcmp(res->on, "on"))
3997 if (!strcmp(res->what, "strip"))
3998 rx_vlan_strip_set(port_id, on);
3999 else if(!strcmp(res->what, "stripq")){
4000 uint16_t queue_id = 0;
4002 /* No queue_id, return */
4004 printf("must specify (port,queue_id)\n");
4007 tmp = strtoul(str + i + 1, NULL, 0);
4008 /* If queue_id greater that what 16-bits can represent, return */
4012 queue_id = (uint16_t)tmp;
4013 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4015 else if (!strcmp(res->what, "filter"))
4016 rx_vlan_filter_set(port_id, on);
4017 else if (!strcmp(res->what, "qinq_strip"))
4018 rx_vlan_qinq_strip_set(port_id, on);
4020 vlan_extend_set(port_id, on);
4025 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4026 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4028 cmdline_parse_token_string_t cmd_vlan_offload_set =
4029 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4031 cmdline_parse_token_string_t cmd_vlan_offload_what =
4032 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4033 what, "strip#filter#qinq_strip#extend#stripq");
4034 cmdline_parse_token_string_t cmd_vlan_offload_on =
4035 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4037 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4038 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4041 cmdline_parse_inst_t cmd_vlan_offload = {
4042 .f = cmd_vlan_offload_parsed,
4044 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4045 "<port_id[,queue_id]>: "
4046 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4048 (void *)&cmd_vlan_offload_vlan,
4049 (void *)&cmd_vlan_offload_set,
4050 (void *)&cmd_vlan_offload_what,
4051 (void *)&cmd_vlan_offload_on,
4052 (void *)&cmd_vlan_offload_portid,
4057 /* *** VLAN TPID SET ON A PORT *** */
4058 struct cmd_vlan_tpid_result {
4059 cmdline_fixed_string_t vlan;
4060 cmdline_fixed_string_t set;
4061 cmdline_fixed_string_t vlan_type;
4062 cmdline_fixed_string_t what;
4068 cmd_vlan_tpid_parsed(void *parsed_result,
4069 __rte_unused struct cmdline *cl,
4070 __rte_unused void *data)
4072 struct cmd_vlan_tpid_result *res = parsed_result;
4073 enum rte_vlan_type vlan_type;
4075 if (!strcmp(res->vlan_type, "inner"))
4076 vlan_type = ETH_VLAN_TYPE_INNER;
4077 else if (!strcmp(res->vlan_type, "outer"))
4078 vlan_type = ETH_VLAN_TYPE_OUTER;
4080 printf("Unknown vlan type\n");
4083 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4086 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4087 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4089 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4090 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4092 cmdline_parse_token_string_t cmd_vlan_type =
4093 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4094 vlan_type, "inner#outer");
4095 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4096 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4098 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4099 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4101 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4102 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4105 cmdline_parse_inst_t cmd_vlan_tpid = {
4106 .f = cmd_vlan_tpid_parsed,
4108 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4109 "Set the VLAN Ether type",
4111 (void *)&cmd_vlan_tpid_vlan,
4112 (void *)&cmd_vlan_tpid_set,
4113 (void *)&cmd_vlan_type,
4114 (void *)&cmd_vlan_tpid_what,
4115 (void *)&cmd_vlan_tpid_tpid,
4116 (void *)&cmd_vlan_tpid_portid,
4121 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4122 struct cmd_rx_vlan_filter_result {
4123 cmdline_fixed_string_t rx_vlan;
4124 cmdline_fixed_string_t what;
4130 cmd_rx_vlan_filter_parsed(void *parsed_result,
4131 __rte_unused struct cmdline *cl,
4132 __rte_unused void *data)
4134 struct cmd_rx_vlan_filter_result *res = parsed_result;
4136 if (!strcmp(res->what, "add"))
4137 rx_vft_set(res->port_id, res->vlan_id, 1);
4139 rx_vft_set(res->port_id, res->vlan_id, 0);
4142 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4143 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4144 rx_vlan, "rx_vlan");
4145 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4146 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4148 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4149 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4151 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4152 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4155 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4156 .f = cmd_rx_vlan_filter_parsed,
4158 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4159 "Add/Remove a VLAN identifier to/from the set of VLAN "
4160 "identifiers filtered by a port",
4162 (void *)&cmd_rx_vlan_filter_rx_vlan,
4163 (void *)&cmd_rx_vlan_filter_what,
4164 (void *)&cmd_rx_vlan_filter_vlanid,
4165 (void *)&cmd_rx_vlan_filter_portid,
4170 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4171 struct cmd_tx_vlan_set_result {
4172 cmdline_fixed_string_t tx_vlan;
4173 cmdline_fixed_string_t set;
4179 cmd_tx_vlan_set_parsed(void *parsed_result,
4180 __rte_unused struct cmdline *cl,
4181 __rte_unused void *data)
4183 struct cmd_tx_vlan_set_result *res = parsed_result;
4185 if (!port_is_stopped(res->port_id)) {
4186 printf("Please stop port %d first\n", res->port_id);
4190 tx_vlan_set(res->port_id, res->vlan_id);
4192 cmd_reconfig_device_queue(res->port_id, 1, 1);
4195 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4196 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4197 tx_vlan, "tx_vlan");
4198 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4199 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4201 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4202 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4204 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4205 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4208 cmdline_parse_inst_t cmd_tx_vlan_set = {
4209 .f = cmd_tx_vlan_set_parsed,
4211 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4212 "Enable hardware insertion of a single VLAN header "
4213 "with a given TAG Identifier in packets sent on a port",
4215 (void *)&cmd_tx_vlan_set_tx_vlan,
4216 (void *)&cmd_tx_vlan_set_set,
4217 (void *)&cmd_tx_vlan_set_portid,
4218 (void *)&cmd_tx_vlan_set_vlanid,
4223 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4224 struct cmd_tx_vlan_set_qinq_result {
4225 cmdline_fixed_string_t tx_vlan;
4226 cmdline_fixed_string_t set;
4229 uint16_t vlan_id_outer;
4233 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4234 __rte_unused struct cmdline *cl,
4235 __rte_unused void *data)
4237 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4239 if (!port_is_stopped(res->port_id)) {
4240 printf("Please stop port %d first\n", res->port_id);
4244 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4246 cmd_reconfig_device_queue(res->port_id, 1, 1);
4249 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4250 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4251 tx_vlan, "tx_vlan");
4252 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4253 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4255 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4256 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4258 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4259 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4261 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4262 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4263 vlan_id_outer, UINT16);
4265 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4266 .f = cmd_tx_vlan_set_qinq_parsed,
4268 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4269 "Enable hardware insertion of double VLAN header "
4270 "with given TAG Identifiers in packets sent on a port",
4272 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4273 (void *)&cmd_tx_vlan_set_qinq_set,
4274 (void *)&cmd_tx_vlan_set_qinq_portid,
4275 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4276 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4281 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4282 struct cmd_tx_vlan_set_pvid_result {
4283 cmdline_fixed_string_t tx_vlan;
4284 cmdline_fixed_string_t set;
4285 cmdline_fixed_string_t pvid;
4288 cmdline_fixed_string_t mode;
4292 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4293 __rte_unused struct cmdline *cl,
4294 __rte_unused void *data)
4296 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4298 if (strcmp(res->mode, "on") == 0)
4299 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4301 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4304 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4305 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4306 tx_vlan, "tx_vlan");
4307 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4308 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4310 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4311 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4313 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4314 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4316 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4317 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4319 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4320 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4323 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4324 .f = cmd_tx_vlan_set_pvid_parsed,
4326 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4328 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4329 (void *)&cmd_tx_vlan_set_pvid_set,
4330 (void *)&cmd_tx_vlan_set_pvid_pvid,
4331 (void *)&cmd_tx_vlan_set_pvid_port_id,
4332 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4333 (void *)&cmd_tx_vlan_set_pvid_mode,
4338 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4339 struct cmd_tx_vlan_reset_result {
4340 cmdline_fixed_string_t tx_vlan;
4341 cmdline_fixed_string_t reset;
4346 cmd_tx_vlan_reset_parsed(void *parsed_result,
4347 __rte_unused struct cmdline *cl,
4348 __rte_unused void *data)
4350 struct cmd_tx_vlan_reset_result *res = parsed_result;
4352 if (!port_is_stopped(res->port_id)) {
4353 printf("Please stop port %d first\n", res->port_id);
4357 tx_vlan_reset(res->port_id);
4359 cmd_reconfig_device_queue(res->port_id, 1, 1);
4362 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4363 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4364 tx_vlan, "tx_vlan");
4365 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4366 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4368 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4369 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4372 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4373 .f = cmd_tx_vlan_reset_parsed,
4375 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4376 "VLAN header in packets sent on a port",
4378 (void *)&cmd_tx_vlan_reset_tx_vlan,
4379 (void *)&cmd_tx_vlan_reset_reset,
4380 (void *)&cmd_tx_vlan_reset_portid,
4386 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4387 struct cmd_csum_result {
4388 cmdline_fixed_string_t csum;
4389 cmdline_fixed_string_t mode;
4390 cmdline_fixed_string_t proto;
4391 cmdline_fixed_string_t hwsw;
4396 csum_show(int port_id)
4398 struct rte_eth_dev_info dev_info;
4399 uint64_t tx_offloads;
4402 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4403 printf("Parse tunnel is %s\n",
4404 (ports[port_id].parse_tunnel) ? "on" : "off");
4405 printf("IP checksum offload is %s\n",
4406 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4407 printf("UDP checksum offload is %s\n",
4408 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4409 printf("TCP checksum offload is %s\n",
4410 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4411 printf("SCTP checksum offload is %s\n",
4412 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4413 printf("Outer-Ip checksum offload is %s\n",
4414 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4415 printf("Outer-Udp checksum offload is %s\n",
4416 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4418 /* display warnings if configuration is not supported by the NIC */
4419 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4423 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4424 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4425 printf("Warning: hardware IP checksum enabled but not "
4426 "supported by port %d\n", port_id);
4428 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4429 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4430 printf("Warning: hardware UDP checksum enabled but not "
4431 "supported by port %d\n", port_id);
4433 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4434 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4435 printf("Warning: hardware TCP checksum enabled but not "
4436 "supported by port %d\n", port_id);
4438 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4439 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4440 printf("Warning: hardware SCTP checksum enabled but not "
4441 "supported by port %d\n", port_id);
4443 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4444 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4445 printf("Warning: hardware outer IP checksum enabled but not "
4446 "supported by port %d\n", port_id);
4448 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4449 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4451 printf("Warning: hardware outer UDP checksum enabled but not "
4452 "supported by port %d\n", port_id);
4457 cmd_config_queue_tx_offloads(struct rte_port *port)
4461 /* Apply queue tx offloads configuration */
4462 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4463 port->tx_conf[k].offloads =
4464 port->dev_conf.txmode.offloads;
4468 cmd_csum_parsed(void *parsed_result,
4469 __rte_unused struct cmdline *cl,
4470 __rte_unused void *data)
4472 struct cmd_csum_result *res = parsed_result;
4474 uint64_t csum_offloads = 0;
4475 struct rte_eth_dev_info dev_info;
4478 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4479 printf("invalid port %d\n", res->port_id);
4482 if (!port_is_stopped(res->port_id)) {
4483 printf("Please stop port %d first\n", res->port_id);
4487 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4491 if (!strcmp(res->mode, "set")) {
4493 if (!strcmp(res->hwsw, "hw"))
4496 if (!strcmp(res->proto, "ip")) {
4497 if (hw == 0 || (dev_info.tx_offload_capa &
4498 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4499 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4501 printf("IP checksum offload is not supported "
4502 "by port %u\n", res->port_id);
4504 } else if (!strcmp(res->proto, "udp")) {
4505 if (hw == 0 || (dev_info.tx_offload_capa &
4506 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4507 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4509 printf("UDP checksum offload is not supported "
4510 "by port %u\n", res->port_id);
4512 } else if (!strcmp(res->proto, "tcp")) {
4513 if (hw == 0 || (dev_info.tx_offload_capa &
4514 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4515 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4517 printf("TCP checksum offload is not supported "
4518 "by port %u\n", res->port_id);
4520 } else if (!strcmp(res->proto, "sctp")) {
4521 if (hw == 0 || (dev_info.tx_offload_capa &
4522 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4523 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4525 printf("SCTP checksum offload is not supported "
4526 "by port %u\n", res->port_id);
4528 } else if (!strcmp(res->proto, "outer-ip")) {
4529 if (hw == 0 || (dev_info.tx_offload_capa &
4530 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4532 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4534 printf("Outer IP checksum offload is not "
4535 "supported by port %u\n", res->port_id);
4537 } else if (!strcmp(res->proto, "outer-udp")) {
4538 if (hw == 0 || (dev_info.tx_offload_capa &
4539 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4541 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4543 printf("Outer UDP checksum offload is not "
4544 "supported by port %u\n", res->port_id);
4549 ports[res->port_id].dev_conf.txmode.offloads |=
4552 ports[res->port_id].dev_conf.txmode.offloads &=
4555 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4557 csum_show(res->port_id);
4559 cmd_reconfig_device_queue(res->port_id, 1, 1);
4562 cmdline_parse_token_string_t cmd_csum_csum =
4563 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4565 cmdline_parse_token_string_t cmd_csum_mode =
4566 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4568 cmdline_parse_token_string_t cmd_csum_proto =
4569 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4570 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4571 cmdline_parse_token_string_t cmd_csum_hwsw =
4572 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4574 cmdline_parse_token_num_t cmd_csum_portid =
4575 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4578 cmdline_parse_inst_t cmd_csum_set = {
4579 .f = cmd_csum_parsed,
4581 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4582 "Enable/Disable hardware calculation of L3/L4 checksum when "
4583 "using csum forward engine",
4585 (void *)&cmd_csum_csum,
4586 (void *)&cmd_csum_mode,
4587 (void *)&cmd_csum_proto,
4588 (void *)&cmd_csum_hwsw,
4589 (void *)&cmd_csum_portid,
4594 cmdline_parse_token_string_t cmd_csum_mode_show =
4595 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4598 cmdline_parse_inst_t cmd_csum_show = {
4599 .f = cmd_csum_parsed,
4601 .help_str = "csum show <port_id>: Show checksum offload configuration",
4603 (void *)&cmd_csum_csum,
4604 (void *)&cmd_csum_mode_show,
4605 (void *)&cmd_csum_portid,
4610 /* Enable/disable tunnel parsing */
4611 struct cmd_csum_tunnel_result {
4612 cmdline_fixed_string_t csum;
4613 cmdline_fixed_string_t parse;
4614 cmdline_fixed_string_t onoff;
4619 cmd_csum_tunnel_parsed(void *parsed_result,
4620 __rte_unused struct cmdline *cl,
4621 __rte_unused void *data)
4623 struct cmd_csum_tunnel_result *res = parsed_result;
4625 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4628 if (!strcmp(res->onoff, "on"))
4629 ports[res->port_id].parse_tunnel = 1;
4631 ports[res->port_id].parse_tunnel = 0;
4633 csum_show(res->port_id);
4636 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4637 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4639 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4640 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4641 parse, "parse-tunnel");
4642 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4643 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4645 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4646 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4649 cmdline_parse_inst_t cmd_csum_tunnel = {
4650 .f = cmd_csum_tunnel_parsed,
4652 .help_str = "csum parse-tunnel on|off <port_id>: "
4653 "Enable/Disable parsing of tunnels for csum engine",
4655 (void *)&cmd_csum_tunnel_csum,
4656 (void *)&cmd_csum_tunnel_parse,
4657 (void *)&cmd_csum_tunnel_onoff,
4658 (void *)&cmd_csum_tunnel_portid,
4663 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4664 struct cmd_tso_set_result {
4665 cmdline_fixed_string_t tso;
4666 cmdline_fixed_string_t mode;
4672 cmd_tso_set_parsed(void *parsed_result,
4673 __rte_unused struct cmdline *cl,
4674 __rte_unused void *data)
4676 struct cmd_tso_set_result *res = parsed_result;
4677 struct rte_eth_dev_info dev_info;
4680 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4682 if (!port_is_stopped(res->port_id)) {
4683 printf("Please stop port %d first\n", res->port_id);
4687 if (!strcmp(res->mode, "set"))
4688 ports[res->port_id].tso_segsz = res->tso_segsz;
4690 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4694 if ((ports[res->port_id].tso_segsz != 0) &&
4695 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4696 printf("Error: TSO is not supported by port %d\n",
4701 if (ports[res->port_id].tso_segsz == 0) {
4702 ports[res->port_id].dev_conf.txmode.offloads &=
4703 ~DEV_TX_OFFLOAD_TCP_TSO;
4704 printf("TSO for non-tunneled packets is disabled\n");
4706 ports[res->port_id].dev_conf.txmode.offloads |=
4707 DEV_TX_OFFLOAD_TCP_TSO;
4708 printf("TSO segment size for non-tunneled packets is %d\n",
4709 ports[res->port_id].tso_segsz);
4711 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4713 /* display warnings if configuration is not supported by the NIC */
4714 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4718 if ((ports[res->port_id].tso_segsz != 0) &&
4719 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4720 printf("Warning: TSO enabled but not "
4721 "supported by port %d\n", res->port_id);
4724 cmd_reconfig_device_queue(res->port_id, 1, 1);
4727 cmdline_parse_token_string_t cmd_tso_set_tso =
4728 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4730 cmdline_parse_token_string_t cmd_tso_set_mode =
4731 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4733 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4734 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4736 cmdline_parse_token_num_t cmd_tso_set_portid =
4737 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4740 cmdline_parse_inst_t cmd_tso_set = {
4741 .f = cmd_tso_set_parsed,
4743 .help_str = "tso set <tso_segsz> <port_id>: "
4744 "Set TSO segment size of non-tunneled packets for csum engine "
4747 (void *)&cmd_tso_set_tso,
4748 (void *)&cmd_tso_set_mode,
4749 (void *)&cmd_tso_set_tso_segsz,
4750 (void *)&cmd_tso_set_portid,
4755 cmdline_parse_token_string_t cmd_tso_show_mode =
4756 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4760 cmdline_parse_inst_t cmd_tso_show = {
4761 .f = cmd_tso_set_parsed,
4763 .help_str = "tso show <port_id>: "
4764 "Show TSO segment size of non-tunneled packets for csum engine",
4766 (void *)&cmd_tso_set_tso,
4767 (void *)&cmd_tso_show_mode,
4768 (void *)&cmd_tso_set_portid,
4773 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4774 struct cmd_tunnel_tso_set_result {
4775 cmdline_fixed_string_t tso;
4776 cmdline_fixed_string_t mode;
4781 static struct rte_eth_dev_info
4782 check_tunnel_tso_nic_support(portid_t port_id)
4784 struct rte_eth_dev_info dev_info;
4786 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4789 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4790 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4791 "not enabled for port %d\n", port_id);
4792 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4793 printf("Warning: GRE TUNNEL TSO not supported therefore "
4794 "not enabled for port %d\n", port_id);
4795 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4796 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4797 "not enabled for port %d\n", port_id);
4798 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4799 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4800 "not enabled for port %d\n", port_id);
4801 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4802 printf("Warning: IP TUNNEL TSO not supported therefore "
4803 "not enabled for port %d\n", port_id);
4804 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4805 printf("Warning: UDP TUNNEL TSO not supported therefore "
4806 "not enabled for port %d\n", port_id);
4811 cmd_tunnel_tso_set_parsed(void *parsed_result,
4812 __rte_unused struct cmdline *cl,
4813 __rte_unused void *data)
4815 struct cmd_tunnel_tso_set_result *res = parsed_result;
4816 struct rte_eth_dev_info dev_info;
4818 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4820 if (!port_is_stopped(res->port_id)) {
4821 printf("Please stop port %d first\n", res->port_id);
4825 if (!strcmp(res->mode, "set"))
4826 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4828 dev_info = check_tunnel_tso_nic_support(res->port_id);
4829 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4830 ports[res->port_id].dev_conf.txmode.offloads &=
4831 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4832 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4833 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4834 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4835 DEV_TX_OFFLOAD_IP_TNL_TSO |
4836 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4837 printf("TSO for tunneled packets is disabled\n");
4839 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4840 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4841 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4842 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4843 DEV_TX_OFFLOAD_IP_TNL_TSO |
4844 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4846 ports[res->port_id].dev_conf.txmode.offloads |=
4847 (tso_offloads & dev_info.tx_offload_capa);
4848 printf("TSO segment size for tunneled packets is %d\n",
4849 ports[res->port_id].tunnel_tso_segsz);
4851 /* Below conditions are needed to make it work:
4852 * (1) tunnel TSO is supported by the NIC;
4853 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4855 * (3) for tunneled pkts with outer L3 of IPv4,
4856 * "csum set outer-ip" must be set to hw, because after tso,
4857 * total_len of outer IP header is changed, and the checksum
4858 * of outer IP header calculated by sw should be wrong; that
4859 * is not necessary for IPv6 tunneled pkts because there's no
4860 * checksum in IP header anymore.
4863 if (!ports[res->port_id].parse_tunnel)
4864 printf("Warning: csum parse_tunnel must be set "
4865 "so that tunneled packets are recognized\n");
4866 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4867 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4868 printf("Warning: csum set outer-ip must be set to hw "
4869 "if outer L3 is IPv4; not necessary for IPv6\n");
4872 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4873 cmd_reconfig_device_queue(res->port_id, 1, 1);
4876 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4877 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4879 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4880 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4882 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4883 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4885 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4886 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4889 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4890 .f = cmd_tunnel_tso_set_parsed,
4892 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4893 "Set TSO segment size of tunneled packets for csum engine "
4896 (void *)&cmd_tunnel_tso_set_tso,
4897 (void *)&cmd_tunnel_tso_set_mode,
4898 (void *)&cmd_tunnel_tso_set_tso_segsz,
4899 (void *)&cmd_tunnel_tso_set_portid,
4904 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4905 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4909 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4910 .f = cmd_tunnel_tso_set_parsed,
4912 .help_str = "tunnel_tso show <port_id> "
4913 "Show TSO segment size of tunneled packets for csum engine",
4915 (void *)&cmd_tunnel_tso_set_tso,
4916 (void *)&cmd_tunnel_tso_show_mode,
4917 (void *)&cmd_tunnel_tso_set_portid,
4922 /* *** SET GRO FOR A PORT *** */
4923 struct cmd_gro_enable_result {
4924 cmdline_fixed_string_t cmd_set;
4925 cmdline_fixed_string_t cmd_port;
4926 cmdline_fixed_string_t cmd_keyword;
4927 cmdline_fixed_string_t cmd_onoff;
4932 cmd_gro_enable_parsed(void *parsed_result,
4933 __rte_unused struct cmdline *cl,
4934 __rte_unused void *data)
4936 struct cmd_gro_enable_result *res;
4938 res = parsed_result;
4939 if (!strcmp(res->cmd_keyword, "gro"))
4940 setup_gro(res->cmd_onoff, res->cmd_pid);
4943 cmdline_parse_token_string_t cmd_gro_enable_set =
4944 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4946 cmdline_parse_token_string_t cmd_gro_enable_port =
4947 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4948 cmd_keyword, "port");
4949 cmdline_parse_token_num_t cmd_gro_enable_pid =
4950 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4952 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4953 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4954 cmd_keyword, "gro");
4955 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4956 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4957 cmd_onoff, "on#off");
4959 cmdline_parse_inst_t cmd_gro_enable = {
4960 .f = cmd_gro_enable_parsed,
4962 .help_str = "set port <port_id> gro on|off",
4964 (void *)&cmd_gro_enable_set,
4965 (void *)&cmd_gro_enable_port,
4966 (void *)&cmd_gro_enable_pid,
4967 (void *)&cmd_gro_enable_keyword,
4968 (void *)&cmd_gro_enable_onoff,
4973 /* *** DISPLAY GRO CONFIGURATION *** */
4974 struct cmd_gro_show_result {
4975 cmdline_fixed_string_t cmd_show;
4976 cmdline_fixed_string_t cmd_port;
4977 cmdline_fixed_string_t cmd_keyword;
4982 cmd_gro_show_parsed(void *parsed_result,
4983 __rte_unused struct cmdline *cl,
4984 __rte_unused void *data)
4986 struct cmd_gro_show_result *res;
4988 res = parsed_result;
4989 if (!strcmp(res->cmd_keyword, "gro"))
4990 show_gro(res->cmd_pid);
4993 cmdline_parse_token_string_t cmd_gro_show_show =
4994 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4996 cmdline_parse_token_string_t cmd_gro_show_port =
4997 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4999 cmdline_parse_token_num_t cmd_gro_show_pid =
5000 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5002 cmdline_parse_token_string_t cmd_gro_show_keyword =
5003 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5004 cmd_keyword, "gro");
5006 cmdline_parse_inst_t cmd_gro_show = {
5007 .f = cmd_gro_show_parsed,
5009 .help_str = "show port <port_id> gro",
5011 (void *)&cmd_gro_show_show,
5012 (void *)&cmd_gro_show_port,
5013 (void *)&cmd_gro_show_pid,
5014 (void *)&cmd_gro_show_keyword,
5019 /* *** SET FLUSH CYCLES FOR GRO *** */
5020 struct cmd_gro_flush_result {
5021 cmdline_fixed_string_t cmd_set;
5022 cmdline_fixed_string_t cmd_keyword;
5023 cmdline_fixed_string_t cmd_flush;
5028 cmd_gro_flush_parsed(void *parsed_result,
5029 __rte_unused struct cmdline *cl,
5030 __rte_unused void *data)
5032 struct cmd_gro_flush_result *res;
5034 res = parsed_result;
5035 if ((!strcmp(res->cmd_keyword, "gro")) &&
5036 (!strcmp(res->cmd_flush, "flush")))
5037 setup_gro_flush_cycles(res->cmd_cycles);
5040 cmdline_parse_token_string_t cmd_gro_flush_set =
5041 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5043 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5044 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5045 cmd_keyword, "gro");
5046 cmdline_parse_token_string_t cmd_gro_flush_flush =
5047 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5048 cmd_flush, "flush");
5049 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5050 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5053 cmdline_parse_inst_t cmd_gro_flush = {
5054 .f = cmd_gro_flush_parsed,
5056 .help_str = "set gro flush <cycles>",
5058 (void *)&cmd_gro_flush_set,
5059 (void *)&cmd_gro_flush_keyword,
5060 (void *)&cmd_gro_flush_flush,
5061 (void *)&cmd_gro_flush_cycles,
5066 /* *** ENABLE/DISABLE GSO *** */
5067 struct cmd_gso_enable_result {
5068 cmdline_fixed_string_t cmd_set;
5069 cmdline_fixed_string_t cmd_port;
5070 cmdline_fixed_string_t cmd_keyword;
5071 cmdline_fixed_string_t cmd_mode;
5076 cmd_gso_enable_parsed(void *parsed_result,
5077 __rte_unused struct cmdline *cl,
5078 __rte_unused void *data)
5080 struct cmd_gso_enable_result *res;
5082 res = parsed_result;
5083 if (!strcmp(res->cmd_keyword, "gso"))
5084 setup_gso(res->cmd_mode, res->cmd_pid);
5087 cmdline_parse_token_string_t cmd_gso_enable_set =
5088 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5090 cmdline_parse_token_string_t cmd_gso_enable_port =
5091 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5093 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5094 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5095 cmd_keyword, "gso");
5096 cmdline_parse_token_string_t cmd_gso_enable_mode =
5097 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5098 cmd_mode, "on#off");
5099 cmdline_parse_token_num_t cmd_gso_enable_pid =
5100 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5103 cmdline_parse_inst_t cmd_gso_enable = {
5104 .f = cmd_gso_enable_parsed,
5106 .help_str = "set port <port_id> gso on|off",
5108 (void *)&cmd_gso_enable_set,
5109 (void *)&cmd_gso_enable_port,
5110 (void *)&cmd_gso_enable_pid,
5111 (void *)&cmd_gso_enable_keyword,
5112 (void *)&cmd_gso_enable_mode,
5117 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5118 struct cmd_gso_size_result {
5119 cmdline_fixed_string_t cmd_set;
5120 cmdline_fixed_string_t cmd_keyword;
5121 cmdline_fixed_string_t cmd_segsz;
5126 cmd_gso_size_parsed(void *parsed_result,
5127 __rte_unused struct cmdline *cl,
5128 __rte_unused void *data)
5130 struct cmd_gso_size_result *res = parsed_result;
5132 if (test_done == 0) {
5133 printf("Before setting GSO segsz, please first"
5134 " stop fowarding\n");
5138 if (!strcmp(res->cmd_keyword, "gso") &&
5139 !strcmp(res->cmd_segsz, "segsz")) {
5140 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5141 printf("gso_size should be larger than %zu."
5142 " Please input a legal value\n",
5143 RTE_GSO_SEG_SIZE_MIN);
5145 gso_max_segment_size = res->cmd_size;
5149 cmdline_parse_token_string_t cmd_gso_size_set =
5150 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5152 cmdline_parse_token_string_t cmd_gso_size_keyword =
5153 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5154 cmd_keyword, "gso");
5155 cmdline_parse_token_string_t cmd_gso_size_segsz =
5156 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5157 cmd_segsz, "segsz");
5158 cmdline_parse_token_num_t cmd_gso_size_size =
5159 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5162 cmdline_parse_inst_t cmd_gso_size = {
5163 .f = cmd_gso_size_parsed,
5165 .help_str = "set gso segsz <length>",
5167 (void *)&cmd_gso_size_set,
5168 (void *)&cmd_gso_size_keyword,
5169 (void *)&cmd_gso_size_segsz,
5170 (void *)&cmd_gso_size_size,
5175 /* *** SHOW GSO CONFIGURATION *** */
5176 struct cmd_gso_show_result {
5177 cmdline_fixed_string_t cmd_show;
5178 cmdline_fixed_string_t cmd_port;
5179 cmdline_fixed_string_t cmd_keyword;
5184 cmd_gso_show_parsed(void *parsed_result,
5185 __rte_unused struct cmdline *cl,
5186 __rte_unused void *data)
5188 struct cmd_gso_show_result *res = parsed_result;
5190 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5191 printf("invalid port id %u\n", res->cmd_pid);
5194 if (!strcmp(res->cmd_keyword, "gso")) {
5195 if (gso_ports[res->cmd_pid].enable) {
5196 printf("Max GSO'd packet size: %uB\n"
5197 "Supported GSO types: TCP/IPv4, "
5198 "UDP/IPv4, VxLAN with inner "
5199 "TCP/IPv4 packet, GRE with inner "
5200 "TCP/IPv4 packet\n",
5201 gso_max_segment_size);
5203 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5207 cmdline_parse_token_string_t cmd_gso_show_show =
5208 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5210 cmdline_parse_token_string_t cmd_gso_show_port =
5211 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5213 cmdline_parse_token_string_t cmd_gso_show_keyword =
5214 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5215 cmd_keyword, "gso");
5216 cmdline_parse_token_num_t cmd_gso_show_pid =
5217 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5220 cmdline_parse_inst_t cmd_gso_show = {
5221 .f = cmd_gso_show_parsed,
5223 .help_str = "show port <port_id> gso",
5225 (void *)&cmd_gso_show_show,
5226 (void *)&cmd_gso_show_port,
5227 (void *)&cmd_gso_show_pid,
5228 (void *)&cmd_gso_show_keyword,
5233 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5234 struct cmd_set_flush_rx {
5235 cmdline_fixed_string_t set;
5236 cmdline_fixed_string_t flush_rx;
5237 cmdline_fixed_string_t mode;
5241 cmd_set_flush_rx_parsed(void *parsed_result,
5242 __rte_unused struct cmdline *cl,
5243 __rte_unused void *data)
5245 struct cmd_set_flush_rx *res = parsed_result;
5246 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5249 cmdline_parse_token_string_t cmd_setflushrx_set =
5250 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5252 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5253 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5254 flush_rx, "flush_rx");
5255 cmdline_parse_token_string_t cmd_setflushrx_mode =
5256 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5260 cmdline_parse_inst_t cmd_set_flush_rx = {
5261 .f = cmd_set_flush_rx_parsed,
5262 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5265 (void *)&cmd_setflushrx_set,
5266 (void *)&cmd_setflushrx_flush_rx,
5267 (void *)&cmd_setflushrx_mode,
5272 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5273 struct cmd_set_link_check {
5274 cmdline_fixed_string_t set;
5275 cmdline_fixed_string_t link_check;
5276 cmdline_fixed_string_t mode;
5280 cmd_set_link_check_parsed(void *parsed_result,
5281 __rte_unused struct cmdline *cl,
5282 __rte_unused void *data)
5284 struct cmd_set_link_check *res = parsed_result;
5285 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5288 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5289 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5291 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5292 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5293 link_check, "link_check");
5294 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5295 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5299 cmdline_parse_inst_t cmd_set_link_check = {
5300 .f = cmd_set_link_check_parsed,
5301 .help_str = "set link_check on|off: Enable/Disable link status check "
5302 "when starting/stopping a port",
5305 (void *)&cmd_setlinkcheck_set,
5306 (void *)&cmd_setlinkcheck_link_check,
5307 (void *)&cmd_setlinkcheck_mode,
5312 /* *** SET NIC BYPASS MODE *** */
5313 struct cmd_set_bypass_mode_result {
5314 cmdline_fixed_string_t set;
5315 cmdline_fixed_string_t bypass;
5316 cmdline_fixed_string_t mode;
5317 cmdline_fixed_string_t value;
5322 cmd_set_bypass_mode_parsed(void *parsed_result,
5323 __rte_unused struct cmdline *cl,
5324 __rte_unused void *data)
5326 struct cmd_set_bypass_mode_result *res = parsed_result;
5327 portid_t port_id = res->port_id;
5328 int32_t rc = -EINVAL;
5330 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5331 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5333 if (!strcmp(res->value, "bypass"))
5334 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5335 else if (!strcmp(res->value, "isolate"))
5336 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5338 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5340 /* Set the bypass mode for the relevant port. */
5341 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5344 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5347 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5348 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5350 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5351 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5353 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5354 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5356 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5357 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5358 value, "normal#bypass#isolate");
5359 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5360 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5363 cmdline_parse_inst_t cmd_set_bypass_mode = {
5364 .f = cmd_set_bypass_mode_parsed,
5365 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5366 "Set the NIC bypass mode for port_id",
5369 (void *)&cmd_setbypass_mode_set,
5370 (void *)&cmd_setbypass_mode_bypass,
5371 (void *)&cmd_setbypass_mode_mode,
5372 (void *)&cmd_setbypass_mode_value,
5373 (void *)&cmd_setbypass_mode_port,
5378 /* *** SET NIC BYPASS EVENT *** */
5379 struct cmd_set_bypass_event_result {
5380 cmdline_fixed_string_t set;
5381 cmdline_fixed_string_t bypass;
5382 cmdline_fixed_string_t event;
5383 cmdline_fixed_string_t event_value;
5384 cmdline_fixed_string_t mode;
5385 cmdline_fixed_string_t mode_value;
5390 cmd_set_bypass_event_parsed(void *parsed_result,
5391 __rte_unused struct cmdline *cl,
5392 __rte_unused void *data)
5394 int32_t rc = -EINVAL;
5395 struct cmd_set_bypass_event_result *res = parsed_result;
5396 portid_t port_id = res->port_id;
5398 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5399 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5400 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5402 if (!strcmp(res->event_value, "timeout"))
5403 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5404 else if (!strcmp(res->event_value, "os_on"))
5405 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5406 else if (!strcmp(res->event_value, "os_off"))
5407 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5408 else if (!strcmp(res->event_value, "power_on"))
5409 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5410 else if (!strcmp(res->event_value, "power_off"))
5411 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5413 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5415 if (!strcmp(res->mode_value, "bypass"))
5416 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5417 else if (!strcmp(res->mode_value, "isolate"))
5418 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5420 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5422 /* Set the watchdog timeout. */
5423 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5426 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5427 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5431 printf("Failed to set timeout value %u "
5432 "for port %d, errto code: %d.\n",
5433 bypass_timeout, port_id, rc);
5437 /* Set the bypass event to transition to bypass mode. */
5438 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5443 printf("\t Failed to set bypass event for port = %d.\n",
5447 cmdline_parse_token_string_t cmd_setbypass_event_set =
5448 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5450 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5451 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5453 cmdline_parse_token_string_t cmd_setbypass_event_event =
5454 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5456 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5457 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5458 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5459 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5460 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5462 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5463 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5464 mode_value, "normal#bypass#isolate");
5465 cmdline_parse_token_num_t cmd_setbypass_event_port =
5466 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5469 cmdline_parse_inst_t cmd_set_bypass_event = {
5470 .f = cmd_set_bypass_event_parsed,
5471 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5472 "power_off mode normal|bypass|isolate <port_id>: "
5473 "Set the NIC bypass event mode for port_id",
5476 (void *)&cmd_setbypass_event_set,
5477 (void *)&cmd_setbypass_event_bypass,
5478 (void *)&cmd_setbypass_event_event,
5479 (void *)&cmd_setbypass_event_event_value,
5480 (void *)&cmd_setbypass_event_mode,
5481 (void *)&cmd_setbypass_event_mode_value,
5482 (void *)&cmd_setbypass_event_port,
5488 /* *** SET NIC BYPASS TIMEOUT *** */
5489 struct cmd_set_bypass_timeout_result {
5490 cmdline_fixed_string_t set;
5491 cmdline_fixed_string_t bypass;
5492 cmdline_fixed_string_t timeout;
5493 cmdline_fixed_string_t value;
5497 cmd_set_bypass_timeout_parsed(void *parsed_result,
5498 __rte_unused struct cmdline *cl,
5499 __rte_unused void *data)
5501 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5503 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5504 if (!strcmp(res->value, "1.5"))
5505 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5506 else if (!strcmp(res->value, "2"))
5507 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5508 else if (!strcmp(res->value, "3"))
5509 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5510 else if (!strcmp(res->value, "4"))
5511 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5512 else if (!strcmp(res->value, "8"))
5513 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5514 else if (!strcmp(res->value, "16"))
5515 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5516 else if (!strcmp(res->value, "32"))
5517 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5519 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5523 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5524 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5526 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5527 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5529 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5530 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5531 timeout, "timeout");
5532 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5533 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5534 value, "0#1.5#2#3#4#8#16#32");
5536 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5537 .f = cmd_set_bypass_timeout_parsed,
5538 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5539 "Set the NIC bypass watchdog timeout in seconds",
5542 (void *)&cmd_setbypass_timeout_set,
5543 (void *)&cmd_setbypass_timeout_bypass,
5544 (void *)&cmd_setbypass_timeout_timeout,
5545 (void *)&cmd_setbypass_timeout_value,
5550 /* *** SHOW NIC BYPASS MODE *** */
5551 struct cmd_show_bypass_config_result {
5552 cmdline_fixed_string_t show;
5553 cmdline_fixed_string_t bypass;
5554 cmdline_fixed_string_t config;
5559 cmd_show_bypass_config_parsed(void *parsed_result,
5560 __rte_unused struct cmdline *cl,
5561 __rte_unused void *data)
5563 struct cmd_show_bypass_config_result *res = parsed_result;
5564 portid_t port_id = res->port_id;
5566 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5567 uint32_t event_mode;
5568 uint32_t bypass_mode;
5569 uint32_t timeout = bypass_timeout;
5572 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5573 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5574 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5575 {"UNKNOWN", "normal", "bypass", "isolate"};
5576 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5584 /* Display the bypass mode.*/
5585 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5586 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5590 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5591 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5593 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5596 /* Display the bypass timeout.*/
5597 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5598 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5600 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5602 /* Display the bypass events and associated modes. */
5603 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5605 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5606 printf("\tFailed to get bypass mode for event = %s\n",
5609 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5610 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5612 printf("\tbypass event: %-16s = %s\n", events[i],
5618 printf("\tFailed to get bypass configuration for port = %d\n",
5622 cmdline_parse_token_string_t cmd_showbypass_config_show =
5623 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5625 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5626 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5628 cmdline_parse_token_string_t cmd_showbypass_config_config =
5629 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5631 cmdline_parse_token_num_t cmd_showbypass_config_port =
5632 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5635 cmdline_parse_inst_t cmd_show_bypass_config = {
5636 .f = cmd_show_bypass_config_parsed,
5637 .help_str = "show bypass config <port_id>: "
5638 "Show the NIC bypass config for port_id",
5641 (void *)&cmd_showbypass_config_show,
5642 (void *)&cmd_showbypass_config_bypass,
5643 (void *)&cmd_showbypass_config_config,
5644 (void *)&cmd_showbypass_config_port,
5649 #ifdef RTE_LIBRTE_PMD_BOND
5650 /* *** SET BONDING MODE *** */
5651 struct cmd_set_bonding_mode_result {
5652 cmdline_fixed_string_t set;
5653 cmdline_fixed_string_t bonding;
5654 cmdline_fixed_string_t mode;
5659 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5660 __rte_unused struct cmdline *cl,
5661 __rte_unused void *data)
5663 struct cmd_set_bonding_mode_result *res = parsed_result;
5664 portid_t port_id = res->port_id;
5666 /* Set the bonding mode for the relevant port. */
5667 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5668 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5671 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5672 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5674 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5675 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5676 bonding, "bonding");
5677 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5678 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5680 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5681 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5683 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5684 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5687 cmdline_parse_inst_t cmd_set_bonding_mode = {
5688 .f = cmd_set_bonding_mode_parsed,
5689 .help_str = "set bonding mode <mode_value> <port_id>: "
5690 "Set the bonding mode for port_id",
5693 (void *) &cmd_setbonding_mode_set,
5694 (void *) &cmd_setbonding_mode_bonding,
5695 (void *) &cmd_setbonding_mode_mode,
5696 (void *) &cmd_setbonding_mode_value,
5697 (void *) &cmd_setbonding_mode_port,
5702 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5703 struct cmd_set_bonding_lacp_dedicated_queues_result {
5704 cmdline_fixed_string_t set;
5705 cmdline_fixed_string_t bonding;
5706 cmdline_fixed_string_t lacp;
5707 cmdline_fixed_string_t dedicated_queues;
5709 cmdline_fixed_string_t mode;
5712 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5713 __rte_unused struct cmdline *cl,
5714 __rte_unused void *data)
5716 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5717 portid_t port_id = res->port_id;
5718 struct rte_port *port;
5720 port = &ports[port_id];
5722 /** Check if the port is not started **/
5723 if (port->port_status != RTE_PORT_STOPPED) {
5724 printf("Please stop port %d first\n", port_id);
5728 if (!strcmp(res->mode, "enable")) {
5729 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5730 printf("Dedicate queues for LACP control packets"
5733 printf("Enabling dedicate queues for LACP control "
5734 "packets on port %d failed\n", port_id);
5735 } else if (!strcmp(res->mode, "disable")) {
5736 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5737 printf("Dedicated queues for LACP control packets "
5740 printf("Disabling dedicated queues for LACP control "
5741 "traffic on port %d failed\n", port_id);
5745 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5746 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5748 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5749 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5750 bonding, "bonding");
5751 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5752 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5754 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5755 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5756 dedicated_queues, "dedicated_queues");
5757 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5758 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5760 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5762 mode, "enable#disable");
5764 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5765 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5766 .help_str = "set bonding lacp dedicated_queues <port_id> "
5768 "Enable/disable dedicated queues for LACP control traffic for port_id",
5771 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5772 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5773 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5774 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5775 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5776 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5781 /* *** SET BALANCE XMIT POLICY *** */
5782 struct cmd_set_bonding_balance_xmit_policy_result {
5783 cmdline_fixed_string_t set;
5784 cmdline_fixed_string_t bonding;
5785 cmdline_fixed_string_t balance_xmit_policy;
5787 cmdline_fixed_string_t policy;
5790 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5791 __rte_unused struct cmdline *cl,
5792 __rte_unused void *data)
5794 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5795 portid_t port_id = res->port_id;
5798 if (!strcmp(res->policy, "l2")) {
5799 policy = BALANCE_XMIT_POLICY_LAYER2;
5800 } else if (!strcmp(res->policy, "l23")) {
5801 policy = BALANCE_XMIT_POLICY_LAYER23;
5802 } else if (!strcmp(res->policy, "l34")) {
5803 policy = BALANCE_XMIT_POLICY_LAYER34;
5805 printf("\t Invalid xmit policy selection");
5809 /* Set the bonding mode for the relevant port. */
5810 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5811 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5816 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5817 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5819 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5820 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5821 bonding, "bonding");
5822 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5823 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5824 balance_xmit_policy, "balance_xmit_policy");
5825 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5826 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5828 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5829 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5830 policy, "l2#l23#l34");
5832 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5833 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5834 .help_str = "set bonding balance_xmit_policy <port_id> "
5836 "Set the bonding balance_xmit_policy for port_id",
5839 (void *)&cmd_setbonding_balance_xmit_policy_set,
5840 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5841 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5842 (void *)&cmd_setbonding_balance_xmit_policy_port,
5843 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5848 /* *** SHOW NIC BONDING CONFIGURATION *** */
5849 struct cmd_show_bonding_config_result {
5850 cmdline_fixed_string_t show;
5851 cmdline_fixed_string_t bonding;
5852 cmdline_fixed_string_t config;
5856 static void cmd_show_bonding_config_parsed(void *parsed_result,
5857 __rte_unused struct cmdline *cl,
5858 __rte_unused void *data)
5860 struct cmd_show_bonding_config_result *res = parsed_result;
5861 int bonding_mode, agg_mode;
5862 portid_t slaves[RTE_MAX_ETHPORTS];
5863 int num_slaves, num_active_slaves;
5866 portid_t port_id = res->port_id;
5868 /* Display the bonding mode.*/
5869 bonding_mode = rte_eth_bond_mode_get(port_id);
5870 if (bonding_mode < 0) {
5871 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5874 printf("\tBonding mode: %d\n", bonding_mode);
5876 if (bonding_mode == BONDING_MODE_BALANCE) {
5877 int balance_xmit_policy;
5879 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5880 if (balance_xmit_policy < 0) {
5881 printf("\tFailed to get balance xmit policy for port = %d\n",
5885 printf("\tBalance Xmit Policy: ");
5887 switch (balance_xmit_policy) {
5888 case BALANCE_XMIT_POLICY_LAYER2:
5889 printf("BALANCE_XMIT_POLICY_LAYER2");
5891 case BALANCE_XMIT_POLICY_LAYER23:
5892 printf("BALANCE_XMIT_POLICY_LAYER23");
5894 case BALANCE_XMIT_POLICY_LAYER34:
5895 printf("BALANCE_XMIT_POLICY_LAYER34");
5902 if (bonding_mode == BONDING_MODE_8023AD) {
5903 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5904 printf("\tIEEE802.3AD Aggregator Mode: ");
5907 printf("bandwidth");
5919 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5921 if (num_slaves < 0) {
5922 printf("\tFailed to get slave list for port = %d\n", port_id);
5925 if (num_slaves > 0) {
5926 printf("\tSlaves (%d): [", num_slaves);
5927 for (i = 0; i < num_slaves - 1; i++)
5928 printf("%d ", slaves[i]);
5930 printf("%d]\n", slaves[num_slaves - 1]);
5932 printf("\tSlaves: []\n");
5936 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5939 if (num_active_slaves < 0) {
5940 printf("\tFailed to get active slave list for port = %d\n", port_id);
5943 if (num_active_slaves > 0) {
5944 printf("\tActive Slaves (%d): [", num_active_slaves);
5945 for (i = 0; i < num_active_slaves - 1; i++)
5946 printf("%d ", slaves[i]);
5948 printf("%d]\n", slaves[num_active_slaves - 1]);
5951 printf("\tActive Slaves: []\n");
5955 primary_id = rte_eth_bond_primary_get(port_id);
5956 if (primary_id < 0) {
5957 printf("\tFailed to get primary slave for port = %d\n", port_id);
5960 printf("\tPrimary: [%d]\n", primary_id);
5964 cmdline_parse_token_string_t cmd_showbonding_config_show =
5965 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5967 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5968 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5969 bonding, "bonding");
5970 cmdline_parse_token_string_t cmd_showbonding_config_config =
5971 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5973 cmdline_parse_token_num_t cmd_showbonding_config_port =
5974 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5977 cmdline_parse_inst_t cmd_show_bonding_config = {
5978 .f = cmd_show_bonding_config_parsed,
5979 .help_str = "show bonding config <port_id>: "
5980 "Show the bonding config for port_id",
5983 (void *)&cmd_showbonding_config_show,
5984 (void *)&cmd_showbonding_config_bonding,
5985 (void *)&cmd_showbonding_config_config,
5986 (void *)&cmd_showbonding_config_port,
5991 /* *** SET BONDING PRIMARY *** */
5992 struct cmd_set_bonding_primary_result {
5993 cmdline_fixed_string_t set;
5994 cmdline_fixed_string_t bonding;
5995 cmdline_fixed_string_t primary;
6000 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6001 __rte_unused struct cmdline *cl,
6002 __rte_unused void *data)
6004 struct cmd_set_bonding_primary_result *res = parsed_result;
6005 portid_t master_port_id = res->port_id;
6006 portid_t slave_port_id = res->slave_id;
6008 /* Set the primary slave for a bonded device. */
6009 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6010 printf("\t Failed to set primary slave for port = %d.\n",
6017 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6018 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6020 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6021 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6022 bonding, "bonding");
6023 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6024 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6025 primary, "primary");
6026 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6027 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6029 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6030 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6033 cmdline_parse_inst_t cmd_set_bonding_primary = {
6034 .f = cmd_set_bonding_primary_parsed,
6035 .help_str = "set bonding primary <slave_id> <port_id>: "
6036 "Set the primary slave for port_id",
6039 (void *)&cmd_setbonding_primary_set,
6040 (void *)&cmd_setbonding_primary_bonding,
6041 (void *)&cmd_setbonding_primary_primary,
6042 (void *)&cmd_setbonding_primary_slave,
6043 (void *)&cmd_setbonding_primary_port,
6048 /* *** ADD SLAVE *** */
6049 struct cmd_add_bonding_slave_result {
6050 cmdline_fixed_string_t add;
6051 cmdline_fixed_string_t bonding;
6052 cmdline_fixed_string_t slave;
6057 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6058 __rte_unused struct cmdline *cl,
6059 __rte_unused void *data)
6061 struct cmd_add_bonding_slave_result *res = parsed_result;
6062 portid_t master_port_id = res->port_id;
6063 portid_t slave_port_id = res->slave_id;
6065 /* add the slave for a bonded device. */
6066 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6067 printf("\t Failed to add slave %d to master port = %d.\n",
6068 slave_port_id, master_port_id);
6072 set_port_slave_flag(slave_port_id);
6075 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6076 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6078 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6079 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6080 bonding, "bonding");
6081 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6082 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6084 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6085 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6087 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6088 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6091 cmdline_parse_inst_t cmd_add_bonding_slave = {
6092 .f = cmd_add_bonding_slave_parsed,
6093 .help_str = "add bonding slave <slave_id> <port_id>: "
6094 "Add a slave device to a bonded device",
6097 (void *)&cmd_addbonding_slave_add,
6098 (void *)&cmd_addbonding_slave_bonding,
6099 (void *)&cmd_addbonding_slave_slave,
6100 (void *)&cmd_addbonding_slave_slaveid,
6101 (void *)&cmd_addbonding_slave_port,
6106 /* *** REMOVE SLAVE *** */
6107 struct cmd_remove_bonding_slave_result {
6108 cmdline_fixed_string_t remove;
6109 cmdline_fixed_string_t bonding;
6110 cmdline_fixed_string_t slave;
6115 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6116 __rte_unused struct cmdline *cl,
6117 __rte_unused void *data)
6119 struct cmd_remove_bonding_slave_result *res = parsed_result;
6120 portid_t master_port_id = res->port_id;
6121 portid_t slave_port_id = res->slave_id;
6123 /* remove the slave from a bonded device. */
6124 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6125 printf("\t Failed to remove slave %d from master port = %d.\n",
6126 slave_port_id, master_port_id);
6130 clear_port_slave_flag(slave_port_id);
6133 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6134 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6136 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6137 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6138 bonding, "bonding");
6139 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6140 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6142 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6143 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6145 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6146 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6149 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6150 .f = cmd_remove_bonding_slave_parsed,
6151 .help_str = "remove bonding slave <slave_id> <port_id>: "
6152 "Remove a slave device from a bonded device",
6155 (void *)&cmd_removebonding_slave_remove,
6156 (void *)&cmd_removebonding_slave_bonding,
6157 (void *)&cmd_removebonding_slave_slave,
6158 (void *)&cmd_removebonding_slave_slaveid,
6159 (void *)&cmd_removebonding_slave_port,
6164 /* *** CREATE BONDED DEVICE *** */
6165 struct cmd_create_bonded_device_result {
6166 cmdline_fixed_string_t create;
6167 cmdline_fixed_string_t bonded;
6168 cmdline_fixed_string_t device;
6173 static int bond_dev_num = 0;
6175 static void cmd_create_bonded_device_parsed(void *parsed_result,
6176 __rte_unused struct cmdline *cl,
6177 __rte_unused void *data)
6179 struct cmd_create_bonded_device_result *res = parsed_result;
6180 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6184 if (test_done == 0) {
6185 printf("Please stop forwarding first\n");
6189 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6192 /* Create a new bonded device. */
6193 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6195 printf("\t Failed to create bonded device.\n");
6198 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6201 /* Update number of ports */
6202 nb_ports = rte_eth_dev_count_avail();
6203 reconfig(port_id, res->socket);
6204 ret = rte_eth_promiscuous_enable(port_id);
6206 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6207 port_id, rte_strerror(-ret));
6209 ports[port_id].need_setup = 0;
6210 ports[port_id].port_status = RTE_PORT_STOPPED;
6215 cmdline_parse_token_string_t cmd_createbonded_device_create =
6216 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6218 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6219 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6221 cmdline_parse_token_string_t cmd_createbonded_device_device =
6222 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6224 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6225 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6227 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6228 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6231 cmdline_parse_inst_t cmd_create_bonded_device = {
6232 .f = cmd_create_bonded_device_parsed,
6233 .help_str = "create bonded device <mode> <socket>: "
6234 "Create a new bonded device with specific bonding mode and socket",
6237 (void *)&cmd_createbonded_device_create,
6238 (void *)&cmd_createbonded_device_bonded,
6239 (void *)&cmd_createbonded_device_device,
6240 (void *)&cmd_createbonded_device_mode,
6241 (void *)&cmd_createbonded_device_socket,
6246 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6247 struct cmd_set_bond_mac_addr_result {
6248 cmdline_fixed_string_t set;
6249 cmdline_fixed_string_t bonding;
6250 cmdline_fixed_string_t mac_addr;
6252 struct rte_ether_addr address;
6255 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6256 __rte_unused struct cmdline *cl,
6257 __rte_unused void *data)
6259 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6262 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6265 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6267 /* check the return value and print it if is < 0 */
6269 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6272 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6273 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6274 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6275 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6277 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6278 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6280 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6281 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6283 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6284 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6286 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6287 .f = cmd_set_bond_mac_addr_parsed,
6289 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6291 (void *)&cmd_set_bond_mac_addr_set,
6292 (void *)&cmd_set_bond_mac_addr_bonding,
6293 (void *)&cmd_set_bond_mac_addr_mac,
6294 (void *)&cmd_set_bond_mac_addr_portnum,
6295 (void *)&cmd_set_bond_mac_addr_addr,
6301 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6302 struct cmd_set_bond_mon_period_result {
6303 cmdline_fixed_string_t set;
6304 cmdline_fixed_string_t bonding;
6305 cmdline_fixed_string_t mon_period;
6310 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6311 __rte_unused struct cmdline *cl,
6312 __rte_unused void *data)
6314 struct cmd_set_bond_mon_period_result *res = parsed_result;
6317 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6319 /* check the return value and print it if is < 0 */
6321 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6324 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6325 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6327 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6328 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6329 bonding, "bonding");
6330 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6331 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6332 mon_period, "mon_period");
6333 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6334 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6336 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6337 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6340 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6341 .f = cmd_set_bond_mon_period_parsed,
6343 .help_str = "set bonding mon_period <port_id> <period_ms>",
6345 (void *)&cmd_set_bond_mon_period_set,
6346 (void *)&cmd_set_bond_mon_period_bonding,
6347 (void *)&cmd_set_bond_mon_period_mon_period,
6348 (void *)&cmd_set_bond_mon_period_portnum,
6349 (void *)&cmd_set_bond_mon_period_period_ms,
6356 struct cmd_set_bonding_agg_mode_policy_result {
6357 cmdline_fixed_string_t set;
6358 cmdline_fixed_string_t bonding;
6359 cmdline_fixed_string_t agg_mode;
6361 cmdline_fixed_string_t policy;
6366 cmd_set_bonding_agg_mode(void *parsed_result,
6367 __rte_unused struct cmdline *cl,
6368 __rte_unused void *data)
6370 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6371 uint8_t policy = AGG_BANDWIDTH;
6373 if (!strcmp(res->policy, "bandwidth"))
6374 policy = AGG_BANDWIDTH;
6375 else if (!strcmp(res->policy, "stable"))
6376 policy = AGG_STABLE;
6377 else if (!strcmp(res->policy, "count"))
6380 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6384 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6385 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6387 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6388 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6389 bonding, "bonding");
6391 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6392 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6393 agg_mode, "agg_mode");
6395 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6396 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6399 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6400 TOKEN_STRING_INITIALIZER(
6401 struct cmd_set_bonding_balance_xmit_policy_result,
6402 policy, "stable#bandwidth#count");
6404 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6405 .f = cmd_set_bonding_agg_mode,
6407 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6409 (void *)&cmd_set_bonding_agg_mode_set,
6410 (void *)&cmd_set_bonding_agg_mode_bonding,
6411 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6412 (void *)&cmd_set_bonding_agg_mode_portnum,
6413 (void *)&cmd_set_bonding_agg_mode_policy_string,
6419 #endif /* RTE_LIBRTE_PMD_BOND */
6421 /* *** SET FORWARDING MODE *** */
6422 struct cmd_set_fwd_mode_result {
6423 cmdline_fixed_string_t set;
6424 cmdline_fixed_string_t fwd;
6425 cmdline_fixed_string_t mode;
6428 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6429 __rte_unused struct cmdline *cl,
6430 __rte_unused void *data)
6432 struct cmd_set_fwd_mode_result *res = parsed_result;
6435 set_pkt_forwarding_mode(res->mode);
6438 cmdline_parse_token_string_t cmd_setfwd_set =
6439 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6440 cmdline_parse_token_string_t cmd_setfwd_fwd =
6441 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6442 cmdline_parse_token_string_t cmd_setfwd_mode =
6443 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6444 "" /* defined at init */);
6446 cmdline_parse_inst_t cmd_set_fwd_mode = {
6447 .f = cmd_set_fwd_mode_parsed,
6449 .help_str = NULL, /* defined at init */
6451 (void *)&cmd_setfwd_set,
6452 (void *)&cmd_setfwd_fwd,
6453 (void *)&cmd_setfwd_mode,
6458 static void cmd_set_fwd_mode_init(void)
6461 static char token[128];
6462 static char help[256];
6463 cmdline_parse_token_string_t *token_struct;
6465 modes = list_pkt_forwarding_modes();
6466 snprintf(help, sizeof(help), "set fwd %s: "
6467 "Set packet forwarding mode", modes);
6468 cmd_set_fwd_mode.help_str = help;
6470 /* string token separator is # */
6471 for (c = token; *modes != '\0'; modes++)
6476 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6477 token_struct->string_data.str = token;
6480 /* *** SET RETRY FORWARDING MODE *** */
6481 struct cmd_set_fwd_retry_mode_result {
6482 cmdline_fixed_string_t set;
6483 cmdline_fixed_string_t fwd;
6484 cmdline_fixed_string_t mode;
6485 cmdline_fixed_string_t retry;
6488 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6489 __rte_unused struct cmdline *cl,
6490 __rte_unused void *data)
6492 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6495 set_pkt_forwarding_mode(res->mode);
6498 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6499 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6501 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6502 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6504 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6505 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6507 "" /* defined at init */);
6508 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6509 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6512 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6513 .f = cmd_set_fwd_retry_mode_parsed,
6515 .help_str = NULL, /* defined at init */
6517 (void *)&cmd_setfwd_retry_set,
6518 (void *)&cmd_setfwd_retry_fwd,
6519 (void *)&cmd_setfwd_retry_mode,
6520 (void *)&cmd_setfwd_retry_retry,
6525 static void cmd_set_fwd_retry_mode_init(void)
6528 static char token[128];
6529 static char help[256];
6530 cmdline_parse_token_string_t *token_struct;
6532 modes = list_pkt_forwarding_retry_modes();
6533 snprintf(help, sizeof(help), "set fwd %s retry: "
6534 "Set packet forwarding mode with retry", modes);
6535 cmd_set_fwd_retry_mode.help_str = help;
6537 /* string token separator is # */
6538 for (c = token; *modes != '\0'; modes++)
6543 token_struct = (cmdline_parse_token_string_t *)
6544 cmd_set_fwd_retry_mode.tokens[2];
6545 token_struct->string_data.str = token;
6548 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6549 struct cmd_set_burst_tx_retry_result {
6550 cmdline_fixed_string_t set;
6551 cmdline_fixed_string_t burst;
6552 cmdline_fixed_string_t tx;
6553 cmdline_fixed_string_t delay;
6555 cmdline_fixed_string_t retry;
6559 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6560 __rte_unused struct cmdline *cl,
6561 __rte_unused void *data)
6563 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6565 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6566 && !strcmp(res->tx, "tx")) {
6567 if (!strcmp(res->delay, "delay"))
6568 burst_tx_delay_time = res->time;
6569 if (!strcmp(res->retry, "retry"))
6570 burst_tx_retry_num = res->retry_num;
6575 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6576 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6577 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6578 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6580 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6581 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6582 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6583 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6584 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6585 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6586 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6587 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6588 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6589 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6591 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6592 .f = cmd_set_burst_tx_retry_parsed,
6593 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6595 (void *)&cmd_set_burst_tx_retry_set,
6596 (void *)&cmd_set_burst_tx_retry_burst,
6597 (void *)&cmd_set_burst_tx_retry_tx,
6598 (void *)&cmd_set_burst_tx_retry_delay,
6599 (void *)&cmd_set_burst_tx_retry_time,
6600 (void *)&cmd_set_burst_tx_retry_retry,
6601 (void *)&cmd_set_burst_tx_retry_retry_num,
6606 /* *** SET PROMISC MODE *** */
6607 struct cmd_set_promisc_mode_result {
6608 cmdline_fixed_string_t set;
6609 cmdline_fixed_string_t promisc;
6610 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6611 uint16_t port_num; /* valid if "allports" argument == 0 */
6612 cmdline_fixed_string_t mode;
6615 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6616 __rte_unused struct cmdline *cl,
6619 struct cmd_set_promisc_mode_result *res = parsed_result;
6623 if (!strcmp(res->mode, "on"))
6630 RTE_ETH_FOREACH_DEV(i)
6631 eth_set_promisc_mode(i, enable);
6633 eth_set_promisc_mode(res->port_num, enable);
6637 cmdline_parse_token_string_t cmd_setpromisc_set =
6638 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6639 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6640 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6642 cmdline_parse_token_string_t cmd_setpromisc_portall =
6643 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6645 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6646 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6648 cmdline_parse_token_string_t cmd_setpromisc_mode =
6649 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6652 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6653 .f = cmd_set_promisc_mode_parsed,
6655 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6657 (void *)&cmd_setpromisc_set,
6658 (void *)&cmd_setpromisc_promisc,
6659 (void *)&cmd_setpromisc_portall,
6660 (void *)&cmd_setpromisc_mode,
6665 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6666 .f = cmd_set_promisc_mode_parsed,
6668 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6670 (void *)&cmd_setpromisc_set,
6671 (void *)&cmd_setpromisc_promisc,
6672 (void *)&cmd_setpromisc_portnum,
6673 (void *)&cmd_setpromisc_mode,
6678 /* *** SET ALLMULTI MODE *** */
6679 struct cmd_set_allmulti_mode_result {
6680 cmdline_fixed_string_t set;
6681 cmdline_fixed_string_t allmulti;
6682 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6683 uint16_t port_num; /* valid if "allports" argument == 0 */
6684 cmdline_fixed_string_t mode;
6687 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6688 __rte_unused struct cmdline *cl,
6691 struct cmd_set_allmulti_mode_result *res = parsed_result;
6695 if (!strcmp(res->mode, "on"))
6702 RTE_ETH_FOREACH_DEV(i) {
6703 eth_set_allmulticast_mode(i, enable);
6707 eth_set_allmulticast_mode(res->port_num, enable);
6711 cmdline_parse_token_string_t cmd_setallmulti_set =
6712 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6713 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6714 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6716 cmdline_parse_token_string_t cmd_setallmulti_portall =
6717 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6719 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6720 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6722 cmdline_parse_token_string_t cmd_setallmulti_mode =
6723 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6726 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6727 .f = cmd_set_allmulti_mode_parsed,
6729 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6731 (void *)&cmd_setallmulti_set,
6732 (void *)&cmd_setallmulti_allmulti,
6733 (void *)&cmd_setallmulti_portall,
6734 (void *)&cmd_setallmulti_mode,
6739 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6740 .f = cmd_set_allmulti_mode_parsed,
6742 .help_str = "set allmulti <port_id> on|off: "
6743 "Set allmulti mode on port_id",
6745 (void *)&cmd_setallmulti_set,
6746 (void *)&cmd_setallmulti_allmulti,
6747 (void *)&cmd_setallmulti_portnum,
6748 (void *)&cmd_setallmulti_mode,
6753 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6754 struct cmd_link_flow_ctrl_set_result {
6755 cmdline_fixed_string_t set;
6756 cmdline_fixed_string_t flow_ctrl;
6757 cmdline_fixed_string_t rx;
6758 cmdline_fixed_string_t rx_lfc_mode;
6759 cmdline_fixed_string_t tx;
6760 cmdline_fixed_string_t tx_lfc_mode;
6761 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6762 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6763 cmdline_fixed_string_t autoneg_str;
6764 cmdline_fixed_string_t autoneg;
6765 cmdline_fixed_string_t hw_str;
6766 uint32_t high_water;
6767 cmdline_fixed_string_t lw_str;
6769 cmdline_fixed_string_t pt_str;
6770 uint16_t pause_time;
6771 cmdline_fixed_string_t xon_str;
6776 cmdline_parse_token_string_t cmd_lfc_set_set =
6777 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6779 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6780 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6781 flow_ctrl, "flow_ctrl");
6782 cmdline_parse_token_string_t cmd_lfc_set_rx =
6783 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6785 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6786 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6787 rx_lfc_mode, "on#off");
6788 cmdline_parse_token_string_t cmd_lfc_set_tx =
6789 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6791 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6792 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6793 tx_lfc_mode, "on#off");
6794 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6795 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6796 hw_str, "high_water");
6797 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6798 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6799 high_water, UINT32);
6800 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6801 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6802 lw_str, "low_water");
6803 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6804 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6806 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6807 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6808 pt_str, "pause_time");
6809 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6810 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6811 pause_time, UINT16);
6812 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6813 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6814 xon_str, "send_xon");
6815 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6816 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6818 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6819 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6820 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6821 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6822 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6823 mac_ctrl_frame_fwd_mode, "on#off");
6824 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6825 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6826 autoneg_str, "autoneg");
6827 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6828 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6830 cmdline_parse_token_num_t cmd_lfc_set_portid =
6831 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6834 /* forward declaration */
6836 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6839 cmdline_parse_inst_t cmd_link_flow_control_set = {
6840 .f = cmd_link_flow_ctrl_set_parsed,
6842 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6843 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6844 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6846 (void *)&cmd_lfc_set_set,
6847 (void *)&cmd_lfc_set_flow_ctrl,
6848 (void *)&cmd_lfc_set_rx,
6849 (void *)&cmd_lfc_set_rx_mode,
6850 (void *)&cmd_lfc_set_tx,
6851 (void *)&cmd_lfc_set_tx_mode,
6852 (void *)&cmd_lfc_set_high_water,
6853 (void *)&cmd_lfc_set_low_water,
6854 (void *)&cmd_lfc_set_pause_time,
6855 (void *)&cmd_lfc_set_send_xon,
6856 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6857 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6858 (void *)&cmd_lfc_set_autoneg_str,
6859 (void *)&cmd_lfc_set_autoneg,
6860 (void *)&cmd_lfc_set_portid,
6865 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6866 .f = cmd_link_flow_ctrl_set_parsed,
6867 .data = (void *)&cmd_link_flow_control_set_rx,
6868 .help_str = "set flow_ctrl rx on|off <port_id>: "
6869 "Change rx flow control parameter",
6871 (void *)&cmd_lfc_set_set,
6872 (void *)&cmd_lfc_set_flow_ctrl,
6873 (void *)&cmd_lfc_set_rx,
6874 (void *)&cmd_lfc_set_rx_mode,
6875 (void *)&cmd_lfc_set_portid,
6880 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6881 .f = cmd_link_flow_ctrl_set_parsed,
6882 .data = (void *)&cmd_link_flow_control_set_tx,
6883 .help_str = "set flow_ctrl tx on|off <port_id>: "
6884 "Change tx flow control parameter",
6886 (void *)&cmd_lfc_set_set,
6887 (void *)&cmd_lfc_set_flow_ctrl,
6888 (void *)&cmd_lfc_set_tx,
6889 (void *)&cmd_lfc_set_tx_mode,
6890 (void *)&cmd_lfc_set_portid,
6895 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6896 .f = cmd_link_flow_ctrl_set_parsed,
6897 .data = (void *)&cmd_link_flow_control_set_hw,
6898 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6899 "Change high water flow control parameter",
6901 (void *)&cmd_lfc_set_set,
6902 (void *)&cmd_lfc_set_flow_ctrl,
6903 (void *)&cmd_lfc_set_high_water_str,
6904 (void *)&cmd_lfc_set_high_water,
6905 (void *)&cmd_lfc_set_portid,
6910 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6911 .f = cmd_link_flow_ctrl_set_parsed,
6912 .data = (void *)&cmd_link_flow_control_set_lw,
6913 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6914 "Change low water flow control parameter",
6916 (void *)&cmd_lfc_set_set,
6917 (void *)&cmd_lfc_set_flow_ctrl,
6918 (void *)&cmd_lfc_set_low_water_str,
6919 (void *)&cmd_lfc_set_low_water,
6920 (void *)&cmd_lfc_set_portid,
6925 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6926 .f = cmd_link_flow_ctrl_set_parsed,
6927 .data = (void *)&cmd_link_flow_control_set_pt,
6928 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6929 "Change pause time flow control parameter",
6931 (void *)&cmd_lfc_set_set,
6932 (void *)&cmd_lfc_set_flow_ctrl,
6933 (void *)&cmd_lfc_set_pause_time_str,
6934 (void *)&cmd_lfc_set_pause_time,
6935 (void *)&cmd_lfc_set_portid,
6940 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6941 .f = cmd_link_flow_ctrl_set_parsed,
6942 .data = (void *)&cmd_link_flow_control_set_xon,
6943 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6944 "Change send_xon flow control parameter",
6946 (void *)&cmd_lfc_set_set,
6947 (void *)&cmd_lfc_set_flow_ctrl,
6948 (void *)&cmd_lfc_set_send_xon_str,
6949 (void *)&cmd_lfc_set_send_xon,
6950 (void *)&cmd_lfc_set_portid,
6955 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6956 .f = cmd_link_flow_ctrl_set_parsed,
6957 .data = (void *)&cmd_link_flow_control_set_macfwd,
6958 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6959 "Change mac ctrl fwd flow control parameter",
6961 (void *)&cmd_lfc_set_set,
6962 (void *)&cmd_lfc_set_flow_ctrl,
6963 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6964 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6965 (void *)&cmd_lfc_set_portid,
6970 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6971 .f = cmd_link_flow_ctrl_set_parsed,
6972 .data = (void *)&cmd_link_flow_control_set_autoneg,
6973 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6974 "Change autoneg flow control parameter",
6976 (void *)&cmd_lfc_set_set,
6977 (void *)&cmd_lfc_set_flow_ctrl,
6978 (void *)&cmd_lfc_set_autoneg_str,
6979 (void *)&cmd_lfc_set_autoneg,
6980 (void *)&cmd_lfc_set_portid,
6986 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6987 __rte_unused struct cmdline *cl,
6990 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6991 cmdline_parse_inst_t *cmd = data;
6992 struct rte_eth_fc_conf fc_conf;
6998 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6999 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7000 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7001 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7003 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7004 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7007 /* Partial command line, retrieve current configuration */
7009 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7011 printf("cannot get current flow ctrl parameters, return"
7012 "code = %d\n", ret);
7016 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7017 (fc_conf.mode == RTE_FC_FULL))
7019 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7020 (fc_conf.mode == RTE_FC_FULL))
7024 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7025 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7027 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7028 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7030 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7032 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7033 fc_conf.high_water = res->high_water;
7035 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7036 fc_conf.low_water = res->low_water;
7038 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7039 fc_conf.pause_time = res->pause_time;
7041 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7042 fc_conf.send_xon = res->send_xon;
7044 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7045 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7046 fc_conf.mac_ctrl_frame_fwd = 1;
7048 fc_conf.mac_ctrl_frame_fwd = 0;
7051 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7052 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7054 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7056 printf("bad flow contrl parameter, return code = %d \n", ret);
7059 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7060 struct cmd_priority_flow_ctrl_set_result {
7061 cmdline_fixed_string_t set;
7062 cmdline_fixed_string_t pfc_ctrl;
7063 cmdline_fixed_string_t rx;
7064 cmdline_fixed_string_t rx_pfc_mode;
7065 cmdline_fixed_string_t tx;
7066 cmdline_fixed_string_t tx_pfc_mode;
7067 uint32_t high_water;
7069 uint16_t pause_time;
7075 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7076 __rte_unused struct cmdline *cl,
7077 __rte_unused void *data)
7079 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7080 struct rte_eth_pfc_conf pfc_conf;
7081 int rx_fc_enable, tx_fc_enable;
7085 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7086 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7087 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7088 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7090 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7091 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7094 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7095 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7096 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7097 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7098 pfc_conf.fc.high_water = res->high_water;
7099 pfc_conf.fc.low_water = res->low_water;
7100 pfc_conf.fc.pause_time = res->pause_time;
7101 pfc_conf.priority = res->priority;
7103 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7105 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7108 cmdline_parse_token_string_t cmd_pfc_set_set =
7109 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7111 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7112 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7113 pfc_ctrl, "pfc_ctrl");
7114 cmdline_parse_token_string_t cmd_pfc_set_rx =
7115 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7117 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7118 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7119 rx_pfc_mode, "on#off");
7120 cmdline_parse_token_string_t cmd_pfc_set_tx =
7121 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7123 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7124 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7125 tx_pfc_mode, "on#off");
7126 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7127 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7128 high_water, UINT32);
7129 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7130 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7132 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7133 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7134 pause_time, UINT16);
7135 cmdline_parse_token_num_t cmd_pfc_set_priority =
7136 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7138 cmdline_parse_token_num_t cmd_pfc_set_portid =
7139 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7142 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7143 .f = cmd_priority_flow_ctrl_set_parsed,
7145 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7146 "<pause_time> <priority> <port_id>: "
7147 "Configure the Ethernet priority flow control",
7149 (void *)&cmd_pfc_set_set,
7150 (void *)&cmd_pfc_set_flow_ctrl,
7151 (void *)&cmd_pfc_set_rx,
7152 (void *)&cmd_pfc_set_rx_mode,
7153 (void *)&cmd_pfc_set_tx,
7154 (void *)&cmd_pfc_set_tx_mode,
7155 (void *)&cmd_pfc_set_high_water,
7156 (void *)&cmd_pfc_set_low_water,
7157 (void *)&cmd_pfc_set_pause_time,
7158 (void *)&cmd_pfc_set_priority,
7159 (void *)&cmd_pfc_set_portid,
7164 /* *** RESET CONFIGURATION *** */
7165 struct cmd_reset_result {
7166 cmdline_fixed_string_t reset;
7167 cmdline_fixed_string_t def;
7170 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7172 __rte_unused void *data)
7174 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7175 set_def_fwd_config();
7178 cmdline_parse_token_string_t cmd_reset_set =
7179 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7180 cmdline_parse_token_string_t cmd_reset_def =
7181 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7184 cmdline_parse_inst_t cmd_reset = {
7185 .f = cmd_reset_parsed,
7187 .help_str = "set default: Reset default forwarding configuration",
7189 (void *)&cmd_reset_set,
7190 (void *)&cmd_reset_def,
7195 /* *** START FORWARDING *** */
7196 struct cmd_start_result {
7197 cmdline_fixed_string_t start;
7200 cmdline_parse_token_string_t cmd_start_start =
7201 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7203 static void cmd_start_parsed(__rte_unused void *parsed_result,
7204 __rte_unused struct cmdline *cl,
7205 __rte_unused void *data)
7207 start_packet_forwarding(0);
7210 cmdline_parse_inst_t cmd_start = {
7211 .f = cmd_start_parsed,
7213 .help_str = "start: Start packet forwarding",
7215 (void *)&cmd_start_start,
7220 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7221 struct cmd_start_tx_first_result {
7222 cmdline_fixed_string_t start;
7223 cmdline_fixed_string_t tx_first;
7227 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7228 __rte_unused struct cmdline *cl,
7229 __rte_unused void *data)
7231 start_packet_forwarding(1);
7234 cmdline_parse_token_string_t cmd_start_tx_first_start =
7235 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7237 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7238 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7239 tx_first, "tx_first");
7241 cmdline_parse_inst_t cmd_start_tx_first = {
7242 .f = cmd_start_tx_first_parsed,
7244 .help_str = "start tx_first: Start packet forwarding, "
7245 "after sending 1 burst of packets",
7247 (void *)&cmd_start_tx_first_start,
7248 (void *)&cmd_start_tx_first_tx_first,
7253 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7254 struct cmd_start_tx_first_n_result {
7255 cmdline_fixed_string_t start;
7256 cmdline_fixed_string_t tx_first;
7261 cmd_start_tx_first_n_parsed(void *parsed_result,
7262 __rte_unused struct cmdline *cl,
7263 __rte_unused void *data)
7265 struct cmd_start_tx_first_n_result *res = parsed_result;
7267 start_packet_forwarding(res->tx_num);
7270 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7271 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7273 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7274 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7275 tx_first, "tx_first");
7276 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7277 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7280 cmdline_parse_inst_t cmd_start_tx_first_n = {
7281 .f = cmd_start_tx_first_n_parsed,
7283 .help_str = "start tx_first <num>: "
7284 "packet forwarding, after sending <num> bursts of packets",
7286 (void *)&cmd_start_tx_first_n_start,
7287 (void *)&cmd_start_tx_first_n_tx_first,
7288 (void *)&cmd_start_tx_first_n_tx_num,
7293 /* *** SET LINK UP *** */
7294 struct cmd_set_link_up_result {
7295 cmdline_fixed_string_t set;
7296 cmdline_fixed_string_t link_up;
7297 cmdline_fixed_string_t port;
7301 cmdline_parse_token_string_t cmd_set_link_up_set =
7302 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7303 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7304 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7306 cmdline_parse_token_string_t cmd_set_link_up_port =
7307 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7308 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7309 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7311 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7312 __rte_unused struct cmdline *cl,
7313 __rte_unused void *data)
7315 struct cmd_set_link_up_result *res = parsed_result;
7316 dev_set_link_up(res->port_id);
7319 cmdline_parse_inst_t cmd_set_link_up = {
7320 .f = cmd_set_link_up_parsed,
7322 .help_str = "set link-up port <port id>",
7324 (void *)&cmd_set_link_up_set,
7325 (void *)&cmd_set_link_up_link_up,
7326 (void *)&cmd_set_link_up_port,
7327 (void *)&cmd_set_link_up_port_id,
7332 /* *** SET LINK DOWN *** */
7333 struct cmd_set_link_down_result {
7334 cmdline_fixed_string_t set;
7335 cmdline_fixed_string_t link_down;
7336 cmdline_fixed_string_t port;
7340 cmdline_parse_token_string_t cmd_set_link_down_set =
7341 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7342 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7343 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7345 cmdline_parse_token_string_t cmd_set_link_down_port =
7346 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7347 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7348 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7350 static void cmd_set_link_down_parsed(
7351 __rte_unused void *parsed_result,
7352 __rte_unused struct cmdline *cl,
7353 __rte_unused void *data)
7355 struct cmd_set_link_down_result *res = parsed_result;
7356 dev_set_link_down(res->port_id);
7359 cmdline_parse_inst_t cmd_set_link_down = {
7360 .f = cmd_set_link_down_parsed,
7362 .help_str = "set link-down port <port id>",
7364 (void *)&cmd_set_link_down_set,
7365 (void *)&cmd_set_link_down_link_down,
7366 (void *)&cmd_set_link_down_port,
7367 (void *)&cmd_set_link_down_port_id,
7372 /* *** SHOW CFG *** */
7373 struct cmd_showcfg_result {
7374 cmdline_fixed_string_t show;
7375 cmdline_fixed_string_t cfg;
7376 cmdline_fixed_string_t what;
7379 static void cmd_showcfg_parsed(void *parsed_result,
7380 __rte_unused struct cmdline *cl,
7381 __rte_unused void *data)
7383 struct cmd_showcfg_result *res = parsed_result;
7384 if (!strcmp(res->what, "rxtx"))
7385 rxtx_config_display();
7386 else if (!strcmp(res->what, "cores"))
7387 fwd_lcores_config_display();
7388 else if (!strcmp(res->what, "fwd"))
7389 pkt_fwd_config_display(&cur_fwd_config);
7390 else if (!strcmp(res->what, "txpkts"))
7391 show_tx_pkt_segments();
7394 cmdline_parse_token_string_t cmd_showcfg_show =
7395 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7396 cmdline_parse_token_string_t cmd_showcfg_port =
7397 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7398 cmdline_parse_token_string_t cmd_showcfg_what =
7399 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7400 "rxtx#cores#fwd#txpkts");
7402 cmdline_parse_inst_t cmd_showcfg = {
7403 .f = cmd_showcfg_parsed,
7405 .help_str = "show config rxtx|cores|fwd|txpkts",
7407 (void *)&cmd_showcfg_show,
7408 (void *)&cmd_showcfg_port,
7409 (void *)&cmd_showcfg_what,
7414 /* *** SHOW ALL PORT INFO *** */
7415 struct cmd_showportall_result {
7416 cmdline_fixed_string_t show;
7417 cmdline_fixed_string_t port;
7418 cmdline_fixed_string_t what;
7419 cmdline_fixed_string_t all;
7422 static void cmd_showportall_parsed(void *parsed_result,
7423 __rte_unused struct cmdline *cl,
7424 __rte_unused void *data)
7428 struct cmd_showportall_result *res = parsed_result;
7429 if (!strcmp(res->show, "clear")) {
7430 if (!strcmp(res->what, "stats"))
7431 RTE_ETH_FOREACH_DEV(i)
7433 else if (!strcmp(res->what, "xstats"))
7434 RTE_ETH_FOREACH_DEV(i)
7435 nic_xstats_clear(i);
7436 } else if (!strcmp(res->what, "info"))
7437 RTE_ETH_FOREACH_DEV(i)
7438 port_infos_display(i);
7439 else if (!strcmp(res->what, "summary")) {
7440 port_summary_header_display();
7441 RTE_ETH_FOREACH_DEV(i)
7442 port_summary_display(i);
7444 else if (!strcmp(res->what, "stats"))
7445 RTE_ETH_FOREACH_DEV(i)
7446 nic_stats_display(i);
7447 else if (!strcmp(res->what, "xstats"))
7448 RTE_ETH_FOREACH_DEV(i)
7449 nic_xstats_display(i);
7450 else if (!strcmp(res->what, "fdir"))
7451 RTE_ETH_FOREACH_DEV(i)
7453 else if (!strcmp(res->what, "stat_qmap"))
7454 RTE_ETH_FOREACH_DEV(i)
7455 nic_stats_mapping_display(i);
7456 else if (!strcmp(res->what, "dcb_tc"))
7457 RTE_ETH_FOREACH_DEV(i)
7458 port_dcb_info_display(i);
7459 else if (!strcmp(res->what, "cap"))
7460 RTE_ETH_FOREACH_DEV(i)
7461 port_offload_cap_display(i);
7464 cmdline_parse_token_string_t cmd_showportall_show =
7465 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7467 cmdline_parse_token_string_t cmd_showportall_port =
7468 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7469 cmdline_parse_token_string_t cmd_showportall_what =
7470 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7471 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7472 cmdline_parse_token_string_t cmd_showportall_all =
7473 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7474 cmdline_parse_inst_t cmd_showportall = {
7475 .f = cmd_showportall_parsed,
7477 .help_str = "show|clear port "
7478 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7480 (void *)&cmd_showportall_show,
7481 (void *)&cmd_showportall_port,
7482 (void *)&cmd_showportall_what,
7483 (void *)&cmd_showportall_all,
7488 /* *** SHOW PORT INFO *** */
7489 struct cmd_showport_result {
7490 cmdline_fixed_string_t show;
7491 cmdline_fixed_string_t port;
7492 cmdline_fixed_string_t what;
7496 static void cmd_showport_parsed(void *parsed_result,
7497 __rte_unused struct cmdline *cl,
7498 __rte_unused void *data)
7500 struct cmd_showport_result *res = parsed_result;
7501 if (!strcmp(res->show, "clear")) {
7502 if (!strcmp(res->what, "stats"))
7503 nic_stats_clear(res->portnum);
7504 else if (!strcmp(res->what, "xstats"))
7505 nic_xstats_clear(res->portnum);
7506 } else if (!strcmp(res->what, "info"))
7507 port_infos_display(res->portnum);
7508 else if (!strcmp(res->what, "summary")) {
7509 port_summary_header_display();
7510 port_summary_display(res->portnum);
7512 else if (!strcmp(res->what, "stats"))
7513 nic_stats_display(res->portnum);
7514 else if (!strcmp(res->what, "xstats"))
7515 nic_xstats_display(res->portnum);
7516 else if (!strcmp(res->what, "fdir"))
7517 fdir_get_infos(res->portnum);
7518 else if (!strcmp(res->what, "stat_qmap"))
7519 nic_stats_mapping_display(res->portnum);
7520 else if (!strcmp(res->what, "dcb_tc"))
7521 port_dcb_info_display(res->portnum);
7522 else if (!strcmp(res->what, "cap"))
7523 port_offload_cap_display(res->portnum);
7526 cmdline_parse_token_string_t cmd_showport_show =
7527 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7529 cmdline_parse_token_string_t cmd_showport_port =
7530 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7531 cmdline_parse_token_string_t cmd_showport_what =
7532 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7533 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7534 cmdline_parse_token_num_t cmd_showport_portnum =
7535 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7537 cmdline_parse_inst_t cmd_showport = {
7538 .f = cmd_showport_parsed,
7540 .help_str = "show|clear port "
7541 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7544 (void *)&cmd_showport_show,
7545 (void *)&cmd_showport_port,
7546 (void *)&cmd_showport_what,
7547 (void *)&cmd_showport_portnum,
7552 /* *** SHOW DEVICE INFO *** */
7553 struct cmd_showdevice_result {
7554 cmdline_fixed_string_t show;
7555 cmdline_fixed_string_t device;
7556 cmdline_fixed_string_t what;
7557 cmdline_fixed_string_t identifier;
7560 static void cmd_showdevice_parsed(void *parsed_result,
7561 __rte_unused struct cmdline *cl,
7562 __rte_unused void *data)
7564 struct cmd_showdevice_result *res = parsed_result;
7565 if (!strcmp(res->what, "info")) {
7566 if (!strcmp(res->identifier, "all"))
7567 device_infos_display(NULL);
7569 device_infos_display(res->identifier);
7573 cmdline_parse_token_string_t cmd_showdevice_show =
7574 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7576 cmdline_parse_token_string_t cmd_showdevice_device =
7577 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7578 cmdline_parse_token_string_t cmd_showdevice_what =
7579 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7581 cmdline_parse_token_string_t cmd_showdevice_identifier =
7582 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7585 cmdline_parse_inst_t cmd_showdevice = {
7586 .f = cmd_showdevice_parsed,
7588 .help_str = "show device info <identifier>|all",
7590 (void *)&cmd_showdevice_show,
7591 (void *)&cmd_showdevice_device,
7592 (void *)&cmd_showdevice_what,
7593 (void *)&cmd_showdevice_identifier,
7597 /* *** SHOW QUEUE INFO *** */
7598 struct cmd_showqueue_result {
7599 cmdline_fixed_string_t show;
7600 cmdline_fixed_string_t type;
7601 cmdline_fixed_string_t what;
7607 cmd_showqueue_parsed(void *parsed_result,
7608 __rte_unused struct cmdline *cl,
7609 __rte_unused void *data)
7611 struct cmd_showqueue_result *res = parsed_result;
7613 if (!strcmp(res->type, "rxq"))
7614 rx_queue_infos_display(res->portnum, res->queuenum);
7615 else if (!strcmp(res->type, "txq"))
7616 tx_queue_infos_display(res->portnum, res->queuenum);
7619 cmdline_parse_token_string_t cmd_showqueue_show =
7620 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7621 cmdline_parse_token_string_t cmd_showqueue_type =
7622 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7623 cmdline_parse_token_string_t cmd_showqueue_what =
7624 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7625 cmdline_parse_token_num_t cmd_showqueue_portnum =
7626 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7627 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7628 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7630 cmdline_parse_inst_t cmd_showqueue = {
7631 .f = cmd_showqueue_parsed,
7633 .help_str = "show rxq|txq info <port_id> <queue_id>",
7635 (void *)&cmd_showqueue_show,
7636 (void *)&cmd_showqueue_type,
7637 (void *)&cmd_showqueue_what,
7638 (void *)&cmd_showqueue_portnum,
7639 (void *)&cmd_showqueue_queuenum,
7644 /* show/clear fwd engine statistics */
7646 cmdline_fixed_string_t action;
7647 cmdline_fixed_string_t fwd;
7648 cmdline_fixed_string_t stats;
7649 cmdline_fixed_string_t all;
7652 cmdline_parse_token_string_t cmd_fwd_action =
7653 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7654 cmdline_parse_token_string_t cmd_fwd_fwd =
7655 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7656 cmdline_parse_token_string_t cmd_fwd_stats =
7657 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7658 cmdline_parse_token_string_t cmd_fwd_all =
7659 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7662 cmd_showfwdall_parsed(void *parsed_result,
7663 __rte_unused struct cmdline *cl,
7664 __rte_unused void *data)
7666 struct fwd_result *res = parsed_result;
7668 if (!strcmp(res->action, "show"))
7669 fwd_stats_display();
7674 static cmdline_parse_inst_t cmd_showfwdall = {
7675 .f = cmd_showfwdall_parsed,
7677 .help_str = "show|clear fwd stats all",
7679 (void *)&cmd_fwd_action,
7680 (void *)&cmd_fwd_fwd,
7681 (void *)&cmd_fwd_stats,
7682 (void *)&cmd_fwd_all,
7687 /* *** READ PORT REGISTER *** */
7688 struct cmd_read_reg_result {
7689 cmdline_fixed_string_t read;
7690 cmdline_fixed_string_t reg;
7696 cmd_read_reg_parsed(void *parsed_result,
7697 __rte_unused struct cmdline *cl,
7698 __rte_unused void *data)
7700 struct cmd_read_reg_result *res = parsed_result;
7701 port_reg_display(res->port_id, res->reg_off);
7704 cmdline_parse_token_string_t cmd_read_reg_read =
7705 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7706 cmdline_parse_token_string_t cmd_read_reg_reg =
7707 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7708 cmdline_parse_token_num_t cmd_read_reg_port_id =
7709 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7710 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7711 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7713 cmdline_parse_inst_t cmd_read_reg = {
7714 .f = cmd_read_reg_parsed,
7716 .help_str = "read reg <port_id> <reg_off>",
7718 (void *)&cmd_read_reg_read,
7719 (void *)&cmd_read_reg_reg,
7720 (void *)&cmd_read_reg_port_id,
7721 (void *)&cmd_read_reg_reg_off,
7726 /* *** READ PORT REGISTER BIT FIELD *** */
7727 struct cmd_read_reg_bit_field_result {
7728 cmdline_fixed_string_t read;
7729 cmdline_fixed_string_t regfield;
7737 cmd_read_reg_bit_field_parsed(void *parsed_result,
7738 __rte_unused struct cmdline *cl,
7739 __rte_unused void *data)
7741 struct cmd_read_reg_bit_field_result *res = parsed_result;
7742 port_reg_bit_field_display(res->port_id, res->reg_off,
7743 res->bit1_pos, res->bit2_pos);
7746 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7747 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7749 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7750 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7751 regfield, "regfield");
7752 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7753 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7755 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7756 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7758 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7759 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7761 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7762 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7765 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7766 .f = cmd_read_reg_bit_field_parsed,
7768 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7769 "Read register bit field between bit_x and bit_y included",
7771 (void *)&cmd_read_reg_bit_field_read,
7772 (void *)&cmd_read_reg_bit_field_regfield,
7773 (void *)&cmd_read_reg_bit_field_port_id,
7774 (void *)&cmd_read_reg_bit_field_reg_off,
7775 (void *)&cmd_read_reg_bit_field_bit1_pos,
7776 (void *)&cmd_read_reg_bit_field_bit2_pos,
7781 /* *** READ PORT REGISTER BIT *** */
7782 struct cmd_read_reg_bit_result {
7783 cmdline_fixed_string_t read;
7784 cmdline_fixed_string_t regbit;
7791 cmd_read_reg_bit_parsed(void *parsed_result,
7792 __rte_unused struct cmdline *cl,
7793 __rte_unused void *data)
7795 struct cmd_read_reg_bit_result *res = parsed_result;
7796 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7799 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7800 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7801 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7802 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7804 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7805 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7806 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7807 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7808 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7809 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7811 cmdline_parse_inst_t cmd_read_reg_bit = {
7812 .f = cmd_read_reg_bit_parsed,
7814 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7816 (void *)&cmd_read_reg_bit_read,
7817 (void *)&cmd_read_reg_bit_regbit,
7818 (void *)&cmd_read_reg_bit_port_id,
7819 (void *)&cmd_read_reg_bit_reg_off,
7820 (void *)&cmd_read_reg_bit_bit_pos,
7825 /* *** WRITE PORT REGISTER *** */
7826 struct cmd_write_reg_result {
7827 cmdline_fixed_string_t write;
7828 cmdline_fixed_string_t reg;
7835 cmd_write_reg_parsed(void *parsed_result,
7836 __rte_unused struct cmdline *cl,
7837 __rte_unused void *data)
7839 struct cmd_write_reg_result *res = parsed_result;
7840 port_reg_set(res->port_id, res->reg_off, res->value);
7843 cmdline_parse_token_string_t cmd_write_reg_write =
7844 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7845 cmdline_parse_token_string_t cmd_write_reg_reg =
7846 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7847 cmdline_parse_token_num_t cmd_write_reg_port_id =
7848 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7849 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7850 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7851 cmdline_parse_token_num_t cmd_write_reg_value =
7852 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7854 cmdline_parse_inst_t cmd_write_reg = {
7855 .f = cmd_write_reg_parsed,
7857 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7859 (void *)&cmd_write_reg_write,
7860 (void *)&cmd_write_reg_reg,
7861 (void *)&cmd_write_reg_port_id,
7862 (void *)&cmd_write_reg_reg_off,
7863 (void *)&cmd_write_reg_value,
7868 /* *** WRITE PORT REGISTER BIT FIELD *** */
7869 struct cmd_write_reg_bit_field_result {
7870 cmdline_fixed_string_t write;
7871 cmdline_fixed_string_t regfield;
7880 cmd_write_reg_bit_field_parsed(void *parsed_result,
7881 __rte_unused struct cmdline *cl,
7882 __rte_unused void *data)
7884 struct cmd_write_reg_bit_field_result *res = parsed_result;
7885 port_reg_bit_field_set(res->port_id, res->reg_off,
7886 res->bit1_pos, res->bit2_pos, res->value);
7889 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7890 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7892 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7893 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7894 regfield, "regfield");
7895 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7896 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7898 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7899 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7901 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7902 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7904 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7905 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7907 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7908 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7911 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7912 .f = cmd_write_reg_bit_field_parsed,
7914 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7916 "Set register bit field between bit_x and bit_y included",
7918 (void *)&cmd_write_reg_bit_field_write,
7919 (void *)&cmd_write_reg_bit_field_regfield,
7920 (void *)&cmd_write_reg_bit_field_port_id,
7921 (void *)&cmd_write_reg_bit_field_reg_off,
7922 (void *)&cmd_write_reg_bit_field_bit1_pos,
7923 (void *)&cmd_write_reg_bit_field_bit2_pos,
7924 (void *)&cmd_write_reg_bit_field_value,
7929 /* *** WRITE PORT REGISTER BIT *** */
7930 struct cmd_write_reg_bit_result {
7931 cmdline_fixed_string_t write;
7932 cmdline_fixed_string_t regbit;
7940 cmd_write_reg_bit_parsed(void *parsed_result,
7941 __rte_unused struct cmdline *cl,
7942 __rte_unused void *data)
7944 struct cmd_write_reg_bit_result *res = parsed_result;
7945 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7948 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7949 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7951 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7952 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7954 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7955 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7956 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7957 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7958 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7959 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7960 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7961 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7963 cmdline_parse_inst_t cmd_write_reg_bit = {
7964 .f = cmd_write_reg_bit_parsed,
7966 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7969 (void *)&cmd_write_reg_bit_write,
7970 (void *)&cmd_write_reg_bit_regbit,
7971 (void *)&cmd_write_reg_bit_port_id,
7972 (void *)&cmd_write_reg_bit_reg_off,
7973 (void *)&cmd_write_reg_bit_bit_pos,
7974 (void *)&cmd_write_reg_bit_value,
7979 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7980 struct cmd_read_rxd_txd_result {
7981 cmdline_fixed_string_t read;
7982 cmdline_fixed_string_t rxd_txd;
7989 cmd_read_rxd_txd_parsed(void *parsed_result,
7990 __rte_unused struct cmdline *cl,
7991 __rte_unused void *data)
7993 struct cmd_read_rxd_txd_result *res = parsed_result;
7995 if (!strcmp(res->rxd_txd, "rxd"))
7996 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7997 else if (!strcmp(res->rxd_txd, "txd"))
7998 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8001 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8002 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8003 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8004 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8006 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8007 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8008 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8009 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8010 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8011 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8013 cmdline_parse_inst_t cmd_read_rxd_txd = {
8014 .f = cmd_read_rxd_txd_parsed,
8016 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8018 (void *)&cmd_read_rxd_txd_read,
8019 (void *)&cmd_read_rxd_txd_rxd_txd,
8020 (void *)&cmd_read_rxd_txd_port_id,
8021 (void *)&cmd_read_rxd_txd_queue_id,
8022 (void *)&cmd_read_rxd_txd_desc_id,
8028 struct cmd_quit_result {
8029 cmdline_fixed_string_t quit;
8032 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8034 __rte_unused void *data)
8039 cmdline_parse_token_string_t cmd_quit_quit =
8040 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8042 cmdline_parse_inst_t cmd_quit = {
8043 .f = cmd_quit_parsed,
8045 .help_str = "quit: Exit application",
8047 (void *)&cmd_quit_quit,
8052 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8053 struct cmd_mac_addr_result {
8054 cmdline_fixed_string_t mac_addr_cmd;
8055 cmdline_fixed_string_t what;
8057 struct rte_ether_addr address;
8060 static void cmd_mac_addr_parsed(void *parsed_result,
8061 __rte_unused struct cmdline *cl,
8062 __rte_unused void *data)
8064 struct cmd_mac_addr_result *res = parsed_result;
8067 if (strcmp(res->what, "add") == 0)
8068 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8069 else if (strcmp(res->what, "set") == 0)
8070 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8073 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8075 /* check the return value and print it if is < 0 */
8077 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8081 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8082 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8084 cmdline_parse_token_string_t cmd_mac_addr_what =
8085 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8087 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8088 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8090 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8091 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8093 cmdline_parse_inst_t cmd_mac_addr = {
8094 .f = cmd_mac_addr_parsed,
8096 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8097 "Add/Remove/Set MAC address on port_id",
8099 (void *)&cmd_mac_addr_cmd,
8100 (void *)&cmd_mac_addr_what,
8101 (void *)&cmd_mac_addr_portnum,
8102 (void *)&cmd_mac_addr_addr,
8107 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8108 struct cmd_eth_peer_result {
8109 cmdline_fixed_string_t set;
8110 cmdline_fixed_string_t eth_peer;
8112 cmdline_fixed_string_t peer_addr;
8115 static void cmd_set_eth_peer_parsed(void *parsed_result,
8116 __rte_unused struct cmdline *cl,
8117 __rte_unused void *data)
8119 struct cmd_eth_peer_result *res = parsed_result;
8121 if (test_done == 0) {
8122 printf("Please stop forwarding first\n");
8125 if (!strcmp(res->eth_peer, "eth-peer")) {
8126 set_fwd_eth_peer(res->port_id, res->peer_addr);
8130 cmdline_parse_token_string_t cmd_eth_peer_set =
8131 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8132 cmdline_parse_token_string_t cmd_eth_peer =
8133 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8134 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8135 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8136 cmdline_parse_token_string_t cmd_eth_peer_addr =
8137 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8139 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8140 .f = cmd_set_eth_peer_parsed,
8142 .help_str = "set eth-peer <port_id> <peer_mac>",
8144 (void *)&cmd_eth_peer_set,
8145 (void *)&cmd_eth_peer,
8146 (void *)&cmd_eth_peer_port_id,
8147 (void *)&cmd_eth_peer_addr,
8152 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8153 struct cmd_set_qmap_result {
8154 cmdline_fixed_string_t set;
8155 cmdline_fixed_string_t qmap;
8156 cmdline_fixed_string_t what;
8163 cmd_set_qmap_parsed(void *parsed_result,
8164 __rte_unused struct cmdline *cl,
8165 __rte_unused void *data)
8167 struct cmd_set_qmap_result *res = parsed_result;
8168 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8170 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8173 cmdline_parse_token_string_t cmd_setqmap_set =
8174 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8176 cmdline_parse_token_string_t cmd_setqmap_qmap =
8177 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8179 cmdline_parse_token_string_t cmd_setqmap_what =
8180 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8182 cmdline_parse_token_num_t cmd_setqmap_portid =
8183 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8185 cmdline_parse_token_num_t cmd_setqmap_queueid =
8186 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8188 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8189 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8192 cmdline_parse_inst_t cmd_set_qmap = {
8193 .f = cmd_set_qmap_parsed,
8195 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8196 "Set statistics mapping value on tx|rx queue_id of port_id",
8198 (void *)&cmd_setqmap_set,
8199 (void *)&cmd_setqmap_qmap,
8200 (void *)&cmd_setqmap_what,
8201 (void *)&cmd_setqmap_portid,
8202 (void *)&cmd_setqmap_queueid,
8203 (void *)&cmd_setqmap_mapvalue,
8208 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8209 struct cmd_set_xstats_hide_zero_result {
8210 cmdline_fixed_string_t keyword;
8211 cmdline_fixed_string_t name;
8212 cmdline_fixed_string_t on_off;
8216 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8217 __rte_unused struct cmdline *cl,
8218 __rte_unused void *data)
8220 struct cmd_set_xstats_hide_zero_result *res;
8221 uint16_t on_off = 0;
8223 res = parsed_result;
8224 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8225 set_xstats_hide_zero(on_off);
8228 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8229 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8231 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8232 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8233 name, "xstats-hide-zero");
8234 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8235 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8238 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8239 .f = cmd_set_xstats_hide_zero_parsed,
8241 .help_str = "set xstats-hide-zero on|off",
8243 (void *)&cmd_set_xstats_hide_zero_keyword,
8244 (void *)&cmd_set_xstats_hide_zero_name,
8245 (void *)&cmd_set_xstats_hide_zero_on_off,
8250 /* *** CONFIGURE UNICAST HASH TABLE *** */
8251 struct cmd_set_uc_hash_table {
8252 cmdline_fixed_string_t set;
8253 cmdline_fixed_string_t port;
8255 cmdline_fixed_string_t what;
8256 struct rte_ether_addr address;
8257 cmdline_fixed_string_t mode;
8261 cmd_set_uc_hash_parsed(void *parsed_result,
8262 __rte_unused struct cmdline *cl,
8263 __rte_unused void *data)
8266 struct cmd_set_uc_hash_table *res = parsed_result;
8268 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8270 if (strcmp(res->what, "uta") == 0)
8271 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8272 &res->address,(uint8_t)is_on);
8274 printf("bad unicast hash table parameter, return code = %d \n", ret);
8278 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8279 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8281 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8282 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8284 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8285 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8287 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8288 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8290 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8291 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8293 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8294 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8297 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8298 .f = cmd_set_uc_hash_parsed,
8300 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8302 (void *)&cmd_set_uc_hash_set,
8303 (void *)&cmd_set_uc_hash_port,
8304 (void *)&cmd_set_uc_hash_portid,
8305 (void *)&cmd_set_uc_hash_what,
8306 (void *)&cmd_set_uc_hash_mac,
8307 (void *)&cmd_set_uc_hash_mode,
8312 struct cmd_set_uc_all_hash_table {
8313 cmdline_fixed_string_t set;
8314 cmdline_fixed_string_t port;
8316 cmdline_fixed_string_t what;
8317 cmdline_fixed_string_t value;
8318 cmdline_fixed_string_t mode;
8322 cmd_set_uc_all_hash_parsed(void *parsed_result,
8323 __rte_unused struct cmdline *cl,
8324 __rte_unused void *data)
8327 struct cmd_set_uc_all_hash_table *res = parsed_result;
8329 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8331 if ((strcmp(res->what, "uta") == 0) &&
8332 (strcmp(res->value, "all") == 0))
8333 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8335 printf("bad unicast hash table parameter,"
8336 "return code = %d \n", ret);
8339 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8340 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8342 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8343 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8345 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8346 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8348 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8349 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8351 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8352 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8354 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8355 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8358 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8359 .f = cmd_set_uc_all_hash_parsed,
8361 .help_str = "set port <port_id> uta all on|off",
8363 (void *)&cmd_set_uc_all_hash_set,
8364 (void *)&cmd_set_uc_all_hash_port,
8365 (void *)&cmd_set_uc_all_hash_portid,
8366 (void *)&cmd_set_uc_all_hash_what,
8367 (void *)&cmd_set_uc_all_hash_value,
8368 (void *)&cmd_set_uc_all_hash_mode,
8373 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8374 struct cmd_set_vf_macvlan_filter {
8375 cmdline_fixed_string_t set;
8376 cmdline_fixed_string_t port;
8378 cmdline_fixed_string_t vf;
8380 struct rte_ether_addr address;
8381 cmdline_fixed_string_t filter_type;
8382 cmdline_fixed_string_t mode;
8386 cmd_set_vf_macvlan_parsed(void *parsed_result,
8387 __rte_unused struct cmdline *cl,
8388 __rte_unused void *data)
8391 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8392 struct rte_eth_mac_filter filter;
8394 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8396 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8398 /* set VF MAC filter */
8402 filter.dst_id = res->vf_id;
8404 if (!strcmp(res->filter_type, "exact-mac"))
8405 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8406 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8407 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8408 else if (!strcmp(res->filter_type, "hashmac"))
8409 filter.filter_type = RTE_MAC_HASH_MATCH;
8410 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8411 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8413 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8416 ret = rte_eth_dev_filter_ctrl(res->port_id,
8417 RTE_ETH_FILTER_MACVLAN,
8421 ret = rte_eth_dev_filter_ctrl(res->port_id,
8422 RTE_ETH_FILTER_MACVLAN,
8423 RTE_ETH_FILTER_DELETE,
8427 printf("bad set MAC hash parameter, return code = %d\n", ret);
8431 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8432 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8434 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8435 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8437 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8438 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8440 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8441 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8443 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8444 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8446 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8447 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8449 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8450 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8451 filter_type, "exact-mac#exact-mac-vlan"
8452 "#hashmac#hashmac-vlan");
8453 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8454 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8457 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8458 .f = cmd_set_vf_macvlan_parsed,
8460 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8461 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8462 "Exact match rule: exact match of MAC or MAC and VLAN; "
8463 "hash match rule: hash match of MAC and exact match of VLAN",
8465 (void *)&cmd_set_vf_macvlan_set,
8466 (void *)&cmd_set_vf_macvlan_port,
8467 (void *)&cmd_set_vf_macvlan_portid,
8468 (void *)&cmd_set_vf_macvlan_vf,
8469 (void *)&cmd_set_vf_macvlan_vf_id,
8470 (void *)&cmd_set_vf_macvlan_mac,
8471 (void *)&cmd_set_vf_macvlan_filter_type,
8472 (void *)&cmd_set_vf_macvlan_mode,
8477 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8478 struct cmd_set_vf_traffic {
8479 cmdline_fixed_string_t set;
8480 cmdline_fixed_string_t port;
8482 cmdline_fixed_string_t vf;
8484 cmdline_fixed_string_t what;
8485 cmdline_fixed_string_t mode;
8489 cmd_set_vf_traffic_parsed(void *parsed_result,
8490 __rte_unused struct cmdline *cl,
8491 __rte_unused void *data)
8493 struct cmd_set_vf_traffic *res = parsed_result;
8494 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8495 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8497 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8500 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8501 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8503 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8504 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8506 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8507 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8509 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8510 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8512 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8513 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8515 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8516 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8518 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8519 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8522 cmdline_parse_inst_t cmd_set_vf_traffic = {
8523 .f = cmd_set_vf_traffic_parsed,
8525 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8527 (void *)&cmd_setvf_traffic_set,
8528 (void *)&cmd_setvf_traffic_port,
8529 (void *)&cmd_setvf_traffic_portid,
8530 (void *)&cmd_setvf_traffic_vf,
8531 (void *)&cmd_setvf_traffic_vfid,
8532 (void *)&cmd_setvf_traffic_what,
8533 (void *)&cmd_setvf_traffic_mode,
8538 /* *** CONFIGURE VF RECEIVE MODE *** */
8539 struct cmd_set_vf_rxmode {
8540 cmdline_fixed_string_t set;
8541 cmdline_fixed_string_t port;
8543 cmdline_fixed_string_t vf;
8545 cmdline_fixed_string_t what;
8546 cmdline_fixed_string_t mode;
8547 cmdline_fixed_string_t on;
8551 cmd_set_vf_rxmode_parsed(void *parsed_result,
8552 __rte_unused struct cmdline *cl,
8553 __rte_unused void *data)
8556 uint16_t vf_rxmode = 0;
8557 struct cmd_set_vf_rxmode *res = parsed_result;
8559 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8560 if (!strcmp(res->what,"rxmode")) {
8561 if (!strcmp(res->mode, "AUPE"))
8562 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8563 else if (!strcmp(res->mode, "ROPE"))
8564 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8565 else if (!strcmp(res->mode, "BAM"))
8566 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8567 else if (!strncmp(res->mode, "MPE",3))
8568 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8571 RTE_SET_USED(is_on);
8573 #ifdef RTE_LIBRTE_IXGBE_PMD
8574 if (ret == -ENOTSUP)
8575 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8576 vf_rxmode, (uint8_t)is_on);
8578 #ifdef RTE_LIBRTE_BNXT_PMD
8579 if (ret == -ENOTSUP)
8580 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8581 vf_rxmode, (uint8_t)is_on);
8584 printf("bad VF receive mode parameter, return code = %d \n",
8588 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8589 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8591 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8592 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8594 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8595 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8597 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8598 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8600 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8601 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8603 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8604 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8606 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8607 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8608 mode, "AUPE#ROPE#BAM#MPE");
8609 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8610 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8613 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8614 .f = cmd_set_vf_rxmode_parsed,
8616 .help_str = "set port <port_id> vf <vf_id> rxmode "
8617 "AUPE|ROPE|BAM|MPE on|off",
8619 (void *)&cmd_set_vf_rxmode_set,
8620 (void *)&cmd_set_vf_rxmode_port,
8621 (void *)&cmd_set_vf_rxmode_portid,
8622 (void *)&cmd_set_vf_rxmode_vf,
8623 (void *)&cmd_set_vf_rxmode_vfid,
8624 (void *)&cmd_set_vf_rxmode_what,
8625 (void *)&cmd_set_vf_rxmode_mode,
8626 (void *)&cmd_set_vf_rxmode_on,
8631 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8632 struct cmd_vf_mac_addr_result {
8633 cmdline_fixed_string_t mac_addr_cmd;
8634 cmdline_fixed_string_t what;
8635 cmdline_fixed_string_t port;
8637 cmdline_fixed_string_t vf;
8639 struct rte_ether_addr address;
8642 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8643 __rte_unused struct cmdline *cl,
8644 __rte_unused void *data)
8646 struct cmd_vf_mac_addr_result *res = parsed_result;
8649 if (strcmp(res->what, "add") != 0)
8652 #ifdef RTE_LIBRTE_I40E_PMD
8653 if (ret == -ENOTSUP)
8654 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8657 #ifdef RTE_LIBRTE_BNXT_PMD
8658 if (ret == -ENOTSUP)
8659 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8664 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8668 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8669 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8670 mac_addr_cmd,"mac_addr");
8671 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8672 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8674 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8675 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8677 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8678 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8680 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8681 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8683 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8684 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8686 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8687 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8690 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8691 .f = cmd_vf_mac_addr_parsed,
8693 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8694 "Add MAC address filtering for a VF on port_id",
8696 (void *)&cmd_vf_mac_addr_cmd,
8697 (void *)&cmd_vf_mac_addr_what,
8698 (void *)&cmd_vf_mac_addr_port,
8699 (void *)&cmd_vf_mac_addr_portnum,
8700 (void *)&cmd_vf_mac_addr_vf,
8701 (void *)&cmd_vf_mac_addr_vfnum,
8702 (void *)&cmd_vf_mac_addr_addr,
8707 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8708 struct cmd_vf_rx_vlan_filter {
8709 cmdline_fixed_string_t rx_vlan;
8710 cmdline_fixed_string_t what;
8712 cmdline_fixed_string_t port;
8714 cmdline_fixed_string_t vf;
8719 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8720 __rte_unused struct cmdline *cl,
8721 __rte_unused void *data)
8723 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8726 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8728 #ifdef RTE_LIBRTE_IXGBE_PMD
8729 if (ret == -ENOTSUP)
8730 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8731 res->vlan_id, res->vf_mask, is_add);
8733 #ifdef RTE_LIBRTE_I40E_PMD
8734 if (ret == -ENOTSUP)
8735 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8736 res->vlan_id, res->vf_mask, is_add);
8738 #ifdef RTE_LIBRTE_BNXT_PMD
8739 if (ret == -ENOTSUP)
8740 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8741 res->vlan_id, res->vf_mask, is_add);
8748 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8749 res->vlan_id, res->vf_mask);
8752 printf("invalid port_id %d\n", res->port_id);
8755 printf("function not implemented or supported\n");
8758 printf("programming error: (%s)\n", strerror(-ret));
8762 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8763 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8764 rx_vlan, "rx_vlan");
8765 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8766 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8768 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8769 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8771 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8772 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8774 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8775 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8777 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8778 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8780 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8781 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8784 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8785 .f = cmd_vf_rx_vlan_filter_parsed,
8787 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8788 "(vf_mask = hexadecimal VF mask)",
8790 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8791 (void *)&cmd_vf_rx_vlan_filter_what,
8792 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8793 (void *)&cmd_vf_rx_vlan_filter_port,
8794 (void *)&cmd_vf_rx_vlan_filter_portid,
8795 (void *)&cmd_vf_rx_vlan_filter_vf,
8796 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8801 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8802 struct cmd_queue_rate_limit_result {
8803 cmdline_fixed_string_t set;
8804 cmdline_fixed_string_t port;
8806 cmdline_fixed_string_t queue;
8808 cmdline_fixed_string_t rate;
8812 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8813 __rte_unused struct cmdline *cl,
8814 __rte_unused void *data)
8816 struct cmd_queue_rate_limit_result *res = parsed_result;
8819 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8820 && (strcmp(res->queue, "queue") == 0)
8821 && (strcmp(res->rate, "rate") == 0))
8822 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8825 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8829 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8830 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8832 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8833 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8835 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8836 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8838 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8839 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8841 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8842 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8844 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8845 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8847 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8848 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8851 cmdline_parse_inst_t cmd_queue_rate_limit = {
8852 .f = cmd_queue_rate_limit_parsed,
8854 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8855 "Set rate limit for a queue on port_id",
8857 (void *)&cmd_queue_rate_limit_set,
8858 (void *)&cmd_queue_rate_limit_port,
8859 (void *)&cmd_queue_rate_limit_portnum,
8860 (void *)&cmd_queue_rate_limit_queue,
8861 (void *)&cmd_queue_rate_limit_queuenum,
8862 (void *)&cmd_queue_rate_limit_rate,
8863 (void *)&cmd_queue_rate_limit_ratenum,
8868 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8869 struct cmd_vf_rate_limit_result {
8870 cmdline_fixed_string_t set;
8871 cmdline_fixed_string_t port;
8873 cmdline_fixed_string_t vf;
8875 cmdline_fixed_string_t rate;
8877 cmdline_fixed_string_t q_msk;
8881 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8882 __rte_unused struct cmdline *cl,
8883 __rte_unused void *data)
8885 struct cmd_vf_rate_limit_result *res = parsed_result;
8888 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8889 && (strcmp(res->vf, "vf") == 0)
8890 && (strcmp(res->rate, "rate") == 0)
8891 && (strcmp(res->q_msk, "queue_mask") == 0))
8892 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8893 res->rate_num, res->q_msk_val);
8895 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8899 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8900 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8902 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8903 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8905 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8906 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8908 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8909 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8911 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8912 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8914 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8915 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8917 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8918 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8920 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8921 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8922 q_msk, "queue_mask");
8923 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8924 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8927 cmdline_parse_inst_t cmd_vf_rate_limit = {
8928 .f = cmd_vf_rate_limit_parsed,
8930 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8931 "queue_mask <queue_mask_value>: "
8932 "Set rate limit for queues of VF on port_id",
8934 (void *)&cmd_vf_rate_limit_set,
8935 (void *)&cmd_vf_rate_limit_port,
8936 (void *)&cmd_vf_rate_limit_portnum,
8937 (void *)&cmd_vf_rate_limit_vf,
8938 (void *)&cmd_vf_rate_limit_vfnum,
8939 (void *)&cmd_vf_rate_limit_rate,
8940 (void *)&cmd_vf_rate_limit_ratenum,
8941 (void *)&cmd_vf_rate_limit_q_msk,
8942 (void *)&cmd_vf_rate_limit_q_msk_val,
8947 /* *** ADD TUNNEL FILTER OF A PORT *** */
8948 struct cmd_tunnel_filter_result {
8949 cmdline_fixed_string_t cmd;
8950 cmdline_fixed_string_t what;
8952 struct rte_ether_addr outer_mac;
8953 struct rte_ether_addr inner_mac;
8954 cmdline_ipaddr_t ip_value;
8955 uint16_t inner_vlan;
8956 cmdline_fixed_string_t tunnel_type;
8957 cmdline_fixed_string_t filter_type;
8963 cmd_tunnel_filter_parsed(void *parsed_result,
8964 __rte_unused struct cmdline *cl,
8965 __rte_unused void *data)
8967 struct cmd_tunnel_filter_result *res = parsed_result;
8968 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8971 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8973 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8974 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8975 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8977 if (res->ip_value.family == AF_INET) {
8978 tunnel_filter_conf.ip_addr.ipv4_addr =
8979 res->ip_value.addr.ipv4.s_addr;
8980 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8982 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8983 &(res->ip_value.addr.ipv6),
8984 sizeof(struct in6_addr));
8985 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8988 if (!strcmp(res->filter_type, "imac-ivlan"))
8989 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8990 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8991 tunnel_filter_conf.filter_type =
8992 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8993 else if (!strcmp(res->filter_type, "imac-tenid"))
8994 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8995 else if (!strcmp(res->filter_type, "imac"))
8996 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8997 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8998 tunnel_filter_conf.filter_type =
8999 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9000 else if (!strcmp(res->filter_type, "oip"))
9001 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9002 else if (!strcmp(res->filter_type, "iip"))
9003 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9005 printf("The filter type is not supported");
9009 if (!strcmp(res->tunnel_type, "vxlan"))
9010 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9011 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9012 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9013 else if (!strcmp(res->tunnel_type, "nvgre"))
9014 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9015 else if (!strcmp(res->tunnel_type, "ipingre"))
9016 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9018 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9022 tunnel_filter_conf.tenant_id = res->tenant_id;
9023 tunnel_filter_conf.queue_id = res->queue_num;
9024 if (!strcmp(res->what, "add"))
9025 ret = rte_eth_dev_filter_ctrl(res->port_id,
9026 RTE_ETH_FILTER_TUNNEL,
9028 &tunnel_filter_conf);
9030 ret = rte_eth_dev_filter_ctrl(res->port_id,
9031 RTE_ETH_FILTER_TUNNEL,
9032 RTE_ETH_FILTER_DELETE,
9033 &tunnel_filter_conf);
9035 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9039 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9040 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9041 cmd, "tunnel_filter");
9042 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9043 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9045 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9046 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9048 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9049 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9051 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9052 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9054 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9055 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9056 inner_vlan, UINT16);
9057 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9058 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9060 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9061 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9062 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9064 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9065 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9066 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9067 "imac#omac-imac-tenid");
9068 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9069 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9071 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9072 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9075 cmdline_parse_inst_t cmd_tunnel_filter = {
9076 .f = cmd_tunnel_filter_parsed,
9078 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9079 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9080 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9081 "<queue_id>: Add/Rm tunnel filter of a port",
9083 (void *)&cmd_tunnel_filter_cmd,
9084 (void *)&cmd_tunnel_filter_what,
9085 (void *)&cmd_tunnel_filter_port_id,
9086 (void *)&cmd_tunnel_filter_outer_mac,
9087 (void *)&cmd_tunnel_filter_inner_mac,
9088 (void *)&cmd_tunnel_filter_ip_value,
9089 (void *)&cmd_tunnel_filter_innner_vlan,
9090 (void *)&cmd_tunnel_filter_tunnel_type,
9091 (void *)&cmd_tunnel_filter_filter_type,
9092 (void *)&cmd_tunnel_filter_tenant_id,
9093 (void *)&cmd_tunnel_filter_queue_num,
9098 /* *** CONFIGURE TUNNEL UDP PORT *** */
9099 struct cmd_tunnel_udp_config {
9100 cmdline_fixed_string_t cmd;
9101 cmdline_fixed_string_t what;
9107 cmd_tunnel_udp_config_parsed(void *parsed_result,
9108 __rte_unused struct cmdline *cl,
9109 __rte_unused void *data)
9111 struct cmd_tunnel_udp_config *res = parsed_result;
9112 struct rte_eth_udp_tunnel tunnel_udp;
9115 tunnel_udp.udp_port = res->udp_port;
9117 if (!strcmp(res->cmd, "rx_vxlan_port"))
9118 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9120 if (!strcmp(res->what, "add"))
9121 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9124 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9128 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9131 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9132 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9133 cmd, "rx_vxlan_port");
9134 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9135 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9137 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9138 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9140 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9141 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9144 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9145 .f = cmd_tunnel_udp_config_parsed,
9147 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9148 "Add/Remove a tunneling UDP port filter",
9150 (void *)&cmd_tunnel_udp_config_cmd,
9151 (void *)&cmd_tunnel_udp_config_what,
9152 (void *)&cmd_tunnel_udp_config_udp_port,
9153 (void *)&cmd_tunnel_udp_config_port_id,
9158 struct cmd_config_tunnel_udp_port {
9159 cmdline_fixed_string_t port;
9160 cmdline_fixed_string_t config;
9162 cmdline_fixed_string_t udp_tunnel_port;
9163 cmdline_fixed_string_t action;
9164 cmdline_fixed_string_t tunnel_type;
9169 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9170 __rte_unused struct cmdline *cl,
9171 __rte_unused void *data)
9173 struct cmd_config_tunnel_udp_port *res = parsed_result;
9174 struct rte_eth_udp_tunnel tunnel_udp;
9177 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9180 tunnel_udp.udp_port = res->udp_port;
9182 if (!strcmp(res->tunnel_type, "vxlan")) {
9183 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9184 } else if (!strcmp(res->tunnel_type, "geneve")) {
9185 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9186 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9187 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9189 printf("Invalid tunnel type\n");
9193 if (!strcmp(res->action, "add"))
9194 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9197 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9201 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9204 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9205 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9207 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9208 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9210 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9211 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9213 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9214 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9217 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9218 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9220 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9221 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9222 "vxlan#geneve#vxlan-gpe");
9223 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9224 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9227 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9228 .f = cmd_cfg_tunnel_udp_port_parsed,
9230 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9232 (void *)&cmd_config_tunnel_udp_port_port,
9233 (void *)&cmd_config_tunnel_udp_port_config,
9234 (void *)&cmd_config_tunnel_udp_port_port_id,
9235 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9236 (void *)&cmd_config_tunnel_udp_port_action,
9237 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9238 (void *)&cmd_config_tunnel_udp_port_value,
9243 /* *** GLOBAL CONFIG *** */
9244 struct cmd_global_config_result {
9245 cmdline_fixed_string_t cmd;
9247 cmdline_fixed_string_t cfg_type;
9252 cmd_global_config_parsed(void *parsed_result,
9253 __rte_unused struct cmdline *cl,
9254 __rte_unused void *data)
9256 struct cmd_global_config_result *res = parsed_result;
9257 struct rte_eth_global_cfg conf;
9260 memset(&conf, 0, sizeof(conf));
9261 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9262 conf.cfg.gre_key_len = res->len;
9263 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9264 RTE_ETH_FILTER_SET, &conf);
9266 printf("Global config error\n");
9269 cmdline_parse_token_string_t cmd_global_config_cmd =
9270 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9272 cmdline_parse_token_num_t cmd_global_config_port_id =
9273 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9275 cmdline_parse_token_string_t cmd_global_config_type =
9276 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9277 cfg_type, "gre-key-len");
9278 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9279 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9282 cmdline_parse_inst_t cmd_global_config = {
9283 .f = cmd_global_config_parsed,
9284 .data = (void *)NULL,
9285 .help_str = "global_config <port_id> gre-key-len <key_len>",
9287 (void *)&cmd_global_config_cmd,
9288 (void *)&cmd_global_config_port_id,
9289 (void *)&cmd_global_config_type,
9290 (void *)&cmd_global_config_gre_key_len,
9295 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9296 struct cmd_set_mirror_mask_result {
9297 cmdline_fixed_string_t set;
9298 cmdline_fixed_string_t port;
9300 cmdline_fixed_string_t mirror;
9302 cmdline_fixed_string_t what;
9303 cmdline_fixed_string_t value;
9304 cmdline_fixed_string_t dstpool;
9306 cmdline_fixed_string_t on;
9309 cmdline_parse_token_string_t cmd_mirror_mask_set =
9310 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9312 cmdline_parse_token_string_t cmd_mirror_mask_port =
9313 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9315 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9316 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9318 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9319 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9320 mirror, "mirror-rule");
9321 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9322 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9324 cmdline_parse_token_string_t cmd_mirror_mask_what =
9325 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9326 what, "pool-mirror-up#pool-mirror-down"
9328 cmdline_parse_token_string_t cmd_mirror_mask_value =
9329 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9331 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9332 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9333 dstpool, "dst-pool");
9334 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9335 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9337 cmdline_parse_token_string_t cmd_mirror_mask_on =
9338 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9342 cmd_set_mirror_mask_parsed(void *parsed_result,
9343 __rte_unused struct cmdline *cl,
9344 __rte_unused void *data)
9347 struct cmd_set_mirror_mask_result *res = parsed_result;
9348 struct rte_eth_mirror_conf mr_conf;
9350 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9352 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9354 mr_conf.dst_pool = res->dstpool_id;
9356 if (!strcmp(res->what, "pool-mirror-up")) {
9357 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9358 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9359 } else if (!strcmp(res->what, "pool-mirror-down")) {
9360 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9361 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9362 } else if (!strcmp(res->what, "vlan-mirror")) {
9363 mr_conf.rule_type = ETH_MIRROR_VLAN;
9364 nb_item = parse_item_list(res->value, "vlan",
9365 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9369 for (i = 0; i < nb_item; i++) {
9370 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9371 printf("Invalid vlan_id: must be < 4096\n");
9375 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9376 mr_conf.vlan.vlan_mask |= 1ULL << i;
9380 if (!strcmp(res->on, "on"))
9381 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9384 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9387 printf("mirror rule add error: (%s)\n", strerror(-ret));
9390 cmdline_parse_inst_t cmd_set_mirror_mask = {
9391 .f = cmd_set_mirror_mask_parsed,
9393 .help_str = "set port <port_id> mirror-rule <rule_id> "
9394 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9395 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9397 (void *)&cmd_mirror_mask_set,
9398 (void *)&cmd_mirror_mask_port,
9399 (void *)&cmd_mirror_mask_portid,
9400 (void *)&cmd_mirror_mask_mirror,
9401 (void *)&cmd_mirror_mask_ruleid,
9402 (void *)&cmd_mirror_mask_what,
9403 (void *)&cmd_mirror_mask_value,
9404 (void *)&cmd_mirror_mask_dstpool,
9405 (void *)&cmd_mirror_mask_poolid,
9406 (void *)&cmd_mirror_mask_on,
9411 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9412 struct cmd_set_mirror_link_result {
9413 cmdline_fixed_string_t set;
9414 cmdline_fixed_string_t port;
9416 cmdline_fixed_string_t mirror;
9418 cmdline_fixed_string_t what;
9419 cmdline_fixed_string_t dstpool;
9421 cmdline_fixed_string_t on;
9424 cmdline_parse_token_string_t cmd_mirror_link_set =
9425 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9427 cmdline_parse_token_string_t cmd_mirror_link_port =
9428 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9430 cmdline_parse_token_num_t cmd_mirror_link_portid =
9431 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9433 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9434 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9435 mirror, "mirror-rule");
9436 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9437 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9439 cmdline_parse_token_string_t cmd_mirror_link_what =
9440 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9441 what, "uplink-mirror#downlink-mirror");
9442 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9443 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9444 dstpool, "dst-pool");
9445 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9446 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9448 cmdline_parse_token_string_t cmd_mirror_link_on =
9449 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9453 cmd_set_mirror_link_parsed(void *parsed_result,
9454 __rte_unused struct cmdline *cl,
9455 __rte_unused void *data)
9458 struct cmd_set_mirror_link_result *res = parsed_result;
9459 struct rte_eth_mirror_conf mr_conf;
9461 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9462 if (!strcmp(res->what, "uplink-mirror"))
9463 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9465 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9467 mr_conf.dst_pool = res->dstpool_id;
9469 if (!strcmp(res->on, "on"))
9470 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9473 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9476 /* check the return value and print it if is < 0 */
9478 printf("mirror rule add error: (%s)\n", strerror(-ret));
9482 cmdline_parse_inst_t cmd_set_mirror_link = {
9483 .f = cmd_set_mirror_link_parsed,
9485 .help_str = "set port <port_id> mirror-rule <rule_id> "
9486 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9488 (void *)&cmd_mirror_link_set,
9489 (void *)&cmd_mirror_link_port,
9490 (void *)&cmd_mirror_link_portid,
9491 (void *)&cmd_mirror_link_mirror,
9492 (void *)&cmd_mirror_link_ruleid,
9493 (void *)&cmd_mirror_link_what,
9494 (void *)&cmd_mirror_link_dstpool,
9495 (void *)&cmd_mirror_link_poolid,
9496 (void *)&cmd_mirror_link_on,
9501 /* *** RESET VM MIRROR RULE *** */
9502 struct cmd_rm_mirror_rule_result {
9503 cmdline_fixed_string_t reset;
9504 cmdline_fixed_string_t port;
9506 cmdline_fixed_string_t mirror;
9510 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9511 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9513 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9514 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9516 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9517 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9519 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9520 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9521 mirror, "mirror-rule");
9522 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9523 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9527 cmd_reset_mirror_rule_parsed(void *parsed_result,
9528 __rte_unused struct cmdline *cl,
9529 __rte_unused void *data)
9532 struct cmd_set_mirror_link_result *res = parsed_result;
9534 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9536 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9539 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9540 .f = cmd_reset_mirror_rule_parsed,
9542 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9544 (void *)&cmd_rm_mirror_rule_reset,
9545 (void *)&cmd_rm_mirror_rule_port,
9546 (void *)&cmd_rm_mirror_rule_portid,
9547 (void *)&cmd_rm_mirror_rule_mirror,
9548 (void *)&cmd_rm_mirror_rule_ruleid,
9553 /* ******************************************************************************** */
9555 struct cmd_dump_result {
9556 cmdline_fixed_string_t dump;
9560 dump_struct_sizes(void)
9562 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9563 DUMP_SIZE(struct rte_mbuf);
9564 DUMP_SIZE(struct rte_mempool);
9565 DUMP_SIZE(struct rte_ring);
9569 static void cmd_dump_parsed(void *parsed_result,
9570 __rte_unused struct cmdline *cl,
9571 __rte_unused void *data)
9573 struct cmd_dump_result *res = parsed_result;
9575 if (!strcmp(res->dump, "dump_physmem"))
9576 rte_dump_physmem_layout(stdout);
9577 else if (!strcmp(res->dump, "dump_memzone"))
9578 rte_memzone_dump(stdout);
9579 else if (!strcmp(res->dump, "dump_struct_sizes"))
9580 dump_struct_sizes();
9581 else if (!strcmp(res->dump, "dump_ring"))
9582 rte_ring_list_dump(stdout);
9583 else if (!strcmp(res->dump, "dump_mempool"))
9584 rte_mempool_list_dump(stdout);
9585 else if (!strcmp(res->dump, "dump_devargs"))
9586 rte_devargs_dump(stdout);
9587 else if (!strcmp(res->dump, "dump_log_types"))
9588 rte_log_dump(stdout);
9591 cmdline_parse_token_string_t cmd_dump_dump =
9592 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9595 "dump_struct_sizes#"
9601 cmdline_parse_inst_t cmd_dump = {
9602 .f = cmd_dump_parsed, /* function to call */
9603 .data = NULL, /* 2nd arg of func */
9604 .help_str = "Dump status",
9605 .tokens = { /* token list, NULL terminated */
9606 (void *)&cmd_dump_dump,
9611 /* ******************************************************************************** */
9613 struct cmd_dump_one_result {
9614 cmdline_fixed_string_t dump;
9615 cmdline_fixed_string_t name;
9618 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9619 __rte_unused void *data)
9621 struct cmd_dump_one_result *res = parsed_result;
9623 if (!strcmp(res->dump, "dump_ring")) {
9625 r = rte_ring_lookup(res->name);
9627 cmdline_printf(cl, "Cannot find ring\n");
9630 rte_ring_dump(stdout, r);
9631 } else if (!strcmp(res->dump, "dump_mempool")) {
9632 struct rte_mempool *mp;
9633 mp = rte_mempool_lookup(res->name);
9635 cmdline_printf(cl, "Cannot find mempool\n");
9638 rte_mempool_dump(stdout, mp);
9642 cmdline_parse_token_string_t cmd_dump_one_dump =
9643 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9644 "dump_ring#dump_mempool");
9646 cmdline_parse_token_string_t cmd_dump_one_name =
9647 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9649 cmdline_parse_inst_t cmd_dump_one = {
9650 .f = cmd_dump_one_parsed, /* function to call */
9651 .data = NULL, /* 2nd arg of func */
9652 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9653 .tokens = { /* token list, NULL terminated */
9654 (void *)&cmd_dump_one_dump,
9655 (void *)&cmd_dump_one_name,
9660 /* *** Add/Del syn filter *** */
9661 struct cmd_syn_filter_result {
9662 cmdline_fixed_string_t filter;
9664 cmdline_fixed_string_t ops;
9665 cmdline_fixed_string_t priority;
9666 cmdline_fixed_string_t high;
9667 cmdline_fixed_string_t queue;
9672 cmd_syn_filter_parsed(void *parsed_result,
9673 __rte_unused struct cmdline *cl,
9674 __rte_unused void *data)
9676 struct cmd_syn_filter_result *res = parsed_result;
9677 struct rte_eth_syn_filter syn_filter;
9680 ret = rte_eth_dev_filter_supported(res->port_id,
9681 RTE_ETH_FILTER_SYN);
9683 printf("syn filter is not supported on port %u.\n",
9688 memset(&syn_filter, 0, sizeof(syn_filter));
9690 if (!strcmp(res->ops, "add")) {
9691 if (!strcmp(res->high, "high"))
9692 syn_filter.hig_pri = 1;
9694 syn_filter.hig_pri = 0;
9696 syn_filter.queue = res->queue_id;
9697 ret = rte_eth_dev_filter_ctrl(res->port_id,
9702 ret = rte_eth_dev_filter_ctrl(res->port_id,
9704 RTE_ETH_FILTER_DELETE,
9708 printf("syn filter programming error: (%s)\n",
9712 cmdline_parse_token_string_t cmd_syn_filter_filter =
9713 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9714 filter, "syn_filter");
9715 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9716 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9718 cmdline_parse_token_string_t cmd_syn_filter_ops =
9719 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9721 cmdline_parse_token_string_t cmd_syn_filter_priority =
9722 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9723 priority, "priority");
9724 cmdline_parse_token_string_t cmd_syn_filter_high =
9725 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9727 cmdline_parse_token_string_t cmd_syn_filter_queue =
9728 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9730 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9731 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9734 cmdline_parse_inst_t cmd_syn_filter = {
9735 .f = cmd_syn_filter_parsed,
9737 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9738 "<queue_id>: Add/Delete syn filter",
9740 (void *)&cmd_syn_filter_filter,
9741 (void *)&cmd_syn_filter_port_id,
9742 (void *)&cmd_syn_filter_ops,
9743 (void *)&cmd_syn_filter_priority,
9744 (void *)&cmd_syn_filter_high,
9745 (void *)&cmd_syn_filter_queue,
9746 (void *)&cmd_syn_filter_queue_id,
9751 /* *** queue region set *** */
9752 struct cmd_queue_region_result {
9753 cmdline_fixed_string_t set;
9754 cmdline_fixed_string_t port;
9756 cmdline_fixed_string_t cmd;
9757 cmdline_fixed_string_t region;
9759 cmdline_fixed_string_t queue_start_index;
9761 cmdline_fixed_string_t queue_num;
9762 uint8_t queue_num_value;
9766 cmd_queue_region_parsed(void *parsed_result,
9767 __rte_unused struct cmdline *cl,
9768 __rte_unused void *data)
9770 struct cmd_queue_region_result *res = parsed_result;
9772 #ifdef RTE_LIBRTE_I40E_PMD
9773 struct rte_pmd_i40e_queue_region_conf region_conf;
9774 enum rte_pmd_i40e_queue_region_op op_type;
9777 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9780 #ifdef RTE_LIBRTE_I40E_PMD
9781 memset(®ion_conf, 0, sizeof(region_conf));
9782 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9783 region_conf.region_id = res->region_id;
9784 region_conf.queue_num = res->queue_num_value;
9785 region_conf.queue_start_index = res->queue_id;
9787 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9788 op_type, ®ion_conf);
9795 printf("function not implemented or supported\n");
9798 printf("queue region config error: (%s)\n", strerror(-ret));
9802 cmdline_parse_token_string_t cmd_queue_region_set =
9803 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9805 cmdline_parse_token_string_t cmd_queue_region_port =
9806 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9807 cmdline_parse_token_num_t cmd_queue_region_port_id =
9808 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9810 cmdline_parse_token_string_t cmd_queue_region_cmd =
9811 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9812 cmd, "queue-region");
9813 cmdline_parse_token_string_t cmd_queue_region_id =
9814 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9815 region, "region_id");
9816 cmdline_parse_token_num_t cmd_queue_region_index =
9817 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9819 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9820 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9821 queue_start_index, "queue_start_index");
9822 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9823 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9825 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9826 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9827 queue_num, "queue_num");
9828 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9829 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9830 queue_num_value, UINT8);
9832 cmdline_parse_inst_t cmd_queue_region = {
9833 .f = cmd_queue_region_parsed,
9835 .help_str = "set port <port_id> queue-region region_id <value> "
9836 "queue_start_index <value> queue_num <value>: Set a queue region",
9838 (void *)&cmd_queue_region_set,
9839 (void *)&cmd_queue_region_port,
9840 (void *)&cmd_queue_region_port_id,
9841 (void *)&cmd_queue_region_cmd,
9842 (void *)&cmd_queue_region_id,
9843 (void *)&cmd_queue_region_index,
9844 (void *)&cmd_queue_region_queue_start_index,
9845 (void *)&cmd_queue_region_queue_id,
9846 (void *)&cmd_queue_region_queue_num,
9847 (void *)&cmd_queue_region_queue_num_value,
9852 /* *** queue region and flowtype set *** */
9853 struct cmd_region_flowtype_result {
9854 cmdline_fixed_string_t set;
9855 cmdline_fixed_string_t port;
9857 cmdline_fixed_string_t cmd;
9858 cmdline_fixed_string_t region;
9860 cmdline_fixed_string_t flowtype;
9861 uint8_t flowtype_id;
9865 cmd_region_flowtype_parsed(void *parsed_result,
9866 __rte_unused struct cmdline *cl,
9867 __rte_unused void *data)
9869 struct cmd_region_flowtype_result *res = parsed_result;
9871 #ifdef RTE_LIBRTE_I40E_PMD
9872 struct rte_pmd_i40e_queue_region_conf region_conf;
9873 enum rte_pmd_i40e_queue_region_op op_type;
9876 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9879 #ifdef RTE_LIBRTE_I40E_PMD
9880 memset(®ion_conf, 0, sizeof(region_conf));
9882 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9883 region_conf.region_id = res->region_id;
9884 region_conf.hw_flowtype = res->flowtype_id;
9886 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9887 op_type, ®ion_conf);
9894 printf("function not implemented or supported\n");
9897 printf("region flowtype config error: (%s)\n", strerror(-ret));
9901 cmdline_parse_token_string_t cmd_region_flowtype_set =
9902 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9904 cmdline_parse_token_string_t cmd_region_flowtype_port =
9905 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9907 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9908 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9910 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9911 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9912 cmd, "queue-region");
9913 cmdline_parse_token_string_t cmd_region_flowtype_index =
9914 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9915 region, "region_id");
9916 cmdline_parse_token_num_t cmd_region_flowtype_id =
9917 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9919 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9920 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9921 flowtype, "flowtype");
9922 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9923 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9924 flowtype_id, UINT8);
9925 cmdline_parse_inst_t cmd_region_flowtype = {
9926 .f = cmd_region_flowtype_parsed,
9928 .help_str = "set port <port_id> queue-region region_id <value> "
9929 "flowtype <value>: Set a flowtype region index",
9931 (void *)&cmd_region_flowtype_set,
9932 (void *)&cmd_region_flowtype_port,
9933 (void *)&cmd_region_flowtype_port_index,
9934 (void *)&cmd_region_flowtype_cmd,
9935 (void *)&cmd_region_flowtype_index,
9936 (void *)&cmd_region_flowtype_id,
9937 (void *)&cmd_region_flowtype_flow_index,
9938 (void *)&cmd_region_flowtype_flow_id,
9943 /* *** User Priority (UP) to queue region (region_id) set *** */
9944 struct cmd_user_priority_region_result {
9945 cmdline_fixed_string_t set;
9946 cmdline_fixed_string_t port;
9948 cmdline_fixed_string_t cmd;
9949 cmdline_fixed_string_t user_priority;
9950 uint8_t user_priority_id;
9951 cmdline_fixed_string_t region;
9956 cmd_user_priority_region_parsed(void *parsed_result,
9957 __rte_unused struct cmdline *cl,
9958 __rte_unused void *data)
9960 struct cmd_user_priority_region_result *res = parsed_result;
9962 #ifdef RTE_LIBRTE_I40E_PMD
9963 struct rte_pmd_i40e_queue_region_conf region_conf;
9964 enum rte_pmd_i40e_queue_region_op op_type;
9967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9970 #ifdef RTE_LIBRTE_I40E_PMD
9971 memset(®ion_conf, 0, sizeof(region_conf));
9972 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9973 region_conf.user_priority = res->user_priority_id;
9974 region_conf.region_id = res->region_id;
9976 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9977 op_type, ®ion_conf);
9984 printf("function not implemented or supported\n");
9987 printf("user_priority region config error: (%s)\n",
9992 cmdline_parse_token_string_t cmd_user_priority_region_set =
9993 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9995 cmdline_parse_token_string_t cmd_user_priority_region_port =
9996 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9998 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9999 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10001 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10002 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10003 cmd, "queue-region");
10004 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10005 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10006 user_priority, "UP");
10007 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10008 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10009 user_priority_id, UINT8);
10010 cmdline_parse_token_string_t cmd_user_priority_region_region =
10011 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10012 region, "region_id");
10013 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10014 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10017 cmdline_parse_inst_t cmd_user_priority_region = {
10018 .f = cmd_user_priority_region_parsed,
10020 .help_str = "set port <port_id> queue-region UP <value> "
10021 "region_id <value>: Set the mapping of User Priority (UP) "
10022 "to queue region (region_id) ",
10024 (void *)&cmd_user_priority_region_set,
10025 (void *)&cmd_user_priority_region_port,
10026 (void *)&cmd_user_priority_region_port_index,
10027 (void *)&cmd_user_priority_region_cmd,
10028 (void *)&cmd_user_priority_region_UP,
10029 (void *)&cmd_user_priority_region_UP_id,
10030 (void *)&cmd_user_priority_region_region,
10031 (void *)&cmd_user_priority_region_region_id,
10036 /* *** flush all queue region related configuration *** */
10037 struct cmd_flush_queue_region_result {
10038 cmdline_fixed_string_t set;
10039 cmdline_fixed_string_t port;
10041 cmdline_fixed_string_t cmd;
10042 cmdline_fixed_string_t flush;
10043 cmdline_fixed_string_t what;
10047 cmd_flush_queue_region_parsed(void *parsed_result,
10048 __rte_unused struct cmdline *cl,
10049 __rte_unused void *data)
10051 struct cmd_flush_queue_region_result *res = parsed_result;
10052 int ret = -ENOTSUP;
10053 #ifdef RTE_LIBRTE_I40E_PMD
10054 struct rte_pmd_i40e_queue_region_conf region_conf;
10055 enum rte_pmd_i40e_queue_region_op op_type;
10058 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10061 #ifdef RTE_LIBRTE_I40E_PMD
10062 memset(®ion_conf, 0, sizeof(region_conf));
10064 if (strcmp(res->what, "on") == 0)
10065 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10067 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10069 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10070 op_type, ®ion_conf);
10077 printf("function not implemented or supported\n");
10080 printf("queue region config flush error: (%s)\n",
10085 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10086 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10088 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10089 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10091 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10092 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10094 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10095 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10096 cmd, "queue-region");
10097 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10098 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10100 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10101 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10104 cmdline_parse_inst_t cmd_flush_queue_region = {
10105 .f = cmd_flush_queue_region_parsed,
10107 .help_str = "set port <port_id> queue-region flush on|off"
10108 ": flush all queue region related configuration",
10110 (void *)&cmd_flush_queue_region_set,
10111 (void *)&cmd_flush_queue_region_port,
10112 (void *)&cmd_flush_queue_region_port_index,
10113 (void *)&cmd_flush_queue_region_cmd,
10114 (void *)&cmd_flush_queue_region_flush,
10115 (void *)&cmd_flush_queue_region_what,
10120 /* *** get all queue region related configuration info *** */
10121 struct cmd_show_queue_region_info {
10122 cmdline_fixed_string_t show;
10123 cmdline_fixed_string_t port;
10125 cmdline_fixed_string_t cmd;
10129 cmd_show_queue_region_info_parsed(void *parsed_result,
10130 __rte_unused struct cmdline *cl,
10131 __rte_unused void *data)
10133 struct cmd_show_queue_region_info *res = parsed_result;
10134 int ret = -ENOTSUP;
10135 #ifdef RTE_LIBRTE_I40E_PMD
10136 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10137 enum rte_pmd_i40e_queue_region_op op_type;
10140 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10143 #ifdef RTE_LIBRTE_I40E_PMD
10144 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10146 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10148 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10149 op_type, &rte_pmd_regions);
10151 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10158 printf("function not implemented or supported\n");
10161 printf("queue region config info show error: (%s)\n",
10166 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10167 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10169 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10170 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10172 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10173 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10175 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10176 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10177 cmd, "queue-region");
10179 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10180 .f = cmd_show_queue_region_info_parsed,
10182 .help_str = "show port <port_id> queue-region"
10183 ": show all queue region related configuration info",
10185 (void *)&cmd_show_queue_region_info_get,
10186 (void *)&cmd_show_queue_region_info_port,
10187 (void *)&cmd_show_queue_region_info_port_index,
10188 (void *)&cmd_show_queue_region_info_cmd,
10193 /* *** ADD/REMOVE A 2tuple FILTER *** */
10194 struct cmd_2tuple_filter_result {
10195 cmdline_fixed_string_t filter;
10197 cmdline_fixed_string_t ops;
10198 cmdline_fixed_string_t dst_port;
10199 uint16_t dst_port_value;
10200 cmdline_fixed_string_t protocol;
10201 uint8_t protocol_value;
10202 cmdline_fixed_string_t mask;
10203 uint8_t mask_value;
10204 cmdline_fixed_string_t tcp_flags;
10205 uint8_t tcp_flags_value;
10206 cmdline_fixed_string_t priority;
10207 uint8_t priority_value;
10208 cmdline_fixed_string_t queue;
10213 cmd_2tuple_filter_parsed(void *parsed_result,
10214 __rte_unused struct cmdline *cl,
10215 __rte_unused void *data)
10217 struct rte_eth_ntuple_filter filter;
10218 struct cmd_2tuple_filter_result *res = parsed_result;
10221 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10223 printf("ntuple filter is not supported on port %u.\n",
10228 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10230 filter.flags = RTE_2TUPLE_FLAGS;
10231 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10232 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10233 filter.proto = res->protocol_value;
10234 filter.priority = res->priority_value;
10235 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10236 printf("nonzero tcp_flags is only meaningful"
10237 " when protocol is TCP.\n");
10240 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10241 printf("invalid TCP flags.\n");
10245 if (res->tcp_flags_value != 0) {
10246 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10247 filter.tcp_flags = res->tcp_flags_value;
10250 /* need convert to big endian. */
10251 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10252 filter.queue = res->queue_id;
10254 if (!strcmp(res->ops, "add"))
10255 ret = rte_eth_dev_filter_ctrl(res->port_id,
10256 RTE_ETH_FILTER_NTUPLE,
10257 RTE_ETH_FILTER_ADD,
10260 ret = rte_eth_dev_filter_ctrl(res->port_id,
10261 RTE_ETH_FILTER_NTUPLE,
10262 RTE_ETH_FILTER_DELETE,
10265 printf("2tuple filter programming error: (%s)\n",
10270 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10271 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10272 filter, "2tuple_filter");
10273 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10274 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10276 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10277 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10279 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10280 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10281 dst_port, "dst_port");
10282 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10283 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10284 dst_port_value, UINT16);
10285 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10286 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10287 protocol, "protocol");
10288 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10289 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10290 protocol_value, UINT8);
10291 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10292 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10294 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10295 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10297 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10298 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10299 tcp_flags, "tcp_flags");
10300 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10301 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10302 tcp_flags_value, UINT8);
10303 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10304 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10305 priority, "priority");
10306 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10307 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10308 priority_value, UINT8);
10309 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10310 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10312 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10313 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10316 cmdline_parse_inst_t cmd_2tuple_filter = {
10317 .f = cmd_2tuple_filter_parsed,
10319 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10320 "<value> mask <value> tcp_flags <value> priority <value> queue "
10321 "<queue_id>: Add a 2tuple filter",
10323 (void *)&cmd_2tuple_filter_filter,
10324 (void *)&cmd_2tuple_filter_port_id,
10325 (void *)&cmd_2tuple_filter_ops,
10326 (void *)&cmd_2tuple_filter_dst_port,
10327 (void *)&cmd_2tuple_filter_dst_port_value,
10328 (void *)&cmd_2tuple_filter_protocol,
10329 (void *)&cmd_2tuple_filter_protocol_value,
10330 (void *)&cmd_2tuple_filter_mask,
10331 (void *)&cmd_2tuple_filter_mask_value,
10332 (void *)&cmd_2tuple_filter_tcp_flags,
10333 (void *)&cmd_2tuple_filter_tcp_flags_value,
10334 (void *)&cmd_2tuple_filter_priority,
10335 (void *)&cmd_2tuple_filter_priority_value,
10336 (void *)&cmd_2tuple_filter_queue,
10337 (void *)&cmd_2tuple_filter_queue_id,
10342 /* *** ADD/REMOVE A 5tuple FILTER *** */
10343 struct cmd_5tuple_filter_result {
10344 cmdline_fixed_string_t filter;
10346 cmdline_fixed_string_t ops;
10347 cmdline_fixed_string_t dst_ip;
10348 cmdline_ipaddr_t dst_ip_value;
10349 cmdline_fixed_string_t src_ip;
10350 cmdline_ipaddr_t src_ip_value;
10351 cmdline_fixed_string_t dst_port;
10352 uint16_t dst_port_value;
10353 cmdline_fixed_string_t src_port;
10354 uint16_t src_port_value;
10355 cmdline_fixed_string_t protocol;
10356 uint8_t protocol_value;
10357 cmdline_fixed_string_t mask;
10358 uint8_t mask_value;
10359 cmdline_fixed_string_t tcp_flags;
10360 uint8_t tcp_flags_value;
10361 cmdline_fixed_string_t priority;
10362 uint8_t priority_value;
10363 cmdline_fixed_string_t queue;
10368 cmd_5tuple_filter_parsed(void *parsed_result,
10369 __rte_unused struct cmdline *cl,
10370 __rte_unused void *data)
10372 struct rte_eth_ntuple_filter filter;
10373 struct cmd_5tuple_filter_result *res = parsed_result;
10376 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10378 printf("ntuple filter is not supported on port %u.\n",
10383 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10385 filter.flags = RTE_5TUPLE_FLAGS;
10386 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10387 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10388 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10389 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10390 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10391 filter.proto = res->protocol_value;
10392 filter.priority = res->priority_value;
10393 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10394 printf("nonzero tcp_flags is only meaningful"
10395 " when protocol is TCP.\n");
10398 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10399 printf("invalid TCP flags.\n");
10403 if (res->tcp_flags_value != 0) {
10404 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10405 filter.tcp_flags = res->tcp_flags_value;
10408 if (res->dst_ip_value.family == AF_INET)
10409 /* no need to convert, already big endian. */
10410 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10412 if (filter.dst_ip_mask == 0) {
10413 printf("can not support ipv6 involved compare.\n");
10419 if (res->src_ip_value.family == AF_INET)
10420 /* no need to convert, already big endian. */
10421 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10423 if (filter.src_ip_mask == 0) {
10424 printf("can not support ipv6 involved compare.\n");
10429 /* need convert to big endian. */
10430 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10431 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10432 filter.queue = res->queue_id;
10434 if (!strcmp(res->ops, "add"))
10435 ret = rte_eth_dev_filter_ctrl(res->port_id,
10436 RTE_ETH_FILTER_NTUPLE,
10437 RTE_ETH_FILTER_ADD,
10440 ret = rte_eth_dev_filter_ctrl(res->port_id,
10441 RTE_ETH_FILTER_NTUPLE,
10442 RTE_ETH_FILTER_DELETE,
10445 printf("5tuple filter programming error: (%s)\n",
10449 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10450 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10451 filter, "5tuple_filter");
10452 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10453 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10455 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10456 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10458 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10459 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10461 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10462 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10464 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10465 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10467 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10468 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10470 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10471 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10472 dst_port, "dst_port");
10473 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10474 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10475 dst_port_value, UINT16);
10476 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10477 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10478 src_port, "src_port");
10479 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10480 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10481 src_port_value, UINT16);
10482 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10483 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10484 protocol, "protocol");
10485 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10486 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10487 protocol_value, UINT8);
10488 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10489 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10491 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10492 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10494 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10495 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10496 tcp_flags, "tcp_flags");
10497 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10498 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10499 tcp_flags_value, UINT8);
10500 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10501 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10502 priority, "priority");
10503 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10504 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10505 priority_value, UINT8);
10506 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10507 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10509 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10510 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10513 cmdline_parse_inst_t cmd_5tuple_filter = {
10514 .f = cmd_5tuple_filter_parsed,
10516 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10517 "src_ip <value> dst_port <value> src_port <value> "
10518 "protocol <value> mask <value> tcp_flags <value> "
10519 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10521 (void *)&cmd_5tuple_filter_filter,
10522 (void *)&cmd_5tuple_filter_port_id,
10523 (void *)&cmd_5tuple_filter_ops,
10524 (void *)&cmd_5tuple_filter_dst_ip,
10525 (void *)&cmd_5tuple_filter_dst_ip_value,
10526 (void *)&cmd_5tuple_filter_src_ip,
10527 (void *)&cmd_5tuple_filter_src_ip_value,
10528 (void *)&cmd_5tuple_filter_dst_port,
10529 (void *)&cmd_5tuple_filter_dst_port_value,
10530 (void *)&cmd_5tuple_filter_src_port,
10531 (void *)&cmd_5tuple_filter_src_port_value,
10532 (void *)&cmd_5tuple_filter_protocol,
10533 (void *)&cmd_5tuple_filter_protocol_value,
10534 (void *)&cmd_5tuple_filter_mask,
10535 (void *)&cmd_5tuple_filter_mask_value,
10536 (void *)&cmd_5tuple_filter_tcp_flags,
10537 (void *)&cmd_5tuple_filter_tcp_flags_value,
10538 (void *)&cmd_5tuple_filter_priority,
10539 (void *)&cmd_5tuple_filter_priority_value,
10540 (void *)&cmd_5tuple_filter_queue,
10541 (void *)&cmd_5tuple_filter_queue_id,
10546 /* *** ADD/REMOVE A flex FILTER *** */
10547 struct cmd_flex_filter_result {
10548 cmdline_fixed_string_t filter;
10549 cmdline_fixed_string_t ops;
10551 cmdline_fixed_string_t len;
10553 cmdline_fixed_string_t bytes;
10554 cmdline_fixed_string_t bytes_value;
10555 cmdline_fixed_string_t mask;
10556 cmdline_fixed_string_t mask_value;
10557 cmdline_fixed_string_t priority;
10558 uint8_t priority_value;
10559 cmdline_fixed_string_t queue;
10563 static int xdigit2val(unsigned char c)
10568 else if (isupper(c))
10569 val = c - 'A' + 10;
10571 val = c - 'a' + 10;
10576 cmd_flex_filter_parsed(void *parsed_result,
10577 __rte_unused struct cmdline *cl,
10578 __rte_unused void *data)
10581 struct rte_eth_flex_filter filter;
10582 struct cmd_flex_filter_result *res = parsed_result;
10583 char *bytes_ptr, *mask_ptr;
10584 uint16_t len, i, j = 0;
10589 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10590 printf("the len exceed the max length 128\n");
10593 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10594 filter.len = res->len_value;
10595 filter.priority = res->priority_value;
10596 filter.queue = res->queue_id;
10597 bytes_ptr = res->bytes_value;
10598 mask_ptr = res->mask_value;
10600 /* translate bytes string to array. */
10601 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10602 (bytes_ptr[1] == 'X')))
10604 len = strnlen(bytes_ptr, res->len_value * 2);
10605 if (len == 0 || (len % 8 != 0)) {
10606 printf("please check len and bytes input\n");
10609 for (i = 0; i < len; i++) {
10611 if (isxdigit(c) == 0) {
10612 /* invalid characters. */
10613 printf("invalid input\n");
10616 val = xdigit2val(c);
10619 filter.bytes[j] = byte;
10620 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10627 /* translate mask string to uint8_t array. */
10628 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10629 (mask_ptr[1] == 'X')))
10631 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10633 printf("invalid input\n");
10638 for (i = 0; i < len; i++) {
10640 if (isxdigit(c) == 0) {
10641 /* invalid characters. */
10642 printf("invalid input\n");
10645 val = xdigit2val(c);
10648 filter.mask[j] = byte;
10649 printf("mask[%d]:%02x ", j, filter.mask[j]);
10657 if (!strcmp(res->ops, "add"))
10658 ret = rte_eth_dev_filter_ctrl(res->port_id,
10659 RTE_ETH_FILTER_FLEXIBLE,
10660 RTE_ETH_FILTER_ADD,
10663 ret = rte_eth_dev_filter_ctrl(res->port_id,
10664 RTE_ETH_FILTER_FLEXIBLE,
10665 RTE_ETH_FILTER_DELETE,
10669 printf("flex filter setting error: (%s)\n", strerror(-ret));
10672 cmdline_parse_token_string_t cmd_flex_filter_filter =
10673 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10674 filter, "flex_filter");
10675 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10676 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10678 cmdline_parse_token_string_t cmd_flex_filter_ops =
10679 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10681 cmdline_parse_token_string_t cmd_flex_filter_len =
10682 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10684 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10685 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10687 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10688 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10690 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10691 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10692 bytes_value, NULL);
10693 cmdline_parse_token_string_t cmd_flex_filter_mask =
10694 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10696 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10697 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10699 cmdline_parse_token_string_t cmd_flex_filter_priority =
10700 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10701 priority, "priority");
10702 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10703 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10704 priority_value, UINT8);
10705 cmdline_parse_token_string_t cmd_flex_filter_queue =
10706 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10708 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10709 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10711 cmdline_parse_inst_t cmd_flex_filter = {
10712 .f = cmd_flex_filter_parsed,
10714 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10715 "<value> mask <value> priority <value> queue <queue_id>: "
10716 "Add/Del a flex filter",
10718 (void *)&cmd_flex_filter_filter,
10719 (void *)&cmd_flex_filter_port_id,
10720 (void *)&cmd_flex_filter_ops,
10721 (void *)&cmd_flex_filter_len,
10722 (void *)&cmd_flex_filter_len_value,
10723 (void *)&cmd_flex_filter_bytes,
10724 (void *)&cmd_flex_filter_bytes_value,
10725 (void *)&cmd_flex_filter_mask,
10726 (void *)&cmd_flex_filter_mask_value,
10727 (void *)&cmd_flex_filter_priority,
10728 (void *)&cmd_flex_filter_priority_value,
10729 (void *)&cmd_flex_filter_queue,
10730 (void *)&cmd_flex_filter_queue_id,
10735 /* *** Filters Control *** */
10737 /* *** deal with ethertype filter *** */
10738 struct cmd_ethertype_filter_result {
10739 cmdline_fixed_string_t filter;
10741 cmdline_fixed_string_t ops;
10742 cmdline_fixed_string_t mac;
10743 struct rte_ether_addr mac_addr;
10744 cmdline_fixed_string_t ethertype;
10745 uint16_t ethertype_value;
10746 cmdline_fixed_string_t drop;
10747 cmdline_fixed_string_t queue;
10751 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10752 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10753 filter, "ethertype_filter");
10754 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10755 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10757 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10758 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10760 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10761 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10762 mac, "mac_addr#mac_ignr");
10763 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10764 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10766 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10767 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10768 ethertype, "ethertype");
10769 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10770 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10771 ethertype_value, UINT16);
10772 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10773 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10775 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10776 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10778 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10779 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10783 cmd_ethertype_filter_parsed(void *parsed_result,
10784 __rte_unused struct cmdline *cl,
10785 __rte_unused void *data)
10787 struct cmd_ethertype_filter_result *res = parsed_result;
10788 struct rte_eth_ethertype_filter filter;
10791 ret = rte_eth_dev_filter_supported(res->port_id,
10792 RTE_ETH_FILTER_ETHERTYPE);
10794 printf("ethertype filter is not supported on port %u.\n",
10799 memset(&filter, 0, sizeof(filter));
10800 if (!strcmp(res->mac, "mac_addr")) {
10801 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10802 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10803 sizeof(struct rte_ether_addr));
10805 if (!strcmp(res->drop, "drop"))
10806 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10807 filter.ether_type = res->ethertype_value;
10808 filter.queue = res->queue_id;
10810 if (!strcmp(res->ops, "add"))
10811 ret = rte_eth_dev_filter_ctrl(res->port_id,
10812 RTE_ETH_FILTER_ETHERTYPE,
10813 RTE_ETH_FILTER_ADD,
10816 ret = rte_eth_dev_filter_ctrl(res->port_id,
10817 RTE_ETH_FILTER_ETHERTYPE,
10818 RTE_ETH_FILTER_DELETE,
10821 printf("ethertype filter programming error: (%s)\n",
10825 cmdline_parse_inst_t cmd_ethertype_filter = {
10826 .f = cmd_ethertype_filter_parsed,
10828 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10829 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10830 "Add or delete an ethertype filter entry",
10832 (void *)&cmd_ethertype_filter_filter,
10833 (void *)&cmd_ethertype_filter_port_id,
10834 (void *)&cmd_ethertype_filter_ops,
10835 (void *)&cmd_ethertype_filter_mac,
10836 (void *)&cmd_ethertype_filter_mac_addr,
10837 (void *)&cmd_ethertype_filter_ethertype,
10838 (void *)&cmd_ethertype_filter_ethertype_value,
10839 (void *)&cmd_ethertype_filter_drop,
10840 (void *)&cmd_ethertype_filter_queue,
10841 (void *)&cmd_ethertype_filter_queue_id,
10846 /* *** deal with flow director filter *** */
10847 struct cmd_flow_director_result {
10848 cmdline_fixed_string_t flow_director_filter;
10850 cmdline_fixed_string_t mode;
10851 cmdline_fixed_string_t mode_value;
10852 cmdline_fixed_string_t ops;
10853 cmdline_fixed_string_t flow;
10854 cmdline_fixed_string_t flow_type;
10855 cmdline_fixed_string_t ether;
10856 uint16_t ether_type;
10857 cmdline_fixed_string_t src;
10858 cmdline_ipaddr_t ip_src;
10860 cmdline_fixed_string_t dst;
10861 cmdline_ipaddr_t ip_dst;
10863 cmdline_fixed_string_t verify_tag;
10864 uint32_t verify_tag_value;
10865 cmdline_fixed_string_t tos;
10867 cmdline_fixed_string_t proto;
10868 uint8_t proto_value;
10869 cmdline_fixed_string_t ttl;
10871 cmdline_fixed_string_t vlan;
10872 uint16_t vlan_value;
10873 cmdline_fixed_string_t flexbytes;
10874 cmdline_fixed_string_t flexbytes_value;
10875 cmdline_fixed_string_t pf_vf;
10876 cmdline_fixed_string_t drop;
10877 cmdline_fixed_string_t queue;
10879 cmdline_fixed_string_t fd_id;
10880 uint32_t fd_id_value;
10881 cmdline_fixed_string_t mac;
10882 struct rte_ether_addr mac_addr;
10883 cmdline_fixed_string_t tunnel;
10884 cmdline_fixed_string_t tunnel_type;
10885 cmdline_fixed_string_t tunnel_id;
10886 uint32_t tunnel_id_value;
10887 cmdline_fixed_string_t packet;
10892 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10895 const char *p, *p0 = q_arg;
10897 unsigned long int_fld;
10898 char *str_fld[max_num];
10903 p = strchr(p0, '(');
10907 p0 = strchr(p, ')');
10912 if (size >= sizeof(s))
10915 snprintf(s, sizeof(s), "%.*s", size, p);
10916 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10917 if (ret < 0 || ret > max_num)
10919 for (i = 0; i < ret; i++) {
10921 int_fld = strtoul(str_fld[i], &end, 0);
10922 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10924 flexbytes[i] = (uint8_t)int_fld;
10930 str2flowtype(char *string)
10933 static const struct {
10936 } flowtype_str[] = {
10937 {"raw", RTE_ETH_FLOW_RAW},
10938 {"ipv4", RTE_ETH_FLOW_IPV4},
10939 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10940 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10941 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10942 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10943 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10944 {"ipv6", RTE_ETH_FLOW_IPV6},
10945 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10946 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10947 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10948 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10949 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10950 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10953 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10954 if (!strcmp(flowtype_str[i].str, string))
10955 return flowtype_str[i].type;
10958 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10959 return (uint16_t)atoi(string);
10961 return RTE_ETH_FLOW_UNKNOWN;
10964 static enum rte_eth_fdir_tunnel_type
10965 str2fdir_tunneltype(char *string)
10969 static const struct {
10971 enum rte_eth_fdir_tunnel_type type;
10972 } tunneltype_str[] = {
10973 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10974 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10977 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10978 if (!strcmp(tunneltype_str[i].str, string))
10979 return tunneltype_str[i].type;
10981 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10984 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10986 if ((ip_addr).family == AF_INET) \
10987 (ip) = (ip_addr).addr.ipv4.s_addr; \
10989 printf("invalid parameter.\n"); \
10994 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10996 if ((ip_addr).family == AF_INET6) \
10997 rte_memcpy(&(ip), \
10998 &((ip_addr).addr.ipv6), \
10999 sizeof(struct in6_addr)); \
11001 printf("invalid parameter.\n"); \
11007 cmd_flow_director_filter_parsed(void *parsed_result,
11008 __rte_unused struct cmdline *cl,
11009 __rte_unused void *data)
11011 struct cmd_flow_director_result *res = parsed_result;
11012 struct rte_eth_fdir_filter entry;
11013 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11015 unsigned long vf_id;
11018 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11020 printf("flow director is not supported on port %u.\n",
11024 memset(flexbytes, 0, sizeof(flexbytes));
11025 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11027 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11028 if (strcmp(res->mode_value, "MAC-VLAN")) {
11029 printf("Please set mode to MAC-VLAN.\n");
11032 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11033 if (strcmp(res->mode_value, "Tunnel")) {
11034 printf("Please set mode to Tunnel.\n");
11038 if (!strcmp(res->mode_value, "raw")) {
11039 #ifdef RTE_LIBRTE_I40E_PMD
11040 struct rte_pmd_i40e_flow_type_mapping
11041 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11042 struct rte_pmd_i40e_pkt_template_conf conf;
11043 uint16_t flow_type = str2flowtype(res->flow_type);
11044 uint16_t i, port = res->port_id;
11047 memset(&conf, 0, sizeof(conf));
11049 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11050 printf("Invalid flow type specified.\n");
11053 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11057 if (mapping[flow_type].pctype == 0ULL) {
11058 printf("Invalid flow type specified.\n");
11061 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11062 if (mapping[flow_type].pctype & (1ULL << i)) {
11063 conf.input.pctype = i;
11068 conf.input.packet = open_file(res->filepath,
11069 &conf.input.length);
11070 if (!conf.input.packet)
11072 if (!strcmp(res->drop, "drop"))
11073 conf.action.behavior =
11074 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11076 conf.action.behavior =
11077 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11078 conf.action.report_status =
11079 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11080 conf.action.rx_queue = res->queue_id;
11081 conf.soft_id = res->fd_id_value;
11082 add = strcmp(res->ops, "del") ? 1 : 0;
11083 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11087 printf("flow director config error: (%s)\n",
11089 close_file(conf.input.packet);
11092 } else if (strcmp(res->mode_value, "IP")) {
11093 printf("Please set mode to IP or raw.\n");
11096 entry.input.flow_type = str2flowtype(res->flow_type);
11099 ret = parse_flexbytes(res->flexbytes_value,
11101 RTE_ETH_FDIR_MAX_FLEXLEN);
11103 printf("error: Cannot parse flexbytes input.\n");
11107 switch (entry.input.flow_type) {
11108 case RTE_ETH_FLOW_FRAG_IPV4:
11109 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11110 entry.input.flow.ip4_flow.proto = res->proto_value;
11112 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11113 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11114 IPV4_ADDR_TO_UINT(res->ip_dst,
11115 entry.input.flow.ip4_flow.dst_ip);
11116 IPV4_ADDR_TO_UINT(res->ip_src,
11117 entry.input.flow.ip4_flow.src_ip);
11118 entry.input.flow.ip4_flow.tos = res->tos_value;
11119 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11120 /* need convert to big endian. */
11121 entry.input.flow.udp4_flow.dst_port =
11122 rte_cpu_to_be_16(res->port_dst);
11123 entry.input.flow.udp4_flow.src_port =
11124 rte_cpu_to_be_16(res->port_src);
11126 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11127 IPV4_ADDR_TO_UINT(res->ip_dst,
11128 entry.input.flow.sctp4_flow.ip.dst_ip);
11129 IPV4_ADDR_TO_UINT(res->ip_src,
11130 entry.input.flow.sctp4_flow.ip.src_ip);
11131 entry.input.flow.ip4_flow.tos = res->tos_value;
11132 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11133 /* need convert to big endian. */
11134 entry.input.flow.sctp4_flow.dst_port =
11135 rte_cpu_to_be_16(res->port_dst);
11136 entry.input.flow.sctp4_flow.src_port =
11137 rte_cpu_to_be_16(res->port_src);
11138 entry.input.flow.sctp4_flow.verify_tag =
11139 rte_cpu_to_be_32(res->verify_tag_value);
11141 case RTE_ETH_FLOW_FRAG_IPV6:
11142 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11143 entry.input.flow.ipv6_flow.proto = res->proto_value;
11145 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11146 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11147 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11148 entry.input.flow.ipv6_flow.dst_ip);
11149 IPV6_ADDR_TO_ARRAY(res->ip_src,
11150 entry.input.flow.ipv6_flow.src_ip);
11151 entry.input.flow.ipv6_flow.tc = res->tos_value;
11152 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11153 /* need convert to big endian. */
11154 entry.input.flow.udp6_flow.dst_port =
11155 rte_cpu_to_be_16(res->port_dst);
11156 entry.input.flow.udp6_flow.src_port =
11157 rte_cpu_to_be_16(res->port_src);
11159 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11160 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11161 entry.input.flow.sctp6_flow.ip.dst_ip);
11162 IPV6_ADDR_TO_ARRAY(res->ip_src,
11163 entry.input.flow.sctp6_flow.ip.src_ip);
11164 entry.input.flow.ipv6_flow.tc = res->tos_value;
11165 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11166 /* need convert to big endian. */
11167 entry.input.flow.sctp6_flow.dst_port =
11168 rte_cpu_to_be_16(res->port_dst);
11169 entry.input.flow.sctp6_flow.src_port =
11170 rte_cpu_to_be_16(res->port_src);
11171 entry.input.flow.sctp6_flow.verify_tag =
11172 rte_cpu_to_be_32(res->verify_tag_value);
11174 case RTE_ETH_FLOW_L2_PAYLOAD:
11175 entry.input.flow.l2_flow.ether_type =
11176 rte_cpu_to_be_16(res->ether_type);
11182 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11183 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11185 sizeof(struct rte_ether_addr));
11187 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11188 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11190 sizeof(struct rte_ether_addr));
11191 entry.input.flow.tunnel_flow.tunnel_type =
11192 str2fdir_tunneltype(res->tunnel_type);
11193 entry.input.flow.tunnel_flow.tunnel_id =
11194 rte_cpu_to_be_32(res->tunnel_id_value);
11197 rte_memcpy(entry.input.flow_ext.flexbytes,
11199 RTE_ETH_FDIR_MAX_FLEXLEN);
11201 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11203 entry.action.flex_off = 0; /*use 0 by default */
11204 if (!strcmp(res->drop, "drop"))
11205 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11207 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11209 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11210 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11211 if (!strcmp(res->pf_vf, "pf"))
11212 entry.input.flow_ext.is_vf = 0;
11213 else if (!strncmp(res->pf_vf, "vf", 2)) {
11214 struct rte_eth_dev_info dev_info;
11216 ret = eth_dev_info_get_print_err(res->port_id,
11222 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11223 if (errno != 0 || *end != '\0' ||
11224 vf_id >= dev_info.max_vfs) {
11225 printf("invalid parameter %s.\n", res->pf_vf);
11228 entry.input.flow_ext.is_vf = 1;
11229 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11231 printf("invalid parameter %s.\n", res->pf_vf);
11236 /* set to report FD ID by default */
11237 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11238 entry.action.rx_queue = res->queue_id;
11239 entry.soft_id = res->fd_id_value;
11240 if (!strcmp(res->ops, "add"))
11241 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11242 RTE_ETH_FILTER_ADD, &entry);
11243 else if (!strcmp(res->ops, "del"))
11244 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11245 RTE_ETH_FILTER_DELETE, &entry);
11247 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11248 RTE_ETH_FILTER_UPDATE, &entry);
11250 printf("flow director programming error: (%s)\n",
11254 cmdline_parse_token_string_t cmd_flow_director_filter =
11255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11256 flow_director_filter, "flow_director_filter");
11257 cmdline_parse_token_num_t cmd_flow_director_port_id =
11258 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11260 cmdline_parse_token_string_t cmd_flow_director_ops =
11261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11262 ops, "add#del#update");
11263 cmdline_parse_token_string_t cmd_flow_director_flow =
11264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11266 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11267 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11269 cmdline_parse_token_string_t cmd_flow_director_ether =
11270 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11272 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11273 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11274 ether_type, UINT16);
11275 cmdline_parse_token_string_t cmd_flow_director_src =
11276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11278 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11279 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11281 cmdline_parse_token_num_t cmd_flow_director_port_src =
11282 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11284 cmdline_parse_token_string_t cmd_flow_director_dst =
11285 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11287 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11288 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11290 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11291 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11293 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11294 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11295 verify_tag, "verify_tag");
11296 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11297 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11298 verify_tag_value, UINT32);
11299 cmdline_parse_token_string_t cmd_flow_director_tos =
11300 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11302 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11303 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11305 cmdline_parse_token_string_t cmd_flow_director_proto =
11306 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11308 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11309 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11310 proto_value, UINT8);
11311 cmdline_parse_token_string_t cmd_flow_director_ttl =
11312 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11314 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11315 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11317 cmdline_parse_token_string_t cmd_flow_director_vlan =
11318 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11320 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11321 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11322 vlan_value, UINT16);
11323 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11324 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11325 flexbytes, "flexbytes");
11326 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11327 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11328 flexbytes_value, NULL);
11329 cmdline_parse_token_string_t cmd_flow_director_drop =
11330 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11332 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11335 cmdline_parse_token_string_t cmd_flow_director_queue =
11336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11338 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11339 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11341 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11344 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11345 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11346 fd_id_value, UINT32);
11348 cmdline_parse_token_string_t cmd_flow_director_mode =
11349 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11351 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11354 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11355 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11356 mode_value, "MAC-VLAN");
11357 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11358 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11359 mode_value, "Tunnel");
11360 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11361 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11362 mode_value, "raw");
11363 cmdline_parse_token_string_t cmd_flow_director_mac =
11364 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11366 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11367 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11369 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11370 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11372 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11373 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11374 tunnel_type, "NVGRE#VxLAN");
11375 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11377 tunnel_id, "tunnel-id");
11378 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11379 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11380 tunnel_id_value, UINT32);
11381 cmdline_parse_token_string_t cmd_flow_director_packet =
11382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11384 cmdline_parse_token_string_t cmd_flow_director_filepath =
11385 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11388 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11389 .f = cmd_flow_director_filter_parsed,
11391 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11392 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11393 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11394 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11395 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11396 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11397 "fd_id <fd_id_value>: "
11398 "Add or delete an ip flow director entry on NIC",
11400 (void *)&cmd_flow_director_filter,
11401 (void *)&cmd_flow_director_port_id,
11402 (void *)&cmd_flow_director_mode,
11403 (void *)&cmd_flow_director_mode_ip,
11404 (void *)&cmd_flow_director_ops,
11405 (void *)&cmd_flow_director_flow,
11406 (void *)&cmd_flow_director_flow_type,
11407 (void *)&cmd_flow_director_src,
11408 (void *)&cmd_flow_director_ip_src,
11409 (void *)&cmd_flow_director_dst,
11410 (void *)&cmd_flow_director_ip_dst,
11411 (void *)&cmd_flow_director_tos,
11412 (void *)&cmd_flow_director_tos_value,
11413 (void *)&cmd_flow_director_proto,
11414 (void *)&cmd_flow_director_proto_value,
11415 (void *)&cmd_flow_director_ttl,
11416 (void *)&cmd_flow_director_ttl_value,
11417 (void *)&cmd_flow_director_vlan,
11418 (void *)&cmd_flow_director_vlan_value,
11419 (void *)&cmd_flow_director_flexbytes,
11420 (void *)&cmd_flow_director_flexbytes_value,
11421 (void *)&cmd_flow_director_drop,
11422 (void *)&cmd_flow_director_pf_vf,
11423 (void *)&cmd_flow_director_queue,
11424 (void *)&cmd_flow_director_queue_id,
11425 (void *)&cmd_flow_director_fd_id,
11426 (void *)&cmd_flow_director_fd_id_value,
11431 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11432 .f = cmd_flow_director_filter_parsed,
11434 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11435 "director entry on NIC",
11437 (void *)&cmd_flow_director_filter,
11438 (void *)&cmd_flow_director_port_id,
11439 (void *)&cmd_flow_director_mode,
11440 (void *)&cmd_flow_director_mode_ip,
11441 (void *)&cmd_flow_director_ops,
11442 (void *)&cmd_flow_director_flow,
11443 (void *)&cmd_flow_director_flow_type,
11444 (void *)&cmd_flow_director_src,
11445 (void *)&cmd_flow_director_ip_src,
11446 (void *)&cmd_flow_director_port_src,
11447 (void *)&cmd_flow_director_dst,
11448 (void *)&cmd_flow_director_ip_dst,
11449 (void *)&cmd_flow_director_port_dst,
11450 (void *)&cmd_flow_director_tos,
11451 (void *)&cmd_flow_director_tos_value,
11452 (void *)&cmd_flow_director_ttl,
11453 (void *)&cmd_flow_director_ttl_value,
11454 (void *)&cmd_flow_director_vlan,
11455 (void *)&cmd_flow_director_vlan_value,
11456 (void *)&cmd_flow_director_flexbytes,
11457 (void *)&cmd_flow_director_flexbytes_value,
11458 (void *)&cmd_flow_director_drop,
11459 (void *)&cmd_flow_director_pf_vf,
11460 (void *)&cmd_flow_director_queue,
11461 (void *)&cmd_flow_director_queue_id,
11462 (void *)&cmd_flow_director_fd_id,
11463 (void *)&cmd_flow_director_fd_id_value,
11468 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11469 .f = cmd_flow_director_filter_parsed,
11471 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11472 "director entry on NIC",
11474 (void *)&cmd_flow_director_filter,
11475 (void *)&cmd_flow_director_port_id,
11476 (void *)&cmd_flow_director_mode,
11477 (void *)&cmd_flow_director_mode_ip,
11478 (void *)&cmd_flow_director_ops,
11479 (void *)&cmd_flow_director_flow,
11480 (void *)&cmd_flow_director_flow_type,
11481 (void *)&cmd_flow_director_src,
11482 (void *)&cmd_flow_director_ip_src,
11483 (void *)&cmd_flow_director_port_src,
11484 (void *)&cmd_flow_director_dst,
11485 (void *)&cmd_flow_director_ip_dst,
11486 (void *)&cmd_flow_director_port_dst,
11487 (void *)&cmd_flow_director_verify_tag,
11488 (void *)&cmd_flow_director_verify_tag_value,
11489 (void *)&cmd_flow_director_tos,
11490 (void *)&cmd_flow_director_tos_value,
11491 (void *)&cmd_flow_director_ttl,
11492 (void *)&cmd_flow_director_ttl_value,
11493 (void *)&cmd_flow_director_vlan,
11494 (void *)&cmd_flow_director_vlan_value,
11495 (void *)&cmd_flow_director_flexbytes,
11496 (void *)&cmd_flow_director_flexbytes_value,
11497 (void *)&cmd_flow_director_drop,
11498 (void *)&cmd_flow_director_pf_vf,
11499 (void *)&cmd_flow_director_queue,
11500 (void *)&cmd_flow_director_queue_id,
11501 (void *)&cmd_flow_director_fd_id,
11502 (void *)&cmd_flow_director_fd_id_value,
11507 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11508 .f = cmd_flow_director_filter_parsed,
11510 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11511 "director entry on NIC",
11513 (void *)&cmd_flow_director_filter,
11514 (void *)&cmd_flow_director_port_id,
11515 (void *)&cmd_flow_director_mode,
11516 (void *)&cmd_flow_director_mode_ip,
11517 (void *)&cmd_flow_director_ops,
11518 (void *)&cmd_flow_director_flow,
11519 (void *)&cmd_flow_director_flow_type,
11520 (void *)&cmd_flow_director_ether,
11521 (void *)&cmd_flow_director_ether_type,
11522 (void *)&cmd_flow_director_flexbytes,
11523 (void *)&cmd_flow_director_flexbytes_value,
11524 (void *)&cmd_flow_director_drop,
11525 (void *)&cmd_flow_director_pf_vf,
11526 (void *)&cmd_flow_director_queue,
11527 (void *)&cmd_flow_director_queue_id,
11528 (void *)&cmd_flow_director_fd_id,
11529 (void *)&cmd_flow_director_fd_id_value,
11534 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11535 .f = cmd_flow_director_filter_parsed,
11537 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11538 "director entry on NIC",
11540 (void *)&cmd_flow_director_filter,
11541 (void *)&cmd_flow_director_port_id,
11542 (void *)&cmd_flow_director_mode,
11543 (void *)&cmd_flow_director_mode_mac_vlan,
11544 (void *)&cmd_flow_director_ops,
11545 (void *)&cmd_flow_director_mac,
11546 (void *)&cmd_flow_director_mac_addr,
11547 (void *)&cmd_flow_director_vlan,
11548 (void *)&cmd_flow_director_vlan_value,
11549 (void *)&cmd_flow_director_flexbytes,
11550 (void *)&cmd_flow_director_flexbytes_value,
11551 (void *)&cmd_flow_director_drop,
11552 (void *)&cmd_flow_director_queue,
11553 (void *)&cmd_flow_director_queue_id,
11554 (void *)&cmd_flow_director_fd_id,
11555 (void *)&cmd_flow_director_fd_id_value,
11560 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11561 .f = cmd_flow_director_filter_parsed,
11563 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11564 "director entry on NIC",
11566 (void *)&cmd_flow_director_filter,
11567 (void *)&cmd_flow_director_port_id,
11568 (void *)&cmd_flow_director_mode,
11569 (void *)&cmd_flow_director_mode_tunnel,
11570 (void *)&cmd_flow_director_ops,
11571 (void *)&cmd_flow_director_mac,
11572 (void *)&cmd_flow_director_mac_addr,
11573 (void *)&cmd_flow_director_vlan,
11574 (void *)&cmd_flow_director_vlan_value,
11575 (void *)&cmd_flow_director_tunnel,
11576 (void *)&cmd_flow_director_tunnel_type,
11577 (void *)&cmd_flow_director_tunnel_id,
11578 (void *)&cmd_flow_director_tunnel_id_value,
11579 (void *)&cmd_flow_director_flexbytes,
11580 (void *)&cmd_flow_director_flexbytes_value,
11581 (void *)&cmd_flow_director_drop,
11582 (void *)&cmd_flow_director_queue,
11583 (void *)&cmd_flow_director_queue_id,
11584 (void *)&cmd_flow_director_fd_id,
11585 (void *)&cmd_flow_director_fd_id_value,
11590 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11591 .f = cmd_flow_director_filter_parsed,
11593 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11594 "director entry on NIC",
11596 (void *)&cmd_flow_director_filter,
11597 (void *)&cmd_flow_director_port_id,
11598 (void *)&cmd_flow_director_mode,
11599 (void *)&cmd_flow_director_mode_raw,
11600 (void *)&cmd_flow_director_ops,
11601 (void *)&cmd_flow_director_flow,
11602 (void *)&cmd_flow_director_flow_type,
11603 (void *)&cmd_flow_director_drop,
11604 (void *)&cmd_flow_director_queue,
11605 (void *)&cmd_flow_director_queue_id,
11606 (void *)&cmd_flow_director_fd_id,
11607 (void *)&cmd_flow_director_fd_id_value,
11608 (void *)&cmd_flow_director_packet,
11609 (void *)&cmd_flow_director_filepath,
11614 struct cmd_flush_flow_director_result {
11615 cmdline_fixed_string_t flush_flow_director;
11619 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11620 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11621 flush_flow_director, "flush_flow_director");
11622 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11623 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11627 cmd_flush_flow_director_parsed(void *parsed_result,
11628 __rte_unused struct cmdline *cl,
11629 __rte_unused void *data)
11631 struct cmd_flow_director_result *res = parsed_result;
11634 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11636 printf("flow director is not supported on port %u.\n",
11641 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11642 RTE_ETH_FILTER_FLUSH, NULL);
11644 printf("flow director table flushing error: (%s)\n",
11648 cmdline_parse_inst_t cmd_flush_flow_director = {
11649 .f = cmd_flush_flow_director_parsed,
11651 .help_str = "flush_flow_director <port_id>: "
11652 "Flush all flow director entries of a device on NIC",
11654 (void *)&cmd_flush_flow_director_flush,
11655 (void *)&cmd_flush_flow_director_port_id,
11660 /* *** deal with flow director mask *** */
11661 struct cmd_flow_director_mask_result {
11662 cmdline_fixed_string_t flow_director_mask;
11664 cmdline_fixed_string_t mode;
11665 cmdline_fixed_string_t mode_value;
11666 cmdline_fixed_string_t vlan;
11667 uint16_t vlan_mask;
11668 cmdline_fixed_string_t src_mask;
11669 cmdline_ipaddr_t ipv4_src;
11670 cmdline_ipaddr_t ipv6_src;
11672 cmdline_fixed_string_t dst_mask;
11673 cmdline_ipaddr_t ipv4_dst;
11674 cmdline_ipaddr_t ipv6_dst;
11676 cmdline_fixed_string_t mac;
11677 uint8_t mac_addr_byte_mask;
11678 cmdline_fixed_string_t tunnel_id;
11679 uint32_t tunnel_id_mask;
11680 cmdline_fixed_string_t tunnel_type;
11681 uint8_t tunnel_type_mask;
11685 cmd_flow_director_mask_parsed(void *parsed_result,
11686 __rte_unused struct cmdline *cl,
11687 __rte_unused void *data)
11689 struct cmd_flow_director_mask_result *res = parsed_result;
11690 struct rte_eth_fdir_masks *mask;
11691 struct rte_port *port;
11693 port = &ports[res->port_id];
11694 /** Check if the port is not started **/
11695 if (port->port_status != RTE_PORT_STOPPED) {
11696 printf("Please stop port %d first\n", res->port_id);
11700 mask = &port->dev_conf.fdir_conf.mask;
11702 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11703 if (strcmp(res->mode_value, "MAC-VLAN")) {
11704 printf("Please set mode to MAC-VLAN.\n");
11708 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11709 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11710 if (strcmp(res->mode_value, "Tunnel")) {
11711 printf("Please set mode to Tunnel.\n");
11715 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11716 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11717 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11718 mask->tunnel_type_mask = res->tunnel_type_mask;
11720 if (strcmp(res->mode_value, "IP")) {
11721 printf("Please set mode to IP.\n");
11725 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11726 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11727 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11728 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11729 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11730 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11731 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11734 cmd_reconfig_device_queue(res->port_id, 1, 1);
11737 cmdline_parse_token_string_t cmd_flow_director_mask =
11738 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11739 flow_director_mask, "flow_director_mask");
11740 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11741 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11743 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11744 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11746 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11747 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11748 vlan_mask, UINT16);
11749 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11750 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11751 src_mask, "src_mask");
11752 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11753 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11755 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11756 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11758 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11759 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11761 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11762 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11763 dst_mask, "dst_mask");
11764 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11765 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11767 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11768 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11770 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11771 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11774 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11777 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11780 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11781 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11782 mode_value, "MAC-VLAN");
11783 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11785 mode_value, "Tunnel");
11786 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11787 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11789 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11790 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11791 mac_addr_byte_mask, UINT8);
11792 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11793 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11794 tunnel_type, "tunnel-type");
11795 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11796 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11797 tunnel_type_mask, UINT8);
11798 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11800 tunnel_id, "tunnel-id");
11801 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11802 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11803 tunnel_id_mask, UINT32);
11805 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11806 .f = cmd_flow_director_mask_parsed,
11808 .help_str = "flow_director_mask ... : "
11809 "Set IP mode flow director's mask on NIC",
11811 (void *)&cmd_flow_director_mask,
11812 (void *)&cmd_flow_director_mask_port_id,
11813 (void *)&cmd_flow_director_mask_mode,
11814 (void *)&cmd_flow_director_mask_mode_ip,
11815 (void *)&cmd_flow_director_mask_vlan,
11816 (void *)&cmd_flow_director_mask_vlan_value,
11817 (void *)&cmd_flow_director_mask_src,
11818 (void *)&cmd_flow_director_mask_ipv4_src,
11819 (void *)&cmd_flow_director_mask_ipv6_src,
11820 (void *)&cmd_flow_director_mask_port_src,
11821 (void *)&cmd_flow_director_mask_dst,
11822 (void *)&cmd_flow_director_mask_ipv4_dst,
11823 (void *)&cmd_flow_director_mask_ipv6_dst,
11824 (void *)&cmd_flow_director_mask_port_dst,
11829 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11830 .f = cmd_flow_director_mask_parsed,
11832 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11833 "flow director's mask on NIC",
11835 (void *)&cmd_flow_director_mask,
11836 (void *)&cmd_flow_director_mask_port_id,
11837 (void *)&cmd_flow_director_mask_mode,
11838 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11839 (void *)&cmd_flow_director_mask_vlan,
11840 (void *)&cmd_flow_director_mask_vlan_value,
11845 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11846 .f = cmd_flow_director_mask_parsed,
11848 .help_str = "flow_director_mask ... : Set tunnel mode "
11849 "flow director's mask on NIC",
11851 (void *)&cmd_flow_director_mask,
11852 (void *)&cmd_flow_director_mask_port_id,
11853 (void *)&cmd_flow_director_mask_mode,
11854 (void *)&cmd_flow_director_mask_mode_tunnel,
11855 (void *)&cmd_flow_director_mask_vlan,
11856 (void *)&cmd_flow_director_mask_vlan_value,
11857 (void *)&cmd_flow_director_mask_mac,
11858 (void *)&cmd_flow_director_mask_mac_value,
11859 (void *)&cmd_flow_director_mask_tunnel_type,
11860 (void *)&cmd_flow_director_mask_tunnel_type_value,
11861 (void *)&cmd_flow_director_mask_tunnel_id,
11862 (void *)&cmd_flow_director_mask_tunnel_id_value,
11867 /* *** deal with flow director mask on flexible payload *** */
11868 struct cmd_flow_director_flex_mask_result {
11869 cmdline_fixed_string_t flow_director_flexmask;
11871 cmdline_fixed_string_t flow;
11872 cmdline_fixed_string_t flow_type;
11873 cmdline_fixed_string_t mask;
11877 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11878 __rte_unused struct cmdline *cl,
11879 __rte_unused void *data)
11881 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11882 struct rte_eth_fdir_info fdir_info;
11883 struct rte_eth_fdir_flex_mask flex_mask;
11884 struct rte_port *port;
11885 uint64_t flow_type_mask;
11889 port = &ports[res->port_id];
11890 /** Check if the port is not started **/
11891 if (port->port_status != RTE_PORT_STOPPED) {
11892 printf("Please stop port %d first\n", res->port_id);
11896 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11897 ret = parse_flexbytes(res->mask,
11899 RTE_ETH_FDIR_MAX_FLEXLEN);
11901 printf("error: Cannot parse mask input.\n");
11905 memset(&fdir_info, 0, sizeof(fdir_info));
11906 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11907 RTE_ETH_FILTER_INFO, &fdir_info);
11909 printf("Cannot get FDir filter info\n");
11913 if (!strcmp(res->flow_type, "none")) {
11914 /* means don't specify the flow type */
11915 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11916 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11917 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11918 0, sizeof(struct rte_eth_fdir_flex_mask));
11919 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11920 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11922 sizeof(struct rte_eth_fdir_flex_mask));
11923 cmd_reconfig_device_queue(res->port_id, 1, 1);
11926 flow_type_mask = fdir_info.flow_types_mask[0];
11927 if (!strcmp(res->flow_type, "all")) {
11928 if (!flow_type_mask) {
11929 printf("No flow type supported\n");
11932 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11933 if (flow_type_mask & (1ULL << i)) {
11934 flex_mask.flow_type = i;
11935 fdir_set_flex_mask(res->port_id, &flex_mask);
11938 cmd_reconfig_device_queue(res->port_id, 1, 1);
11941 flex_mask.flow_type = str2flowtype(res->flow_type);
11942 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11943 printf("Flow type %s not supported on port %d\n",
11944 res->flow_type, res->port_id);
11947 fdir_set_flex_mask(res->port_id, &flex_mask);
11948 cmd_reconfig_device_queue(res->port_id, 1, 1);
11951 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11952 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11953 flow_director_flexmask,
11954 "flow_director_flex_mask");
11955 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11956 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11958 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11961 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11963 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11964 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11965 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11966 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11969 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11970 .f = cmd_flow_director_flex_mask_parsed,
11972 .help_str = "flow_director_flex_mask ... : "
11973 "Set flow director's flex mask on NIC",
11975 (void *)&cmd_flow_director_flexmask,
11976 (void *)&cmd_flow_director_flexmask_port_id,
11977 (void *)&cmd_flow_director_flexmask_flow,
11978 (void *)&cmd_flow_director_flexmask_flow_type,
11979 (void *)&cmd_flow_director_flexmask_mask,
11984 /* *** deal with flow director flexible payload configuration *** */
11985 struct cmd_flow_director_flexpayload_result {
11986 cmdline_fixed_string_t flow_director_flexpayload;
11988 cmdline_fixed_string_t payload_layer;
11989 cmdline_fixed_string_t payload_cfg;
11993 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11996 const char *p, *p0 = q_arg;
11998 unsigned long int_fld;
11999 char *str_fld[max_num];
12004 p = strchr(p0, '(');
12008 p0 = strchr(p, ')');
12013 if (size >= sizeof(s))
12016 snprintf(s, sizeof(s), "%.*s", size, p);
12017 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12018 if (ret < 0 || ret > max_num)
12020 for (i = 0; i < ret; i++) {
12022 int_fld = strtoul(str_fld[i], &end, 0);
12023 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12025 offsets[i] = (uint16_t)int_fld;
12031 cmd_flow_director_flxpld_parsed(void *parsed_result,
12032 __rte_unused struct cmdline *cl,
12033 __rte_unused void *data)
12035 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12036 struct rte_eth_flex_payload_cfg flex_cfg;
12037 struct rte_port *port;
12040 port = &ports[res->port_id];
12041 /** Check if the port is not started **/
12042 if (port->port_status != RTE_PORT_STOPPED) {
12043 printf("Please stop port %d first\n", res->port_id);
12047 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12049 if (!strcmp(res->payload_layer, "raw"))
12050 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12051 else if (!strcmp(res->payload_layer, "l2"))
12052 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12053 else if (!strcmp(res->payload_layer, "l3"))
12054 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12055 else if (!strcmp(res->payload_layer, "l4"))
12056 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12058 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12059 RTE_ETH_FDIR_MAX_FLEXLEN);
12061 printf("error: Cannot parse flex payload input.\n");
12065 fdir_set_flex_payload(res->port_id, &flex_cfg);
12066 cmd_reconfig_device_queue(res->port_id, 1, 1);
12069 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12070 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12071 flow_director_flexpayload,
12072 "flow_director_flex_payload");
12073 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12074 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12076 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12077 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12078 payload_layer, "raw#l2#l3#l4");
12079 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12080 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12081 payload_cfg, NULL);
12083 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12084 .f = cmd_flow_director_flxpld_parsed,
12086 .help_str = "flow_director_flexpayload ... : "
12087 "Set flow director's flex payload on NIC",
12089 (void *)&cmd_flow_director_flexpayload,
12090 (void *)&cmd_flow_director_flexpayload_port_id,
12091 (void *)&cmd_flow_director_flexpayload_payload_layer,
12092 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12097 /* Generic flow interface command. */
12098 extern cmdline_parse_inst_t cmd_flow;
12100 /* *** Classification Filters Control *** */
12101 /* *** Get symmetric hash enable per port *** */
12102 struct cmd_get_sym_hash_ena_per_port_result {
12103 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12108 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12109 __rte_unused struct cmdline *cl,
12110 __rte_unused void *data)
12112 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12113 struct rte_eth_hash_filter_info info;
12116 if (rte_eth_dev_filter_supported(res->port_id,
12117 RTE_ETH_FILTER_HASH) < 0) {
12118 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12123 memset(&info, 0, sizeof(info));
12124 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12125 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12126 RTE_ETH_FILTER_GET, &info);
12129 printf("Cannot get symmetric hash enable per port "
12130 "on port %u\n", res->port_id);
12134 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12135 "enabled" : "disabled", res->port_id);
12138 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12139 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12140 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12141 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12142 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12145 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12146 .f = cmd_get_sym_hash_per_port_parsed,
12148 .help_str = "get_sym_hash_ena_per_port <port_id>",
12150 (void *)&cmd_get_sym_hash_ena_per_port_all,
12151 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12156 /* *** Set symmetric hash enable per port *** */
12157 struct cmd_set_sym_hash_ena_per_port_result {
12158 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12159 cmdline_fixed_string_t enable;
12164 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12165 __rte_unused struct cmdline *cl,
12166 __rte_unused void *data)
12168 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12169 struct rte_eth_hash_filter_info info;
12172 if (rte_eth_dev_filter_supported(res->port_id,
12173 RTE_ETH_FILTER_HASH) < 0) {
12174 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12179 memset(&info, 0, sizeof(info));
12180 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12181 if (!strcmp(res->enable, "enable"))
12182 info.info.enable = 1;
12183 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12184 RTE_ETH_FILTER_SET, &info);
12186 printf("Cannot set symmetric hash enable per port on "
12187 "port %u\n", res->port_id);
12190 printf("Symmetric hash has been set to %s on port %u\n",
12191 res->enable, res->port_id);
12194 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12195 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12196 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12197 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12198 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12200 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12201 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12202 enable, "enable#disable");
12204 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12205 .f = cmd_set_sym_hash_per_port_parsed,
12207 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12209 (void *)&cmd_set_sym_hash_ena_per_port_all,
12210 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12211 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12216 /* Get global config of hash function */
12217 struct cmd_get_hash_global_config_result {
12218 cmdline_fixed_string_t get_hash_global_config;
12223 flowtype_to_str(uint16_t ftype)
12229 } ftype_table[] = {
12230 {"ipv4", RTE_ETH_FLOW_IPV4},
12231 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12232 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12233 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12234 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12235 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12236 {"ipv6", RTE_ETH_FLOW_IPV6},
12237 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12238 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12239 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12240 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12241 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12242 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12243 {"port", RTE_ETH_FLOW_PORT},
12244 {"vxlan", RTE_ETH_FLOW_VXLAN},
12245 {"geneve", RTE_ETH_FLOW_GENEVE},
12246 {"nvgre", RTE_ETH_FLOW_NVGRE},
12247 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12250 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12251 if (ftype_table[i].ftype == ftype)
12252 return ftype_table[i].str;
12259 cmd_get_hash_global_config_parsed(void *parsed_result,
12260 __rte_unused struct cmdline *cl,
12261 __rte_unused void *data)
12263 struct cmd_get_hash_global_config_result *res = parsed_result;
12264 struct rte_eth_hash_filter_info info;
12265 uint32_t idx, offset;
12270 if (rte_eth_dev_filter_supported(res->port_id,
12271 RTE_ETH_FILTER_HASH) < 0) {
12272 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12277 memset(&info, 0, sizeof(info));
12278 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12279 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12280 RTE_ETH_FILTER_GET, &info);
12282 printf("Cannot get hash global configurations by port %d\n",
12287 switch (info.info.global_conf.hash_func) {
12288 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12289 printf("Hash function is Toeplitz\n");
12291 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12292 printf("Hash function is Simple XOR\n");
12294 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12295 printf("Hash function is Symmetric Toeplitz\n");
12298 printf("Unknown hash function\n");
12302 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12303 idx = i / UINT64_BIT;
12304 offset = i % UINT64_BIT;
12305 if (!(info.info.global_conf.valid_bit_mask[idx] &
12308 str = flowtype_to_str(i);
12311 printf("Symmetric hash is %s globally for flow type %s "
12313 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12314 (1ULL << offset)) ? "enabled" : "disabled"), str,
12319 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12320 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12321 get_hash_global_config, "get_hash_global_config");
12322 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12323 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12326 cmdline_parse_inst_t cmd_get_hash_global_config = {
12327 .f = cmd_get_hash_global_config_parsed,
12329 .help_str = "get_hash_global_config <port_id>",
12331 (void *)&cmd_get_hash_global_config_all,
12332 (void *)&cmd_get_hash_global_config_port_id,
12337 /* Set global config of hash function */
12338 struct cmd_set_hash_global_config_result {
12339 cmdline_fixed_string_t set_hash_global_config;
12341 cmdline_fixed_string_t hash_func;
12342 cmdline_fixed_string_t flow_type;
12343 cmdline_fixed_string_t enable;
12347 cmd_set_hash_global_config_parsed(void *parsed_result,
12348 __rte_unused struct cmdline *cl,
12349 __rte_unused void *data)
12351 struct cmd_set_hash_global_config_result *res = parsed_result;
12352 struct rte_eth_hash_filter_info info;
12353 uint32_t ftype, idx, offset;
12356 if (rte_eth_dev_filter_supported(res->port_id,
12357 RTE_ETH_FILTER_HASH) < 0) {
12358 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12362 memset(&info, 0, sizeof(info));
12363 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12364 if (!strcmp(res->hash_func, "toeplitz"))
12365 info.info.global_conf.hash_func =
12366 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12367 else if (!strcmp(res->hash_func, "simple_xor"))
12368 info.info.global_conf.hash_func =
12369 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12370 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12371 info.info.global_conf.hash_func =
12372 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12373 else if (!strcmp(res->hash_func, "default"))
12374 info.info.global_conf.hash_func =
12375 RTE_ETH_HASH_FUNCTION_DEFAULT;
12377 ftype = str2flowtype(res->flow_type);
12378 idx = ftype / UINT64_BIT;
12379 offset = ftype % UINT64_BIT;
12380 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12381 if (!strcmp(res->enable, "enable"))
12382 info.info.global_conf.sym_hash_enable_mask[idx] |=
12384 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12385 RTE_ETH_FILTER_SET, &info);
12387 printf("Cannot set global hash configurations by port %d\n",
12390 printf("Global hash configurations have been set "
12391 "successfully by port %d\n", res->port_id);
12394 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12395 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12396 set_hash_global_config, "set_hash_global_config");
12397 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12398 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12400 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12401 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12402 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12403 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12404 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12406 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12407 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12408 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12409 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12410 enable, "enable#disable");
12412 cmdline_parse_inst_t cmd_set_hash_global_config = {
12413 .f = cmd_set_hash_global_config_parsed,
12415 .help_str = "set_hash_global_config <port_id> "
12416 "toeplitz|simple_xor|symmetric_toeplitz|default "
12417 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12418 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12419 "l2_payload enable|disable",
12421 (void *)&cmd_set_hash_global_config_all,
12422 (void *)&cmd_set_hash_global_config_port_id,
12423 (void *)&cmd_set_hash_global_config_hash_func,
12424 (void *)&cmd_set_hash_global_config_flow_type,
12425 (void *)&cmd_set_hash_global_config_enable,
12430 /* Set hash input set */
12431 struct cmd_set_hash_input_set_result {
12432 cmdline_fixed_string_t set_hash_input_set;
12434 cmdline_fixed_string_t flow_type;
12435 cmdline_fixed_string_t inset_field;
12436 cmdline_fixed_string_t select;
12439 static enum rte_eth_input_set_field
12440 str2inset(char *string)
12444 static const struct {
12446 enum rte_eth_input_set_field inset;
12447 } inset_table[] = {
12448 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12449 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12450 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12451 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12452 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12453 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12454 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12455 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12456 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12457 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12458 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12459 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12460 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12461 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12462 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12463 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12464 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12465 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12466 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12467 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12468 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12469 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12470 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12471 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12472 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12473 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12474 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12475 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12476 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12477 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12478 {"none", RTE_ETH_INPUT_SET_NONE},
12481 for (i = 0; i < RTE_DIM(inset_table); i++) {
12482 if (!strcmp(string, inset_table[i].str))
12483 return inset_table[i].inset;
12486 return RTE_ETH_INPUT_SET_UNKNOWN;
12490 cmd_set_hash_input_set_parsed(void *parsed_result,
12491 __rte_unused struct cmdline *cl,
12492 __rte_unused void *data)
12494 struct cmd_set_hash_input_set_result *res = parsed_result;
12495 struct rte_eth_hash_filter_info info;
12497 memset(&info, 0, sizeof(info));
12498 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12499 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12500 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12501 info.info.input_set_conf.inset_size = 1;
12502 if (!strcmp(res->select, "select"))
12503 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12504 else if (!strcmp(res->select, "add"))
12505 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12506 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12507 RTE_ETH_FILTER_SET, &info);
12510 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12511 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12512 set_hash_input_set, "set_hash_input_set");
12513 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12514 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12516 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12517 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12519 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12520 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12522 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12523 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12524 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12525 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12526 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12528 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12529 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12530 select, "select#add");
12532 cmdline_parse_inst_t cmd_set_hash_input_set = {
12533 .f = cmd_set_hash_input_set_parsed,
12535 .help_str = "set_hash_input_set <port_id> "
12536 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12537 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12538 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12539 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12540 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12541 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12542 "fld-7th|fld-8th|none select|add",
12544 (void *)&cmd_set_hash_input_set_cmd,
12545 (void *)&cmd_set_hash_input_set_port_id,
12546 (void *)&cmd_set_hash_input_set_flow_type,
12547 (void *)&cmd_set_hash_input_set_field,
12548 (void *)&cmd_set_hash_input_set_select,
12553 /* Set flow director input set */
12554 struct cmd_set_fdir_input_set_result {
12555 cmdline_fixed_string_t set_fdir_input_set;
12557 cmdline_fixed_string_t flow_type;
12558 cmdline_fixed_string_t inset_field;
12559 cmdline_fixed_string_t select;
12563 cmd_set_fdir_input_set_parsed(void *parsed_result,
12564 __rte_unused struct cmdline *cl,
12565 __rte_unused void *data)
12567 struct cmd_set_fdir_input_set_result *res = parsed_result;
12568 struct rte_eth_fdir_filter_info info;
12570 memset(&info, 0, sizeof(info));
12571 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12572 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12573 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12574 info.info.input_set_conf.inset_size = 1;
12575 if (!strcmp(res->select, "select"))
12576 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12577 else if (!strcmp(res->select, "add"))
12578 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12579 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12580 RTE_ETH_FILTER_SET, &info);
12583 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12584 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12585 set_fdir_input_set, "set_fdir_input_set");
12586 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12587 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12589 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12590 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12592 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12593 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12594 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12595 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12597 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12598 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12599 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12600 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12601 "sctp-veri-tag#none");
12602 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12603 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12604 select, "select#add");
12606 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12607 .f = cmd_set_fdir_input_set_parsed,
12609 .help_str = "set_fdir_input_set <port_id> "
12610 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12611 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12612 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12613 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12614 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12615 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12616 "sctp-veri-tag|none select|add",
12618 (void *)&cmd_set_fdir_input_set_cmd,
12619 (void *)&cmd_set_fdir_input_set_port_id,
12620 (void *)&cmd_set_fdir_input_set_flow_type,
12621 (void *)&cmd_set_fdir_input_set_field,
12622 (void *)&cmd_set_fdir_input_set_select,
12627 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12628 struct cmd_mcast_addr_result {
12629 cmdline_fixed_string_t mcast_addr_cmd;
12630 cmdline_fixed_string_t what;
12632 struct rte_ether_addr mc_addr;
12635 static void cmd_mcast_addr_parsed(void *parsed_result,
12636 __rte_unused struct cmdline *cl,
12637 __rte_unused void *data)
12639 struct cmd_mcast_addr_result *res = parsed_result;
12641 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12642 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12643 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12644 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12645 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12648 if (strcmp(res->what, "add") == 0)
12649 mcast_addr_add(res->port_num, &res->mc_addr);
12651 mcast_addr_remove(res->port_num, &res->mc_addr);
12654 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12655 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12656 mcast_addr_cmd, "mcast_addr");
12657 cmdline_parse_token_string_t cmd_mcast_addr_what =
12658 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12660 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12661 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12662 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12663 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12665 cmdline_parse_inst_t cmd_mcast_addr = {
12666 .f = cmd_mcast_addr_parsed,
12668 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12669 "Add/Remove multicast MAC address on port_id",
12671 (void *)&cmd_mcast_addr_cmd,
12672 (void *)&cmd_mcast_addr_what,
12673 (void *)&cmd_mcast_addr_portnum,
12674 (void *)&cmd_mcast_addr_addr,
12679 /* l2 tunnel config
12680 * only support E-tag now.
12683 /* Ether type config */
12684 struct cmd_config_l2_tunnel_eth_type_result {
12685 cmdline_fixed_string_t port;
12686 cmdline_fixed_string_t config;
12687 cmdline_fixed_string_t all;
12689 cmdline_fixed_string_t l2_tunnel;
12690 cmdline_fixed_string_t l2_tunnel_type;
12691 cmdline_fixed_string_t eth_type;
12692 uint16_t eth_type_val;
12695 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12696 TOKEN_STRING_INITIALIZER
12697 (struct cmd_config_l2_tunnel_eth_type_result,
12699 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12700 TOKEN_STRING_INITIALIZER
12701 (struct cmd_config_l2_tunnel_eth_type_result,
12703 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12704 TOKEN_STRING_INITIALIZER
12705 (struct cmd_config_l2_tunnel_eth_type_result,
12707 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12708 TOKEN_NUM_INITIALIZER
12709 (struct cmd_config_l2_tunnel_eth_type_result,
12711 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12712 TOKEN_STRING_INITIALIZER
12713 (struct cmd_config_l2_tunnel_eth_type_result,
12714 l2_tunnel, "l2-tunnel");
12715 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12716 TOKEN_STRING_INITIALIZER
12717 (struct cmd_config_l2_tunnel_eth_type_result,
12718 l2_tunnel_type, "E-tag");
12719 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12720 TOKEN_STRING_INITIALIZER
12721 (struct cmd_config_l2_tunnel_eth_type_result,
12722 eth_type, "ether-type");
12723 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12724 TOKEN_NUM_INITIALIZER
12725 (struct cmd_config_l2_tunnel_eth_type_result,
12726 eth_type_val, UINT16);
12728 static enum rte_eth_tunnel_type
12729 str2fdir_l2_tunnel_type(char *string)
12733 static const struct {
12735 enum rte_eth_tunnel_type type;
12736 } l2_tunnel_type_str[] = {
12737 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12740 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12741 if (!strcmp(l2_tunnel_type_str[i].str, string))
12742 return l2_tunnel_type_str[i].type;
12744 return RTE_TUNNEL_TYPE_NONE;
12747 /* ether type config for all ports */
12749 cmd_config_l2_tunnel_eth_type_all_parsed
12750 (void *parsed_result,
12751 __rte_unused struct cmdline *cl,
12752 __rte_unused void *data)
12754 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12755 struct rte_eth_l2_tunnel_conf entry;
12758 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12759 entry.ether_type = res->eth_type_val;
12761 RTE_ETH_FOREACH_DEV(pid) {
12762 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12766 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12767 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12769 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12771 (void *)&cmd_config_l2_tunnel_eth_type_port,
12772 (void *)&cmd_config_l2_tunnel_eth_type_config,
12773 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12774 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12775 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12776 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12777 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12782 /* ether type config for a specific port */
12784 cmd_config_l2_tunnel_eth_type_specific_parsed(
12785 void *parsed_result,
12786 __rte_unused struct cmdline *cl,
12787 __rte_unused void *data)
12789 struct cmd_config_l2_tunnel_eth_type_result *res =
12791 struct rte_eth_l2_tunnel_conf entry;
12793 if (port_id_is_invalid(res->id, ENABLED_WARN))
12796 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12797 entry.ether_type = res->eth_type_val;
12799 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12802 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12803 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12805 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12807 (void *)&cmd_config_l2_tunnel_eth_type_port,
12808 (void *)&cmd_config_l2_tunnel_eth_type_config,
12809 (void *)&cmd_config_l2_tunnel_eth_type_id,
12810 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12811 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12812 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12813 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12818 /* Enable/disable l2 tunnel */
12819 struct cmd_config_l2_tunnel_en_dis_result {
12820 cmdline_fixed_string_t port;
12821 cmdline_fixed_string_t config;
12822 cmdline_fixed_string_t all;
12824 cmdline_fixed_string_t l2_tunnel;
12825 cmdline_fixed_string_t l2_tunnel_type;
12826 cmdline_fixed_string_t en_dis;
12829 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12830 TOKEN_STRING_INITIALIZER
12831 (struct cmd_config_l2_tunnel_en_dis_result,
12833 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12834 TOKEN_STRING_INITIALIZER
12835 (struct cmd_config_l2_tunnel_en_dis_result,
12837 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12838 TOKEN_STRING_INITIALIZER
12839 (struct cmd_config_l2_tunnel_en_dis_result,
12841 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12842 TOKEN_NUM_INITIALIZER
12843 (struct cmd_config_l2_tunnel_en_dis_result,
12845 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12846 TOKEN_STRING_INITIALIZER
12847 (struct cmd_config_l2_tunnel_en_dis_result,
12848 l2_tunnel, "l2-tunnel");
12849 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12850 TOKEN_STRING_INITIALIZER
12851 (struct cmd_config_l2_tunnel_en_dis_result,
12852 l2_tunnel_type, "E-tag");
12853 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12854 TOKEN_STRING_INITIALIZER
12855 (struct cmd_config_l2_tunnel_en_dis_result,
12856 en_dis, "enable#disable");
12858 /* enable/disable l2 tunnel for all ports */
12860 cmd_config_l2_tunnel_en_dis_all_parsed(
12861 void *parsed_result,
12862 __rte_unused struct cmdline *cl,
12863 __rte_unused void *data)
12865 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12866 struct rte_eth_l2_tunnel_conf entry;
12870 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12872 if (!strcmp("enable", res->en_dis))
12877 RTE_ETH_FOREACH_DEV(pid) {
12878 rte_eth_dev_l2_tunnel_offload_set(pid,
12880 ETH_L2_TUNNEL_ENABLE_MASK,
12885 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12886 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12888 .help_str = "port config all l2-tunnel E-tag enable|disable",
12890 (void *)&cmd_config_l2_tunnel_en_dis_port,
12891 (void *)&cmd_config_l2_tunnel_en_dis_config,
12892 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12893 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12894 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12895 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12900 /* enable/disable l2 tunnel for a port */
12902 cmd_config_l2_tunnel_en_dis_specific_parsed(
12903 void *parsed_result,
12904 __rte_unused struct cmdline *cl,
12905 __rte_unused void *data)
12907 struct cmd_config_l2_tunnel_en_dis_result *res =
12909 struct rte_eth_l2_tunnel_conf entry;
12911 if (port_id_is_invalid(res->id, ENABLED_WARN))
12914 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12916 if (!strcmp("enable", res->en_dis))
12917 rte_eth_dev_l2_tunnel_offload_set(res->id,
12919 ETH_L2_TUNNEL_ENABLE_MASK,
12922 rte_eth_dev_l2_tunnel_offload_set(res->id,
12924 ETH_L2_TUNNEL_ENABLE_MASK,
12928 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12929 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12931 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12933 (void *)&cmd_config_l2_tunnel_en_dis_port,
12934 (void *)&cmd_config_l2_tunnel_en_dis_config,
12935 (void *)&cmd_config_l2_tunnel_en_dis_id,
12936 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12937 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12938 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12943 /* E-tag configuration */
12945 /* Common result structure for all E-tag configuration */
12946 struct cmd_config_e_tag_result {
12947 cmdline_fixed_string_t e_tag;
12948 cmdline_fixed_string_t set;
12949 cmdline_fixed_string_t insertion;
12950 cmdline_fixed_string_t stripping;
12951 cmdline_fixed_string_t forwarding;
12952 cmdline_fixed_string_t filter;
12953 cmdline_fixed_string_t add;
12954 cmdline_fixed_string_t del;
12955 cmdline_fixed_string_t on;
12956 cmdline_fixed_string_t off;
12957 cmdline_fixed_string_t on_off;
12958 cmdline_fixed_string_t port_tag_id;
12959 uint32_t port_tag_id_val;
12960 cmdline_fixed_string_t e_tag_id;
12961 uint16_t e_tag_id_val;
12962 cmdline_fixed_string_t dst_pool;
12963 uint8_t dst_pool_val;
12964 cmdline_fixed_string_t port;
12966 cmdline_fixed_string_t vf;
12970 /* Common CLI fields for all E-tag configuration */
12971 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12972 TOKEN_STRING_INITIALIZER
12973 (struct cmd_config_e_tag_result,
12975 cmdline_parse_token_string_t cmd_config_e_tag_set =
12976 TOKEN_STRING_INITIALIZER
12977 (struct cmd_config_e_tag_result,
12979 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12980 TOKEN_STRING_INITIALIZER
12981 (struct cmd_config_e_tag_result,
12982 insertion, "insertion");
12983 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12984 TOKEN_STRING_INITIALIZER
12985 (struct cmd_config_e_tag_result,
12986 stripping, "stripping");
12987 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12988 TOKEN_STRING_INITIALIZER
12989 (struct cmd_config_e_tag_result,
12990 forwarding, "forwarding");
12991 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12992 TOKEN_STRING_INITIALIZER
12993 (struct cmd_config_e_tag_result,
12995 cmdline_parse_token_string_t cmd_config_e_tag_add =
12996 TOKEN_STRING_INITIALIZER
12997 (struct cmd_config_e_tag_result,
12999 cmdline_parse_token_string_t cmd_config_e_tag_del =
13000 TOKEN_STRING_INITIALIZER
13001 (struct cmd_config_e_tag_result,
13003 cmdline_parse_token_string_t cmd_config_e_tag_on =
13004 TOKEN_STRING_INITIALIZER
13005 (struct cmd_config_e_tag_result,
13007 cmdline_parse_token_string_t cmd_config_e_tag_off =
13008 TOKEN_STRING_INITIALIZER
13009 (struct cmd_config_e_tag_result,
13011 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13012 TOKEN_STRING_INITIALIZER
13013 (struct cmd_config_e_tag_result,
13015 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13016 TOKEN_STRING_INITIALIZER
13017 (struct cmd_config_e_tag_result,
13018 port_tag_id, "port-tag-id");
13019 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13020 TOKEN_NUM_INITIALIZER
13021 (struct cmd_config_e_tag_result,
13022 port_tag_id_val, UINT32);
13023 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13024 TOKEN_STRING_INITIALIZER
13025 (struct cmd_config_e_tag_result,
13026 e_tag_id, "e-tag-id");
13027 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13028 TOKEN_NUM_INITIALIZER
13029 (struct cmd_config_e_tag_result,
13030 e_tag_id_val, UINT16);
13031 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13032 TOKEN_STRING_INITIALIZER
13033 (struct cmd_config_e_tag_result,
13034 dst_pool, "dst-pool");
13035 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13036 TOKEN_NUM_INITIALIZER
13037 (struct cmd_config_e_tag_result,
13038 dst_pool_val, UINT8);
13039 cmdline_parse_token_string_t cmd_config_e_tag_port =
13040 TOKEN_STRING_INITIALIZER
13041 (struct cmd_config_e_tag_result,
13043 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13044 TOKEN_NUM_INITIALIZER
13045 (struct cmd_config_e_tag_result,
13047 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13048 TOKEN_STRING_INITIALIZER
13049 (struct cmd_config_e_tag_result,
13051 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13052 TOKEN_NUM_INITIALIZER
13053 (struct cmd_config_e_tag_result,
13056 /* E-tag insertion configuration */
13058 cmd_config_e_tag_insertion_en_parsed(
13059 void *parsed_result,
13060 __rte_unused struct cmdline *cl,
13061 __rte_unused void *data)
13063 struct cmd_config_e_tag_result *res =
13065 struct rte_eth_l2_tunnel_conf entry;
13067 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13070 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13071 entry.tunnel_id = res->port_tag_id_val;
13072 entry.vf_id = res->vf_id;
13073 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13075 ETH_L2_TUNNEL_INSERTION_MASK,
13080 cmd_config_e_tag_insertion_dis_parsed(
13081 void *parsed_result,
13082 __rte_unused struct cmdline *cl,
13083 __rte_unused void *data)
13085 struct cmd_config_e_tag_result *res =
13087 struct rte_eth_l2_tunnel_conf entry;
13089 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13092 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13093 entry.vf_id = res->vf_id;
13095 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13097 ETH_L2_TUNNEL_INSERTION_MASK,
13101 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13102 .f = cmd_config_e_tag_insertion_en_parsed,
13104 .help_str = "E-tag ... : E-tag insertion enable",
13106 (void *)&cmd_config_e_tag_e_tag,
13107 (void *)&cmd_config_e_tag_set,
13108 (void *)&cmd_config_e_tag_insertion,
13109 (void *)&cmd_config_e_tag_on,
13110 (void *)&cmd_config_e_tag_port_tag_id,
13111 (void *)&cmd_config_e_tag_port_tag_id_val,
13112 (void *)&cmd_config_e_tag_port,
13113 (void *)&cmd_config_e_tag_port_id,
13114 (void *)&cmd_config_e_tag_vf,
13115 (void *)&cmd_config_e_tag_vf_id,
13120 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13121 .f = cmd_config_e_tag_insertion_dis_parsed,
13123 .help_str = "E-tag ... : E-tag insertion disable",
13125 (void *)&cmd_config_e_tag_e_tag,
13126 (void *)&cmd_config_e_tag_set,
13127 (void *)&cmd_config_e_tag_insertion,
13128 (void *)&cmd_config_e_tag_off,
13129 (void *)&cmd_config_e_tag_port,
13130 (void *)&cmd_config_e_tag_port_id,
13131 (void *)&cmd_config_e_tag_vf,
13132 (void *)&cmd_config_e_tag_vf_id,
13137 /* E-tag stripping configuration */
13139 cmd_config_e_tag_stripping_parsed(
13140 void *parsed_result,
13141 __rte_unused struct cmdline *cl,
13142 __rte_unused void *data)
13144 struct cmd_config_e_tag_result *res =
13146 struct rte_eth_l2_tunnel_conf entry;
13148 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13151 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13153 if (!strcmp(res->on_off, "on"))
13154 rte_eth_dev_l2_tunnel_offload_set
13157 ETH_L2_TUNNEL_STRIPPING_MASK,
13160 rte_eth_dev_l2_tunnel_offload_set
13163 ETH_L2_TUNNEL_STRIPPING_MASK,
13167 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13168 .f = cmd_config_e_tag_stripping_parsed,
13170 .help_str = "E-tag ... : E-tag stripping enable/disable",
13172 (void *)&cmd_config_e_tag_e_tag,
13173 (void *)&cmd_config_e_tag_set,
13174 (void *)&cmd_config_e_tag_stripping,
13175 (void *)&cmd_config_e_tag_on_off,
13176 (void *)&cmd_config_e_tag_port,
13177 (void *)&cmd_config_e_tag_port_id,
13182 /* E-tag forwarding configuration */
13184 cmd_config_e_tag_forwarding_parsed(
13185 void *parsed_result,
13186 __rte_unused struct cmdline *cl,
13187 __rte_unused void *data)
13189 struct cmd_config_e_tag_result *res = parsed_result;
13190 struct rte_eth_l2_tunnel_conf entry;
13192 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13195 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13197 if (!strcmp(res->on_off, "on"))
13198 rte_eth_dev_l2_tunnel_offload_set
13201 ETH_L2_TUNNEL_FORWARDING_MASK,
13204 rte_eth_dev_l2_tunnel_offload_set
13207 ETH_L2_TUNNEL_FORWARDING_MASK,
13211 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13212 .f = cmd_config_e_tag_forwarding_parsed,
13214 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13216 (void *)&cmd_config_e_tag_e_tag,
13217 (void *)&cmd_config_e_tag_set,
13218 (void *)&cmd_config_e_tag_forwarding,
13219 (void *)&cmd_config_e_tag_on_off,
13220 (void *)&cmd_config_e_tag_port,
13221 (void *)&cmd_config_e_tag_port_id,
13226 /* E-tag filter configuration */
13228 cmd_config_e_tag_filter_add_parsed(
13229 void *parsed_result,
13230 __rte_unused struct cmdline *cl,
13231 __rte_unused void *data)
13233 struct cmd_config_e_tag_result *res = parsed_result;
13234 struct rte_eth_l2_tunnel_conf entry;
13237 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13240 if (res->e_tag_id_val > 0x3fff) {
13241 printf("e-tag-id must be equal or less than 0x3fff.\n");
13245 ret = rte_eth_dev_filter_supported(res->port_id,
13246 RTE_ETH_FILTER_L2_TUNNEL);
13248 printf("E-tag filter is not supported on port %u.\n",
13253 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13254 entry.tunnel_id = res->e_tag_id_val;
13255 entry.pool = res->dst_pool_val;
13257 ret = rte_eth_dev_filter_ctrl(res->port_id,
13258 RTE_ETH_FILTER_L2_TUNNEL,
13259 RTE_ETH_FILTER_ADD,
13262 printf("E-tag filter programming error: (%s)\n",
13266 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13267 .f = cmd_config_e_tag_filter_add_parsed,
13269 .help_str = "E-tag ... : E-tag filter add",
13271 (void *)&cmd_config_e_tag_e_tag,
13272 (void *)&cmd_config_e_tag_set,
13273 (void *)&cmd_config_e_tag_filter,
13274 (void *)&cmd_config_e_tag_add,
13275 (void *)&cmd_config_e_tag_e_tag_id,
13276 (void *)&cmd_config_e_tag_e_tag_id_val,
13277 (void *)&cmd_config_e_tag_dst_pool,
13278 (void *)&cmd_config_e_tag_dst_pool_val,
13279 (void *)&cmd_config_e_tag_port,
13280 (void *)&cmd_config_e_tag_port_id,
13286 cmd_config_e_tag_filter_del_parsed(
13287 void *parsed_result,
13288 __rte_unused struct cmdline *cl,
13289 __rte_unused void *data)
13291 struct cmd_config_e_tag_result *res = parsed_result;
13292 struct rte_eth_l2_tunnel_conf entry;
13295 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13298 if (res->e_tag_id_val > 0x3fff) {
13299 printf("e-tag-id must be less than 0x3fff.\n");
13303 ret = rte_eth_dev_filter_supported(res->port_id,
13304 RTE_ETH_FILTER_L2_TUNNEL);
13306 printf("E-tag filter is not supported on port %u.\n",
13311 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13312 entry.tunnel_id = res->e_tag_id_val;
13314 ret = rte_eth_dev_filter_ctrl(res->port_id,
13315 RTE_ETH_FILTER_L2_TUNNEL,
13316 RTE_ETH_FILTER_DELETE,
13319 printf("E-tag filter programming error: (%s)\n",
13323 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13324 .f = cmd_config_e_tag_filter_del_parsed,
13326 .help_str = "E-tag ... : E-tag filter delete",
13328 (void *)&cmd_config_e_tag_e_tag,
13329 (void *)&cmd_config_e_tag_set,
13330 (void *)&cmd_config_e_tag_filter,
13331 (void *)&cmd_config_e_tag_del,
13332 (void *)&cmd_config_e_tag_e_tag_id,
13333 (void *)&cmd_config_e_tag_e_tag_id_val,
13334 (void *)&cmd_config_e_tag_port,
13335 (void *)&cmd_config_e_tag_port_id,
13340 /* vf vlan anti spoof configuration */
13342 /* Common result structure for vf vlan anti spoof */
13343 struct cmd_vf_vlan_anti_spoof_result {
13344 cmdline_fixed_string_t set;
13345 cmdline_fixed_string_t vf;
13346 cmdline_fixed_string_t vlan;
13347 cmdline_fixed_string_t antispoof;
13350 cmdline_fixed_string_t on_off;
13353 /* Common CLI fields for vf vlan anti spoof enable disable */
13354 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13355 TOKEN_STRING_INITIALIZER
13356 (struct cmd_vf_vlan_anti_spoof_result,
13358 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13359 TOKEN_STRING_INITIALIZER
13360 (struct cmd_vf_vlan_anti_spoof_result,
13362 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13363 TOKEN_STRING_INITIALIZER
13364 (struct cmd_vf_vlan_anti_spoof_result,
13366 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13367 TOKEN_STRING_INITIALIZER
13368 (struct cmd_vf_vlan_anti_spoof_result,
13369 antispoof, "antispoof");
13370 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13371 TOKEN_NUM_INITIALIZER
13372 (struct cmd_vf_vlan_anti_spoof_result,
13374 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13375 TOKEN_NUM_INITIALIZER
13376 (struct cmd_vf_vlan_anti_spoof_result,
13378 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13379 TOKEN_STRING_INITIALIZER
13380 (struct cmd_vf_vlan_anti_spoof_result,
13384 cmd_set_vf_vlan_anti_spoof_parsed(
13385 void *parsed_result,
13386 __rte_unused struct cmdline *cl,
13387 __rte_unused void *data)
13389 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13390 int ret = -ENOTSUP;
13392 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13397 #ifdef RTE_LIBRTE_IXGBE_PMD
13398 if (ret == -ENOTSUP)
13399 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13400 res->vf_id, is_on);
13402 #ifdef RTE_LIBRTE_I40E_PMD
13403 if (ret == -ENOTSUP)
13404 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13405 res->vf_id, is_on);
13407 #ifdef RTE_LIBRTE_BNXT_PMD
13408 if (ret == -ENOTSUP)
13409 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13410 res->vf_id, is_on);
13417 printf("invalid vf_id %d\n", res->vf_id);
13420 printf("invalid port_id %d\n", res->port_id);
13423 printf("function not implemented\n");
13426 printf("programming error: (%s)\n", strerror(-ret));
13430 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13431 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13433 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13435 (void *)&cmd_vf_vlan_anti_spoof_set,
13436 (void *)&cmd_vf_vlan_anti_spoof_vf,
13437 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13438 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13439 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13440 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13441 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13446 /* vf mac anti spoof configuration */
13448 /* Common result structure for vf mac anti spoof */
13449 struct cmd_vf_mac_anti_spoof_result {
13450 cmdline_fixed_string_t set;
13451 cmdline_fixed_string_t vf;
13452 cmdline_fixed_string_t mac;
13453 cmdline_fixed_string_t antispoof;
13456 cmdline_fixed_string_t on_off;
13459 /* Common CLI fields for vf mac anti spoof enable disable */
13460 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13461 TOKEN_STRING_INITIALIZER
13462 (struct cmd_vf_mac_anti_spoof_result,
13464 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13465 TOKEN_STRING_INITIALIZER
13466 (struct cmd_vf_mac_anti_spoof_result,
13468 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13469 TOKEN_STRING_INITIALIZER
13470 (struct cmd_vf_mac_anti_spoof_result,
13472 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13473 TOKEN_STRING_INITIALIZER
13474 (struct cmd_vf_mac_anti_spoof_result,
13475 antispoof, "antispoof");
13476 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13477 TOKEN_NUM_INITIALIZER
13478 (struct cmd_vf_mac_anti_spoof_result,
13480 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13481 TOKEN_NUM_INITIALIZER
13482 (struct cmd_vf_mac_anti_spoof_result,
13484 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13485 TOKEN_STRING_INITIALIZER
13486 (struct cmd_vf_mac_anti_spoof_result,
13490 cmd_set_vf_mac_anti_spoof_parsed(
13491 void *parsed_result,
13492 __rte_unused struct cmdline *cl,
13493 __rte_unused void *data)
13495 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13496 int ret = -ENOTSUP;
13498 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13500 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13503 #ifdef RTE_LIBRTE_IXGBE_PMD
13504 if (ret == -ENOTSUP)
13505 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13506 res->vf_id, is_on);
13508 #ifdef RTE_LIBRTE_I40E_PMD
13509 if (ret == -ENOTSUP)
13510 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13511 res->vf_id, is_on);
13513 #ifdef RTE_LIBRTE_BNXT_PMD
13514 if (ret == -ENOTSUP)
13515 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13516 res->vf_id, is_on);
13523 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13526 printf("invalid port_id %d\n", res->port_id);
13529 printf("function not implemented\n");
13532 printf("programming error: (%s)\n", strerror(-ret));
13536 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13537 .f = cmd_set_vf_mac_anti_spoof_parsed,
13539 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13541 (void *)&cmd_vf_mac_anti_spoof_set,
13542 (void *)&cmd_vf_mac_anti_spoof_vf,
13543 (void *)&cmd_vf_mac_anti_spoof_mac,
13544 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13545 (void *)&cmd_vf_mac_anti_spoof_port_id,
13546 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13547 (void *)&cmd_vf_mac_anti_spoof_on_off,
13552 /* vf vlan strip queue configuration */
13554 /* Common result structure for vf mac anti spoof */
13555 struct cmd_vf_vlan_stripq_result {
13556 cmdline_fixed_string_t set;
13557 cmdline_fixed_string_t vf;
13558 cmdline_fixed_string_t vlan;
13559 cmdline_fixed_string_t stripq;
13562 cmdline_fixed_string_t on_off;
13565 /* Common CLI fields for vf vlan strip enable disable */
13566 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13567 TOKEN_STRING_INITIALIZER
13568 (struct cmd_vf_vlan_stripq_result,
13570 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13571 TOKEN_STRING_INITIALIZER
13572 (struct cmd_vf_vlan_stripq_result,
13574 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13575 TOKEN_STRING_INITIALIZER
13576 (struct cmd_vf_vlan_stripq_result,
13578 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13579 TOKEN_STRING_INITIALIZER
13580 (struct cmd_vf_vlan_stripq_result,
13582 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13583 TOKEN_NUM_INITIALIZER
13584 (struct cmd_vf_vlan_stripq_result,
13586 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13587 TOKEN_NUM_INITIALIZER
13588 (struct cmd_vf_vlan_stripq_result,
13590 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13591 TOKEN_STRING_INITIALIZER
13592 (struct cmd_vf_vlan_stripq_result,
13596 cmd_set_vf_vlan_stripq_parsed(
13597 void *parsed_result,
13598 __rte_unused struct cmdline *cl,
13599 __rte_unused void *data)
13601 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13602 int ret = -ENOTSUP;
13604 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13606 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13609 #ifdef RTE_LIBRTE_IXGBE_PMD
13610 if (ret == -ENOTSUP)
13611 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13612 res->vf_id, is_on);
13614 #ifdef RTE_LIBRTE_I40E_PMD
13615 if (ret == -ENOTSUP)
13616 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13617 res->vf_id, is_on);
13619 #ifdef RTE_LIBRTE_BNXT_PMD
13620 if (ret == -ENOTSUP)
13621 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13622 res->vf_id, is_on);
13629 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13632 printf("invalid port_id %d\n", res->port_id);
13635 printf("function not implemented\n");
13638 printf("programming error: (%s)\n", strerror(-ret));
13642 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13643 .f = cmd_set_vf_vlan_stripq_parsed,
13645 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13647 (void *)&cmd_vf_vlan_stripq_set,
13648 (void *)&cmd_vf_vlan_stripq_vf,
13649 (void *)&cmd_vf_vlan_stripq_vlan,
13650 (void *)&cmd_vf_vlan_stripq_stripq,
13651 (void *)&cmd_vf_vlan_stripq_port_id,
13652 (void *)&cmd_vf_vlan_stripq_vf_id,
13653 (void *)&cmd_vf_vlan_stripq_on_off,
13658 /* vf vlan insert configuration */
13660 /* Common result structure for vf vlan insert */
13661 struct cmd_vf_vlan_insert_result {
13662 cmdline_fixed_string_t set;
13663 cmdline_fixed_string_t vf;
13664 cmdline_fixed_string_t vlan;
13665 cmdline_fixed_string_t insert;
13671 /* Common CLI fields for vf vlan insert enable disable */
13672 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13673 TOKEN_STRING_INITIALIZER
13674 (struct cmd_vf_vlan_insert_result,
13676 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13677 TOKEN_STRING_INITIALIZER
13678 (struct cmd_vf_vlan_insert_result,
13680 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13681 TOKEN_STRING_INITIALIZER
13682 (struct cmd_vf_vlan_insert_result,
13684 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13685 TOKEN_STRING_INITIALIZER
13686 (struct cmd_vf_vlan_insert_result,
13688 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13689 TOKEN_NUM_INITIALIZER
13690 (struct cmd_vf_vlan_insert_result,
13692 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13693 TOKEN_NUM_INITIALIZER
13694 (struct cmd_vf_vlan_insert_result,
13696 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13697 TOKEN_NUM_INITIALIZER
13698 (struct cmd_vf_vlan_insert_result,
13702 cmd_set_vf_vlan_insert_parsed(
13703 void *parsed_result,
13704 __rte_unused struct cmdline *cl,
13705 __rte_unused void *data)
13707 struct cmd_vf_vlan_insert_result *res = parsed_result;
13708 int ret = -ENOTSUP;
13710 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13713 #ifdef RTE_LIBRTE_IXGBE_PMD
13714 if (ret == -ENOTSUP)
13715 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13718 #ifdef RTE_LIBRTE_I40E_PMD
13719 if (ret == -ENOTSUP)
13720 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13723 #ifdef RTE_LIBRTE_BNXT_PMD
13724 if (ret == -ENOTSUP)
13725 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13733 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13736 printf("invalid port_id %d\n", res->port_id);
13739 printf("function not implemented\n");
13742 printf("programming error: (%s)\n", strerror(-ret));
13746 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13747 .f = cmd_set_vf_vlan_insert_parsed,
13749 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13751 (void *)&cmd_vf_vlan_insert_set,
13752 (void *)&cmd_vf_vlan_insert_vf,
13753 (void *)&cmd_vf_vlan_insert_vlan,
13754 (void *)&cmd_vf_vlan_insert_insert,
13755 (void *)&cmd_vf_vlan_insert_port_id,
13756 (void *)&cmd_vf_vlan_insert_vf_id,
13757 (void *)&cmd_vf_vlan_insert_vlan_id,
13762 /* tx loopback configuration */
13764 /* Common result structure for tx loopback */
13765 struct cmd_tx_loopback_result {
13766 cmdline_fixed_string_t set;
13767 cmdline_fixed_string_t tx;
13768 cmdline_fixed_string_t loopback;
13770 cmdline_fixed_string_t on_off;
13773 /* Common CLI fields for tx loopback enable disable */
13774 cmdline_parse_token_string_t cmd_tx_loopback_set =
13775 TOKEN_STRING_INITIALIZER
13776 (struct cmd_tx_loopback_result,
13778 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13779 TOKEN_STRING_INITIALIZER
13780 (struct cmd_tx_loopback_result,
13782 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13783 TOKEN_STRING_INITIALIZER
13784 (struct cmd_tx_loopback_result,
13785 loopback, "loopback");
13786 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13787 TOKEN_NUM_INITIALIZER
13788 (struct cmd_tx_loopback_result,
13790 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13791 TOKEN_STRING_INITIALIZER
13792 (struct cmd_tx_loopback_result,
13796 cmd_set_tx_loopback_parsed(
13797 void *parsed_result,
13798 __rte_unused struct cmdline *cl,
13799 __rte_unused void *data)
13801 struct cmd_tx_loopback_result *res = parsed_result;
13802 int ret = -ENOTSUP;
13804 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13806 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13809 #ifdef RTE_LIBRTE_IXGBE_PMD
13810 if (ret == -ENOTSUP)
13811 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13813 #ifdef RTE_LIBRTE_I40E_PMD
13814 if (ret == -ENOTSUP)
13815 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13817 #ifdef RTE_LIBRTE_BNXT_PMD
13818 if (ret == -ENOTSUP)
13819 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13821 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13822 if (ret == -ENOTSUP)
13823 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13830 printf("invalid is_on %d\n", is_on);
13833 printf("invalid port_id %d\n", res->port_id);
13836 printf("function not implemented\n");
13839 printf("programming error: (%s)\n", strerror(-ret));
13843 cmdline_parse_inst_t cmd_set_tx_loopback = {
13844 .f = cmd_set_tx_loopback_parsed,
13846 .help_str = "set tx loopback <port_id> on|off",
13848 (void *)&cmd_tx_loopback_set,
13849 (void *)&cmd_tx_loopback_tx,
13850 (void *)&cmd_tx_loopback_loopback,
13851 (void *)&cmd_tx_loopback_port_id,
13852 (void *)&cmd_tx_loopback_on_off,
13857 /* all queues drop enable configuration */
13859 /* Common result structure for all queues drop enable */
13860 struct cmd_all_queues_drop_en_result {
13861 cmdline_fixed_string_t set;
13862 cmdline_fixed_string_t all;
13863 cmdline_fixed_string_t queues;
13864 cmdline_fixed_string_t drop;
13866 cmdline_fixed_string_t on_off;
13869 /* Common CLI fields for tx loopback enable disable */
13870 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13871 TOKEN_STRING_INITIALIZER
13872 (struct cmd_all_queues_drop_en_result,
13874 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13875 TOKEN_STRING_INITIALIZER
13876 (struct cmd_all_queues_drop_en_result,
13878 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13879 TOKEN_STRING_INITIALIZER
13880 (struct cmd_all_queues_drop_en_result,
13882 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13883 TOKEN_STRING_INITIALIZER
13884 (struct cmd_all_queues_drop_en_result,
13886 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13887 TOKEN_NUM_INITIALIZER
13888 (struct cmd_all_queues_drop_en_result,
13890 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13891 TOKEN_STRING_INITIALIZER
13892 (struct cmd_all_queues_drop_en_result,
13896 cmd_set_all_queues_drop_en_parsed(
13897 void *parsed_result,
13898 __rte_unused struct cmdline *cl,
13899 __rte_unused void *data)
13901 struct cmd_all_queues_drop_en_result *res = parsed_result;
13902 int ret = -ENOTSUP;
13903 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13908 #ifdef RTE_LIBRTE_IXGBE_PMD
13909 if (ret == -ENOTSUP)
13910 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13912 #ifdef RTE_LIBRTE_BNXT_PMD
13913 if (ret == -ENOTSUP)
13914 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13920 printf("invalid is_on %d\n", is_on);
13923 printf("invalid port_id %d\n", res->port_id);
13926 printf("function not implemented\n");
13929 printf("programming error: (%s)\n", strerror(-ret));
13933 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13934 .f = cmd_set_all_queues_drop_en_parsed,
13936 .help_str = "set all queues drop <port_id> on|off",
13938 (void *)&cmd_all_queues_drop_en_set,
13939 (void *)&cmd_all_queues_drop_en_all,
13940 (void *)&cmd_all_queues_drop_en_queues,
13941 (void *)&cmd_all_queues_drop_en_drop,
13942 (void *)&cmd_all_queues_drop_en_port_id,
13943 (void *)&cmd_all_queues_drop_en_on_off,
13948 /* vf split drop enable configuration */
13950 /* Common result structure for vf split drop enable */
13951 struct cmd_vf_split_drop_en_result {
13952 cmdline_fixed_string_t set;
13953 cmdline_fixed_string_t vf;
13954 cmdline_fixed_string_t split;
13955 cmdline_fixed_string_t drop;
13958 cmdline_fixed_string_t on_off;
13961 /* Common CLI fields for vf split drop enable disable */
13962 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13963 TOKEN_STRING_INITIALIZER
13964 (struct cmd_vf_split_drop_en_result,
13966 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13967 TOKEN_STRING_INITIALIZER
13968 (struct cmd_vf_split_drop_en_result,
13970 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13971 TOKEN_STRING_INITIALIZER
13972 (struct cmd_vf_split_drop_en_result,
13974 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13975 TOKEN_STRING_INITIALIZER
13976 (struct cmd_vf_split_drop_en_result,
13978 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13979 TOKEN_NUM_INITIALIZER
13980 (struct cmd_vf_split_drop_en_result,
13982 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13983 TOKEN_NUM_INITIALIZER
13984 (struct cmd_vf_split_drop_en_result,
13986 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13987 TOKEN_STRING_INITIALIZER
13988 (struct cmd_vf_split_drop_en_result,
13992 cmd_set_vf_split_drop_en_parsed(
13993 void *parsed_result,
13994 __rte_unused struct cmdline *cl,
13995 __rte_unused void *data)
13997 struct cmd_vf_split_drop_en_result *res = parsed_result;
13998 int ret = -ENOTSUP;
13999 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14001 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14004 #ifdef RTE_LIBRTE_IXGBE_PMD
14005 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14012 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14015 printf("invalid port_id %d\n", res->port_id);
14018 printf("not supported on port %d\n", res->port_id);
14021 printf("programming error: (%s)\n", strerror(-ret));
14025 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14026 .f = cmd_set_vf_split_drop_en_parsed,
14028 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14030 (void *)&cmd_vf_split_drop_en_set,
14031 (void *)&cmd_vf_split_drop_en_vf,
14032 (void *)&cmd_vf_split_drop_en_split,
14033 (void *)&cmd_vf_split_drop_en_drop,
14034 (void *)&cmd_vf_split_drop_en_port_id,
14035 (void *)&cmd_vf_split_drop_en_vf_id,
14036 (void *)&cmd_vf_split_drop_en_on_off,
14041 /* vf mac address configuration */
14043 /* Common result structure for vf mac address */
14044 struct cmd_set_vf_mac_addr_result {
14045 cmdline_fixed_string_t set;
14046 cmdline_fixed_string_t vf;
14047 cmdline_fixed_string_t mac;
14048 cmdline_fixed_string_t addr;
14051 struct rte_ether_addr mac_addr;
14055 /* Common CLI fields for vf split drop enable disable */
14056 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14057 TOKEN_STRING_INITIALIZER
14058 (struct cmd_set_vf_mac_addr_result,
14060 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14061 TOKEN_STRING_INITIALIZER
14062 (struct cmd_set_vf_mac_addr_result,
14064 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14065 TOKEN_STRING_INITIALIZER
14066 (struct cmd_set_vf_mac_addr_result,
14068 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14069 TOKEN_STRING_INITIALIZER
14070 (struct cmd_set_vf_mac_addr_result,
14072 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14073 TOKEN_NUM_INITIALIZER
14074 (struct cmd_set_vf_mac_addr_result,
14076 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14077 TOKEN_NUM_INITIALIZER
14078 (struct cmd_set_vf_mac_addr_result,
14080 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14081 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14085 cmd_set_vf_mac_addr_parsed(
14086 void *parsed_result,
14087 __rte_unused struct cmdline *cl,
14088 __rte_unused void *data)
14090 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14091 int ret = -ENOTSUP;
14093 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14096 #ifdef RTE_LIBRTE_IXGBE_PMD
14097 if (ret == -ENOTSUP)
14098 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14101 #ifdef RTE_LIBRTE_I40E_PMD
14102 if (ret == -ENOTSUP)
14103 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14106 #ifdef RTE_LIBRTE_BNXT_PMD
14107 if (ret == -ENOTSUP)
14108 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14116 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14119 printf("invalid port_id %d\n", res->port_id);
14122 printf("function not implemented\n");
14125 printf("programming error: (%s)\n", strerror(-ret));
14129 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14130 .f = cmd_set_vf_mac_addr_parsed,
14132 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14134 (void *)&cmd_set_vf_mac_addr_set,
14135 (void *)&cmd_set_vf_mac_addr_vf,
14136 (void *)&cmd_set_vf_mac_addr_mac,
14137 (void *)&cmd_set_vf_mac_addr_addr,
14138 (void *)&cmd_set_vf_mac_addr_port_id,
14139 (void *)&cmd_set_vf_mac_addr_vf_id,
14140 (void *)&cmd_set_vf_mac_addr_mac_addr,
14145 /* MACsec configuration */
14147 /* Common result structure for MACsec offload enable */
14148 struct cmd_macsec_offload_on_result {
14149 cmdline_fixed_string_t set;
14150 cmdline_fixed_string_t macsec;
14151 cmdline_fixed_string_t offload;
14153 cmdline_fixed_string_t on;
14154 cmdline_fixed_string_t encrypt;
14155 cmdline_fixed_string_t en_on_off;
14156 cmdline_fixed_string_t replay_protect;
14157 cmdline_fixed_string_t rp_on_off;
14160 /* Common CLI fields for MACsec offload disable */
14161 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14162 TOKEN_STRING_INITIALIZER
14163 (struct cmd_macsec_offload_on_result,
14165 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14166 TOKEN_STRING_INITIALIZER
14167 (struct cmd_macsec_offload_on_result,
14169 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14170 TOKEN_STRING_INITIALIZER
14171 (struct cmd_macsec_offload_on_result,
14172 offload, "offload");
14173 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14174 TOKEN_NUM_INITIALIZER
14175 (struct cmd_macsec_offload_on_result,
14177 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14178 TOKEN_STRING_INITIALIZER
14179 (struct cmd_macsec_offload_on_result,
14181 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14182 TOKEN_STRING_INITIALIZER
14183 (struct cmd_macsec_offload_on_result,
14184 encrypt, "encrypt");
14185 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14186 TOKEN_STRING_INITIALIZER
14187 (struct cmd_macsec_offload_on_result,
14188 en_on_off, "on#off");
14189 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14190 TOKEN_STRING_INITIALIZER
14191 (struct cmd_macsec_offload_on_result,
14192 replay_protect, "replay-protect");
14193 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14194 TOKEN_STRING_INITIALIZER
14195 (struct cmd_macsec_offload_on_result,
14196 rp_on_off, "on#off");
14199 cmd_set_macsec_offload_on_parsed(
14200 void *parsed_result,
14201 __rte_unused struct cmdline *cl,
14202 __rte_unused void *data)
14204 struct cmd_macsec_offload_on_result *res = parsed_result;
14205 int ret = -ENOTSUP;
14206 portid_t port_id = res->port_id;
14207 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14208 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14209 struct rte_eth_dev_info dev_info;
14211 if (port_id_is_invalid(port_id, ENABLED_WARN))
14213 if (!port_is_stopped(port_id)) {
14214 printf("Please stop port %d first\n", port_id);
14218 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14222 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14223 #ifdef RTE_LIBRTE_IXGBE_PMD
14224 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14232 ports[port_id].dev_conf.txmode.offloads |=
14233 DEV_TX_OFFLOAD_MACSEC_INSERT;
14234 cmd_reconfig_device_queue(port_id, 1, 1);
14237 printf("invalid port_id %d\n", port_id);
14240 printf("not supported on port %d\n", port_id);
14243 printf("programming error: (%s)\n", strerror(-ret));
14247 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14248 .f = cmd_set_macsec_offload_on_parsed,
14250 .help_str = "set macsec offload <port_id> on "
14251 "encrypt on|off replay-protect on|off",
14253 (void *)&cmd_macsec_offload_on_set,
14254 (void *)&cmd_macsec_offload_on_macsec,
14255 (void *)&cmd_macsec_offload_on_offload,
14256 (void *)&cmd_macsec_offload_on_port_id,
14257 (void *)&cmd_macsec_offload_on_on,
14258 (void *)&cmd_macsec_offload_on_encrypt,
14259 (void *)&cmd_macsec_offload_on_en_on_off,
14260 (void *)&cmd_macsec_offload_on_replay_protect,
14261 (void *)&cmd_macsec_offload_on_rp_on_off,
14266 /* Common result structure for MACsec offload disable */
14267 struct cmd_macsec_offload_off_result {
14268 cmdline_fixed_string_t set;
14269 cmdline_fixed_string_t macsec;
14270 cmdline_fixed_string_t offload;
14272 cmdline_fixed_string_t off;
14275 /* Common CLI fields for MACsec offload disable */
14276 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14277 TOKEN_STRING_INITIALIZER
14278 (struct cmd_macsec_offload_off_result,
14280 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14281 TOKEN_STRING_INITIALIZER
14282 (struct cmd_macsec_offload_off_result,
14284 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14285 TOKEN_STRING_INITIALIZER
14286 (struct cmd_macsec_offload_off_result,
14287 offload, "offload");
14288 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14289 TOKEN_NUM_INITIALIZER
14290 (struct cmd_macsec_offload_off_result,
14292 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14293 TOKEN_STRING_INITIALIZER
14294 (struct cmd_macsec_offload_off_result,
14298 cmd_set_macsec_offload_off_parsed(
14299 void *parsed_result,
14300 __rte_unused struct cmdline *cl,
14301 __rte_unused void *data)
14303 struct cmd_macsec_offload_off_result *res = parsed_result;
14304 int ret = -ENOTSUP;
14305 struct rte_eth_dev_info dev_info;
14306 portid_t port_id = res->port_id;
14308 if (port_id_is_invalid(port_id, ENABLED_WARN))
14310 if (!port_is_stopped(port_id)) {
14311 printf("Please stop port %d first\n", port_id);
14315 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14319 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14320 #ifdef RTE_LIBRTE_IXGBE_PMD
14321 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14326 ports[port_id].dev_conf.txmode.offloads &=
14327 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14328 cmd_reconfig_device_queue(port_id, 1, 1);
14331 printf("invalid port_id %d\n", port_id);
14334 printf("not supported on port %d\n", port_id);
14337 printf("programming error: (%s)\n", strerror(-ret));
14341 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14342 .f = cmd_set_macsec_offload_off_parsed,
14344 .help_str = "set macsec offload <port_id> off",
14346 (void *)&cmd_macsec_offload_off_set,
14347 (void *)&cmd_macsec_offload_off_macsec,
14348 (void *)&cmd_macsec_offload_off_offload,
14349 (void *)&cmd_macsec_offload_off_port_id,
14350 (void *)&cmd_macsec_offload_off_off,
14355 /* Common result structure for MACsec secure connection configure */
14356 struct cmd_macsec_sc_result {
14357 cmdline_fixed_string_t set;
14358 cmdline_fixed_string_t macsec;
14359 cmdline_fixed_string_t sc;
14360 cmdline_fixed_string_t tx_rx;
14362 struct rte_ether_addr mac;
14366 /* Common CLI fields for MACsec secure connection configure */
14367 cmdline_parse_token_string_t cmd_macsec_sc_set =
14368 TOKEN_STRING_INITIALIZER
14369 (struct cmd_macsec_sc_result,
14371 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14372 TOKEN_STRING_INITIALIZER
14373 (struct cmd_macsec_sc_result,
14375 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14376 TOKEN_STRING_INITIALIZER
14377 (struct cmd_macsec_sc_result,
14379 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14380 TOKEN_STRING_INITIALIZER
14381 (struct cmd_macsec_sc_result,
14383 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14384 TOKEN_NUM_INITIALIZER
14385 (struct cmd_macsec_sc_result,
14387 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14388 TOKEN_ETHERADDR_INITIALIZER
14389 (struct cmd_macsec_sc_result,
14391 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14392 TOKEN_NUM_INITIALIZER
14393 (struct cmd_macsec_sc_result,
14397 cmd_set_macsec_sc_parsed(
14398 void *parsed_result,
14399 __rte_unused struct cmdline *cl,
14400 __rte_unused void *data)
14402 struct cmd_macsec_sc_result *res = parsed_result;
14403 int ret = -ENOTSUP;
14404 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14406 #ifdef RTE_LIBRTE_IXGBE_PMD
14408 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14409 res->mac.addr_bytes) :
14410 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14411 res->mac.addr_bytes, res->pi);
14413 RTE_SET_USED(is_tx);
14419 printf("invalid port_id %d\n", res->port_id);
14422 printf("not supported on port %d\n", res->port_id);
14425 printf("programming error: (%s)\n", strerror(-ret));
14429 cmdline_parse_inst_t cmd_set_macsec_sc = {
14430 .f = cmd_set_macsec_sc_parsed,
14432 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14434 (void *)&cmd_macsec_sc_set,
14435 (void *)&cmd_macsec_sc_macsec,
14436 (void *)&cmd_macsec_sc_sc,
14437 (void *)&cmd_macsec_sc_tx_rx,
14438 (void *)&cmd_macsec_sc_port_id,
14439 (void *)&cmd_macsec_sc_mac,
14440 (void *)&cmd_macsec_sc_pi,
14445 /* Common result structure for MACsec secure connection configure */
14446 struct cmd_macsec_sa_result {
14447 cmdline_fixed_string_t set;
14448 cmdline_fixed_string_t macsec;
14449 cmdline_fixed_string_t sa;
14450 cmdline_fixed_string_t tx_rx;
14455 cmdline_fixed_string_t key;
14458 /* Common CLI fields for MACsec secure connection configure */
14459 cmdline_parse_token_string_t cmd_macsec_sa_set =
14460 TOKEN_STRING_INITIALIZER
14461 (struct cmd_macsec_sa_result,
14463 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14464 TOKEN_STRING_INITIALIZER
14465 (struct cmd_macsec_sa_result,
14467 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14468 TOKEN_STRING_INITIALIZER
14469 (struct cmd_macsec_sa_result,
14471 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14472 TOKEN_STRING_INITIALIZER
14473 (struct cmd_macsec_sa_result,
14475 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14476 TOKEN_NUM_INITIALIZER
14477 (struct cmd_macsec_sa_result,
14479 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14480 TOKEN_NUM_INITIALIZER
14481 (struct cmd_macsec_sa_result,
14483 cmdline_parse_token_num_t cmd_macsec_sa_an =
14484 TOKEN_NUM_INITIALIZER
14485 (struct cmd_macsec_sa_result,
14487 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14488 TOKEN_NUM_INITIALIZER
14489 (struct cmd_macsec_sa_result,
14491 cmdline_parse_token_string_t cmd_macsec_sa_key =
14492 TOKEN_STRING_INITIALIZER
14493 (struct cmd_macsec_sa_result,
14497 cmd_set_macsec_sa_parsed(
14498 void *parsed_result,
14499 __rte_unused struct cmdline *cl,
14500 __rte_unused void *data)
14502 struct cmd_macsec_sa_result *res = parsed_result;
14503 int ret = -ENOTSUP;
14504 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14505 uint8_t key[16] = { 0 };
14511 key_len = strlen(res->key) / 2;
14515 for (i = 0; i < key_len; i++) {
14516 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14519 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14522 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14525 #ifdef RTE_LIBRTE_IXGBE_PMD
14527 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14528 res->idx, res->an, res->pn, key) :
14529 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14530 res->idx, res->an, res->pn, key);
14532 RTE_SET_USED(is_tx);
14539 printf("invalid idx %d or an %d\n", res->idx, res->an);
14542 printf("invalid port_id %d\n", res->port_id);
14545 printf("not supported on port %d\n", res->port_id);
14548 printf("programming error: (%s)\n", strerror(-ret));
14552 cmdline_parse_inst_t cmd_set_macsec_sa = {
14553 .f = cmd_set_macsec_sa_parsed,
14555 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14557 (void *)&cmd_macsec_sa_set,
14558 (void *)&cmd_macsec_sa_macsec,
14559 (void *)&cmd_macsec_sa_sa,
14560 (void *)&cmd_macsec_sa_tx_rx,
14561 (void *)&cmd_macsec_sa_port_id,
14562 (void *)&cmd_macsec_sa_idx,
14563 (void *)&cmd_macsec_sa_an,
14564 (void *)&cmd_macsec_sa_pn,
14565 (void *)&cmd_macsec_sa_key,
14570 /* VF unicast promiscuous mode configuration */
14572 /* Common result structure for VF unicast promiscuous mode */
14573 struct cmd_vf_promisc_result {
14574 cmdline_fixed_string_t set;
14575 cmdline_fixed_string_t vf;
14576 cmdline_fixed_string_t promisc;
14579 cmdline_fixed_string_t on_off;
14582 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14583 cmdline_parse_token_string_t cmd_vf_promisc_set =
14584 TOKEN_STRING_INITIALIZER
14585 (struct cmd_vf_promisc_result,
14587 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14588 TOKEN_STRING_INITIALIZER
14589 (struct cmd_vf_promisc_result,
14591 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14592 TOKEN_STRING_INITIALIZER
14593 (struct cmd_vf_promisc_result,
14594 promisc, "promisc");
14595 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14596 TOKEN_NUM_INITIALIZER
14597 (struct cmd_vf_promisc_result,
14599 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14600 TOKEN_NUM_INITIALIZER
14601 (struct cmd_vf_promisc_result,
14603 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14604 TOKEN_STRING_INITIALIZER
14605 (struct cmd_vf_promisc_result,
14609 cmd_set_vf_promisc_parsed(
14610 void *parsed_result,
14611 __rte_unused struct cmdline *cl,
14612 __rte_unused void *data)
14614 struct cmd_vf_promisc_result *res = parsed_result;
14615 int ret = -ENOTSUP;
14617 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14619 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14622 #ifdef RTE_LIBRTE_I40E_PMD
14623 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14624 res->vf_id, is_on);
14631 printf("invalid vf_id %d\n", res->vf_id);
14634 printf("invalid port_id %d\n", res->port_id);
14637 printf("function not implemented\n");
14640 printf("programming error: (%s)\n", strerror(-ret));
14644 cmdline_parse_inst_t cmd_set_vf_promisc = {
14645 .f = cmd_set_vf_promisc_parsed,
14647 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14648 "Set unicast promiscuous mode for a VF from the PF",
14650 (void *)&cmd_vf_promisc_set,
14651 (void *)&cmd_vf_promisc_vf,
14652 (void *)&cmd_vf_promisc_promisc,
14653 (void *)&cmd_vf_promisc_port_id,
14654 (void *)&cmd_vf_promisc_vf_id,
14655 (void *)&cmd_vf_promisc_on_off,
14660 /* VF multicast promiscuous mode configuration */
14662 /* Common result structure for VF multicast promiscuous mode */
14663 struct cmd_vf_allmulti_result {
14664 cmdline_fixed_string_t set;
14665 cmdline_fixed_string_t vf;
14666 cmdline_fixed_string_t allmulti;
14669 cmdline_fixed_string_t on_off;
14672 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14673 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14674 TOKEN_STRING_INITIALIZER
14675 (struct cmd_vf_allmulti_result,
14677 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14678 TOKEN_STRING_INITIALIZER
14679 (struct cmd_vf_allmulti_result,
14681 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14682 TOKEN_STRING_INITIALIZER
14683 (struct cmd_vf_allmulti_result,
14684 allmulti, "allmulti");
14685 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14686 TOKEN_NUM_INITIALIZER
14687 (struct cmd_vf_allmulti_result,
14689 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14690 TOKEN_NUM_INITIALIZER
14691 (struct cmd_vf_allmulti_result,
14693 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14694 TOKEN_STRING_INITIALIZER
14695 (struct cmd_vf_allmulti_result,
14699 cmd_set_vf_allmulti_parsed(
14700 void *parsed_result,
14701 __rte_unused struct cmdline *cl,
14702 __rte_unused void *data)
14704 struct cmd_vf_allmulti_result *res = parsed_result;
14705 int ret = -ENOTSUP;
14707 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14709 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14712 #ifdef RTE_LIBRTE_I40E_PMD
14713 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14714 res->vf_id, is_on);
14721 printf("invalid vf_id %d\n", res->vf_id);
14724 printf("invalid port_id %d\n", res->port_id);
14727 printf("function not implemented\n");
14730 printf("programming error: (%s)\n", strerror(-ret));
14734 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14735 .f = cmd_set_vf_allmulti_parsed,
14737 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14738 "Set multicast promiscuous mode for a VF from the PF",
14740 (void *)&cmd_vf_allmulti_set,
14741 (void *)&cmd_vf_allmulti_vf,
14742 (void *)&cmd_vf_allmulti_allmulti,
14743 (void *)&cmd_vf_allmulti_port_id,
14744 (void *)&cmd_vf_allmulti_vf_id,
14745 (void *)&cmd_vf_allmulti_on_off,
14750 /* vf broadcast mode configuration */
14752 /* Common result structure for vf broadcast */
14753 struct cmd_set_vf_broadcast_result {
14754 cmdline_fixed_string_t set;
14755 cmdline_fixed_string_t vf;
14756 cmdline_fixed_string_t broadcast;
14759 cmdline_fixed_string_t on_off;
14762 /* Common CLI fields for vf broadcast enable disable */
14763 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14764 TOKEN_STRING_INITIALIZER
14765 (struct cmd_set_vf_broadcast_result,
14767 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14768 TOKEN_STRING_INITIALIZER
14769 (struct cmd_set_vf_broadcast_result,
14771 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14772 TOKEN_STRING_INITIALIZER
14773 (struct cmd_set_vf_broadcast_result,
14774 broadcast, "broadcast");
14775 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14776 TOKEN_NUM_INITIALIZER
14777 (struct cmd_set_vf_broadcast_result,
14779 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14780 TOKEN_NUM_INITIALIZER
14781 (struct cmd_set_vf_broadcast_result,
14783 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14784 TOKEN_STRING_INITIALIZER
14785 (struct cmd_set_vf_broadcast_result,
14789 cmd_set_vf_broadcast_parsed(
14790 void *parsed_result,
14791 __rte_unused struct cmdline *cl,
14792 __rte_unused void *data)
14794 struct cmd_set_vf_broadcast_result *res = parsed_result;
14795 int ret = -ENOTSUP;
14797 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14799 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14802 #ifdef RTE_LIBRTE_I40E_PMD
14803 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14804 res->vf_id, is_on);
14811 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14814 printf("invalid port_id %d\n", res->port_id);
14817 printf("function not implemented\n");
14820 printf("programming error: (%s)\n", strerror(-ret));
14824 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14825 .f = cmd_set_vf_broadcast_parsed,
14827 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14829 (void *)&cmd_set_vf_broadcast_set,
14830 (void *)&cmd_set_vf_broadcast_vf,
14831 (void *)&cmd_set_vf_broadcast_broadcast,
14832 (void *)&cmd_set_vf_broadcast_port_id,
14833 (void *)&cmd_set_vf_broadcast_vf_id,
14834 (void *)&cmd_set_vf_broadcast_on_off,
14839 /* vf vlan tag configuration */
14841 /* Common result structure for vf vlan tag */
14842 struct cmd_set_vf_vlan_tag_result {
14843 cmdline_fixed_string_t set;
14844 cmdline_fixed_string_t vf;
14845 cmdline_fixed_string_t vlan;
14846 cmdline_fixed_string_t tag;
14849 cmdline_fixed_string_t on_off;
14852 /* Common CLI fields for vf vlan tag enable disable */
14853 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14854 TOKEN_STRING_INITIALIZER
14855 (struct cmd_set_vf_vlan_tag_result,
14857 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14858 TOKEN_STRING_INITIALIZER
14859 (struct cmd_set_vf_vlan_tag_result,
14861 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14862 TOKEN_STRING_INITIALIZER
14863 (struct cmd_set_vf_vlan_tag_result,
14865 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14866 TOKEN_STRING_INITIALIZER
14867 (struct cmd_set_vf_vlan_tag_result,
14869 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14870 TOKEN_NUM_INITIALIZER
14871 (struct cmd_set_vf_vlan_tag_result,
14873 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14874 TOKEN_NUM_INITIALIZER
14875 (struct cmd_set_vf_vlan_tag_result,
14877 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14878 TOKEN_STRING_INITIALIZER
14879 (struct cmd_set_vf_vlan_tag_result,
14883 cmd_set_vf_vlan_tag_parsed(
14884 void *parsed_result,
14885 __rte_unused struct cmdline *cl,
14886 __rte_unused void *data)
14888 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14889 int ret = -ENOTSUP;
14891 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14893 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14896 #ifdef RTE_LIBRTE_I40E_PMD
14897 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14898 res->vf_id, is_on);
14905 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14908 printf("invalid port_id %d\n", res->port_id);
14911 printf("function not implemented\n");
14914 printf("programming error: (%s)\n", strerror(-ret));
14918 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14919 .f = cmd_set_vf_vlan_tag_parsed,
14921 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14923 (void *)&cmd_set_vf_vlan_tag_set,
14924 (void *)&cmd_set_vf_vlan_tag_vf,
14925 (void *)&cmd_set_vf_vlan_tag_vlan,
14926 (void *)&cmd_set_vf_vlan_tag_tag,
14927 (void *)&cmd_set_vf_vlan_tag_port_id,
14928 (void *)&cmd_set_vf_vlan_tag_vf_id,
14929 (void *)&cmd_set_vf_vlan_tag_on_off,
14934 /* Common definition of VF and TC TX bandwidth configuration */
14935 struct cmd_vf_tc_bw_result {
14936 cmdline_fixed_string_t set;
14937 cmdline_fixed_string_t vf;
14938 cmdline_fixed_string_t tc;
14939 cmdline_fixed_string_t tx;
14940 cmdline_fixed_string_t min_bw;
14941 cmdline_fixed_string_t max_bw;
14942 cmdline_fixed_string_t strict_link_prio;
14947 cmdline_fixed_string_t bw_list;
14951 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14952 TOKEN_STRING_INITIALIZER
14953 (struct cmd_vf_tc_bw_result,
14955 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14956 TOKEN_STRING_INITIALIZER
14957 (struct cmd_vf_tc_bw_result,
14959 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14960 TOKEN_STRING_INITIALIZER
14961 (struct cmd_vf_tc_bw_result,
14963 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14964 TOKEN_STRING_INITIALIZER
14965 (struct cmd_vf_tc_bw_result,
14967 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14968 TOKEN_STRING_INITIALIZER
14969 (struct cmd_vf_tc_bw_result,
14970 strict_link_prio, "strict-link-priority");
14971 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14972 TOKEN_STRING_INITIALIZER
14973 (struct cmd_vf_tc_bw_result,
14974 min_bw, "min-bandwidth");
14975 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14976 TOKEN_STRING_INITIALIZER
14977 (struct cmd_vf_tc_bw_result,
14978 max_bw, "max-bandwidth");
14979 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14980 TOKEN_NUM_INITIALIZER
14981 (struct cmd_vf_tc_bw_result,
14983 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14984 TOKEN_NUM_INITIALIZER
14985 (struct cmd_vf_tc_bw_result,
14987 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14988 TOKEN_NUM_INITIALIZER
14989 (struct cmd_vf_tc_bw_result,
14991 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14992 TOKEN_NUM_INITIALIZER
14993 (struct cmd_vf_tc_bw_result,
14995 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14996 TOKEN_STRING_INITIALIZER
14997 (struct cmd_vf_tc_bw_result,
14999 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15000 TOKEN_NUM_INITIALIZER
15001 (struct cmd_vf_tc_bw_result,
15004 /* VF max bandwidth setting */
15006 cmd_vf_max_bw_parsed(
15007 void *parsed_result,
15008 __rte_unused struct cmdline *cl,
15009 __rte_unused void *data)
15011 struct cmd_vf_tc_bw_result *res = parsed_result;
15012 int ret = -ENOTSUP;
15014 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15017 #ifdef RTE_LIBRTE_I40E_PMD
15018 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15019 res->vf_id, res->bw);
15026 printf("invalid vf_id %d or bandwidth %d\n",
15027 res->vf_id, res->bw);
15030 printf("invalid port_id %d\n", res->port_id);
15033 printf("function not implemented\n");
15036 printf("programming error: (%s)\n", strerror(-ret));
15040 cmdline_parse_inst_t cmd_vf_max_bw = {
15041 .f = cmd_vf_max_bw_parsed,
15043 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15045 (void *)&cmd_vf_tc_bw_set,
15046 (void *)&cmd_vf_tc_bw_vf,
15047 (void *)&cmd_vf_tc_bw_tx,
15048 (void *)&cmd_vf_tc_bw_max_bw,
15049 (void *)&cmd_vf_tc_bw_port_id,
15050 (void *)&cmd_vf_tc_bw_vf_id,
15051 (void *)&cmd_vf_tc_bw_bw,
15057 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15062 const char *p, *p0 = str;
15069 p = strchr(p0, '(');
15071 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15075 p0 = strchr(p, ')');
15077 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15081 if (size >= sizeof(s)) {
15082 printf("The string size exceeds the internal buffer size\n");
15085 snprintf(s, sizeof(s), "%.*s", size, p);
15086 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15088 printf("Failed to get the bandwidth list. ");
15092 for (i = 0; i < ret; i++)
15093 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15098 /* TC min bandwidth setting */
15100 cmd_vf_tc_min_bw_parsed(
15101 void *parsed_result,
15102 __rte_unused struct cmdline *cl,
15103 __rte_unused void *data)
15105 struct cmd_vf_tc_bw_result *res = parsed_result;
15108 int ret = -ENOTSUP;
15110 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15113 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15117 #ifdef RTE_LIBRTE_I40E_PMD
15118 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15126 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15129 printf("invalid port_id %d\n", res->port_id);
15132 printf("function not implemented\n");
15135 printf("programming error: (%s)\n", strerror(-ret));
15139 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15140 .f = cmd_vf_tc_min_bw_parsed,
15142 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15143 " <bw1, bw2, ...>",
15145 (void *)&cmd_vf_tc_bw_set,
15146 (void *)&cmd_vf_tc_bw_vf,
15147 (void *)&cmd_vf_tc_bw_tc,
15148 (void *)&cmd_vf_tc_bw_tx,
15149 (void *)&cmd_vf_tc_bw_min_bw,
15150 (void *)&cmd_vf_tc_bw_port_id,
15151 (void *)&cmd_vf_tc_bw_vf_id,
15152 (void *)&cmd_vf_tc_bw_bw_list,
15158 cmd_tc_min_bw_parsed(
15159 void *parsed_result,
15160 __rte_unused struct cmdline *cl,
15161 __rte_unused void *data)
15163 struct cmd_vf_tc_bw_result *res = parsed_result;
15164 struct rte_port *port;
15167 int ret = -ENOTSUP;
15169 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15172 port = &ports[res->port_id];
15173 /** Check if the port is not started **/
15174 if (port->port_status != RTE_PORT_STOPPED) {
15175 printf("Please stop port %d first\n", res->port_id);
15179 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15183 #ifdef RTE_LIBRTE_IXGBE_PMD
15184 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15191 printf("invalid bandwidth\n");
15194 printf("invalid port_id %d\n", res->port_id);
15197 printf("function not implemented\n");
15200 printf("programming error: (%s)\n", strerror(-ret));
15204 cmdline_parse_inst_t cmd_tc_min_bw = {
15205 .f = cmd_tc_min_bw_parsed,
15207 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15209 (void *)&cmd_vf_tc_bw_set,
15210 (void *)&cmd_vf_tc_bw_tc,
15211 (void *)&cmd_vf_tc_bw_tx,
15212 (void *)&cmd_vf_tc_bw_min_bw,
15213 (void *)&cmd_vf_tc_bw_port_id,
15214 (void *)&cmd_vf_tc_bw_bw_list,
15219 /* TC max bandwidth setting */
15221 cmd_vf_tc_max_bw_parsed(
15222 void *parsed_result,
15223 __rte_unused struct cmdline *cl,
15224 __rte_unused void *data)
15226 struct cmd_vf_tc_bw_result *res = parsed_result;
15227 int ret = -ENOTSUP;
15229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15232 #ifdef RTE_LIBRTE_I40E_PMD
15233 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15234 res->tc_no, res->bw);
15241 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15242 res->vf_id, res->tc_no, res->bw);
15245 printf("invalid port_id %d\n", res->port_id);
15248 printf("function not implemented\n");
15251 printf("programming error: (%s)\n", strerror(-ret));
15255 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15256 .f = cmd_vf_tc_max_bw_parsed,
15258 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15261 (void *)&cmd_vf_tc_bw_set,
15262 (void *)&cmd_vf_tc_bw_vf,
15263 (void *)&cmd_vf_tc_bw_tc,
15264 (void *)&cmd_vf_tc_bw_tx,
15265 (void *)&cmd_vf_tc_bw_max_bw,
15266 (void *)&cmd_vf_tc_bw_port_id,
15267 (void *)&cmd_vf_tc_bw_vf_id,
15268 (void *)&cmd_vf_tc_bw_tc_no,
15269 (void *)&cmd_vf_tc_bw_bw,
15275 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15277 /* *** Set Port default Traffic Management Hierarchy *** */
15278 struct cmd_set_port_tm_hierarchy_default_result {
15279 cmdline_fixed_string_t set;
15280 cmdline_fixed_string_t port;
15281 cmdline_fixed_string_t tm;
15282 cmdline_fixed_string_t hierarchy;
15283 cmdline_fixed_string_t def;
15287 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15288 TOKEN_STRING_INITIALIZER(
15289 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15290 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15291 TOKEN_STRING_INITIALIZER(
15292 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15293 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15294 TOKEN_STRING_INITIALIZER(
15295 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15296 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15297 TOKEN_STRING_INITIALIZER(
15298 struct cmd_set_port_tm_hierarchy_default_result,
15299 hierarchy, "hierarchy");
15300 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15301 TOKEN_STRING_INITIALIZER(
15302 struct cmd_set_port_tm_hierarchy_default_result,
15304 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15305 TOKEN_NUM_INITIALIZER(
15306 struct cmd_set_port_tm_hierarchy_default_result,
15309 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15310 __rte_unused struct cmdline *cl,
15311 __rte_unused void *data)
15313 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15314 struct rte_port *p;
15315 portid_t port_id = res->port_id;
15317 if (port_id_is_invalid(port_id, ENABLED_WARN))
15320 p = &ports[port_id];
15322 /* Forward mode: tm */
15323 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15324 printf(" softnicfwd mode not enabled(error)\n");
15328 /* Set the default tm hierarchy */
15329 p->softport.default_tm_hierarchy_enable = 1;
15332 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15333 .f = cmd_set_port_tm_hierarchy_default_parsed,
15335 .help_str = "set port tm hierarchy default <port_id>",
15337 (void *)&cmd_set_port_tm_hierarchy_default_set,
15338 (void *)&cmd_set_port_tm_hierarchy_default_port,
15339 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15340 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15341 (void *)&cmd_set_port_tm_hierarchy_default_default,
15342 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15348 /** Set VXLAN encapsulation details */
15349 struct cmd_set_vxlan_result {
15350 cmdline_fixed_string_t set;
15351 cmdline_fixed_string_t vxlan;
15352 cmdline_fixed_string_t pos_token;
15353 cmdline_fixed_string_t ip_version;
15354 uint32_t vlan_present:1;
15358 cmdline_ipaddr_t ip_src;
15359 cmdline_ipaddr_t ip_dst;
15363 struct rte_ether_addr eth_src;
15364 struct rte_ether_addr eth_dst;
15367 cmdline_parse_token_string_t cmd_set_vxlan_set =
15368 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15369 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15370 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15371 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15372 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15374 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15375 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15376 "vxlan-with-vlan");
15377 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15378 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15380 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15381 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15383 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15384 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15386 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15387 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15388 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15389 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15391 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15392 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15393 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15394 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15396 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15397 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15398 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15399 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15401 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15402 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15403 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15404 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15406 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15407 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15408 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15409 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15411 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15412 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15413 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15414 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15416 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15417 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15418 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15419 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15421 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15422 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15423 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15424 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15426 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15427 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15428 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15429 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15431 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15432 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15434 static void cmd_set_vxlan_parsed(void *parsed_result,
15435 __rte_unused struct cmdline *cl,
15436 __rte_unused void *data)
15438 struct cmd_set_vxlan_result *res = parsed_result;
15443 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15446 vxlan_encap_conf.select_tos_ttl = 0;
15447 if (strcmp(res->vxlan, "vxlan") == 0)
15448 vxlan_encap_conf.select_vlan = 0;
15449 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15450 vxlan_encap_conf.select_vlan = 1;
15451 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15452 vxlan_encap_conf.select_vlan = 0;
15453 vxlan_encap_conf.select_tos_ttl = 1;
15455 if (strcmp(res->ip_version, "ipv4") == 0)
15456 vxlan_encap_conf.select_ipv4 = 1;
15457 else if (strcmp(res->ip_version, "ipv6") == 0)
15458 vxlan_encap_conf.select_ipv4 = 0;
15461 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15462 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15463 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15464 vxlan_encap_conf.ip_tos = res->tos;
15465 vxlan_encap_conf.ip_ttl = res->ttl;
15466 if (vxlan_encap_conf.select_ipv4) {
15467 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15468 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15470 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15471 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15473 if (vxlan_encap_conf.select_vlan)
15474 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15475 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15476 RTE_ETHER_ADDR_LEN);
15477 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15478 RTE_ETHER_ADDR_LEN);
15481 cmdline_parse_inst_t cmd_set_vxlan = {
15482 .f = cmd_set_vxlan_parsed,
15484 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15485 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15486 " eth-src <eth-src> eth-dst <eth-dst>",
15488 (void *)&cmd_set_vxlan_set,
15489 (void *)&cmd_set_vxlan_vxlan,
15490 (void *)&cmd_set_vxlan_ip_version,
15491 (void *)&cmd_set_vxlan_ip_version_value,
15492 (void *)&cmd_set_vxlan_vni,
15493 (void *)&cmd_set_vxlan_vni_value,
15494 (void *)&cmd_set_vxlan_udp_src,
15495 (void *)&cmd_set_vxlan_udp_src_value,
15496 (void *)&cmd_set_vxlan_udp_dst,
15497 (void *)&cmd_set_vxlan_udp_dst_value,
15498 (void *)&cmd_set_vxlan_ip_src,
15499 (void *)&cmd_set_vxlan_ip_src_value,
15500 (void *)&cmd_set_vxlan_ip_dst,
15501 (void *)&cmd_set_vxlan_ip_dst_value,
15502 (void *)&cmd_set_vxlan_eth_src,
15503 (void *)&cmd_set_vxlan_eth_src_value,
15504 (void *)&cmd_set_vxlan_eth_dst,
15505 (void *)&cmd_set_vxlan_eth_dst_value,
15510 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15511 .f = cmd_set_vxlan_parsed,
15513 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15514 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15515 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15516 " eth-dst <eth-dst>",
15518 (void *)&cmd_set_vxlan_set,
15519 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15520 (void *)&cmd_set_vxlan_ip_version,
15521 (void *)&cmd_set_vxlan_ip_version_value,
15522 (void *)&cmd_set_vxlan_vni,
15523 (void *)&cmd_set_vxlan_vni_value,
15524 (void *)&cmd_set_vxlan_udp_src,
15525 (void *)&cmd_set_vxlan_udp_src_value,
15526 (void *)&cmd_set_vxlan_udp_dst,
15527 (void *)&cmd_set_vxlan_udp_dst_value,
15528 (void *)&cmd_set_vxlan_ip_tos,
15529 (void *)&cmd_set_vxlan_ip_tos_value,
15530 (void *)&cmd_set_vxlan_ip_ttl,
15531 (void *)&cmd_set_vxlan_ip_ttl_value,
15532 (void *)&cmd_set_vxlan_ip_src,
15533 (void *)&cmd_set_vxlan_ip_src_value,
15534 (void *)&cmd_set_vxlan_ip_dst,
15535 (void *)&cmd_set_vxlan_ip_dst_value,
15536 (void *)&cmd_set_vxlan_eth_src,
15537 (void *)&cmd_set_vxlan_eth_src_value,
15538 (void *)&cmd_set_vxlan_eth_dst,
15539 (void *)&cmd_set_vxlan_eth_dst_value,
15544 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15545 .f = cmd_set_vxlan_parsed,
15547 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15548 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15549 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15552 (void *)&cmd_set_vxlan_set,
15553 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15554 (void *)&cmd_set_vxlan_ip_version,
15555 (void *)&cmd_set_vxlan_ip_version_value,
15556 (void *)&cmd_set_vxlan_vni,
15557 (void *)&cmd_set_vxlan_vni_value,
15558 (void *)&cmd_set_vxlan_udp_src,
15559 (void *)&cmd_set_vxlan_udp_src_value,
15560 (void *)&cmd_set_vxlan_udp_dst,
15561 (void *)&cmd_set_vxlan_udp_dst_value,
15562 (void *)&cmd_set_vxlan_ip_src,
15563 (void *)&cmd_set_vxlan_ip_src_value,
15564 (void *)&cmd_set_vxlan_ip_dst,
15565 (void *)&cmd_set_vxlan_ip_dst_value,
15566 (void *)&cmd_set_vxlan_vlan,
15567 (void *)&cmd_set_vxlan_vlan_value,
15568 (void *)&cmd_set_vxlan_eth_src,
15569 (void *)&cmd_set_vxlan_eth_src_value,
15570 (void *)&cmd_set_vxlan_eth_dst,
15571 (void *)&cmd_set_vxlan_eth_dst_value,
15576 /** Set NVGRE encapsulation details */
15577 struct cmd_set_nvgre_result {
15578 cmdline_fixed_string_t set;
15579 cmdline_fixed_string_t nvgre;
15580 cmdline_fixed_string_t pos_token;
15581 cmdline_fixed_string_t ip_version;
15583 cmdline_ipaddr_t ip_src;
15584 cmdline_ipaddr_t ip_dst;
15586 struct rte_ether_addr eth_src;
15587 struct rte_ether_addr eth_dst;
15590 cmdline_parse_token_string_t cmd_set_nvgre_set =
15591 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15592 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15593 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15594 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15595 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15596 "nvgre-with-vlan");
15597 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15598 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15600 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15601 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15603 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15604 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15606 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15607 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15608 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15609 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15611 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15612 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15613 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15614 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15616 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15617 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15618 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15619 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15621 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15622 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15623 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15624 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15626 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15627 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15628 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15629 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15631 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15632 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15634 static void cmd_set_nvgre_parsed(void *parsed_result,
15635 __rte_unused struct cmdline *cl,
15636 __rte_unused void *data)
15638 struct cmd_set_nvgre_result *res = parsed_result;
15640 uint32_t nvgre_tni;
15643 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15646 if (strcmp(res->nvgre, "nvgre") == 0)
15647 nvgre_encap_conf.select_vlan = 0;
15648 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15649 nvgre_encap_conf.select_vlan = 1;
15650 if (strcmp(res->ip_version, "ipv4") == 0)
15651 nvgre_encap_conf.select_ipv4 = 1;
15652 else if (strcmp(res->ip_version, "ipv6") == 0)
15653 nvgre_encap_conf.select_ipv4 = 0;
15656 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15657 if (nvgre_encap_conf.select_ipv4) {
15658 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15659 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15661 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15662 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15664 if (nvgre_encap_conf.select_vlan)
15665 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15666 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15667 RTE_ETHER_ADDR_LEN);
15668 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15669 RTE_ETHER_ADDR_LEN);
15672 cmdline_parse_inst_t cmd_set_nvgre = {
15673 .f = cmd_set_nvgre_parsed,
15675 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15676 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15677 " eth-dst <eth-dst>",
15679 (void *)&cmd_set_nvgre_set,
15680 (void *)&cmd_set_nvgre_nvgre,
15681 (void *)&cmd_set_nvgre_ip_version,
15682 (void *)&cmd_set_nvgre_ip_version_value,
15683 (void *)&cmd_set_nvgre_tni,
15684 (void *)&cmd_set_nvgre_tni_value,
15685 (void *)&cmd_set_nvgre_ip_src,
15686 (void *)&cmd_set_nvgre_ip_src_value,
15687 (void *)&cmd_set_nvgre_ip_dst,
15688 (void *)&cmd_set_nvgre_ip_dst_value,
15689 (void *)&cmd_set_nvgre_eth_src,
15690 (void *)&cmd_set_nvgre_eth_src_value,
15691 (void *)&cmd_set_nvgre_eth_dst,
15692 (void *)&cmd_set_nvgre_eth_dst_value,
15697 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15698 .f = cmd_set_nvgre_parsed,
15700 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15701 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15702 " eth-src <eth-src> eth-dst <eth-dst>",
15704 (void *)&cmd_set_nvgre_set,
15705 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15706 (void *)&cmd_set_nvgre_ip_version,
15707 (void *)&cmd_set_nvgre_ip_version_value,
15708 (void *)&cmd_set_nvgre_tni,
15709 (void *)&cmd_set_nvgre_tni_value,
15710 (void *)&cmd_set_nvgre_ip_src,
15711 (void *)&cmd_set_nvgre_ip_src_value,
15712 (void *)&cmd_set_nvgre_ip_dst,
15713 (void *)&cmd_set_nvgre_ip_dst_value,
15714 (void *)&cmd_set_nvgre_vlan,
15715 (void *)&cmd_set_nvgre_vlan_value,
15716 (void *)&cmd_set_nvgre_eth_src,
15717 (void *)&cmd_set_nvgre_eth_src_value,
15718 (void *)&cmd_set_nvgre_eth_dst,
15719 (void *)&cmd_set_nvgre_eth_dst_value,
15724 /** Set L2 encapsulation details */
15725 struct cmd_set_l2_encap_result {
15726 cmdline_fixed_string_t set;
15727 cmdline_fixed_string_t l2_encap;
15728 cmdline_fixed_string_t pos_token;
15729 cmdline_fixed_string_t ip_version;
15730 uint32_t vlan_present:1;
15732 struct rte_ether_addr eth_src;
15733 struct rte_ether_addr eth_dst;
15736 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15737 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15738 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15739 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15740 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15741 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15742 "l2_encap-with-vlan");
15743 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15744 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15746 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15747 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15749 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15750 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15752 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15753 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15754 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15755 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15757 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15758 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15759 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15760 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15762 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15763 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15765 static void cmd_set_l2_encap_parsed(void *parsed_result,
15766 __rte_unused struct cmdline *cl,
15767 __rte_unused void *data)
15769 struct cmd_set_l2_encap_result *res = parsed_result;
15771 if (strcmp(res->l2_encap, "l2_encap") == 0)
15772 l2_encap_conf.select_vlan = 0;
15773 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15774 l2_encap_conf.select_vlan = 1;
15775 if (strcmp(res->ip_version, "ipv4") == 0)
15776 l2_encap_conf.select_ipv4 = 1;
15777 else if (strcmp(res->ip_version, "ipv6") == 0)
15778 l2_encap_conf.select_ipv4 = 0;
15781 if (l2_encap_conf.select_vlan)
15782 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15783 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15784 RTE_ETHER_ADDR_LEN);
15785 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15786 RTE_ETHER_ADDR_LEN);
15789 cmdline_parse_inst_t cmd_set_l2_encap = {
15790 .f = cmd_set_l2_encap_parsed,
15792 .help_str = "set l2_encap ip-version ipv4|ipv6"
15793 " eth-src <eth-src> eth-dst <eth-dst>",
15795 (void *)&cmd_set_l2_encap_set,
15796 (void *)&cmd_set_l2_encap_l2_encap,
15797 (void *)&cmd_set_l2_encap_ip_version,
15798 (void *)&cmd_set_l2_encap_ip_version_value,
15799 (void *)&cmd_set_l2_encap_eth_src,
15800 (void *)&cmd_set_l2_encap_eth_src_value,
15801 (void *)&cmd_set_l2_encap_eth_dst,
15802 (void *)&cmd_set_l2_encap_eth_dst_value,
15807 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15808 .f = cmd_set_l2_encap_parsed,
15810 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15811 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15813 (void *)&cmd_set_l2_encap_set,
15814 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15815 (void *)&cmd_set_l2_encap_ip_version,
15816 (void *)&cmd_set_l2_encap_ip_version_value,
15817 (void *)&cmd_set_l2_encap_vlan,
15818 (void *)&cmd_set_l2_encap_vlan_value,
15819 (void *)&cmd_set_l2_encap_eth_src,
15820 (void *)&cmd_set_l2_encap_eth_src_value,
15821 (void *)&cmd_set_l2_encap_eth_dst,
15822 (void *)&cmd_set_l2_encap_eth_dst_value,
15827 /** Set L2 decapsulation details */
15828 struct cmd_set_l2_decap_result {
15829 cmdline_fixed_string_t set;
15830 cmdline_fixed_string_t l2_decap;
15831 cmdline_fixed_string_t pos_token;
15832 uint32_t vlan_present:1;
15835 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15836 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15837 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15838 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15840 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15841 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15842 "l2_decap-with-vlan");
15844 static void cmd_set_l2_decap_parsed(void *parsed_result,
15845 __rte_unused struct cmdline *cl,
15846 __rte_unused void *data)
15848 struct cmd_set_l2_decap_result *res = parsed_result;
15850 if (strcmp(res->l2_decap, "l2_decap") == 0)
15851 l2_decap_conf.select_vlan = 0;
15852 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15853 l2_decap_conf.select_vlan = 1;
15856 cmdline_parse_inst_t cmd_set_l2_decap = {
15857 .f = cmd_set_l2_decap_parsed,
15859 .help_str = "set l2_decap",
15861 (void *)&cmd_set_l2_decap_set,
15862 (void *)&cmd_set_l2_decap_l2_decap,
15867 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15868 .f = cmd_set_l2_decap_parsed,
15870 .help_str = "set l2_decap-with-vlan",
15872 (void *)&cmd_set_l2_decap_set,
15873 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15878 /** Set MPLSoGRE encapsulation details */
15879 struct cmd_set_mplsogre_encap_result {
15880 cmdline_fixed_string_t set;
15881 cmdline_fixed_string_t mplsogre;
15882 cmdline_fixed_string_t pos_token;
15883 cmdline_fixed_string_t ip_version;
15884 uint32_t vlan_present:1;
15886 cmdline_ipaddr_t ip_src;
15887 cmdline_ipaddr_t ip_dst;
15889 struct rte_ether_addr eth_src;
15890 struct rte_ether_addr eth_dst;
15893 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15894 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15896 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15897 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15899 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15900 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15901 mplsogre, "mplsogre_encap-with-vlan");
15902 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15903 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15904 pos_token, "ip-version");
15905 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15906 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15907 ip_version, "ipv4#ipv6");
15908 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15909 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15910 pos_token, "label");
15911 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15912 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15914 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15915 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15916 pos_token, "ip-src");
15917 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15918 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15919 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15920 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15921 pos_token, "ip-dst");
15922 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15923 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15924 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15925 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15926 pos_token, "vlan-tci");
15927 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15928 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15930 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15931 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15932 pos_token, "eth-src");
15933 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15934 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15936 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15937 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15938 pos_token, "eth-dst");
15939 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15940 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15943 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15944 __rte_unused struct cmdline *cl,
15945 __rte_unused void *data)
15947 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15949 uint32_t mplsogre_label;
15952 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15955 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15956 mplsogre_encap_conf.select_vlan = 0;
15957 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15958 mplsogre_encap_conf.select_vlan = 1;
15959 if (strcmp(res->ip_version, "ipv4") == 0)
15960 mplsogre_encap_conf.select_ipv4 = 1;
15961 else if (strcmp(res->ip_version, "ipv6") == 0)
15962 mplsogre_encap_conf.select_ipv4 = 0;
15965 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15966 if (mplsogre_encap_conf.select_ipv4) {
15967 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15968 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15970 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15971 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15973 if (mplsogre_encap_conf.select_vlan)
15974 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15975 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15976 RTE_ETHER_ADDR_LEN);
15977 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15978 RTE_ETHER_ADDR_LEN);
15981 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15982 .f = cmd_set_mplsogre_encap_parsed,
15984 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15985 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15986 " eth-dst <eth-dst>",
15988 (void *)&cmd_set_mplsogre_encap_set,
15989 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15990 (void *)&cmd_set_mplsogre_encap_ip_version,
15991 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15992 (void *)&cmd_set_mplsogre_encap_label,
15993 (void *)&cmd_set_mplsogre_encap_label_value,
15994 (void *)&cmd_set_mplsogre_encap_ip_src,
15995 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15996 (void *)&cmd_set_mplsogre_encap_ip_dst,
15997 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15998 (void *)&cmd_set_mplsogre_encap_eth_src,
15999 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16000 (void *)&cmd_set_mplsogre_encap_eth_dst,
16001 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16006 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16007 .f = cmd_set_mplsogre_encap_parsed,
16009 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16010 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16011 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16013 (void *)&cmd_set_mplsogre_encap_set,
16014 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16015 (void *)&cmd_set_mplsogre_encap_ip_version,
16016 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16017 (void *)&cmd_set_mplsogre_encap_label,
16018 (void *)&cmd_set_mplsogre_encap_label_value,
16019 (void *)&cmd_set_mplsogre_encap_ip_src,
16020 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16021 (void *)&cmd_set_mplsogre_encap_ip_dst,
16022 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16023 (void *)&cmd_set_mplsogre_encap_vlan,
16024 (void *)&cmd_set_mplsogre_encap_vlan_value,
16025 (void *)&cmd_set_mplsogre_encap_eth_src,
16026 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16027 (void *)&cmd_set_mplsogre_encap_eth_dst,
16028 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16033 /** Set MPLSoGRE decapsulation details */
16034 struct cmd_set_mplsogre_decap_result {
16035 cmdline_fixed_string_t set;
16036 cmdline_fixed_string_t mplsogre;
16037 cmdline_fixed_string_t pos_token;
16038 cmdline_fixed_string_t ip_version;
16039 uint32_t vlan_present:1;
16042 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16043 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16045 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16046 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16048 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16049 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16050 mplsogre, "mplsogre_decap-with-vlan");
16051 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16052 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16053 pos_token, "ip-version");
16054 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16055 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16056 ip_version, "ipv4#ipv6");
16058 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16059 __rte_unused struct cmdline *cl,
16060 __rte_unused void *data)
16062 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16064 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16065 mplsogre_decap_conf.select_vlan = 0;
16066 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16067 mplsogre_decap_conf.select_vlan = 1;
16068 if (strcmp(res->ip_version, "ipv4") == 0)
16069 mplsogre_decap_conf.select_ipv4 = 1;
16070 else if (strcmp(res->ip_version, "ipv6") == 0)
16071 mplsogre_decap_conf.select_ipv4 = 0;
16074 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16075 .f = cmd_set_mplsogre_decap_parsed,
16077 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16079 (void *)&cmd_set_mplsogre_decap_set,
16080 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16081 (void *)&cmd_set_mplsogre_decap_ip_version,
16082 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16087 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16088 .f = cmd_set_mplsogre_decap_parsed,
16090 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16092 (void *)&cmd_set_mplsogre_decap_set,
16093 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16094 (void *)&cmd_set_mplsogre_decap_ip_version,
16095 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16100 /** Set MPLSoUDP encapsulation details */
16101 struct cmd_set_mplsoudp_encap_result {
16102 cmdline_fixed_string_t set;
16103 cmdline_fixed_string_t mplsoudp;
16104 cmdline_fixed_string_t pos_token;
16105 cmdline_fixed_string_t ip_version;
16106 uint32_t vlan_present:1;
16110 cmdline_ipaddr_t ip_src;
16111 cmdline_ipaddr_t ip_dst;
16113 struct rte_ether_addr eth_src;
16114 struct rte_ether_addr eth_dst;
16117 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16118 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16120 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16121 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16123 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16124 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16125 mplsoudp, "mplsoudp_encap-with-vlan");
16126 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16127 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16128 pos_token, "ip-version");
16129 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16130 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16131 ip_version, "ipv4#ipv6");
16132 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16133 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16134 pos_token, "label");
16135 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16136 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16138 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16139 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16140 pos_token, "udp-src");
16141 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16142 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16144 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16145 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16146 pos_token, "udp-dst");
16147 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16148 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16150 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16151 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16152 pos_token, "ip-src");
16153 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16154 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16155 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16156 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16157 pos_token, "ip-dst");
16158 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16159 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16160 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16161 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16162 pos_token, "vlan-tci");
16163 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16164 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16166 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16167 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16168 pos_token, "eth-src");
16169 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16170 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16172 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16173 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16174 pos_token, "eth-dst");
16175 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16176 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16179 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16180 __rte_unused struct cmdline *cl,
16181 __rte_unused void *data)
16183 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16185 uint32_t mplsoudp_label;
16188 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16191 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16192 mplsoudp_encap_conf.select_vlan = 0;
16193 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16194 mplsoudp_encap_conf.select_vlan = 1;
16195 if (strcmp(res->ip_version, "ipv4") == 0)
16196 mplsoudp_encap_conf.select_ipv4 = 1;
16197 else if (strcmp(res->ip_version, "ipv6") == 0)
16198 mplsoudp_encap_conf.select_ipv4 = 0;
16201 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16202 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16203 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16204 if (mplsoudp_encap_conf.select_ipv4) {
16205 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16206 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16208 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16209 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16211 if (mplsoudp_encap_conf.select_vlan)
16212 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16213 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16214 RTE_ETHER_ADDR_LEN);
16215 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16216 RTE_ETHER_ADDR_LEN);
16219 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16220 .f = cmd_set_mplsoudp_encap_parsed,
16222 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16223 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16224 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16226 (void *)&cmd_set_mplsoudp_encap_set,
16227 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16228 (void *)&cmd_set_mplsoudp_encap_ip_version,
16229 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16230 (void *)&cmd_set_mplsoudp_encap_label,
16231 (void *)&cmd_set_mplsoudp_encap_label_value,
16232 (void *)&cmd_set_mplsoudp_encap_udp_src,
16233 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16234 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16235 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16236 (void *)&cmd_set_mplsoudp_encap_ip_src,
16237 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16238 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16239 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16240 (void *)&cmd_set_mplsoudp_encap_eth_src,
16241 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16242 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16243 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16248 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16249 .f = cmd_set_mplsoudp_encap_parsed,
16251 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16252 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16253 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16254 " eth-src <eth-src> eth-dst <eth-dst>",
16256 (void *)&cmd_set_mplsoudp_encap_set,
16257 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16258 (void *)&cmd_set_mplsoudp_encap_ip_version,
16259 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16260 (void *)&cmd_set_mplsoudp_encap_label,
16261 (void *)&cmd_set_mplsoudp_encap_label_value,
16262 (void *)&cmd_set_mplsoudp_encap_udp_src,
16263 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16264 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16265 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16266 (void *)&cmd_set_mplsoudp_encap_ip_src,
16267 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16268 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16269 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16270 (void *)&cmd_set_mplsoudp_encap_vlan,
16271 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16272 (void *)&cmd_set_mplsoudp_encap_eth_src,
16273 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16274 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16275 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16280 /** Set MPLSoUDP decapsulation details */
16281 struct cmd_set_mplsoudp_decap_result {
16282 cmdline_fixed_string_t set;
16283 cmdline_fixed_string_t mplsoudp;
16284 cmdline_fixed_string_t pos_token;
16285 cmdline_fixed_string_t ip_version;
16286 uint32_t vlan_present:1;
16289 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16290 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16292 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16293 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16295 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16296 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16297 mplsoudp, "mplsoudp_decap-with-vlan");
16298 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16299 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16300 pos_token, "ip-version");
16301 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16302 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16303 ip_version, "ipv4#ipv6");
16305 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16306 __rte_unused struct cmdline *cl,
16307 __rte_unused void *data)
16309 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16311 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16312 mplsoudp_decap_conf.select_vlan = 0;
16313 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16314 mplsoudp_decap_conf.select_vlan = 1;
16315 if (strcmp(res->ip_version, "ipv4") == 0)
16316 mplsoudp_decap_conf.select_ipv4 = 1;
16317 else if (strcmp(res->ip_version, "ipv6") == 0)
16318 mplsoudp_decap_conf.select_ipv4 = 0;
16321 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16322 .f = cmd_set_mplsoudp_decap_parsed,
16324 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16326 (void *)&cmd_set_mplsoudp_decap_set,
16327 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16328 (void *)&cmd_set_mplsoudp_decap_ip_version,
16329 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16334 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16335 .f = cmd_set_mplsoudp_decap_parsed,
16337 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16339 (void *)&cmd_set_mplsoudp_decap_set,
16340 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16341 (void *)&cmd_set_mplsoudp_decap_ip_version,
16342 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16347 /* Strict link priority scheduling mode setting */
16349 cmd_strict_link_prio_parsed(
16350 void *parsed_result,
16351 __rte_unused struct cmdline *cl,
16352 __rte_unused void *data)
16354 struct cmd_vf_tc_bw_result *res = parsed_result;
16355 int ret = -ENOTSUP;
16357 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16360 #ifdef RTE_LIBRTE_I40E_PMD
16361 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16368 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16371 printf("invalid port_id %d\n", res->port_id);
16374 printf("function not implemented\n");
16377 printf("programming error: (%s)\n", strerror(-ret));
16381 cmdline_parse_inst_t cmd_strict_link_prio = {
16382 .f = cmd_strict_link_prio_parsed,
16384 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16386 (void *)&cmd_vf_tc_bw_set,
16387 (void *)&cmd_vf_tc_bw_tx,
16388 (void *)&cmd_vf_tc_bw_strict_link_prio,
16389 (void *)&cmd_vf_tc_bw_port_id,
16390 (void *)&cmd_vf_tc_bw_tc_map,
16395 /* Load dynamic device personalization*/
16396 struct cmd_ddp_add_result {
16397 cmdline_fixed_string_t ddp;
16398 cmdline_fixed_string_t add;
16403 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16404 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16405 cmdline_parse_token_string_t cmd_ddp_add_add =
16406 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16407 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16408 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16409 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16410 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16413 cmd_ddp_add_parsed(
16414 void *parsed_result,
16415 __rte_unused struct cmdline *cl,
16416 __rte_unused void *data)
16418 struct cmd_ddp_add_result *res = parsed_result;
16424 int ret = -ENOTSUP;
16426 if (!all_ports_stopped()) {
16427 printf("Please stop all ports first\n");
16431 filepath = strdup(res->filepath);
16432 if (filepath == NULL) {
16433 printf("Failed to allocate memory\n");
16436 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16438 buff = open_file(file_fld[0], &size);
16440 free((void *)filepath);
16444 #ifdef RTE_LIBRTE_I40E_PMD
16445 if (ret == -ENOTSUP)
16446 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16448 RTE_PMD_I40E_PKG_OP_WR_ADD);
16451 if (ret == -EEXIST)
16452 printf("Profile has already existed.\n");
16454 printf("Failed to load profile.\n");
16455 else if (file_num == 2)
16456 save_file(file_fld[1], buff, size);
16459 free((void *)filepath);
16462 cmdline_parse_inst_t cmd_ddp_add = {
16463 .f = cmd_ddp_add_parsed,
16465 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16467 (void *)&cmd_ddp_add_ddp,
16468 (void *)&cmd_ddp_add_add,
16469 (void *)&cmd_ddp_add_port_id,
16470 (void *)&cmd_ddp_add_filepath,
16475 /* Delete dynamic device personalization*/
16476 struct cmd_ddp_del_result {
16477 cmdline_fixed_string_t ddp;
16478 cmdline_fixed_string_t del;
16483 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16484 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16485 cmdline_parse_token_string_t cmd_ddp_del_del =
16486 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16487 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16488 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16489 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16490 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16493 cmd_ddp_del_parsed(
16494 void *parsed_result,
16495 __rte_unused struct cmdline *cl,
16496 __rte_unused void *data)
16498 struct cmd_ddp_del_result *res = parsed_result;
16501 int ret = -ENOTSUP;
16503 if (!all_ports_stopped()) {
16504 printf("Please stop all ports first\n");
16508 buff = open_file(res->filepath, &size);
16512 #ifdef RTE_LIBRTE_I40E_PMD
16513 if (ret == -ENOTSUP)
16514 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16516 RTE_PMD_I40E_PKG_OP_WR_DEL);
16519 if (ret == -EACCES)
16520 printf("Profile does not exist.\n");
16522 printf("Failed to delete profile.\n");
16527 cmdline_parse_inst_t cmd_ddp_del = {
16528 .f = cmd_ddp_del_parsed,
16530 .help_str = "ddp del <port_id> <backup_profile_path>",
16532 (void *)&cmd_ddp_del_ddp,
16533 (void *)&cmd_ddp_del_del,
16534 (void *)&cmd_ddp_del_port_id,
16535 (void *)&cmd_ddp_del_filepath,
16540 /* Get dynamic device personalization profile info */
16541 struct cmd_ddp_info_result {
16542 cmdline_fixed_string_t ddp;
16543 cmdline_fixed_string_t get;
16544 cmdline_fixed_string_t info;
16548 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16549 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16550 cmdline_parse_token_string_t cmd_ddp_info_get =
16551 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16552 cmdline_parse_token_string_t cmd_ddp_info_info =
16553 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16554 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16555 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16558 cmd_ddp_info_parsed(
16559 void *parsed_result,
16560 __rte_unused struct cmdline *cl,
16561 __rte_unused void *data)
16563 struct cmd_ddp_info_result *res = parsed_result;
16566 int ret = -ENOTSUP;
16567 #ifdef RTE_LIBRTE_I40E_PMD
16570 uint32_t buff_size = 0;
16571 struct rte_pmd_i40e_profile_info info;
16572 uint32_t dev_num = 0;
16573 struct rte_pmd_i40e_ddp_device_id *devs;
16574 uint32_t proto_num = 0;
16575 struct rte_pmd_i40e_proto_info *proto = NULL;
16576 uint32_t pctype_num = 0;
16577 struct rte_pmd_i40e_ptype_info *pctype;
16578 uint32_t ptype_num = 0;
16579 struct rte_pmd_i40e_ptype_info *ptype;
16584 pkg = open_file(res->filepath, &pkg_size);
16588 #ifdef RTE_LIBRTE_I40E_PMD
16589 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16590 (uint8_t *)&info, sizeof(info),
16591 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16593 printf("Global Track id: 0x%x\n", info.track_id);
16594 printf("Global Version: %d.%d.%d.%d\n",
16595 info.version.major,
16596 info.version.minor,
16597 info.version.update,
16598 info.version.draft);
16599 printf("Global Package name: %s\n\n", info.name);
16602 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16603 (uint8_t *)&info, sizeof(info),
16604 RTE_PMD_I40E_PKG_INFO_HEADER);
16606 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16607 printf("i40e Profile Version: %d.%d.%d.%d\n",
16608 info.version.major,
16609 info.version.minor,
16610 info.version.update,
16611 info.version.draft);
16612 printf("i40e Profile name: %s\n\n", info.name);
16615 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16616 (uint8_t *)&buff_size, sizeof(buff_size),
16617 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16618 if (!ret && buff_size) {
16619 buff = (uint8_t *)malloc(buff_size);
16621 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16623 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16625 printf("Package Notes:\n%s\n\n", buff);
16630 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16631 (uint8_t *)&dev_num, sizeof(dev_num),
16632 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16633 if (!ret && dev_num) {
16634 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16635 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16637 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16638 (uint8_t *)devs, buff_size,
16639 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16641 printf("List of supported devices:\n");
16642 for (i = 0; i < dev_num; i++) {
16643 printf(" %04X:%04X %04X:%04X\n",
16644 devs[i].vendor_dev_id >> 16,
16645 devs[i].vendor_dev_id & 0xFFFF,
16646 devs[i].sub_vendor_dev_id >> 16,
16647 devs[i].sub_vendor_dev_id & 0xFFFF);
16655 /* get information about protocols and packet types */
16656 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16657 (uint8_t *)&proto_num, sizeof(proto_num),
16658 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16659 if (ret || !proto_num)
16660 goto no_print_return;
16662 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16663 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16665 goto no_print_return;
16667 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16669 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16671 printf("List of used protocols:\n");
16672 for (i = 0; i < proto_num; i++)
16673 printf(" %2u: %s\n", proto[i].proto_id,
16677 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16678 (uint8_t *)&pctype_num, sizeof(pctype_num),
16679 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16680 if (ret || !pctype_num)
16681 goto no_print_pctypes;
16683 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16684 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16686 goto no_print_pctypes;
16688 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16690 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16693 goto no_print_pctypes;
16696 printf("List of defined packet classification types:\n");
16697 for (i = 0; i < pctype_num; i++) {
16698 printf(" %2u:", pctype[i].ptype_id);
16699 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16700 proto_id = pctype[i].protocols[j];
16701 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16702 for (n = 0; n < proto_num; n++) {
16703 if (proto[n].proto_id == proto_id) {
16704 printf(" %s", proto[n].name);
16717 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16719 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16720 if (ret || !ptype_num)
16721 goto no_print_return;
16723 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16724 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16726 goto no_print_return;
16728 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16730 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16733 goto no_print_return;
16735 printf("List of defined packet types:\n");
16736 for (i = 0; i < ptype_num; i++) {
16737 printf(" %2u:", ptype[i].ptype_id);
16738 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16739 proto_id = ptype[i].protocols[j];
16740 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16741 for (n = 0; n < proto_num; n++) {
16742 if (proto[n].proto_id == proto_id) {
16743 printf(" %s", proto[n].name);
16759 if (ret == -ENOTSUP)
16760 printf("Function not supported in PMD driver\n");
16764 cmdline_parse_inst_t cmd_ddp_get_info = {
16765 .f = cmd_ddp_info_parsed,
16767 .help_str = "ddp get info <profile_path>",
16769 (void *)&cmd_ddp_info_ddp,
16770 (void *)&cmd_ddp_info_get,
16771 (void *)&cmd_ddp_info_info,
16772 (void *)&cmd_ddp_info_filepath,
16777 /* Get dynamic device personalization profile info list*/
16778 #define PROFILE_INFO_SIZE 48
16779 #define MAX_PROFILE_NUM 16
16781 struct cmd_ddp_get_list_result {
16782 cmdline_fixed_string_t ddp;
16783 cmdline_fixed_string_t get;
16784 cmdline_fixed_string_t list;
16788 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16789 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16790 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16791 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16792 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16793 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16794 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16795 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16798 cmd_ddp_get_list_parsed(
16799 __rte_unused void *parsed_result,
16800 __rte_unused struct cmdline *cl,
16801 __rte_unused void *data)
16803 #ifdef RTE_LIBRTE_I40E_PMD
16804 struct cmd_ddp_get_list_result *res = parsed_result;
16805 struct rte_pmd_i40e_profile_list *p_list;
16806 struct rte_pmd_i40e_profile_info *p_info;
16811 int ret = -ENOTSUP;
16813 #ifdef RTE_LIBRTE_I40E_PMD
16814 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16815 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16817 printf("%s: Failed to malloc buffer\n", __func__);
16819 if (ret == -ENOTSUP)
16820 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16821 (uint8_t *)p_list, size);
16824 p_num = p_list->p_count;
16825 printf("Profile number is: %d\n\n", p_num);
16827 for (i = 0; i < p_num; i++) {
16828 p_info = &p_list->p_info[i];
16829 printf("Profile %d:\n", i);
16830 printf("Track id: 0x%x\n", p_info->track_id);
16831 printf("Version: %d.%d.%d.%d\n",
16832 p_info->version.major,
16833 p_info->version.minor,
16834 p_info->version.update,
16835 p_info->version.draft);
16836 printf("Profile name: %s\n\n", p_info->name);
16844 printf("Failed to get ddp list\n");
16847 cmdline_parse_inst_t cmd_ddp_get_list = {
16848 .f = cmd_ddp_get_list_parsed,
16850 .help_str = "ddp get list <port_id>",
16852 (void *)&cmd_ddp_get_list_ddp,
16853 (void *)&cmd_ddp_get_list_get,
16854 (void *)&cmd_ddp_get_list_list,
16855 (void *)&cmd_ddp_get_list_port_id,
16860 /* Configure input set */
16861 struct cmd_cfg_input_set_result {
16862 cmdline_fixed_string_t port;
16863 cmdline_fixed_string_t cfg;
16865 cmdline_fixed_string_t pctype;
16867 cmdline_fixed_string_t inset_type;
16868 cmdline_fixed_string_t opt;
16869 cmdline_fixed_string_t field;
16874 cmd_cfg_input_set_parsed(
16875 __rte_unused void *parsed_result,
16876 __rte_unused struct cmdline *cl,
16877 __rte_unused void *data)
16879 #ifdef RTE_LIBRTE_I40E_PMD
16880 struct cmd_cfg_input_set_result *res = parsed_result;
16881 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16882 struct rte_pmd_i40e_inset inset;
16884 int ret = -ENOTSUP;
16886 if (!all_ports_stopped()) {
16887 printf("Please stop all ports first\n");
16891 #ifdef RTE_LIBRTE_I40E_PMD
16892 if (!strcmp(res->inset_type, "hash_inset"))
16893 inset_type = INSET_HASH;
16894 else if (!strcmp(res->inset_type, "fdir_inset"))
16895 inset_type = INSET_FDIR;
16896 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16897 inset_type = INSET_FDIR_FLX;
16898 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16899 &inset, inset_type);
16901 printf("Failed to get input set.\n");
16905 if (!strcmp(res->opt, "get")) {
16906 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16909 printf("Field index %d is enabled.\n", res->field_idx);
16911 printf("Field index %d is disabled.\n", res->field_idx);
16913 } else if (!strcmp(res->opt, "set"))
16914 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16916 else if (!strcmp(res->opt, "clear"))
16917 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16920 printf("Failed to configure input set field.\n");
16924 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16925 &inset, inset_type);
16927 printf("Failed to set input set.\n");
16932 if (ret == -ENOTSUP)
16933 printf("Function not supported\n");
16936 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16937 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16939 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16940 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16942 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16943 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16945 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16946 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16948 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16949 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16951 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16952 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16954 "hash_inset#fdir_inset#fdir_flx_inset");
16955 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16956 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16957 opt, "get#set#clear");
16958 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16959 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16961 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16962 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16965 cmdline_parse_inst_t cmd_cfg_input_set = {
16966 .f = cmd_cfg_input_set_parsed,
16968 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16969 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16971 (void *)&cmd_cfg_input_set_port,
16972 (void *)&cmd_cfg_input_set_cfg,
16973 (void *)&cmd_cfg_input_set_port_id,
16974 (void *)&cmd_cfg_input_set_pctype,
16975 (void *)&cmd_cfg_input_set_pctype_id,
16976 (void *)&cmd_cfg_input_set_inset_type,
16977 (void *)&cmd_cfg_input_set_opt,
16978 (void *)&cmd_cfg_input_set_field,
16979 (void *)&cmd_cfg_input_set_field_idx,
16984 /* Clear input set */
16985 struct cmd_clear_input_set_result {
16986 cmdline_fixed_string_t port;
16987 cmdline_fixed_string_t cfg;
16989 cmdline_fixed_string_t pctype;
16991 cmdline_fixed_string_t inset_type;
16992 cmdline_fixed_string_t clear;
16993 cmdline_fixed_string_t all;
16997 cmd_clear_input_set_parsed(
16998 __rte_unused void *parsed_result,
16999 __rte_unused struct cmdline *cl,
17000 __rte_unused void *data)
17002 #ifdef RTE_LIBRTE_I40E_PMD
17003 struct cmd_clear_input_set_result *res = parsed_result;
17004 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17005 struct rte_pmd_i40e_inset inset;
17007 int ret = -ENOTSUP;
17009 if (!all_ports_stopped()) {
17010 printf("Please stop all ports first\n");
17014 #ifdef RTE_LIBRTE_I40E_PMD
17015 if (!strcmp(res->inset_type, "hash_inset"))
17016 inset_type = INSET_HASH;
17017 else if (!strcmp(res->inset_type, "fdir_inset"))
17018 inset_type = INSET_FDIR;
17019 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17020 inset_type = INSET_FDIR_FLX;
17022 memset(&inset, 0, sizeof(inset));
17024 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17025 &inset, inset_type);
17027 printf("Failed to clear input set.\n");
17033 if (ret == -ENOTSUP)
17034 printf("Function not supported\n");
17037 cmdline_parse_token_string_t cmd_clear_input_set_port =
17038 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17040 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17041 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17043 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17044 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17046 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17047 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17049 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17050 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17052 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17053 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17055 "hash_inset#fdir_inset#fdir_flx_inset");
17056 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17057 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17059 cmdline_parse_token_string_t cmd_clear_input_set_all =
17060 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17063 cmdline_parse_inst_t cmd_clear_input_set = {
17064 .f = cmd_clear_input_set_parsed,
17066 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17067 "fdir_inset|fdir_flx_inset clear all",
17069 (void *)&cmd_clear_input_set_port,
17070 (void *)&cmd_clear_input_set_cfg,
17071 (void *)&cmd_clear_input_set_port_id,
17072 (void *)&cmd_clear_input_set_pctype,
17073 (void *)&cmd_clear_input_set_pctype_id,
17074 (void *)&cmd_clear_input_set_inset_type,
17075 (void *)&cmd_clear_input_set_clear,
17076 (void *)&cmd_clear_input_set_all,
17081 /* show vf stats */
17083 /* Common result structure for show vf stats */
17084 struct cmd_show_vf_stats_result {
17085 cmdline_fixed_string_t show;
17086 cmdline_fixed_string_t vf;
17087 cmdline_fixed_string_t stats;
17092 /* Common CLI fields show vf stats*/
17093 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17094 TOKEN_STRING_INITIALIZER
17095 (struct cmd_show_vf_stats_result,
17097 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17098 TOKEN_STRING_INITIALIZER
17099 (struct cmd_show_vf_stats_result,
17101 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17102 TOKEN_STRING_INITIALIZER
17103 (struct cmd_show_vf_stats_result,
17105 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17106 TOKEN_NUM_INITIALIZER
17107 (struct cmd_show_vf_stats_result,
17109 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17110 TOKEN_NUM_INITIALIZER
17111 (struct cmd_show_vf_stats_result,
17115 cmd_show_vf_stats_parsed(
17116 void *parsed_result,
17117 __rte_unused struct cmdline *cl,
17118 __rte_unused void *data)
17120 struct cmd_show_vf_stats_result *res = parsed_result;
17121 struct rte_eth_stats stats;
17122 int ret = -ENOTSUP;
17123 static const char *nic_stats_border = "########################";
17125 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17128 memset(&stats, 0, sizeof(stats));
17130 #ifdef RTE_LIBRTE_I40E_PMD
17131 if (ret == -ENOTSUP)
17132 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17136 #ifdef RTE_LIBRTE_BNXT_PMD
17137 if (ret == -ENOTSUP)
17138 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17147 printf("invalid vf_id %d\n", res->vf_id);
17150 printf("invalid port_id %d\n", res->port_id);
17153 printf("function not implemented\n");
17156 printf("programming error: (%s)\n", strerror(-ret));
17159 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17160 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17162 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17164 stats.ipackets, stats.imissed, stats.ibytes);
17165 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17166 printf(" RX-nombuf: %-10"PRIu64"\n",
17168 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17170 stats.opackets, stats.oerrors, stats.obytes);
17172 printf(" %s############################%s\n",
17173 nic_stats_border, nic_stats_border);
17176 cmdline_parse_inst_t cmd_show_vf_stats = {
17177 .f = cmd_show_vf_stats_parsed,
17179 .help_str = "show vf stats <port_id> <vf_id>",
17181 (void *)&cmd_show_vf_stats_show,
17182 (void *)&cmd_show_vf_stats_vf,
17183 (void *)&cmd_show_vf_stats_stats,
17184 (void *)&cmd_show_vf_stats_port_id,
17185 (void *)&cmd_show_vf_stats_vf_id,
17190 /* clear vf stats */
17192 /* Common result structure for clear vf stats */
17193 struct cmd_clear_vf_stats_result {
17194 cmdline_fixed_string_t clear;
17195 cmdline_fixed_string_t vf;
17196 cmdline_fixed_string_t stats;
17201 /* Common CLI fields clear vf stats*/
17202 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17203 TOKEN_STRING_INITIALIZER
17204 (struct cmd_clear_vf_stats_result,
17206 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17207 TOKEN_STRING_INITIALIZER
17208 (struct cmd_clear_vf_stats_result,
17210 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17211 TOKEN_STRING_INITIALIZER
17212 (struct cmd_clear_vf_stats_result,
17214 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17215 TOKEN_NUM_INITIALIZER
17216 (struct cmd_clear_vf_stats_result,
17218 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17219 TOKEN_NUM_INITIALIZER
17220 (struct cmd_clear_vf_stats_result,
17224 cmd_clear_vf_stats_parsed(
17225 void *parsed_result,
17226 __rte_unused struct cmdline *cl,
17227 __rte_unused void *data)
17229 struct cmd_clear_vf_stats_result *res = parsed_result;
17230 int ret = -ENOTSUP;
17232 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17235 #ifdef RTE_LIBRTE_I40E_PMD
17236 if (ret == -ENOTSUP)
17237 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17240 #ifdef RTE_LIBRTE_BNXT_PMD
17241 if (ret == -ENOTSUP)
17242 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17250 printf("invalid vf_id %d\n", res->vf_id);
17253 printf("invalid port_id %d\n", res->port_id);
17256 printf("function not implemented\n");
17259 printf("programming error: (%s)\n", strerror(-ret));
17263 cmdline_parse_inst_t cmd_clear_vf_stats = {
17264 .f = cmd_clear_vf_stats_parsed,
17266 .help_str = "clear vf stats <port_id> <vf_id>",
17268 (void *)&cmd_clear_vf_stats_clear,
17269 (void *)&cmd_clear_vf_stats_vf,
17270 (void *)&cmd_clear_vf_stats_stats,
17271 (void *)&cmd_clear_vf_stats_port_id,
17272 (void *)&cmd_clear_vf_stats_vf_id,
17277 /* port config pctype mapping reset */
17279 /* Common result structure for port config pctype mapping reset */
17280 struct cmd_pctype_mapping_reset_result {
17281 cmdline_fixed_string_t port;
17282 cmdline_fixed_string_t config;
17284 cmdline_fixed_string_t pctype;
17285 cmdline_fixed_string_t mapping;
17286 cmdline_fixed_string_t reset;
17289 /* Common CLI fields for port config pctype mapping reset*/
17290 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17291 TOKEN_STRING_INITIALIZER
17292 (struct cmd_pctype_mapping_reset_result,
17294 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17295 TOKEN_STRING_INITIALIZER
17296 (struct cmd_pctype_mapping_reset_result,
17298 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17299 TOKEN_NUM_INITIALIZER
17300 (struct cmd_pctype_mapping_reset_result,
17302 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17303 TOKEN_STRING_INITIALIZER
17304 (struct cmd_pctype_mapping_reset_result,
17306 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17307 TOKEN_STRING_INITIALIZER
17308 (struct cmd_pctype_mapping_reset_result,
17309 mapping, "mapping");
17310 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17311 TOKEN_STRING_INITIALIZER
17312 (struct cmd_pctype_mapping_reset_result,
17316 cmd_pctype_mapping_reset_parsed(
17317 void *parsed_result,
17318 __rte_unused struct cmdline *cl,
17319 __rte_unused void *data)
17321 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17322 int ret = -ENOTSUP;
17324 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17327 #ifdef RTE_LIBRTE_I40E_PMD
17328 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17335 printf("invalid port_id %d\n", res->port_id);
17338 printf("function not implemented\n");
17341 printf("programming error: (%s)\n", strerror(-ret));
17345 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17346 .f = cmd_pctype_mapping_reset_parsed,
17348 .help_str = "port config <port_id> pctype mapping reset",
17350 (void *)&cmd_pctype_mapping_reset_port,
17351 (void *)&cmd_pctype_mapping_reset_config,
17352 (void *)&cmd_pctype_mapping_reset_port_id,
17353 (void *)&cmd_pctype_mapping_reset_pctype,
17354 (void *)&cmd_pctype_mapping_reset_mapping,
17355 (void *)&cmd_pctype_mapping_reset_reset,
17360 /* show port pctype mapping */
17362 /* Common result structure for show port pctype mapping */
17363 struct cmd_pctype_mapping_get_result {
17364 cmdline_fixed_string_t show;
17365 cmdline_fixed_string_t port;
17367 cmdline_fixed_string_t pctype;
17368 cmdline_fixed_string_t mapping;
17371 /* Common CLI fields for pctype mapping get */
17372 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17373 TOKEN_STRING_INITIALIZER
17374 (struct cmd_pctype_mapping_get_result,
17376 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17377 TOKEN_STRING_INITIALIZER
17378 (struct cmd_pctype_mapping_get_result,
17380 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17381 TOKEN_NUM_INITIALIZER
17382 (struct cmd_pctype_mapping_get_result,
17384 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17385 TOKEN_STRING_INITIALIZER
17386 (struct cmd_pctype_mapping_get_result,
17388 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17389 TOKEN_STRING_INITIALIZER
17390 (struct cmd_pctype_mapping_get_result,
17391 mapping, "mapping");
17394 cmd_pctype_mapping_get_parsed(
17395 void *parsed_result,
17396 __rte_unused struct cmdline *cl,
17397 __rte_unused void *data)
17399 struct cmd_pctype_mapping_get_result *res = parsed_result;
17400 int ret = -ENOTSUP;
17401 #ifdef RTE_LIBRTE_I40E_PMD
17402 struct rte_pmd_i40e_flow_type_mapping
17403 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17404 int i, j, first_pctype;
17407 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17410 #ifdef RTE_LIBRTE_I40E_PMD
17411 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17418 printf("invalid port_id %d\n", res->port_id);
17421 printf("function not implemented\n");
17424 printf("programming error: (%s)\n", strerror(-ret));
17428 #ifdef RTE_LIBRTE_I40E_PMD
17429 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17430 if (mapping[i].pctype != 0ULL) {
17433 printf("pctype: ");
17434 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17435 if (mapping[i].pctype & (1ULL << j)) {
17436 printf(first_pctype ?
17437 "%02d" : ",%02d", j);
17441 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17447 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17448 .f = cmd_pctype_mapping_get_parsed,
17450 .help_str = "show port <port_id> pctype mapping",
17452 (void *)&cmd_pctype_mapping_get_show,
17453 (void *)&cmd_pctype_mapping_get_port,
17454 (void *)&cmd_pctype_mapping_get_port_id,
17455 (void *)&cmd_pctype_mapping_get_pctype,
17456 (void *)&cmd_pctype_mapping_get_mapping,
17461 /* port config pctype mapping update */
17463 /* Common result structure for port config pctype mapping update */
17464 struct cmd_pctype_mapping_update_result {
17465 cmdline_fixed_string_t port;
17466 cmdline_fixed_string_t config;
17468 cmdline_fixed_string_t pctype;
17469 cmdline_fixed_string_t mapping;
17470 cmdline_fixed_string_t update;
17471 cmdline_fixed_string_t pctype_list;
17472 uint16_t flow_type;
17475 /* Common CLI fields for pctype mapping update*/
17476 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17477 TOKEN_STRING_INITIALIZER
17478 (struct cmd_pctype_mapping_update_result,
17480 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17481 TOKEN_STRING_INITIALIZER
17482 (struct cmd_pctype_mapping_update_result,
17484 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17485 TOKEN_NUM_INITIALIZER
17486 (struct cmd_pctype_mapping_update_result,
17488 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17489 TOKEN_STRING_INITIALIZER
17490 (struct cmd_pctype_mapping_update_result,
17492 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17493 TOKEN_STRING_INITIALIZER
17494 (struct cmd_pctype_mapping_update_result,
17495 mapping, "mapping");
17496 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17497 TOKEN_STRING_INITIALIZER
17498 (struct cmd_pctype_mapping_update_result,
17500 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17501 TOKEN_STRING_INITIALIZER
17502 (struct cmd_pctype_mapping_update_result,
17503 pctype_list, NULL);
17504 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17505 TOKEN_NUM_INITIALIZER
17506 (struct cmd_pctype_mapping_update_result,
17507 flow_type, UINT16);
17510 cmd_pctype_mapping_update_parsed(
17511 void *parsed_result,
17512 __rte_unused struct cmdline *cl,
17513 __rte_unused void *data)
17515 struct cmd_pctype_mapping_update_result *res = parsed_result;
17516 int ret = -ENOTSUP;
17517 #ifdef RTE_LIBRTE_I40E_PMD
17518 struct rte_pmd_i40e_flow_type_mapping mapping;
17520 unsigned int nb_item;
17521 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17524 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17527 #ifdef RTE_LIBRTE_I40E_PMD
17528 nb_item = parse_item_list(res->pctype_list, "pctypes",
17529 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17530 mapping.flow_type = res->flow_type;
17531 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17532 mapping.pctype |= (1ULL << pctype_list[i]);
17533 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17543 printf("invalid pctype or flow type\n");
17546 printf("invalid port_id %d\n", res->port_id);
17549 printf("function not implemented\n");
17552 printf("programming error: (%s)\n", strerror(-ret));
17556 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17557 .f = cmd_pctype_mapping_update_parsed,
17559 .help_str = "port config <port_id> pctype mapping update"
17560 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17562 (void *)&cmd_pctype_mapping_update_port,
17563 (void *)&cmd_pctype_mapping_update_config,
17564 (void *)&cmd_pctype_mapping_update_port_id,
17565 (void *)&cmd_pctype_mapping_update_pctype,
17566 (void *)&cmd_pctype_mapping_update_mapping,
17567 (void *)&cmd_pctype_mapping_update_update,
17568 (void *)&cmd_pctype_mapping_update_pc_type,
17569 (void *)&cmd_pctype_mapping_update_flow_type,
17574 /* ptype mapping get */
17576 /* Common result structure for ptype mapping get */
17577 struct cmd_ptype_mapping_get_result {
17578 cmdline_fixed_string_t ptype;
17579 cmdline_fixed_string_t mapping;
17580 cmdline_fixed_string_t get;
17582 uint8_t valid_only;
17585 /* Common CLI fields for ptype mapping get */
17586 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17587 TOKEN_STRING_INITIALIZER
17588 (struct cmd_ptype_mapping_get_result,
17590 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17591 TOKEN_STRING_INITIALIZER
17592 (struct cmd_ptype_mapping_get_result,
17593 mapping, "mapping");
17594 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17595 TOKEN_STRING_INITIALIZER
17596 (struct cmd_ptype_mapping_get_result,
17598 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17599 TOKEN_NUM_INITIALIZER
17600 (struct cmd_ptype_mapping_get_result,
17602 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17603 TOKEN_NUM_INITIALIZER
17604 (struct cmd_ptype_mapping_get_result,
17605 valid_only, UINT8);
17608 cmd_ptype_mapping_get_parsed(
17609 void *parsed_result,
17610 __rte_unused struct cmdline *cl,
17611 __rte_unused void *data)
17613 struct cmd_ptype_mapping_get_result *res = parsed_result;
17614 int ret = -ENOTSUP;
17615 #ifdef RTE_LIBRTE_I40E_PMD
17616 int max_ptype_num = 256;
17617 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17622 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17625 #ifdef RTE_LIBRTE_I40E_PMD
17626 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17637 printf("invalid port_id %d\n", res->port_id);
17640 printf("function not implemented\n");
17643 printf("programming error: (%s)\n", strerror(-ret));
17646 #ifdef RTE_LIBRTE_I40E_PMD
17648 for (i = 0; i < count; i++)
17649 printf("%3d\t0x%08x\n",
17650 mapping[i].hw_ptype, mapping[i].sw_ptype);
17655 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17656 .f = cmd_ptype_mapping_get_parsed,
17658 .help_str = "ptype mapping get <port_id> <valid_only>",
17660 (void *)&cmd_ptype_mapping_get_ptype,
17661 (void *)&cmd_ptype_mapping_get_mapping,
17662 (void *)&cmd_ptype_mapping_get_get,
17663 (void *)&cmd_ptype_mapping_get_port_id,
17664 (void *)&cmd_ptype_mapping_get_valid_only,
17669 /* ptype mapping replace */
17671 /* Common result structure for ptype mapping replace */
17672 struct cmd_ptype_mapping_replace_result {
17673 cmdline_fixed_string_t ptype;
17674 cmdline_fixed_string_t mapping;
17675 cmdline_fixed_string_t replace;
17682 /* Common CLI fields for ptype mapping replace */
17683 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17684 TOKEN_STRING_INITIALIZER
17685 (struct cmd_ptype_mapping_replace_result,
17687 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17688 TOKEN_STRING_INITIALIZER
17689 (struct cmd_ptype_mapping_replace_result,
17690 mapping, "mapping");
17691 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17692 TOKEN_STRING_INITIALIZER
17693 (struct cmd_ptype_mapping_replace_result,
17694 replace, "replace");
17695 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17696 TOKEN_NUM_INITIALIZER
17697 (struct cmd_ptype_mapping_replace_result,
17699 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17700 TOKEN_NUM_INITIALIZER
17701 (struct cmd_ptype_mapping_replace_result,
17703 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17704 TOKEN_NUM_INITIALIZER
17705 (struct cmd_ptype_mapping_replace_result,
17707 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17708 TOKEN_NUM_INITIALIZER
17709 (struct cmd_ptype_mapping_replace_result,
17713 cmd_ptype_mapping_replace_parsed(
17714 void *parsed_result,
17715 __rte_unused struct cmdline *cl,
17716 __rte_unused void *data)
17718 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17719 int ret = -ENOTSUP;
17721 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17724 #ifdef RTE_LIBRTE_I40E_PMD
17725 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17735 printf("invalid ptype 0x%8x or 0x%8x\n",
17736 res->target, res->pkt_type);
17739 printf("invalid port_id %d\n", res->port_id);
17742 printf("function not implemented\n");
17745 printf("programming error: (%s)\n", strerror(-ret));
17749 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17750 .f = cmd_ptype_mapping_replace_parsed,
17753 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17755 (void *)&cmd_ptype_mapping_replace_ptype,
17756 (void *)&cmd_ptype_mapping_replace_mapping,
17757 (void *)&cmd_ptype_mapping_replace_replace,
17758 (void *)&cmd_ptype_mapping_replace_port_id,
17759 (void *)&cmd_ptype_mapping_replace_target,
17760 (void *)&cmd_ptype_mapping_replace_mask,
17761 (void *)&cmd_ptype_mapping_replace_pkt_type,
17766 /* ptype mapping reset */
17768 /* Common result structure for ptype mapping reset */
17769 struct cmd_ptype_mapping_reset_result {
17770 cmdline_fixed_string_t ptype;
17771 cmdline_fixed_string_t mapping;
17772 cmdline_fixed_string_t reset;
17776 /* Common CLI fields for ptype mapping reset*/
17777 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17778 TOKEN_STRING_INITIALIZER
17779 (struct cmd_ptype_mapping_reset_result,
17781 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17782 TOKEN_STRING_INITIALIZER
17783 (struct cmd_ptype_mapping_reset_result,
17784 mapping, "mapping");
17785 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17786 TOKEN_STRING_INITIALIZER
17787 (struct cmd_ptype_mapping_reset_result,
17789 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17790 TOKEN_NUM_INITIALIZER
17791 (struct cmd_ptype_mapping_reset_result,
17795 cmd_ptype_mapping_reset_parsed(
17796 void *parsed_result,
17797 __rte_unused struct cmdline *cl,
17798 __rte_unused void *data)
17800 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17801 int ret = -ENOTSUP;
17803 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17806 #ifdef RTE_LIBRTE_I40E_PMD
17807 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17814 printf("invalid port_id %d\n", res->port_id);
17817 printf("function not implemented\n");
17820 printf("programming error: (%s)\n", strerror(-ret));
17824 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17825 .f = cmd_ptype_mapping_reset_parsed,
17827 .help_str = "ptype mapping reset <port_id>",
17829 (void *)&cmd_ptype_mapping_reset_ptype,
17830 (void *)&cmd_ptype_mapping_reset_mapping,
17831 (void *)&cmd_ptype_mapping_reset_reset,
17832 (void *)&cmd_ptype_mapping_reset_port_id,
17837 /* ptype mapping update */
17839 /* Common result structure for ptype mapping update */
17840 struct cmd_ptype_mapping_update_result {
17841 cmdline_fixed_string_t ptype;
17842 cmdline_fixed_string_t mapping;
17843 cmdline_fixed_string_t reset;
17849 /* Common CLI fields for ptype mapping update*/
17850 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17851 TOKEN_STRING_INITIALIZER
17852 (struct cmd_ptype_mapping_update_result,
17854 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17855 TOKEN_STRING_INITIALIZER
17856 (struct cmd_ptype_mapping_update_result,
17857 mapping, "mapping");
17858 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17859 TOKEN_STRING_INITIALIZER
17860 (struct cmd_ptype_mapping_update_result,
17862 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17863 TOKEN_NUM_INITIALIZER
17864 (struct cmd_ptype_mapping_update_result,
17866 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17867 TOKEN_NUM_INITIALIZER
17868 (struct cmd_ptype_mapping_update_result,
17870 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17871 TOKEN_NUM_INITIALIZER
17872 (struct cmd_ptype_mapping_update_result,
17876 cmd_ptype_mapping_update_parsed(
17877 void *parsed_result,
17878 __rte_unused struct cmdline *cl,
17879 __rte_unused void *data)
17881 struct cmd_ptype_mapping_update_result *res = parsed_result;
17882 int ret = -ENOTSUP;
17883 #ifdef RTE_LIBRTE_I40E_PMD
17884 struct rte_pmd_i40e_ptype_mapping mapping;
17886 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17889 #ifdef RTE_LIBRTE_I40E_PMD
17890 mapping.hw_ptype = res->hw_ptype;
17891 mapping.sw_ptype = res->sw_ptype;
17892 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17902 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17905 printf("invalid port_id %d\n", res->port_id);
17908 printf("function not implemented\n");
17911 printf("programming error: (%s)\n", strerror(-ret));
17915 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17916 .f = cmd_ptype_mapping_update_parsed,
17918 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17920 (void *)&cmd_ptype_mapping_update_ptype,
17921 (void *)&cmd_ptype_mapping_update_mapping,
17922 (void *)&cmd_ptype_mapping_update_update,
17923 (void *)&cmd_ptype_mapping_update_port_id,
17924 (void *)&cmd_ptype_mapping_update_hw_ptype,
17925 (void *)&cmd_ptype_mapping_update_sw_ptype,
17930 /* Common result structure for file commands */
17931 struct cmd_cmdfile_result {
17932 cmdline_fixed_string_t load;
17933 cmdline_fixed_string_t filename;
17936 /* Common CLI fields for file commands */
17937 cmdline_parse_token_string_t cmd_load_cmdfile =
17938 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17939 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17940 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17943 cmd_load_from_file_parsed(
17944 void *parsed_result,
17945 __rte_unused struct cmdline *cl,
17946 __rte_unused void *data)
17948 struct cmd_cmdfile_result *res = parsed_result;
17950 cmdline_read_from_file(res->filename);
17953 cmdline_parse_inst_t cmd_load_from_file = {
17954 .f = cmd_load_from_file_parsed,
17956 .help_str = "load <filename>",
17958 (void *)&cmd_load_cmdfile,
17959 (void *)&cmd_load_cmdfile_filename,
17964 /* Get Rx offloads capabilities */
17965 struct cmd_rx_offload_get_capa_result {
17966 cmdline_fixed_string_t show;
17967 cmdline_fixed_string_t port;
17969 cmdline_fixed_string_t rx_offload;
17970 cmdline_fixed_string_t capabilities;
17973 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17974 TOKEN_STRING_INITIALIZER
17975 (struct cmd_rx_offload_get_capa_result,
17977 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17978 TOKEN_STRING_INITIALIZER
17979 (struct cmd_rx_offload_get_capa_result,
17981 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17982 TOKEN_NUM_INITIALIZER
17983 (struct cmd_rx_offload_get_capa_result,
17985 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17986 TOKEN_STRING_INITIALIZER
17987 (struct cmd_rx_offload_get_capa_result,
17988 rx_offload, "rx_offload");
17989 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17990 TOKEN_STRING_INITIALIZER
17991 (struct cmd_rx_offload_get_capa_result,
17992 capabilities, "capabilities");
17995 print_rx_offloads(uint64_t offloads)
17997 uint64_t single_offload;
18005 begin = __builtin_ctzll(offloads);
18006 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18008 single_offload = 1ULL << begin;
18009 for (bit = begin; bit < end; bit++) {
18010 if (offloads & single_offload)
18012 rte_eth_dev_rx_offload_name(single_offload));
18013 single_offload <<= 1;
18018 cmd_rx_offload_get_capa_parsed(
18019 void *parsed_result,
18020 __rte_unused struct cmdline *cl,
18021 __rte_unused void *data)
18023 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18024 struct rte_eth_dev_info dev_info;
18025 portid_t port_id = res->port_id;
18026 uint64_t queue_offloads;
18027 uint64_t port_offloads;
18030 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18034 queue_offloads = dev_info.rx_queue_offload_capa;
18035 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18037 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18038 printf(" Per Queue :");
18039 print_rx_offloads(queue_offloads);
18042 printf(" Per Port :");
18043 print_rx_offloads(port_offloads);
18047 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18048 .f = cmd_rx_offload_get_capa_parsed,
18050 .help_str = "show port <port_id> rx_offload capabilities",
18052 (void *)&cmd_rx_offload_get_capa_show,
18053 (void *)&cmd_rx_offload_get_capa_port,
18054 (void *)&cmd_rx_offload_get_capa_port_id,
18055 (void *)&cmd_rx_offload_get_capa_rx_offload,
18056 (void *)&cmd_rx_offload_get_capa_capabilities,
18061 /* Get Rx offloads configuration */
18062 struct cmd_rx_offload_get_configuration_result {
18063 cmdline_fixed_string_t show;
18064 cmdline_fixed_string_t port;
18066 cmdline_fixed_string_t rx_offload;
18067 cmdline_fixed_string_t configuration;
18070 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18071 TOKEN_STRING_INITIALIZER
18072 (struct cmd_rx_offload_get_configuration_result,
18074 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18075 TOKEN_STRING_INITIALIZER
18076 (struct cmd_rx_offload_get_configuration_result,
18078 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18079 TOKEN_NUM_INITIALIZER
18080 (struct cmd_rx_offload_get_configuration_result,
18082 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18083 TOKEN_STRING_INITIALIZER
18084 (struct cmd_rx_offload_get_configuration_result,
18085 rx_offload, "rx_offload");
18086 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18087 TOKEN_STRING_INITIALIZER
18088 (struct cmd_rx_offload_get_configuration_result,
18089 configuration, "configuration");
18092 cmd_rx_offload_get_configuration_parsed(
18093 void *parsed_result,
18094 __rte_unused struct cmdline *cl,
18095 __rte_unused void *data)
18097 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18098 struct rte_eth_dev_info dev_info;
18099 portid_t port_id = res->port_id;
18100 struct rte_port *port = &ports[port_id];
18101 uint64_t port_offloads;
18102 uint64_t queue_offloads;
18103 uint16_t nb_rx_queues;
18107 printf("Rx Offloading Configuration of port %d :\n", port_id);
18109 port_offloads = port->dev_conf.rxmode.offloads;
18111 print_rx_offloads(port_offloads);
18114 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18118 nb_rx_queues = dev_info.nb_rx_queues;
18119 for (q = 0; q < nb_rx_queues; q++) {
18120 queue_offloads = port->rx_conf[q].offloads;
18121 printf(" Queue[%2d] :", q);
18122 print_rx_offloads(queue_offloads);
18128 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18129 .f = cmd_rx_offload_get_configuration_parsed,
18131 .help_str = "show port <port_id> rx_offload configuration",
18133 (void *)&cmd_rx_offload_get_configuration_show,
18134 (void *)&cmd_rx_offload_get_configuration_port,
18135 (void *)&cmd_rx_offload_get_configuration_port_id,
18136 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18137 (void *)&cmd_rx_offload_get_configuration_configuration,
18142 /* Enable/Disable a per port offloading */
18143 struct cmd_config_per_port_rx_offload_result {
18144 cmdline_fixed_string_t port;
18145 cmdline_fixed_string_t config;
18147 cmdline_fixed_string_t rx_offload;
18148 cmdline_fixed_string_t offload;
18149 cmdline_fixed_string_t on_off;
18152 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18153 TOKEN_STRING_INITIALIZER
18154 (struct cmd_config_per_port_rx_offload_result,
18156 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18157 TOKEN_STRING_INITIALIZER
18158 (struct cmd_config_per_port_rx_offload_result,
18160 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18161 TOKEN_NUM_INITIALIZER
18162 (struct cmd_config_per_port_rx_offload_result,
18164 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18165 TOKEN_STRING_INITIALIZER
18166 (struct cmd_config_per_port_rx_offload_result,
18167 rx_offload, "rx_offload");
18168 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18169 TOKEN_STRING_INITIALIZER
18170 (struct cmd_config_per_port_rx_offload_result,
18171 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18172 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18173 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18174 "scatter#timestamp#security#keep_crc#rss_hash");
18175 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18176 TOKEN_STRING_INITIALIZER
18177 (struct cmd_config_per_port_rx_offload_result,
18181 search_rx_offload(const char *name)
18183 uint64_t single_offload;
18184 const char *single_name;
18188 single_offload = 1;
18189 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18190 single_name = rte_eth_dev_rx_offload_name(single_offload);
18191 if (!strcasecmp(single_name, name)) {
18195 single_offload <<= 1;
18199 return single_offload;
18205 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18206 __rte_unused struct cmdline *cl,
18207 __rte_unused void *data)
18209 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18210 portid_t port_id = res->port_id;
18211 struct rte_eth_dev_info dev_info;
18212 struct rte_port *port = &ports[port_id];
18213 uint64_t single_offload;
18214 uint16_t nb_rx_queues;
18218 if (port->port_status != RTE_PORT_STOPPED) {
18219 printf("Error: Can't config offload when Port %d "
18220 "is not stopped\n", port_id);
18224 single_offload = search_rx_offload(res->offload);
18225 if (single_offload == 0) {
18226 printf("Unknown offload name: %s\n", res->offload);
18230 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18234 nb_rx_queues = dev_info.nb_rx_queues;
18235 if (!strcmp(res->on_off, "on")) {
18236 port->dev_conf.rxmode.offloads |= single_offload;
18237 for (q = 0; q < nb_rx_queues; q++)
18238 port->rx_conf[q].offloads |= single_offload;
18240 port->dev_conf.rxmode.offloads &= ~single_offload;
18241 for (q = 0; q < nb_rx_queues; q++)
18242 port->rx_conf[q].offloads &= ~single_offload;
18245 cmd_reconfig_device_queue(port_id, 1, 1);
18248 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18249 .f = cmd_config_per_port_rx_offload_parsed,
18251 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18252 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18253 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18254 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18257 (void *)&cmd_config_per_port_rx_offload_result_port,
18258 (void *)&cmd_config_per_port_rx_offload_result_config,
18259 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18260 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18261 (void *)&cmd_config_per_port_rx_offload_result_offload,
18262 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18267 /* Enable/Disable a per queue offloading */
18268 struct cmd_config_per_queue_rx_offload_result {
18269 cmdline_fixed_string_t port;
18271 cmdline_fixed_string_t rxq;
18273 cmdline_fixed_string_t rx_offload;
18274 cmdline_fixed_string_t offload;
18275 cmdline_fixed_string_t on_off;
18278 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18279 TOKEN_STRING_INITIALIZER
18280 (struct cmd_config_per_queue_rx_offload_result,
18282 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18283 TOKEN_NUM_INITIALIZER
18284 (struct cmd_config_per_queue_rx_offload_result,
18286 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18287 TOKEN_STRING_INITIALIZER
18288 (struct cmd_config_per_queue_rx_offload_result,
18290 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18291 TOKEN_NUM_INITIALIZER
18292 (struct cmd_config_per_queue_rx_offload_result,
18294 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18295 TOKEN_STRING_INITIALIZER
18296 (struct cmd_config_per_queue_rx_offload_result,
18297 rx_offload, "rx_offload");
18298 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18299 TOKEN_STRING_INITIALIZER
18300 (struct cmd_config_per_queue_rx_offload_result,
18301 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18302 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18303 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18304 "scatter#timestamp#security#keep_crc");
18305 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18306 TOKEN_STRING_INITIALIZER
18307 (struct cmd_config_per_queue_rx_offload_result,
18311 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18312 __rte_unused struct cmdline *cl,
18313 __rte_unused void *data)
18315 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18316 struct rte_eth_dev_info dev_info;
18317 portid_t port_id = res->port_id;
18318 uint16_t queue_id = res->queue_id;
18319 struct rte_port *port = &ports[port_id];
18320 uint64_t single_offload;
18323 if (port->port_status != RTE_PORT_STOPPED) {
18324 printf("Error: Can't config offload when Port %d "
18325 "is not stopped\n", port_id);
18329 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18333 if (queue_id >= dev_info.nb_rx_queues) {
18334 printf("Error: input queue_id should be 0 ... "
18335 "%d\n", dev_info.nb_rx_queues - 1);
18339 single_offload = search_rx_offload(res->offload);
18340 if (single_offload == 0) {
18341 printf("Unknown offload name: %s\n", res->offload);
18345 if (!strcmp(res->on_off, "on"))
18346 port->rx_conf[queue_id].offloads |= single_offload;
18348 port->rx_conf[queue_id].offloads &= ~single_offload;
18350 cmd_reconfig_device_queue(port_id, 1, 1);
18353 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18354 .f = cmd_config_per_queue_rx_offload_parsed,
18356 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18357 "vlan_strip|ipv4_cksum|"
18358 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18359 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18360 "jumbo_frame|scatter|timestamp|security|keep_crc "
18363 (void *)&cmd_config_per_queue_rx_offload_result_port,
18364 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18365 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18366 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18367 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18368 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18369 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18374 /* Get Tx offloads capabilities */
18375 struct cmd_tx_offload_get_capa_result {
18376 cmdline_fixed_string_t show;
18377 cmdline_fixed_string_t port;
18379 cmdline_fixed_string_t tx_offload;
18380 cmdline_fixed_string_t capabilities;
18383 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18384 TOKEN_STRING_INITIALIZER
18385 (struct cmd_tx_offload_get_capa_result,
18387 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18388 TOKEN_STRING_INITIALIZER
18389 (struct cmd_tx_offload_get_capa_result,
18391 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18392 TOKEN_NUM_INITIALIZER
18393 (struct cmd_tx_offload_get_capa_result,
18395 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18396 TOKEN_STRING_INITIALIZER
18397 (struct cmd_tx_offload_get_capa_result,
18398 tx_offload, "tx_offload");
18399 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18400 TOKEN_STRING_INITIALIZER
18401 (struct cmd_tx_offload_get_capa_result,
18402 capabilities, "capabilities");
18405 print_tx_offloads(uint64_t offloads)
18407 uint64_t single_offload;
18415 begin = __builtin_ctzll(offloads);
18416 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18418 single_offload = 1ULL << begin;
18419 for (bit = begin; bit < end; bit++) {
18420 if (offloads & single_offload)
18422 rte_eth_dev_tx_offload_name(single_offload));
18423 single_offload <<= 1;
18428 cmd_tx_offload_get_capa_parsed(
18429 void *parsed_result,
18430 __rte_unused struct cmdline *cl,
18431 __rte_unused void *data)
18433 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18434 struct rte_eth_dev_info dev_info;
18435 portid_t port_id = res->port_id;
18436 uint64_t queue_offloads;
18437 uint64_t port_offloads;
18440 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18444 queue_offloads = dev_info.tx_queue_offload_capa;
18445 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18447 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18448 printf(" Per Queue :");
18449 print_tx_offloads(queue_offloads);
18452 printf(" Per Port :");
18453 print_tx_offloads(port_offloads);
18457 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18458 .f = cmd_tx_offload_get_capa_parsed,
18460 .help_str = "show port <port_id> tx_offload capabilities",
18462 (void *)&cmd_tx_offload_get_capa_show,
18463 (void *)&cmd_tx_offload_get_capa_port,
18464 (void *)&cmd_tx_offload_get_capa_port_id,
18465 (void *)&cmd_tx_offload_get_capa_tx_offload,
18466 (void *)&cmd_tx_offload_get_capa_capabilities,
18471 /* Get Tx offloads configuration */
18472 struct cmd_tx_offload_get_configuration_result {
18473 cmdline_fixed_string_t show;
18474 cmdline_fixed_string_t port;
18476 cmdline_fixed_string_t tx_offload;
18477 cmdline_fixed_string_t configuration;
18480 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18481 TOKEN_STRING_INITIALIZER
18482 (struct cmd_tx_offload_get_configuration_result,
18484 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18485 TOKEN_STRING_INITIALIZER
18486 (struct cmd_tx_offload_get_configuration_result,
18488 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18489 TOKEN_NUM_INITIALIZER
18490 (struct cmd_tx_offload_get_configuration_result,
18492 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18493 TOKEN_STRING_INITIALIZER
18494 (struct cmd_tx_offload_get_configuration_result,
18495 tx_offload, "tx_offload");
18496 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18497 TOKEN_STRING_INITIALIZER
18498 (struct cmd_tx_offload_get_configuration_result,
18499 configuration, "configuration");
18502 cmd_tx_offload_get_configuration_parsed(
18503 void *parsed_result,
18504 __rte_unused struct cmdline *cl,
18505 __rte_unused void *data)
18507 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18508 struct rte_eth_dev_info dev_info;
18509 portid_t port_id = res->port_id;
18510 struct rte_port *port = &ports[port_id];
18511 uint64_t port_offloads;
18512 uint64_t queue_offloads;
18513 uint16_t nb_tx_queues;
18517 printf("Tx Offloading Configuration of port %d :\n", port_id);
18519 port_offloads = port->dev_conf.txmode.offloads;
18521 print_tx_offloads(port_offloads);
18524 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18528 nb_tx_queues = dev_info.nb_tx_queues;
18529 for (q = 0; q < nb_tx_queues; q++) {
18530 queue_offloads = port->tx_conf[q].offloads;
18531 printf(" Queue[%2d] :", q);
18532 print_tx_offloads(queue_offloads);
18538 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18539 .f = cmd_tx_offload_get_configuration_parsed,
18541 .help_str = "show port <port_id> tx_offload configuration",
18543 (void *)&cmd_tx_offload_get_configuration_show,
18544 (void *)&cmd_tx_offload_get_configuration_port,
18545 (void *)&cmd_tx_offload_get_configuration_port_id,
18546 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18547 (void *)&cmd_tx_offload_get_configuration_configuration,
18552 /* Enable/Disable a per port offloading */
18553 struct cmd_config_per_port_tx_offload_result {
18554 cmdline_fixed_string_t port;
18555 cmdline_fixed_string_t config;
18557 cmdline_fixed_string_t tx_offload;
18558 cmdline_fixed_string_t offload;
18559 cmdline_fixed_string_t on_off;
18562 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18563 TOKEN_STRING_INITIALIZER
18564 (struct cmd_config_per_port_tx_offload_result,
18566 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18567 TOKEN_STRING_INITIALIZER
18568 (struct cmd_config_per_port_tx_offload_result,
18570 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18571 TOKEN_NUM_INITIALIZER
18572 (struct cmd_config_per_port_tx_offload_result,
18574 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18575 TOKEN_STRING_INITIALIZER
18576 (struct cmd_config_per_port_tx_offload_result,
18577 tx_offload, "tx_offload");
18578 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18579 TOKEN_STRING_INITIALIZER
18580 (struct cmd_config_per_port_tx_offload_result,
18581 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18582 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18583 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18584 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18585 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18586 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18587 TOKEN_STRING_INITIALIZER
18588 (struct cmd_config_per_port_tx_offload_result,
18592 search_tx_offload(const char *name)
18594 uint64_t single_offload;
18595 const char *single_name;
18599 single_offload = 1;
18600 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18601 single_name = rte_eth_dev_tx_offload_name(single_offload);
18602 if (single_name == NULL)
18604 if (!strcasecmp(single_name, name)) {
18607 } else if (!strcasecmp(single_name, "UNKNOWN"))
18609 single_offload <<= 1;
18613 return single_offload;
18619 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18620 __rte_unused struct cmdline *cl,
18621 __rte_unused void *data)
18623 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18624 portid_t port_id = res->port_id;
18625 struct rte_eth_dev_info dev_info;
18626 struct rte_port *port = &ports[port_id];
18627 uint64_t single_offload;
18628 uint16_t nb_tx_queues;
18632 if (port->port_status != RTE_PORT_STOPPED) {
18633 printf("Error: Can't config offload when Port %d "
18634 "is not stopped\n", port_id);
18638 single_offload = search_tx_offload(res->offload);
18639 if (single_offload == 0) {
18640 printf("Unknown offload name: %s\n", res->offload);
18644 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18648 nb_tx_queues = dev_info.nb_tx_queues;
18649 if (!strcmp(res->on_off, "on")) {
18650 port->dev_conf.txmode.offloads |= single_offload;
18651 for (q = 0; q < nb_tx_queues; q++)
18652 port->tx_conf[q].offloads |= single_offload;
18654 port->dev_conf.txmode.offloads &= ~single_offload;
18655 for (q = 0; q < nb_tx_queues; q++)
18656 port->tx_conf[q].offloads &= ~single_offload;
18659 cmd_reconfig_device_queue(port_id, 1, 1);
18662 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18663 .f = cmd_config_per_port_tx_offload_parsed,
18665 .help_str = "port config <port_id> tx_offload "
18666 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18667 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18668 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18669 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18670 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18672 (void *)&cmd_config_per_port_tx_offload_result_port,
18673 (void *)&cmd_config_per_port_tx_offload_result_config,
18674 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18675 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18676 (void *)&cmd_config_per_port_tx_offload_result_offload,
18677 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18682 /* Enable/Disable a per queue offloading */
18683 struct cmd_config_per_queue_tx_offload_result {
18684 cmdline_fixed_string_t port;
18686 cmdline_fixed_string_t txq;
18688 cmdline_fixed_string_t tx_offload;
18689 cmdline_fixed_string_t offload;
18690 cmdline_fixed_string_t on_off;
18693 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18694 TOKEN_STRING_INITIALIZER
18695 (struct cmd_config_per_queue_tx_offload_result,
18697 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18698 TOKEN_NUM_INITIALIZER
18699 (struct cmd_config_per_queue_tx_offload_result,
18701 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18702 TOKEN_STRING_INITIALIZER
18703 (struct cmd_config_per_queue_tx_offload_result,
18705 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18706 TOKEN_NUM_INITIALIZER
18707 (struct cmd_config_per_queue_tx_offload_result,
18709 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18710 TOKEN_STRING_INITIALIZER
18711 (struct cmd_config_per_queue_tx_offload_result,
18712 tx_offload, "tx_offload");
18713 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18714 TOKEN_STRING_INITIALIZER
18715 (struct cmd_config_per_queue_tx_offload_result,
18716 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18717 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18718 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18719 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18720 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18721 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18722 TOKEN_STRING_INITIALIZER
18723 (struct cmd_config_per_queue_tx_offload_result,
18727 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18728 __rte_unused struct cmdline *cl,
18729 __rte_unused void *data)
18731 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18732 struct rte_eth_dev_info dev_info;
18733 portid_t port_id = res->port_id;
18734 uint16_t queue_id = res->queue_id;
18735 struct rte_port *port = &ports[port_id];
18736 uint64_t single_offload;
18739 if (port->port_status != RTE_PORT_STOPPED) {
18740 printf("Error: Can't config offload when Port %d "
18741 "is not stopped\n", port_id);
18745 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18749 if (queue_id >= dev_info.nb_tx_queues) {
18750 printf("Error: input queue_id should be 0 ... "
18751 "%d\n", dev_info.nb_tx_queues - 1);
18755 single_offload = search_tx_offload(res->offload);
18756 if (single_offload == 0) {
18757 printf("Unknown offload name: %s\n", res->offload);
18761 if (!strcmp(res->on_off, "on"))
18762 port->tx_conf[queue_id].offloads |= single_offload;
18764 port->tx_conf[queue_id].offloads &= ~single_offload;
18766 cmd_reconfig_device_queue(port_id, 1, 1);
18769 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18770 .f = cmd_config_per_queue_tx_offload_parsed,
18772 .help_str = "port <port_id> txq <queue_id> tx_offload "
18773 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18774 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18775 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18776 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18777 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18780 (void *)&cmd_config_per_queue_tx_offload_result_port,
18781 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18782 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18783 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18784 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18785 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18786 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18791 /* *** configure tx_metadata for specific port *** */
18792 struct cmd_config_tx_metadata_specific_result {
18793 cmdline_fixed_string_t port;
18794 cmdline_fixed_string_t keyword;
18796 cmdline_fixed_string_t item;
18801 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18802 __rte_unused struct cmdline *cl,
18803 __rte_unused void *data)
18805 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18807 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18809 ports[res->port_id].tx_metadata = res->value;
18810 /* Add/remove callback to insert valid metadata in every Tx packet. */
18811 if (ports[res->port_id].tx_metadata)
18812 add_tx_md_callback(res->port_id);
18814 remove_tx_md_callback(res->port_id);
18815 rte_flow_dynf_metadata_register();
18818 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18819 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18821 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18822 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18823 keyword, "config");
18824 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18825 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18827 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18828 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18829 item, "tx_metadata");
18830 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18831 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18834 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18835 .f = cmd_config_tx_metadata_specific_parsed,
18837 .help_str = "port config <port_id> tx_metadata <value>",
18839 (void *)&cmd_config_tx_metadata_specific_port,
18840 (void *)&cmd_config_tx_metadata_specific_keyword,
18841 (void *)&cmd_config_tx_metadata_specific_id,
18842 (void *)&cmd_config_tx_metadata_specific_item,
18843 (void *)&cmd_config_tx_metadata_specific_value,
18848 /* *** set dynf *** */
18849 struct cmd_config_tx_dynf_specific_result {
18850 cmdline_fixed_string_t port;
18851 cmdline_fixed_string_t keyword;
18853 cmdline_fixed_string_t item;
18854 cmdline_fixed_string_t name;
18855 cmdline_fixed_string_t value;
18859 cmd_config_dynf_specific_parsed(void *parsed_result,
18860 __rte_unused struct cmdline *cl,
18861 __rte_unused void *data)
18863 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18864 struct rte_mbuf_dynflag desc_flag;
18866 uint64_t old_port_flags;
18868 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18870 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18872 if (strlcpy(desc_flag.name, res->name,
18873 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18874 printf("Flag name too long\n");
18877 desc_flag.flags = 0;
18878 flag = rte_mbuf_dynflag_register(&desc_flag);
18880 printf("Can't register flag\n");
18883 strcpy(dynf_names[flag], desc_flag.name);
18885 old_port_flags = ports[res->port_id].mbuf_dynf;
18886 if (!strcmp(res->value, "set")) {
18887 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18888 if (old_port_flags == 0)
18889 add_tx_dynf_callback(res->port_id);
18891 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18892 if (ports[res->port_id].mbuf_dynf == 0)
18893 remove_tx_dynf_callback(res->port_id);
18897 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18898 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18900 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18901 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18902 keyword, "config");
18903 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18904 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18906 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18907 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18909 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18910 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18912 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18913 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18914 value, "set#clear");
18916 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18917 .f = cmd_config_dynf_specific_parsed,
18919 .help_str = "port config <port id> dynf <name> set|clear",
18921 (void *)&cmd_config_tx_dynf_specific_port,
18922 (void *)&cmd_config_tx_dynf_specific_keyword,
18923 (void *)&cmd_config_tx_dynf_specific_port_id,
18924 (void *)&cmd_config_tx_dynf_specific_item,
18925 (void *)&cmd_config_tx_dynf_specific_name,
18926 (void *)&cmd_config_tx_dynf_specific_value,
18931 /* *** display tx_metadata per port configuration *** */
18932 struct cmd_show_tx_metadata_result {
18933 cmdline_fixed_string_t cmd_show;
18934 cmdline_fixed_string_t cmd_port;
18935 cmdline_fixed_string_t cmd_keyword;
18940 cmd_show_tx_metadata_parsed(void *parsed_result,
18941 __rte_unused struct cmdline *cl,
18942 __rte_unused void *data)
18944 struct cmd_show_tx_metadata_result *res = parsed_result;
18946 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18947 printf("invalid port id %u\n", res->cmd_pid);
18950 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18951 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18952 ports[res->cmd_pid].tx_metadata);
18956 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18957 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18959 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18960 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18962 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18963 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18965 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18966 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18967 cmd_keyword, "tx_metadata");
18969 cmdline_parse_inst_t cmd_show_tx_metadata = {
18970 .f = cmd_show_tx_metadata_parsed,
18972 .help_str = "show port <port_id> tx_metadata",
18974 (void *)&cmd_show_tx_metadata_show,
18975 (void *)&cmd_show_tx_metadata_port,
18976 (void *)&cmd_show_tx_metadata_pid,
18977 (void *)&cmd_show_tx_metadata_keyword,
18982 /* show port supported ptypes */
18984 /* Common result structure for show port ptypes */
18985 struct cmd_show_port_supported_ptypes_result {
18986 cmdline_fixed_string_t show;
18987 cmdline_fixed_string_t port;
18989 cmdline_fixed_string_t ptypes;
18992 /* Common CLI fields for show port ptypes */
18993 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18994 TOKEN_STRING_INITIALIZER
18995 (struct cmd_show_port_supported_ptypes_result,
18997 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18998 TOKEN_STRING_INITIALIZER
18999 (struct cmd_show_port_supported_ptypes_result,
19001 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19002 TOKEN_NUM_INITIALIZER
19003 (struct cmd_show_port_supported_ptypes_result,
19005 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19006 TOKEN_STRING_INITIALIZER
19007 (struct cmd_show_port_supported_ptypes_result,
19011 cmd_show_port_supported_ptypes_parsed(
19012 void *parsed_result,
19013 __rte_unused struct cmdline *cl,
19014 __rte_unused void *data)
19016 #define RSVD_PTYPE_MASK 0xf0000000
19017 #define MAX_PTYPES_PER_LAYER 16
19018 #define LTYPE_NAMESIZE 32
19019 #define PTYPE_NAMESIZE 256
19020 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19021 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19022 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19023 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19024 uint16_t port_id = res->port_id;
19027 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19031 while (ptype_mask != RSVD_PTYPE_MASK) {
19033 switch (ptype_mask) {
19034 case RTE_PTYPE_L2_MASK:
19035 strlcpy(ltype, "L2", sizeof(ltype));
19037 case RTE_PTYPE_L3_MASK:
19038 strlcpy(ltype, "L3", sizeof(ltype));
19040 case RTE_PTYPE_L4_MASK:
19041 strlcpy(ltype, "L4", sizeof(ltype));
19043 case RTE_PTYPE_TUNNEL_MASK:
19044 strlcpy(ltype, "Tunnel", sizeof(ltype));
19046 case RTE_PTYPE_INNER_L2_MASK:
19047 strlcpy(ltype, "Inner L2", sizeof(ltype));
19049 case RTE_PTYPE_INNER_L3_MASK:
19050 strlcpy(ltype, "Inner L3", sizeof(ltype));
19052 case RTE_PTYPE_INNER_L4_MASK:
19053 strlcpy(ltype, "Inner L4", sizeof(ltype));
19059 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19060 ptype_mask, ptypes,
19061 MAX_PTYPES_PER_LAYER);
19064 printf("Supported %s ptypes:\n", ltype);
19066 printf("%s ptypes unsupported\n", ltype);
19068 for (i = 0; i < ret; ++i) {
19069 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19070 printf("%s\n", buf);
19077 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19078 .f = cmd_show_port_supported_ptypes_parsed,
19080 .help_str = "show port <port_id> ptypes",
19082 (void *)&cmd_show_port_supported_ptypes_show,
19083 (void *)&cmd_show_port_supported_ptypes_port,
19084 (void *)&cmd_show_port_supported_ptypes_port_id,
19085 (void *)&cmd_show_port_supported_ptypes_ptypes,
19090 /* *** display rx/tx descriptor status *** */
19091 struct cmd_show_rx_tx_desc_status_result {
19092 cmdline_fixed_string_t cmd_show;
19093 cmdline_fixed_string_t cmd_port;
19094 cmdline_fixed_string_t cmd_keyword;
19095 cmdline_fixed_string_t cmd_desc;
19096 cmdline_fixed_string_t cmd_status;
19103 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19104 __rte_unused struct cmdline *cl,
19105 __rte_unused void *data)
19107 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19110 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19111 printf("invalid port id %u\n", res->cmd_pid);
19115 if (!strcmp(res->cmd_keyword, "rxq")) {
19116 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19119 printf("Invalid queueid = %d\n", res->cmd_qid);
19122 if (rc == RTE_ETH_RX_DESC_AVAIL)
19123 printf("Desc status = AVAILABLE\n");
19124 else if (rc == RTE_ETH_RX_DESC_DONE)
19125 printf("Desc status = DONE\n");
19127 printf("Desc status = UNAVAILABLE\n");
19128 } else if (!strcmp(res->cmd_keyword, "txq")) {
19129 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19132 printf("Invalid queueid = %d\n", res->cmd_qid);
19135 if (rc == RTE_ETH_TX_DESC_FULL)
19136 printf("Desc status = FULL\n");
19137 else if (rc == RTE_ETH_TX_DESC_DONE)
19138 printf("Desc status = DONE\n");
19140 printf("Desc status = UNAVAILABLE\n");
19144 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19145 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19147 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19148 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19150 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19151 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19153 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19154 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19155 cmd_keyword, "rxq#txq");
19156 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19157 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19159 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19160 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19162 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19163 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19165 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19166 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19167 cmd_status, "status");
19168 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19169 .f = cmd_show_rx_tx_desc_status_parsed,
19171 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19174 (void *)&cmd_show_rx_tx_desc_status_show,
19175 (void *)&cmd_show_rx_tx_desc_status_port,
19176 (void *)&cmd_show_rx_tx_desc_status_pid,
19177 (void *)&cmd_show_rx_tx_desc_status_keyword,
19178 (void *)&cmd_show_rx_tx_desc_status_qid,
19179 (void *)&cmd_show_rx_tx_desc_status_desc,
19180 (void *)&cmd_show_rx_tx_desc_status_did,
19181 (void *)&cmd_show_rx_tx_desc_status_status,
19186 /* Common result structure for set port ptypes */
19187 struct cmd_set_port_ptypes_result {
19188 cmdline_fixed_string_t set;
19189 cmdline_fixed_string_t port;
19191 cmdline_fixed_string_t ptype_mask;
19195 /* Common CLI fields for set port ptypes */
19196 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19197 TOKEN_STRING_INITIALIZER
19198 (struct cmd_set_port_ptypes_result,
19200 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19201 TOKEN_STRING_INITIALIZER
19202 (struct cmd_set_port_ptypes_result,
19204 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19205 TOKEN_NUM_INITIALIZER
19206 (struct cmd_set_port_ptypes_result,
19208 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19209 TOKEN_STRING_INITIALIZER
19210 (struct cmd_set_port_ptypes_result,
19211 ptype_mask, "ptype_mask");
19212 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19213 TOKEN_NUM_INITIALIZER
19214 (struct cmd_set_port_ptypes_result,
19218 cmd_set_port_ptypes_parsed(
19219 void *parsed_result,
19220 __rte_unused struct cmdline *cl,
19221 __rte_unused void *data)
19223 struct cmd_set_port_ptypes_result *res = parsed_result;
19224 #define PTYPE_NAMESIZE 256
19225 char ptype_name[PTYPE_NAMESIZE];
19226 uint16_t port_id = res->port_id;
19227 uint32_t ptype_mask = res->mask;
19230 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19233 printf("Port %d doesn't support any ptypes.\n", port_id);
19237 uint32_t ptypes[ret];
19239 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19241 printf("Unable to set requested ptypes for Port %d\n", port_id);
19245 printf("Successfully set following ptypes for Port %d\n", port_id);
19246 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19247 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19248 printf("%s\n", ptype_name);
19251 clear_ptypes = false;
19254 cmdline_parse_inst_t cmd_set_port_ptypes = {
19255 .f = cmd_set_port_ptypes_parsed,
19257 .help_str = "set port <port_id> ptype_mask <mask>",
19259 (void *)&cmd_set_port_ptypes_set,
19260 (void *)&cmd_set_port_ptypes_port,
19261 (void *)&cmd_set_port_ptypes_port_id,
19262 (void *)&cmd_set_port_ptypes_mask_str,
19263 (void *)&cmd_set_port_ptypes_mask_u32,
19268 /* *** display mac addresses added to a port *** */
19269 struct cmd_showport_macs_result {
19270 cmdline_fixed_string_t cmd_show;
19271 cmdline_fixed_string_t cmd_port;
19272 cmdline_fixed_string_t cmd_keyword;
19277 cmd_showport_macs_parsed(void *parsed_result,
19278 __rte_unused struct cmdline *cl,
19279 __rte_unused void *data)
19281 struct cmd_showport_macs_result *res = parsed_result;
19283 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19286 if (!strcmp(res->cmd_keyword, "macs"))
19287 show_macs(res->cmd_pid);
19288 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19289 show_mcast_macs(res->cmd_pid);
19292 cmdline_parse_token_string_t cmd_showport_macs_show =
19293 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19295 cmdline_parse_token_string_t cmd_showport_macs_port =
19296 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19298 cmdline_parse_token_num_t cmd_showport_macs_pid =
19299 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19301 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19302 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19303 cmd_keyword, "macs#mcast_macs");
19305 cmdline_parse_inst_t cmd_showport_macs = {
19306 .f = cmd_showport_macs_parsed,
19308 .help_str = "show port <port_id> macs|mcast_macs",
19310 (void *)&cmd_showport_macs_show,
19311 (void *)&cmd_showport_macs_port,
19312 (void *)&cmd_showport_macs_pid,
19313 (void *)&cmd_showport_macs_keyword,
19318 /* ******************************************************************************** */
19320 /* list of instructions */
19321 cmdline_parse_ctx_t main_ctx[] = {
19322 (cmdline_parse_inst_t *)&cmd_help_brief,
19323 (cmdline_parse_inst_t *)&cmd_help_long,
19324 (cmdline_parse_inst_t *)&cmd_quit,
19325 (cmdline_parse_inst_t *)&cmd_load_from_file,
19326 (cmdline_parse_inst_t *)&cmd_showport,
19327 (cmdline_parse_inst_t *)&cmd_showqueue,
19328 (cmdline_parse_inst_t *)&cmd_showportall,
19329 (cmdline_parse_inst_t *)&cmd_showdevice,
19330 (cmdline_parse_inst_t *)&cmd_showcfg,
19331 (cmdline_parse_inst_t *)&cmd_showfwdall,
19332 (cmdline_parse_inst_t *)&cmd_start,
19333 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19334 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19335 (cmdline_parse_inst_t *)&cmd_set_link_up,
19336 (cmdline_parse_inst_t *)&cmd_set_link_down,
19337 (cmdline_parse_inst_t *)&cmd_reset,
19338 (cmdline_parse_inst_t *)&cmd_set_numbers,
19339 (cmdline_parse_inst_t *)&cmd_set_log,
19340 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19341 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19342 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19343 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19344 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19345 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19346 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19347 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19348 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19349 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19350 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19351 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19352 (cmdline_parse_inst_t *)&cmd_set_link_check,
19353 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19354 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19355 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19356 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19357 #ifdef RTE_LIBRTE_PMD_BOND
19358 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19359 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19360 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19361 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19362 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19363 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19364 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19365 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19366 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19367 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19368 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19370 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19371 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19372 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19373 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19374 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19375 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19376 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19377 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19378 (cmdline_parse_inst_t *)&cmd_csum_set,
19379 (cmdline_parse_inst_t *)&cmd_csum_show,
19380 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19381 (cmdline_parse_inst_t *)&cmd_tso_set,
19382 (cmdline_parse_inst_t *)&cmd_tso_show,
19383 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19384 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19385 (cmdline_parse_inst_t *)&cmd_gro_enable,
19386 (cmdline_parse_inst_t *)&cmd_gro_flush,
19387 (cmdline_parse_inst_t *)&cmd_gro_show,
19388 (cmdline_parse_inst_t *)&cmd_gso_enable,
19389 (cmdline_parse_inst_t *)&cmd_gso_size,
19390 (cmdline_parse_inst_t *)&cmd_gso_show,
19391 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19392 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19393 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19394 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19395 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19396 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19397 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19398 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19399 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19400 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19401 (cmdline_parse_inst_t *)&cmd_config_dcb,
19402 (cmdline_parse_inst_t *)&cmd_read_reg,
19403 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19404 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19405 (cmdline_parse_inst_t *)&cmd_write_reg,
19406 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19407 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19408 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19409 (cmdline_parse_inst_t *)&cmd_stop,
19410 (cmdline_parse_inst_t *)&cmd_mac_addr,
19411 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19412 (cmdline_parse_inst_t *)&cmd_set_qmap,
19413 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19414 (cmdline_parse_inst_t *)&cmd_operate_port,
19415 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19416 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19417 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19418 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19419 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19420 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19421 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19422 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19423 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19424 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19425 (cmdline_parse_inst_t *)&cmd_config_mtu,
19426 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19427 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19428 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19429 (cmdline_parse_inst_t *)&cmd_config_rss,
19430 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19431 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19432 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19433 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19434 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19435 (cmdline_parse_inst_t *)&cmd_showport_reta,
19436 (cmdline_parse_inst_t *)&cmd_showport_macs,
19437 (cmdline_parse_inst_t *)&cmd_config_burst,
19438 (cmdline_parse_inst_t *)&cmd_config_thresh,
19439 (cmdline_parse_inst_t *)&cmd_config_threshold,
19440 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19441 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19442 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19443 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19444 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19445 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19446 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19447 (cmdline_parse_inst_t *)&cmd_global_config,
19448 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19449 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19450 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19451 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19452 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19453 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19454 (cmdline_parse_inst_t *)&cmd_dump,
19455 (cmdline_parse_inst_t *)&cmd_dump_one,
19456 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19457 (cmdline_parse_inst_t *)&cmd_syn_filter,
19458 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19459 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19460 (cmdline_parse_inst_t *)&cmd_flex_filter,
19461 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19462 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19463 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19464 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19465 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19466 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19467 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19468 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19469 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19470 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19471 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19472 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19473 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19474 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19475 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19476 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19477 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19478 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19479 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19480 (cmdline_parse_inst_t *)&cmd_flow,
19481 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19482 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19483 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19484 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19485 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19486 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19487 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19488 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19489 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19490 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19491 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19492 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19493 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19494 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19495 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19496 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19497 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19498 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19499 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19500 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19501 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19502 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19503 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19504 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19505 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19506 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19507 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19508 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19509 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19510 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19511 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19512 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19513 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19514 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19515 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19516 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19517 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19518 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19519 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19520 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19521 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19522 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19523 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19524 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19525 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19526 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19527 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19528 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19529 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19530 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19531 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19533 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19534 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19535 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19536 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19537 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19538 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19539 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19540 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19541 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19542 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19543 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19544 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19545 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19546 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19547 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19548 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19549 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19550 (cmdline_parse_inst_t *)&cmd_ddp_add,
19551 (cmdline_parse_inst_t *)&cmd_ddp_del,
19552 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19553 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19554 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19555 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19556 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19557 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19558 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19559 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19560 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19561 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19562 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19563 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19565 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19566 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19567 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19568 (cmdline_parse_inst_t *)&cmd_queue_region,
19569 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19570 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19571 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19572 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19573 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19574 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19575 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19576 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19577 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19578 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19579 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19580 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19581 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19582 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19583 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19584 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19585 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19586 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19587 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19588 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19589 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19590 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19591 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19592 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19593 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19594 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19595 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19596 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19597 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19598 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19599 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19600 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19601 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19602 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19603 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19604 #ifdef RTE_LIBRTE_BPF
19605 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19606 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19608 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19609 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19610 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19611 (cmdline_parse_inst_t *)&cmd_set_raw,
19612 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19613 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19614 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19618 /* read cmdline commands from file */
19620 cmdline_read_from_file(const char *filename)
19622 struct cmdline *cl;
19624 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19626 printf("Failed to create file based cmdline context: %s\n",
19631 cmdline_interact(cl);
19636 printf("Read CLI commands from %s\n", filename);
19639 /* prompt function, called from main on MASTER lcore */
19643 /* initialize non-constant commands */
19644 cmd_set_fwd_mode_init();
19645 cmd_set_fwd_retry_mode_init();
19647 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19648 if (testpmd_cl == NULL)
19650 cmdline_interact(testpmd_cl);
19651 cmdline_stdin_exit(testpmd_cl);
19657 if (testpmd_cl != NULL)
19658 cmdline_quit(testpmd_cl);
19662 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19664 if (id == (portid_t)RTE_PORT_ALL) {
19667 RTE_ETH_FOREACH_DEV(pid) {
19668 /* check if need_reconfig has been set to 1 */
19669 if (ports[pid].need_reconfig == 0)
19670 ports[pid].need_reconfig = dev;
19671 /* check if need_reconfig_queues has been set to 1 */
19672 if (ports[pid].need_reconfig_queues == 0)
19673 ports[pid].need_reconfig_queues = queue;
19675 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19676 /* check if need_reconfig has been set to 1 */
19677 if (ports[id].need_reconfig == 0)
19678 ports[id].need_reconfig = dev;
19679 /* check if need_reconfig_queues has been set to 1 */
19680 if (ports[id].need_reconfig_queues == 0)
19681 ports[id].need_reconfig_queues = queue;