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);
9570 /* Dump the socket memory statistics on console */
9572 dump_socket_mem(FILE *f)
9574 struct rte_malloc_socket_stats socket_stats;
9579 unsigned int n_alloc = 0;
9580 unsigned int n_free = 0;
9581 static size_t last_allocs;
9582 static size_t last_total;
9585 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9586 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9587 !socket_stats.heap_totalsz_bytes)
9589 total += socket_stats.heap_totalsz_bytes;
9590 alloc += socket_stats.heap_allocsz_bytes;
9591 free += socket_stats.heap_freesz_bytes;
9592 n_alloc += socket_stats.alloc_count;
9593 n_free += socket_stats.free_count;
9595 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9597 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9598 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9599 (double)socket_stats.heap_allocsz_bytes * 100 /
9600 (double)socket_stats.heap_totalsz_bytes,
9601 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9602 socket_stats.alloc_count,
9603 socket_stats.free_count);
9606 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9607 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9608 (double)alloc * 100 / (double)total,
9609 (double)free / (1024 * 1024),
9612 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9613 ((double)total - (double)last_total) / (1024 * 1024),
9614 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9615 last_allocs = alloc;
9619 static void cmd_dump_parsed(void *parsed_result,
9620 __rte_unused struct cmdline *cl,
9621 __rte_unused void *data)
9623 struct cmd_dump_result *res = parsed_result;
9625 if (!strcmp(res->dump, "dump_physmem"))
9626 rte_dump_physmem_layout(stdout);
9627 else if (!strcmp(res->dump, "dump_socket_mem"))
9628 dump_socket_mem(stdout);
9629 else if (!strcmp(res->dump, "dump_memzone"))
9630 rte_memzone_dump(stdout);
9631 else if (!strcmp(res->dump, "dump_struct_sizes"))
9632 dump_struct_sizes();
9633 else if (!strcmp(res->dump, "dump_ring"))
9634 rte_ring_list_dump(stdout);
9635 else if (!strcmp(res->dump, "dump_mempool"))
9636 rte_mempool_list_dump(stdout);
9637 else if (!strcmp(res->dump, "dump_devargs"))
9638 rte_devargs_dump(stdout);
9639 else if (!strcmp(res->dump, "dump_log_types"))
9640 rte_log_dump(stdout);
9643 cmdline_parse_token_string_t cmd_dump_dump =
9644 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9648 "dump_struct_sizes#"
9654 cmdline_parse_inst_t cmd_dump = {
9655 .f = cmd_dump_parsed, /* function to call */
9656 .data = NULL, /* 2nd arg of func */
9657 .help_str = "Dump status",
9658 .tokens = { /* token list, NULL terminated */
9659 (void *)&cmd_dump_dump,
9664 /* ******************************************************************************** */
9666 struct cmd_dump_one_result {
9667 cmdline_fixed_string_t dump;
9668 cmdline_fixed_string_t name;
9671 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9672 __rte_unused void *data)
9674 struct cmd_dump_one_result *res = parsed_result;
9676 if (!strcmp(res->dump, "dump_ring")) {
9678 r = rte_ring_lookup(res->name);
9680 cmdline_printf(cl, "Cannot find ring\n");
9683 rte_ring_dump(stdout, r);
9684 } else if (!strcmp(res->dump, "dump_mempool")) {
9685 struct rte_mempool *mp;
9686 mp = rte_mempool_lookup(res->name);
9688 cmdline_printf(cl, "Cannot find mempool\n");
9691 rte_mempool_dump(stdout, mp);
9695 cmdline_parse_token_string_t cmd_dump_one_dump =
9696 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9697 "dump_ring#dump_mempool");
9699 cmdline_parse_token_string_t cmd_dump_one_name =
9700 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9702 cmdline_parse_inst_t cmd_dump_one = {
9703 .f = cmd_dump_one_parsed, /* function to call */
9704 .data = NULL, /* 2nd arg of func */
9705 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9706 .tokens = { /* token list, NULL terminated */
9707 (void *)&cmd_dump_one_dump,
9708 (void *)&cmd_dump_one_name,
9713 /* *** Add/Del syn filter *** */
9714 struct cmd_syn_filter_result {
9715 cmdline_fixed_string_t filter;
9717 cmdline_fixed_string_t ops;
9718 cmdline_fixed_string_t priority;
9719 cmdline_fixed_string_t high;
9720 cmdline_fixed_string_t queue;
9725 cmd_syn_filter_parsed(void *parsed_result,
9726 __rte_unused struct cmdline *cl,
9727 __rte_unused void *data)
9729 struct cmd_syn_filter_result *res = parsed_result;
9730 struct rte_eth_syn_filter syn_filter;
9733 ret = rte_eth_dev_filter_supported(res->port_id,
9734 RTE_ETH_FILTER_SYN);
9736 printf("syn filter is not supported on port %u.\n",
9741 memset(&syn_filter, 0, sizeof(syn_filter));
9743 if (!strcmp(res->ops, "add")) {
9744 if (!strcmp(res->high, "high"))
9745 syn_filter.hig_pri = 1;
9747 syn_filter.hig_pri = 0;
9749 syn_filter.queue = res->queue_id;
9750 ret = rte_eth_dev_filter_ctrl(res->port_id,
9755 ret = rte_eth_dev_filter_ctrl(res->port_id,
9757 RTE_ETH_FILTER_DELETE,
9761 printf("syn filter programming error: (%s)\n",
9765 cmdline_parse_token_string_t cmd_syn_filter_filter =
9766 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9767 filter, "syn_filter");
9768 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9769 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9771 cmdline_parse_token_string_t cmd_syn_filter_ops =
9772 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9774 cmdline_parse_token_string_t cmd_syn_filter_priority =
9775 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9776 priority, "priority");
9777 cmdline_parse_token_string_t cmd_syn_filter_high =
9778 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9780 cmdline_parse_token_string_t cmd_syn_filter_queue =
9781 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9783 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9784 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9787 cmdline_parse_inst_t cmd_syn_filter = {
9788 .f = cmd_syn_filter_parsed,
9790 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9791 "<queue_id>: Add/Delete syn filter",
9793 (void *)&cmd_syn_filter_filter,
9794 (void *)&cmd_syn_filter_port_id,
9795 (void *)&cmd_syn_filter_ops,
9796 (void *)&cmd_syn_filter_priority,
9797 (void *)&cmd_syn_filter_high,
9798 (void *)&cmd_syn_filter_queue,
9799 (void *)&cmd_syn_filter_queue_id,
9804 /* *** queue region set *** */
9805 struct cmd_queue_region_result {
9806 cmdline_fixed_string_t set;
9807 cmdline_fixed_string_t port;
9809 cmdline_fixed_string_t cmd;
9810 cmdline_fixed_string_t region;
9812 cmdline_fixed_string_t queue_start_index;
9814 cmdline_fixed_string_t queue_num;
9815 uint8_t queue_num_value;
9819 cmd_queue_region_parsed(void *parsed_result,
9820 __rte_unused struct cmdline *cl,
9821 __rte_unused void *data)
9823 struct cmd_queue_region_result *res = parsed_result;
9825 #ifdef RTE_LIBRTE_I40E_PMD
9826 struct rte_pmd_i40e_queue_region_conf region_conf;
9827 enum rte_pmd_i40e_queue_region_op op_type;
9830 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9833 #ifdef RTE_LIBRTE_I40E_PMD
9834 memset(®ion_conf, 0, sizeof(region_conf));
9835 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9836 region_conf.region_id = res->region_id;
9837 region_conf.queue_num = res->queue_num_value;
9838 region_conf.queue_start_index = res->queue_id;
9840 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9841 op_type, ®ion_conf);
9848 printf("function not implemented or supported\n");
9851 printf("queue region config error: (%s)\n", strerror(-ret));
9855 cmdline_parse_token_string_t cmd_queue_region_set =
9856 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9858 cmdline_parse_token_string_t cmd_queue_region_port =
9859 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9860 cmdline_parse_token_num_t cmd_queue_region_port_id =
9861 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9863 cmdline_parse_token_string_t cmd_queue_region_cmd =
9864 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9865 cmd, "queue-region");
9866 cmdline_parse_token_string_t cmd_queue_region_id =
9867 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9868 region, "region_id");
9869 cmdline_parse_token_num_t cmd_queue_region_index =
9870 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9872 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9873 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9874 queue_start_index, "queue_start_index");
9875 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9876 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9878 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9879 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9880 queue_num, "queue_num");
9881 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9882 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9883 queue_num_value, UINT8);
9885 cmdline_parse_inst_t cmd_queue_region = {
9886 .f = cmd_queue_region_parsed,
9888 .help_str = "set port <port_id> queue-region region_id <value> "
9889 "queue_start_index <value> queue_num <value>: Set a queue region",
9891 (void *)&cmd_queue_region_set,
9892 (void *)&cmd_queue_region_port,
9893 (void *)&cmd_queue_region_port_id,
9894 (void *)&cmd_queue_region_cmd,
9895 (void *)&cmd_queue_region_id,
9896 (void *)&cmd_queue_region_index,
9897 (void *)&cmd_queue_region_queue_start_index,
9898 (void *)&cmd_queue_region_queue_id,
9899 (void *)&cmd_queue_region_queue_num,
9900 (void *)&cmd_queue_region_queue_num_value,
9905 /* *** queue region and flowtype set *** */
9906 struct cmd_region_flowtype_result {
9907 cmdline_fixed_string_t set;
9908 cmdline_fixed_string_t port;
9910 cmdline_fixed_string_t cmd;
9911 cmdline_fixed_string_t region;
9913 cmdline_fixed_string_t flowtype;
9914 uint8_t flowtype_id;
9918 cmd_region_flowtype_parsed(void *parsed_result,
9919 __rte_unused struct cmdline *cl,
9920 __rte_unused void *data)
9922 struct cmd_region_flowtype_result *res = parsed_result;
9924 #ifdef RTE_LIBRTE_I40E_PMD
9925 struct rte_pmd_i40e_queue_region_conf region_conf;
9926 enum rte_pmd_i40e_queue_region_op op_type;
9929 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9932 #ifdef RTE_LIBRTE_I40E_PMD
9933 memset(®ion_conf, 0, sizeof(region_conf));
9935 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9936 region_conf.region_id = res->region_id;
9937 region_conf.hw_flowtype = res->flowtype_id;
9939 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9940 op_type, ®ion_conf);
9947 printf("function not implemented or supported\n");
9950 printf("region flowtype config error: (%s)\n", strerror(-ret));
9954 cmdline_parse_token_string_t cmd_region_flowtype_set =
9955 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9957 cmdline_parse_token_string_t cmd_region_flowtype_port =
9958 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9960 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9961 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9963 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9964 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9965 cmd, "queue-region");
9966 cmdline_parse_token_string_t cmd_region_flowtype_index =
9967 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9968 region, "region_id");
9969 cmdline_parse_token_num_t cmd_region_flowtype_id =
9970 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9972 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9973 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9974 flowtype, "flowtype");
9975 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9976 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9977 flowtype_id, UINT8);
9978 cmdline_parse_inst_t cmd_region_flowtype = {
9979 .f = cmd_region_flowtype_parsed,
9981 .help_str = "set port <port_id> queue-region region_id <value> "
9982 "flowtype <value>: Set a flowtype region index",
9984 (void *)&cmd_region_flowtype_set,
9985 (void *)&cmd_region_flowtype_port,
9986 (void *)&cmd_region_flowtype_port_index,
9987 (void *)&cmd_region_flowtype_cmd,
9988 (void *)&cmd_region_flowtype_index,
9989 (void *)&cmd_region_flowtype_id,
9990 (void *)&cmd_region_flowtype_flow_index,
9991 (void *)&cmd_region_flowtype_flow_id,
9996 /* *** User Priority (UP) to queue region (region_id) set *** */
9997 struct cmd_user_priority_region_result {
9998 cmdline_fixed_string_t set;
9999 cmdline_fixed_string_t port;
10001 cmdline_fixed_string_t cmd;
10002 cmdline_fixed_string_t user_priority;
10003 uint8_t user_priority_id;
10004 cmdline_fixed_string_t region;
10009 cmd_user_priority_region_parsed(void *parsed_result,
10010 __rte_unused struct cmdline *cl,
10011 __rte_unused void *data)
10013 struct cmd_user_priority_region_result *res = parsed_result;
10014 int ret = -ENOTSUP;
10015 #ifdef RTE_LIBRTE_I40E_PMD
10016 struct rte_pmd_i40e_queue_region_conf region_conf;
10017 enum rte_pmd_i40e_queue_region_op op_type;
10020 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10023 #ifdef RTE_LIBRTE_I40E_PMD
10024 memset(®ion_conf, 0, sizeof(region_conf));
10025 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10026 region_conf.user_priority = res->user_priority_id;
10027 region_conf.region_id = res->region_id;
10029 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10030 op_type, ®ion_conf);
10037 printf("function not implemented or supported\n");
10040 printf("user_priority region config error: (%s)\n",
10045 cmdline_parse_token_string_t cmd_user_priority_region_set =
10046 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10048 cmdline_parse_token_string_t cmd_user_priority_region_port =
10049 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10051 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10052 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10054 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10055 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10056 cmd, "queue-region");
10057 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10058 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10059 user_priority, "UP");
10060 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10061 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10062 user_priority_id, UINT8);
10063 cmdline_parse_token_string_t cmd_user_priority_region_region =
10064 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10065 region, "region_id");
10066 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10067 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10070 cmdline_parse_inst_t cmd_user_priority_region = {
10071 .f = cmd_user_priority_region_parsed,
10073 .help_str = "set port <port_id> queue-region UP <value> "
10074 "region_id <value>: Set the mapping of User Priority (UP) "
10075 "to queue region (region_id) ",
10077 (void *)&cmd_user_priority_region_set,
10078 (void *)&cmd_user_priority_region_port,
10079 (void *)&cmd_user_priority_region_port_index,
10080 (void *)&cmd_user_priority_region_cmd,
10081 (void *)&cmd_user_priority_region_UP,
10082 (void *)&cmd_user_priority_region_UP_id,
10083 (void *)&cmd_user_priority_region_region,
10084 (void *)&cmd_user_priority_region_region_id,
10089 /* *** flush all queue region related configuration *** */
10090 struct cmd_flush_queue_region_result {
10091 cmdline_fixed_string_t set;
10092 cmdline_fixed_string_t port;
10094 cmdline_fixed_string_t cmd;
10095 cmdline_fixed_string_t flush;
10096 cmdline_fixed_string_t what;
10100 cmd_flush_queue_region_parsed(void *parsed_result,
10101 __rte_unused struct cmdline *cl,
10102 __rte_unused void *data)
10104 struct cmd_flush_queue_region_result *res = parsed_result;
10105 int ret = -ENOTSUP;
10106 #ifdef RTE_LIBRTE_I40E_PMD
10107 struct rte_pmd_i40e_queue_region_conf region_conf;
10108 enum rte_pmd_i40e_queue_region_op op_type;
10111 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10114 #ifdef RTE_LIBRTE_I40E_PMD
10115 memset(®ion_conf, 0, sizeof(region_conf));
10117 if (strcmp(res->what, "on") == 0)
10118 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10120 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10122 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10123 op_type, ®ion_conf);
10130 printf("function not implemented or supported\n");
10133 printf("queue region config flush error: (%s)\n",
10138 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10139 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10141 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10142 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10144 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10145 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10147 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10148 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10149 cmd, "queue-region");
10150 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10151 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10153 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10154 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10157 cmdline_parse_inst_t cmd_flush_queue_region = {
10158 .f = cmd_flush_queue_region_parsed,
10160 .help_str = "set port <port_id> queue-region flush on|off"
10161 ": flush all queue region related configuration",
10163 (void *)&cmd_flush_queue_region_set,
10164 (void *)&cmd_flush_queue_region_port,
10165 (void *)&cmd_flush_queue_region_port_index,
10166 (void *)&cmd_flush_queue_region_cmd,
10167 (void *)&cmd_flush_queue_region_flush,
10168 (void *)&cmd_flush_queue_region_what,
10173 /* *** get all queue region related configuration info *** */
10174 struct cmd_show_queue_region_info {
10175 cmdline_fixed_string_t show;
10176 cmdline_fixed_string_t port;
10178 cmdline_fixed_string_t cmd;
10182 cmd_show_queue_region_info_parsed(void *parsed_result,
10183 __rte_unused struct cmdline *cl,
10184 __rte_unused void *data)
10186 struct cmd_show_queue_region_info *res = parsed_result;
10187 int ret = -ENOTSUP;
10188 #ifdef RTE_LIBRTE_I40E_PMD
10189 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10190 enum rte_pmd_i40e_queue_region_op op_type;
10193 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10196 #ifdef RTE_LIBRTE_I40E_PMD
10197 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10199 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10201 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10202 op_type, &rte_pmd_regions);
10204 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10211 printf("function not implemented or supported\n");
10214 printf("queue region config info show error: (%s)\n",
10219 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10220 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10222 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10223 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10225 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10226 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10228 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10229 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10230 cmd, "queue-region");
10232 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10233 .f = cmd_show_queue_region_info_parsed,
10235 .help_str = "show port <port_id> queue-region"
10236 ": show all queue region related configuration info",
10238 (void *)&cmd_show_queue_region_info_get,
10239 (void *)&cmd_show_queue_region_info_port,
10240 (void *)&cmd_show_queue_region_info_port_index,
10241 (void *)&cmd_show_queue_region_info_cmd,
10246 /* *** ADD/REMOVE A 2tuple FILTER *** */
10247 struct cmd_2tuple_filter_result {
10248 cmdline_fixed_string_t filter;
10250 cmdline_fixed_string_t ops;
10251 cmdline_fixed_string_t dst_port;
10252 uint16_t dst_port_value;
10253 cmdline_fixed_string_t protocol;
10254 uint8_t protocol_value;
10255 cmdline_fixed_string_t mask;
10256 uint8_t mask_value;
10257 cmdline_fixed_string_t tcp_flags;
10258 uint8_t tcp_flags_value;
10259 cmdline_fixed_string_t priority;
10260 uint8_t priority_value;
10261 cmdline_fixed_string_t queue;
10266 cmd_2tuple_filter_parsed(void *parsed_result,
10267 __rte_unused struct cmdline *cl,
10268 __rte_unused void *data)
10270 struct rte_eth_ntuple_filter filter;
10271 struct cmd_2tuple_filter_result *res = parsed_result;
10274 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10276 printf("ntuple filter is not supported on port %u.\n",
10281 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10283 filter.flags = RTE_2TUPLE_FLAGS;
10284 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10285 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10286 filter.proto = res->protocol_value;
10287 filter.priority = res->priority_value;
10288 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10289 printf("nonzero tcp_flags is only meaningful"
10290 " when protocol is TCP.\n");
10293 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10294 printf("invalid TCP flags.\n");
10298 if (res->tcp_flags_value != 0) {
10299 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10300 filter.tcp_flags = res->tcp_flags_value;
10303 /* need convert to big endian. */
10304 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10305 filter.queue = res->queue_id;
10307 if (!strcmp(res->ops, "add"))
10308 ret = rte_eth_dev_filter_ctrl(res->port_id,
10309 RTE_ETH_FILTER_NTUPLE,
10310 RTE_ETH_FILTER_ADD,
10313 ret = rte_eth_dev_filter_ctrl(res->port_id,
10314 RTE_ETH_FILTER_NTUPLE,
10315 RTE_ETH_FILTER_DELETE,
10318 printf("2tuple filter programming error: (%s)\n",
10323 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10324 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10325 filter, "2tuple_filter");
10326 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10327 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10329 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10330 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10332 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10333 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10334 dst_port, "dst_port");
10335 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10336 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10337 dst_port_value, UINT16);
10338 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10339 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10340 protocol, "protocol");
10341 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10342 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10343 protocol_value, UINT8);
10344 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10345 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10347 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10348 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10350 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10351 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10352 tcp_flags, "tcp_flags");
10353 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10354 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10355 tcp_flags_value, UINT8);
10356 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10357 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10358 priority, "priority");
10359 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10360 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10361 priority_value, UINT8);
10362 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10363 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10365 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10366 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10369 cmdline_parse_inst_t cmd_2tuple_filter = {
10370 .f = cmd_2tuple_filter_parsed,
10372 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10373 "<value> mask <value> tcp_flags <value> priority <value> queue "
10374 "<queue_id>: Add a 2tuple filter",
10376 (void *)&cmd_2tuple_filter_filter,
10377 (void *)&cmd_2tuple_filter_port_id,
10378 (void *)&cmd_2tuple_filter_ops,
10379 (void *)&cmd_2tuple_filter_dst_port,
10380 (void *)&cmd_2tuple_filter_dst_port_value,
10381 (void *)&cmd_2tuple_filter_protocol,
10382 (void *)&cmd_2tuple_filter_protocol_value,
10383 (void *)&cmd_2tuple_filter_mask,
10384 (void *)&cmd_2tuple_filter_mask_value,
10385 (void *)&cmd_2tuple_filter_tcp_flags,
10386 (void *)&cmd_2tuple_filter_tcp_flags_value,
10387 (void *)&cmd_2tuple_filter_priority,
10388 (void *)&cmd_2tuple_filter_priority_value,
10389 (void *)&cmd_2tuple_filter_queue,
10390 (void *)&cmd_2tuple_filter_queue_id,
10395 /* *** ADD/REMOVE A 5tuple FILTER *** */
10396 struct cmd_5tuple_filter_result {
10397 cmdline_fixed_string_t filter;
10399 cmdline_fixed_string_t ops;
10400 cmdline_fixed_string_t dst_ip;
10401 cmdline_ipaddr_t dst_ip_value;
10402 cmdline_fixed_string_t src_ip;
10403 cmdline_ipaddr_t src_ip_value;
10404 cmdline_fixed_string_t dst_port;
10405 uint16_t dst_port_value;
10406 cmdline_fixed_string_t src_port;
10407 uint16_t src_port_value;
10408 cmdline_fixed_string_t protocol;
10409 uint8_t protocol_value;
10410 cmdline_fixed_string_t mask;
10411 uint8_t mask_value;
10412 cmdline_fixed_string_t tcp_flags;
10413 uint8_t tcp_flags_value;
10414 cmdline_fixed_string_t priority;
10415 uint8_t priority_value;
10416 cmdline_fixed_string_t queue;
10421 cmd_5tuple_filter_parsed(void *parsed_result,
10422 __rte_unused struct cmdline *cl,
10423 __rte_unused void *data)
10425 struct rte_eth_ntuple_filter filter;
10426 struct cmd_5tuple_filter_result *res = parsed_result;
10429 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10431 printf("ntuple filter is not supported on port %u.\n",
10436 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10438 filter.flags = RTE_5TUPLE_FLAGS;
10439 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10440 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10441 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10442 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10443 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10444 filter.proto = res->protocol_value;
10445 filter.priority = res->priority_value;
10446 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10447 printf("nonzero tcp_flags is only meaningful"
10448 " when protocol is TCP.\n");
10451 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10452 printf("invalid TCP flags.\n");
10456 if (res->tcp_flags_value != 0) {
10457 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10458 filter.tcp_flags = res->tcp_flags_value;
10461 if (res->dst_ip_value.family == AF_INET)
10462 /* no need to convert, already big endian. */
10463 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10465 if (filter.dst_ip_mask == 0) {
10466 printf("can not support ipv6 involved compare.\n");
10472 if (res->src_ip_value.family == AF_INET)
10473 /* no need to convert, already big endian. */
10474 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10476 if (filter.src_ip_mask == 0) {
10477 printf("can not support ipv6 involved compare.\n");
10482 /* need convert to big endian. */
10483 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10484 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10485 filter.queue = res->queue_id;
10487 if (!strcmp(res->ops, "add"))
10488 ret = rte_eth_dev_filter_ctrl(res->port_id,
10489 RTE_ETH_FILTER_NTUPLE,
10490 RTE_ETH_FILTER_ADD,
10493 ret = rte_eth_dev_filter_ctrl(res->port_id,
10494 RTE_ETH_FILTER_NTUPLE,
10495 RTE_ETH_FILTER_DELETE,
10498 printf("5tuple filter programming error: (%s)\n",
10502 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10503 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10504 filter, "5tuple_filter");
10505 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10506 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10508 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10509 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10511 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10512 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10514 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10515 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10517 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10518 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10520 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10521 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10523 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10524 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10525 dst_port, "dst_port");
10526 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10527 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10528 dst_port_value, UINT16);
10529 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10530 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10531 src_port, "src_port");
10532 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10533 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10534 src_port_value, UINT16);
10535 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10536 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10537 protocol, "protocol");
10538 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10539 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10540 protocol_value, UINT8);
10541 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10542 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10544 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10545 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10547 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10548 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10549 tcp_flags, "tcp_flags");
10550 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10551 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10552 tcp_flags_value, UINT8);
10553 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10554 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10555 priority, "priority");
10556 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10557 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10558 priority_value, UINT8);
10559 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10560 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10562 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10563 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10566 cmdline_parse_inst_t cmd_5tuple_filter = {
10567 .f = cmd_5tuple_filter_parsed,
10569 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10570 "src_ip <value> dst_port <value> src_port <value> "
10571 "protocol <value> mask <value> tcp_flags <value> "
10572 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10574 (void *)&cmd_5tuple_filter_filter,
10575 (void *)&cmd_5tuple_filter_port_id,
10576 (void *)&cmd_5tuple_filter_ops,
10577 (void *)&cmd_5tuple_filter_dst_ip,
10578 (void *)&cmd_5tuple_filter_dst_ip_value,
10579 (void *)&cmd_5tuple_filter_src_ip,
10580 (void *)&cmd_5tuple_filter_src_ip_value,
10581 (void *)&cmd_5tuple_filter_dst_port,
10582 (void *)&cmd_5tuple_filter_dst_port_value,
10583 (void *)&cmd_5tuple_filter_src_port,
10584 (void *)&cmd_5tuple_filter_src_port_value,
10585 (void *)&cmd_5tuple_filter_protocol,
10586 (void *)&cmd_5tuple_filter_protocol_value,
10587 (void *)&cmd_5tuple_filter_mask,
10588 (void *)&cmd_5tuple_filter_mask_value,
10589 (void *)&cmd_5tuple_filter_tcp_flags,
10590 (void *)&cmd_5tuple_filter_tcp_flags_value,
10591 (void *)&cmd_5tuple_filter_priority,
10592 (void *)&cmd_5tuple_filter_priority_value,
10593 (void *)&cmd_5tuple_filter_queue,
10594 (void *)&cmd_5tuple_filter_queue_id,
10599 /* *** ADD/REMOVE A flex FILTER *** */
10600 struct cmd_flex_filter_result {
10601 cmdline_fixed_string_t filter;
10602 cmdline_fixed_string_t ops;
10604 cmdline_fixed_string_t len;
10606 cmdline_fixed_string_t bytes;
10607 cmdline_fixed_string_t bytes_value;
10608 cmdline_fixed_string_t mask;
10609 cmdline_fixed_string_t mask_value;
10610 cmdline_fixed_string_t priority;
10611 uint8_t priority_value;
10612 cmdline_fixed_string_t queue;
10616 static int xdigit2val(unsigned char c)
10621 else if (isupper(c))
10622 val = c - 'A' + 10;
10624 val = c - 'a' + 10;
10629 cmd_flex_filter_parsed(void *parsed_result,
10630 __rte_unused struct cmdline *cl,
10631 __rte_unused void *data)
10634 struct rte_eth_flex_filter filter;
10635 struct cmd_flex_filter_result *res = parsed_result;
10636 char *bytes_ptr, *mask_ptr;
10637 uint16_t len, i, j = 0;
10642 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10643 printf("the len exceed the max length 128\n");
10646 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10647 filter.len = res->len_value;
10648 filter.priority = res->priority_value;
10649 filter.queue = res->queue_id;
10650 bytes_ptr = res->bytes_value;
10651 mask_ptr = res->mask_value;
10653 /* translate bytes string to array. */
10654 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10655 (bytes_ptr[1] == 'X')))
10657 len = strnlen(bytes_ptr, res->len_value * 2);
10658 if (len == 0 || (len % 8 != 0)) {
10659 printf("please check len and bytes input\n");
10662 for (i = 0; i < len; i++) {
10664 if (isxdigit(c) == 0) {
10665 /* invalid characters. */
10666 printf("invalid input\n");
10669 val = xdigit2val(c);
10672 filter.bytes[j] = byte;
10673 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10680 /* translate mask string to uint8_t array. */
10681 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10682 (mask_ptr[1] == 'X')))
10684 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10686 printf("invalid input\n");
10691 for (i = 0; i < len; i++) {
10693 if (isxdigit(c) == 0) {
10694 /* invalid characters. */
10695 printf("invalid input\n");
10698 val = xdigit2val(c);
10701 filter.mask[j] = byte;
10702 printf("mask[%d]:%02x ", j, filter.mask[j]);
10710 if (!strcmp(res->ops, "add"))
10711 ret = rte_eth_dev_filter_ctrl(res->port_id,
10712 RTE_ETH_FILTER_FLEXIBLE,
10713 RTE_ETH_FILTER_ADD,
10716 ret = rte_eth_dev_filter_ctrl(res->port_id,
10717 RTE_ETH_FILTER_FLEXIBLE,
10718 RTE_ETH_FILTER_DELETE,
10722 printf("flex filter setting error: (%s)\n", strerror(-ret));
10725 cmdline_parse_token_string_t cmd_flex_filter_filter =
10726 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10727 filter, "flex_filter");
10728 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10729 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10731 cmdline_parse_token_string_t cmd_flex_filter_ops =
10732 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10734 cmdline_parse_token_string_t cmd_flex_filter_len =
10735 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10737 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10738 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10740 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10741 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10743 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10744 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10745 bytes_value, NULL);
10746 cmdline_parse_token_string_t cmd_flex_filter_mask =
10747 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10749 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10750 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10752 cmdline_parse_token_string_t cmd_flex_filter_priority =
10753 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10754 priority, "priority");
10755 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10756 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10757 priority_value, UINT8);
10758 cmdline_parse_token_string_t cmd_flex_filter_queue =
10759 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10761 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10762 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10764 cmdline_parse_inst_t cmd_flex_filter = {
10765 .f = cmd_flex_filter_parsed,
10767 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10768 "<value> mask <value> priority <value> queue <queue_id>: "
10769 "Add/Del a flex filter",
10771 (void *)&cmd_flex_filter_filter,
10772 (void *)&cmd_flex_filter_port_id,
10773 (void *)&cmd_flex_filter_ops,
10774 (void *)&cmd_flex_filter_len,
10775 (void *)&cmd_flex_filter_len_value,
10776 (void *)&cmd_flex_filter_bytes,
10777 (void *)&cmd_flex_filter_bytes_value,
10778 (void *)&cmd_flex_filter_mask,
10779 (void *)&cmd_flex_filter_mask_value,
10780 (void *)&cmd_flex_filter_priority,
10781 (void *)&cmd_flex_filter_priority_value,
10782 (void *)&cmd_flex_filter_queue,
10783 (void *)&cmd_flex_filter_queue_id,
10788 /* *** Filters Control *** */
10790 /* *** deal with ethertype filter *** */
10791 struct cmd_ethertype_filter_result {
10792 cmdline_fixed_string_t filter;
10794 cmdline_fixed_string_t ops;
10795 cmdline_fixed_string_t mac;
10796 struct rte_ether_addr mac_addr;
10797 cmdline_fixed_string_t ethertype;
10798 uint16_t ethertype_value;
10799 cmdline_fixed_string_t drop;
10800 cmdline_fixed_string_t queue;
10804 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10805 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10806 filter, "ethertype_filter");
10807 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10808 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10810 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10811 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10813 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10814 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10815 mac, "mac_addr#mac_ignr");
10816 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10817 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10819 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10820 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10821 ethertype, "ethertype");
10822 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10823 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10824 ethertype_value, UINT16);
10825 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10826 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10828 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10829 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10831 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10832 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10836 cmd_ethertype_filter_parsed(void *parsed_result,
10837 __rte_unused struct cmdline *cl,
10838 __rte_unused void *data)
10840 struct cmd_ethertype_filter_result *res = parsed_result;
10841 struct rte_eth_ethertype_filter filter;
10844 ret = rte_eth_dev_filter_supported(res->port_id,
10845 RTE_ETH_FILTER_ETHERTYPE);
10847 printf("ethertype filter is not supported on port %u.\n",
10852 memset(&filter, 0, sizeof(filter));
10853 if (!strcmp(res->mac, "mac_addr")) {
10854 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10855 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10856 sizeof(struct rte_ether_addr));
10858 if (!strcmp(res->drop, "drop"))
10859 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10860 filter.ether_type = res->ethertype_value;
10861 filter.queue = res->queue_id;
10863 if (!strcmp(res->ops, "add"))
10864 ret = rte_eth_dev_filter_ctrl(res->port_id,
10865 RTE_ETH_FILTER_ETHERTYPE,
10866 RTE_ETH_FILTER_ADD,
10869 ret = rte_eth_dev_filter_ctrl(res->port_id,
10870 RTE_ETH_FILTER_ETHERTYPE,
10871 RTE_ETH_FILTER_DELETE,
10874 printf("ethertype filter programming error: (%s)\n",
10878 cmdline_parse_inst_t cmd_ethertype_filter = {
10879 .f = cmd_ethertype_filter_parsed,
10881 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10882 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10883 "Add or delete an ethertype filter entry",
10885 (void *)&cmd_ethertype_filter_filter,
10886 (void *)&cmd_ethertype_filter_port_id,
10887 (void *)&cmd_ethertype_filter_ops,
10888 (void *)&cmd_ethertype_filter_mac,
10889 (void *)&cmd_ethertype_filter_mac_addr,
10890 (void *)&cmd_ethertype_filter_ethertype,
10891 (void *)&cmd_ethertype_filter_ethertype_value,
10892 (void *)&cmd_ethertype_filter_drop,
10893 (void *)&cmd_ethertype_filter_queue,
10894 (void *)&cmd_ethertype_filter_queue_id,
10899 /* *** deal with flow director filter *** */
10900 struct cmd_flow_director_result {
10901 cmdline_fixed_string_t flow_director_filter;
10903 cmdline_fixed_string_t mode;
10904 cmdline_fixed_string_t mode_value;
10905 cmdline_fixed_string_t ops;
10906 cmdline_fixed_string_t flow;
10907 cmdline_fixed_string_t flow_type;
10908 cmdline_fixed_string_t ether;
10909 uint16_t ether_type;
10910 cmdline_fixed_string_t src;
10911 cmdline_ipaddr_t ip_src;
10913 cmdline_fixed_string_t dst;
10914 cmdline_ipaddr_t ip_dst;
10916 cmdline_fixed_string_t verify_tag;
10917 uint32_t verify_tag_value;
10918 cmdline_fixed_string_t tos;
10920 cmdline_fixed_string_t proto;
10921 uint8_t proto_value;
10922 cmdline_fixed_string_t ttl;
10924 cmdline_fixed_string_t vlan;
10925 uint16_t vlan_value;
10926 cmdline_fixed_string_t flexbytes;
10927 cmdline_fixed_string_t flexbytes_value;
10928 cmdline_fixed_string_t pf_vf;
10929 cmdline_fixed_string_t drop;
10930 cmdline_fixed_string_t queue;
10932 cmdline_fixed_string_t fd_id;
10933 uint32_t fd_id_value;
10934 cmdline_fixed_string_t mac;
10935 struct rte_ether_addr mac_addr;
10936 cmdline_fixed_string_t tunnel;
10937 cmdline_fixed_string_t tunnel_type;
10938 cmdline_fixed_string_t tunnel_id;
10939 uint32_t tunnel_id_value;
10940 cmdline_fixed_string_t packet;
10945 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10948 const char *p, *p0 = q_arg;
10950 unsigned long int_fld;
10951 char *str_fld[max_num];
10956 p = strchr(p0, '(');
10960 p0 = strchr(p, ')');
10965 if (size >= sizeof(s))
10968 snprintf(s, sizeof(s), "%.*s", size, p);
10969 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10970 if (ret < 0 || ret > max_num)
10972 for (i = 0; i < ret; i++) {
10974 int_fld = strtoul(str_fld[i], &end, 0);
10975 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10977 flexbytes[i] = (uint8_t)int_fld;
10983 str2flowtype(char *string)
10986 static const struct {
10989 } flowtype_str[] = {
10990 {"raw", RTE_ETH_FLOW_RAW},
10991 {"ipv4", RTE_ETH_FLOW_IPV4},
10992 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10993 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10994 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10995 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10996 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10997 {"ipv6", RTE_ETH_FLOW_IPV6},
10998 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10999 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11000 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11001 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11002 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11003 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11006 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11007 if (!strcmp(flowtype_str[i].str, string))
11008 return flowtype_str[i].type;
11011 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11012 return (uint16_t)atoi(string);
11014 return RTE_ETH_FLOW_UNKNOWN;
11017 static enum rte_eth_fdir_tunnel_type
11018 str2fdir_tunneltype(char *string)
11022 static const struct {
11024 enum rte_eth_fdir_tunnel_type type;
11025 } tunneltype_str[] = {
11026 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11027 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11030 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11031 if (!strcmp(tunneltype_str[i].str, string))
11032 return tunneltype_str[i].type;
11034 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11037 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11039 if ((ip_addr).family == AF_INET) \
11040 (ip) = (ip_addr).addr.ipv4.s_addr; \
11042 printf("invalid parameter.\n"); \
11047 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11049 if ((ip_addr).family == AF_INET6) \
11050 rte_memcpy(&(ip), \
11051 &((ip_addr).addr.ipv6), \
11052 sizeof(struct in6_addr)); \
11054 printf("invalid parameter.\n"); \
11060 cmd_flow_director_filter_parsed(void *parsed_result,
11061 __rte_unused struct cmdline *cl,
11062 __rte_unused void *data)
11064 struct cmd_flow_director_result *res = parsed_result;
11065 struct rte_eth_fdir_filter entry;
11066 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11068 unsigned long vf_id;
11071 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11073 printf("flow director is not supported on port %u.\n",
11077 memset(flexbytes, 0, sizeof(flexbytes));
11078 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11080 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11081 if (strcmp(res->mode_value, "MAC-VLAN")) {
11082 printf("Please set mode to MAC-VLAN.\n");
11085 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11086 if (strcmp(res->mode_value, "Tunnel")) {
11087 printf("Please set mode to Tunnel.\n");
11091 if (!strcmp(res->mode_value, "raw")) {
11092 #ifdef RTE_LIBRTE_I40E_PMD
11093 struct rte_pmd_i40e_flow_type_mapping
11094 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11095 struct rte_pmd_i40e_pkt_template_conf conf;
11096 uint16_t flow_type = str2flowtype(res->flow_type);
11097 uint16_t i, port = res->port_id;
11100 memset(&conf, 0, sizeof(conf));
11102 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11103 printf("Invalid flow type specified.\n");
11106 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11110 if (mapping[flow_type].pctype == 0ULL) {
11111 printf("Invalid flow type specified.\n");
11114 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11115 if (mapping[flow_type].pctype & (1ULL << i)) {
11116 conf.input.pctype = i;
11121 conf.input.packet = open_file(res->filepath,
11122 &conf.input.length);
11123 if (!conf.input.packet)
11125 if (!strcmp(res->drop, "drop"))
11126 conf.action.behavior =
11127 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11129 conf.action.behavior =
11130 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11131 conf.action.report_status =
11132 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11133 conf.action.rx_queue = res->queue_id;
11134 conf.soft_id = res->fd_id_value;
11135 add = strcmp(res->ops, "del") ? 1 : 0;
11136 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11140 printf("flow director config error: (%s)\n",
11142 close_file(conf.input.packet);
11145 } else if (strcmp(res->mode_value, "IP")) {
11146 printf("Please set mode to IP or raw.\n");
11149 entry.input.flow_type = str2flowtype(res->flow_type);
11152 ret = parse_flexbytes(res->flexbytes_value,
11154 RTE_ETH_FDIR_MAX_FLEXLEN);
11156 printf("error: Cannot parse flexbytes input.\n");
11160 switch (entry.input.flow_type) {
11161 case RTE_ETH_FLOW_FRAG_IPV4:
11162 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11163 entry.input.flow.ip4_flow.proto = res->proto_value;
11165 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11166 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11167 IPV4_ADDR_TO_UINT(res->ip_dst,
11168 entry.input.flow.ip4_flow.dst_ip);
11169 IPV4_ADDR_TO_UINT(res->ip_src,
11170 entry.input.flow.ip4_flow.src_ip);
11171 entry.input.flow.ip4_flow.tos = res->tos_value;
11172 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11173 /* need convert to big endian. */
11174 entry.input.flow.udp4_flow.dst_port =
11175 rte_cpu_to_be_16(res->port_dst);
11176 entry.input.flow.udp4_flow.src_port =
11177 rte_cpu_to_be_16(res->port_src);
11179 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11180 IPV4_ADDR_TO_UINT(res->ip_dst,
11181 entry.input.flow.sctp4_flow.ip.dst_ip);
11182 IPV4_ADDR_TO_UINT(res->ip_src,
11183 entry.input.flow.sctp4_flow.ip.src_ip);
11184 entry.input.flow.ip4_flow.tos = res->tos_value;
11185 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11186 /* need convert to big endian. */
11187 entry.input.flow.sctp4_flow.dst_port =
11188 rte_cpu_to_be_16(res->port_dst);
11189 entry.input.flow.sctp4_flow.src_port =
11190 rte_cpu_to_be_16(res->port_src);
11191 entry.input.flow.sctp4_flow.verify_tag =
11192 rte_cpu_to_be_32(res->verify_tag_value);
11194 case RTE_ETH_FLOW_FRAG_IPV6:
11195 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11196 entry.input.flow.ipv6_flow.proto = res->proto_value;
11198 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11199 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11200 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11201 entry.input.flow.ipv6_flow.dst_ip);
11202 IPV6_ADDR_TO_ARRAY(res->ip_src,
11203 entry.input.flow.ipv6_flow.src_ip);
11204 entry.input.flow.ipv6_flow.tc = res->tos_value;
11205 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11206 /* need convert to big endian. */
11207 entry.input.flow.udp6_flow.dst_port =
11208 rte_cpu_to_be_16(res->port_dst);
11209 entry.input.flow.udp6_flow.src_port =
11210 rte_cpu_to_be_16(res->port_src);
11212 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11213 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11214 entry.input.flow.sctp6_flow.ip.dst_ip);
11215 IPV6_ADDR_TO_ARRAY(res->ip_src,
11216 entry.input.flow.sctp6_flow.ip.src_ip);
11217 entry.input.flow.ipv6_flow.tc = res->tos_value;
11218 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11219 /* need convert to big endian. */
11220 entry.input.flow.sctp6_flow.dst_port =
11221 rte_cpu_to_be_16(res->port_dst);
11222 entry.input.flow.sctp6_flow.src_port =
11223 rte_cpu_to_be_16(res->port_src);
11224 entry.input.flow.sctp6_flow.verify_tag =
11225 rte_cpu_to_be_32(res->verify_tag_value);
11227 case RTE_ETH_FLOW_L2_PAYLOAD:
11228 entry.input.flow.l2_flow.ether_type =
11229 rte_cpu_to_be_16(res->ether_type);
11235 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11236 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11238 sizeof(struct rte_ether_addr));
11240 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11241 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11243 sizeof(struct rte_ether_addr));
11244 entry.input.flow.tunnel_flow.tunnel_type =
11245 str2fdir_tunneltype(res->tunnel_type);
11246 entry.input.flow.tunnel_flow.tunnel_id =
11247 rte_cpu_to_be_32(res->tunnel_id_value);
11250 rte_memcpy(entry.input.flow_ext.flexbytes,
11252 RTE_ETH_FDIR_MAX_FLEXLEN);
11254 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11256 entry.action.flex_off = 0; /*use 0 by default */
11257 if (!strcmp(res->drop, "drop"))
11258 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11260 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11262 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11263 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11264 if (!strcmp(res->pf_vf, "pf"))
11265 entry.input.flow_ext.is_vf = 0;
11266 else if (!strncmp(res->pf_vf, "vf", 2)) {
11267 struct rte_eth_dev_info dev_info;
11269 ret = eth_dev_info_get_print_err(res->port_id,
11275 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11276 if (errno != 0 || *end != '\0' ||
11277 vf_id >= dev_info.max_vfs) {
11278 printf("invalid parameter %s.\n", res->pf_vf);
11281 entry.input.flow_ext.is_vf = 1;
11282 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11284 printf("invalid parameter %s.\n", res->pf_vf);
11289 /* set to report FD ID by default */
11290 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11291 entry.action.rx_queue = res->queue_id;
11292 entry.soft_id = res->fd_id_value;
11293 if (!strcmp(res->ops, "add"))
11294 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11295 RTE_ETH_FILTER_ADD, &entry);
11296 else if (!strcmp(res->ops, "del"))
11297 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11298 RTE_ETH_FILTER_DELETE, &entry);
11300 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11301 RTE_ETH_FILTER_UPDATE, &entry);
11303 printf("flow director programming error: (%s)\n",
11307 cmdline_parse_token_string_t cmd_flow_director_filter =
11308 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11309 flow_director_filter, "flow_director_filter");
11310 cmdline_parse_token_num_t cmd_flow_director_port_id =
11311 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11313 cmdline_parse_token_string_t cmd_flow_director_ops =
11314 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11315 ops, "add#del#update");
11316 cmdline_parse_token_string_t cmd_flow_director_flow =
11317 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11319 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11320 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11322 cmdline_parse_token_string_t cmd_flow_director_ether =
11323 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11325 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11326 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11327 ether_type, UINT16);
11328 cmdline_parse_token_string_t cmd_flow_director_src =
11329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11331 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11332 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11334 cmdline_parse_token_num_t cmd_flow_director_port_src =
11335 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11337 cmdline_parse_token_string_t cmd_flow_director_dst =
11338 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11340 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11341 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11343 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11344 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11346 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11348 verify_tag, "verify_tag");
11349 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11350 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11351 verify_tag_value, UINT32);
11352 cmdline_parse_token_string_t cmd_flow_director_tos =
11353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11355 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11356 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11358 cmdline_parse_token_string_t cmd_flow_director_proto =
11359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11361 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11362 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11363 proto_value, UINT8);
11364 cmdline_parse_token_string_t cmd_flow_director_ttl =
11365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11367 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11368 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11370 cmdline_parse_token_string_t cmd_flow_director_vlan =
11371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11373 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11374 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11375 vlan_value, UINT16);
11376 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11377 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11378 flexbytes, "flexbytes");
11379 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11380 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11381 flexbytes_value, NULL);
11382 cmdline_parse_token_string_t cmd_flow_director_drop =
11383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11385 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11386 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11388 cmdline_parse_token_string_t cmd_flow_director_queue =
11389 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11391 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11392 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11394 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11395 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11397 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11398 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11399 fd_id_value, UINT32);
11401 cmdline_parse_token_string_t cmd_flow_director_mode =
11402 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11404 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11407 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11408 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11409 mode_value, "MAC-VLAN");
11410 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11411 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11412 mode_value, "Tunnel");
11413 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11414 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11415 mode_value, "raw");
11416 cmdline_parse_token_string_t cmd_flow_director_mac =
11417 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11419 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11420 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11422 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11423 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11425 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11426 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11427 tunnel_type, "NVGRE#VxLAN");
11428 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11430 tunnel_id, "tunnel-id");
11431 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11432 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11433 tunnel_id_value, UINT32);
11434 cmdline_parse_token_string_t cmd_flow_director_packet =
11435 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11437 cmdline_parse_token_string_t cmd_flow_director_filepath =
11438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11441 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11442 .f = cmd_flow_director_filter_parsed,
11444 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11445 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11446 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11447 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11448 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11449 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11450 "fd_id <fd_id_value>: "
11451 "Add or delete an ip flow director entry on NIC",
11453 (void *)&cmd_flow_director_filter,
11454 (void *)&cmd_flow_director_port_id,
11455 (void *)&cmd_flow_director_mode,
11456 (void *)&cmd_flow_director_mode_ip,
11457 (void *)&cmd_flow_director_ops,
11458 (void *)&cmd_flow_director_flow,
11459 (void *)&cmd_flow_director_flow_type,
11460 (void *)&cmd_flow_director_src,
11461 (void *)&cmd_flow_director_ip_src,
11462 (void *)&cmd_flow_director_dst,
11463 (void *)&cmd_flow_director_ip_dst,
11464 (void *)&cmd_flow_director_tos,
11465 (void *)&cmd_flow_director_tos_value,
11466 (void *)&cmd_flow_director_proto,
11467 (void *)&cmd_flow_director_proto_value,
11468 (void *)&cmd_flow_director_ttl,
11469 (void *)&cmd_flow_director_ttl_value,
11470 (void *)&cmd_flow_director_vlan,
11471 (void *)&cmd_flow_director_vlan_value,
11472 (void *)&cmd_flow_director_flexbytes,
11473 (void *)&cmd_flow_director_flexbytes_value,
11474 (void *)&cmd_flow_director_drop,
11475 (void *)&cmd_flow_director_pf_vf,
11476 (void *)&cmd_flow_director_queue,
11477 (void *)&cmd_flow_director_queue_id,
11478 (void *)&cmd_flow_director_fd_id,
11479 (void *)&cmd_flow_director_fd_id_value,
11484 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11485 .f = cmd_flow_director_filter_parsed,
11487 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11488 "director entry on NIC",
11490 (void *)&cmd_flow_director_filter,
11491 (void *)&cmd_flow_director_port_id,
11492 (void *)&cmd_flow_director_mode,
11493 (void *)&cmd_flow_director_mode_ip,
11494 (void *)&cmd_flow_director_ops,
11495 (void *)&cmd_flow_director_flow,
11496 (void *)&cmd_flow_director_flow_type,
11497 (void *)&cmd_flow_director_src,
11498 (void *)&cmd_flow_director_ip_src,
11499 (void *)&cmd_flow_director_port_src,
11500 (void *)&cmd_flow_director_dst,
11501 (void *)&cmd_flow_director_ip_dst,
11502 (void *)&cmd_flow_director_port_dst,
11503 (void *)&cmd_flow_director_tos,
11504 (void *)&cmd_flow_director_tos_value,
11505 (void *)&cmd_flow_director_ttl,
11506 (void *)&cmd_flow_director_ttl_value,
11507 (void *)&cmd_flow_director_vlan,
11508 (void *)&cmd_flow_director_vlan_value,
11509 (void *)&cmd_flow_director_flexbytes,
11510 (void *)&cmd_flow_director_flexbytes_value,
11511 (void *)&cmd_flow_director_drop,
11512 (void *)&cmd_flow_director_pf_vf,
11513 (void *)&cmd_flow_director_queue,
11514 (void *)&cmd_flow_director_queue_id,
11515 (void *)&cmd_flow_director_fd_id,
11516 (void *)&cmd_flow_director_fd_id_value,
11521 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11522 .f = cmd_flow_director_filter_parsed,
11524 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11525 "director entry on NIC",
11527 (void *)&cmd_flow_director_filter,
11528 (void *)&cmd_flow_director_port_id,
11529 (void *)&cmd_flow_director_mode,
11530 (void *)&cmd_flow_director_mode_ip,
11531 (void *)&cmd_flow_director_ops,
11532 (void *)&cmd_flow_director_flow,
11533 (void *)&cmd_flow_director_flow_type,
11534 (void *)&cmd_flow_director_src,
11535 (void *)&cmd_flow_director_ip_src,
11536 (void *)&cmd_flow_director_port_src,
11537 (void *)&cmd_flow_director_dst,
11538 (void *)&cmd_flow_director_ip_dst,
11539 (void *)&cmd_flow_director_port_dst,
11540 (void *)&cmd_flow_director_verify_tag,
11541 (void *)&cmd_flow_director_verify_tag_value,
11542 (void *)&cmd_flow_director_tos,
11543 (void *)&cmd_flow_director_tos_value,
11544 (void *)&cmd_flow_director_ttl,
11545 (void *)&cmd_flow_director_ttl_value,
11546 (void *)&cmd_flow_director_vlan,
11547 (void *)&cmd_flow_director_vlan_value,
11548 (void *)&cmd_flow_director_flexbytes,
11549 (void *)&cmd_flow_director_flexbytes_value,
11550 (void *)&cmd_flow_director_drop,
11551 (void *)&cmd_flow_director_pf_vf,
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_l2_flow_director = {
11561 .f = cmd_flow_director_filter_parsed,
11563 .help_str = "flow_director_filter ... : Add or delete a L2 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_ip,
11570 (void *)&cmd_flow_director_ops,
11571 (void *)&cmd_flow_director_flow,
11572 (void *)&cmd_flow_director_flow_type,
11573 (void *)&cmd_flow_director_ether,
11574 (void *)&cmd_flow_director_ether_type,
11575 (void *)&cmd_flow_director_flexbytes,
11576 (void *)&cmd_flow_director_flexbytes_value,
11577 (void *)&cmd_flow_director_drop,
11578 (void *)&cmd_flow_director_pf_vf,
11579 (void *)&cmd_flow_director_queue,
11580 (void *)&cmd_flow_director_queue_id,
11581 (void *)&cmd_flow_director_fd_id,
11582 (void *)&cmd_flow_director_fd_id_value,
11587 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11588 .f = cmd_flow_director_filter_parsed,
11590 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11591 "director entry on NIC",
11593 (void *)&cmd_flow_director_filter,
11594 (void *)&cmd_flow_director_port_id,
11595 (void *)&cmd_flow_director_mode,
11596 (void *)&cmd_flow_director_mode_mac_vlan,
11597 (void *)&cmd_flow_director_ops,
11598 (void *)&cmd_flow_director_mac,
11599 (void *)&cmd_flow_director_mac_addr,
11600 (void *)&cmd_flow_director_vlan,
11601 (void *)&cmd_flow_director_vlan_value,
11602 (void *)&cmd_flow_director_flexbytes,
11603 (void *)&cmd_flow_director_flexbytes_value,
11604 (void *)&cmd_flow_director_drop,
11605 (void *)&cmd_flow_director_queue,
11606 (void *)&cmd_flow_director_queue_id,
11607 (void *)&cmd_flow_director_fd_id,
11608 (void *)&cmd_flow_director_fd_id_value,
11613 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11614 .f = cmd_flow_director_filter_parsed,
11616 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11617 "director entry on NIC",
11619 (void *)&cmd_flow_director_filter,
11620 (void *)&cmd_flow_director_port_id,
11621 (void *)&cmd_flow_director_mode,
11622 (void *)&cmd_flow_director_mode_tunnel,
11623 (void *)&cmd_flow_director_ops,
11624 (void *)&cmd_flow_director_mac,
11625 (void *)&cmd_flow_director_mac_addr,
11626 (void *)&cmd_flow_director_vlan,
11627 (void *)&cmd_flow_director_vlan_value,
11628 (void *)&cmd_flow_director_tunnel,
11629 (void *)&cmd_flow_director_tunnel_type,
11630 (void *)&cmd_flow_director_tunnel_id,
11631 (void *)&cmd_flow_director_tunnel_id_value,
11632 (void *)&cmd_flow_director_flexbytes,
11633 (void *)&cmd_flow_director_flexbytes_value,
11634 (void *)&cmd_flow_director_drop,
11635 (void *)&cmd_flow_director_queue,
11636 (void *)&cmd_flow_director_queue_id,
11637 (void *)&cmd_flow_director_fd_id,
11638 (void *)&cmd_flow_director_fd_id_value,
11643 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11644 .f = cmd_flow_director_filter_parsed,
11646 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11647 "director entry on NIC",
11649 (void *)&cmd_flow_director_filter,
11650 (void *)&cmd_flow_director_port_id,
11651 (void *)&cmd_flow_director_mode,
11652 (void *)&cmd_flow_director_mode_raw,
11653 (void *)&cmd_flow_director_ops,
11654 (void *)&cmd_flow_director_flow,
11655 (void *)&cmd_flow_director_flow_type,
11656 (void *)&cmd_flow_director_drop,
11657 (void *)&cmd_flow_director_queue,
11658 (void *)&cmd_flow_director_queue_id,
11659 (void *)&cmd_flow_director_fd_id,
11660 (void *)&cmd_flow_director_fd_id_value,
11661 (void *)&cmd_flow_director_packet,
11662 (void *)&cmd_flow_director_filepath,
11667 struct cmd_flush_flow_director_result {
11668 cmdline_fixed_string_t flush_flow_director;
11672 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11673 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11674 flush_flow_director, "flush_flow_director");
11675 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11676 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11680 cmd_flush_flow_director_parsed(void *parsed_result,
11681 __rte_unused struct cmdline *cl,
11682 __rte_unused void *data)
11684 struct cmd_flow_director_result *res = parsed_result;
11687 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11689 printf("flow director is not supported on port %u.\n",
11694 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11695 RTE_ETH_FILTER_FLUSH, NULL);
11697 printf("flow director table flushing error: (%s)\n",
11701 cmdline_parse_inst_t cmd_flush_flow_director = {
11702 .f = cmd_flush_flow_director_parsed,
11704 .help_str = "flush_flow_director <port_id>: "
11705 "Flush all flow director entries of a device on NIC",
11707 (void *)&cmd_flush_flow_director_flush,
11708 (void *)&cmd_flush_flow_director_port_id,
11713 /* *** deal with flow director mask *** */
11714 struct cmd_flow_director_mask_result {
11715 cmdline_fixed_string_t flow_director_mask;
11717 cmdline_fixed_string_t mode;
11718 cmdline_fixed_string_t mode_value;
11719 cmdline_fixed_string_t vlan;
11720 uint16_t vlan_mask;
11721 cmdline_fixed_string_t src_mask;
11722 cmdline_ipaddr_t ipv4_src;
11723 cmdline_ipaddr_t ipv6_src;
11725 cmdline_fixed_string_t dst_mask;
11726 cmdline_ipaddr_t ipv4_dst;
11727 cmdline_ipaddr_t ipv6_dst;
11729 cmdline_fixed_string_t mac;
11730 uint8_t mac_addr_byte_mask;
11731 cmdline_fixed_string_t tunnel_id;
11732 uint32_t tunnel_id_mask;
11733 cmdline_fixed_string_t tunnel_type;
11734 uint8_t tunnel_type_mask;
11738 cmd_flow_director_mask_parsed(void *parsed_result,
11739 __rte_unused struct cmdline *cl,
11740 __rte_unused void *data)
11742 struct cmd_flow_director_mask_result *res = parsed_result;
11743 struct rte_eth_fdir_masks *mask;
11744 struct rte_port *port;
11746 port = &ports[res->port_id];
11747 /** Check if the port is not started **/
11748 if (port->port_status != RTE_PORT_STOPPED) {
11749 printf("Please stop port %d first\n", res->port_id);
11753 mask = &port->dev_conf.fdir_conf.mask;
11755 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11756 if (strcmp(res->mode_value, "MAC-VLAN")) {
11757 printf("Please set mode to MAC-VLAN.\n");
11761 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11762 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11763 if (strcmp(res->mode_value, "Tunnel")) {
11764 printf("Please set mode to Tunnel.\n");
11768 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11769 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11770 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11771 mask->tunnel_type_mask = res->tunnel_type_mask;
11773 if (strcmp(res->mode_value, "IP")) {
11774 printf("Please set mode to IP.\n");
11778 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11779 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11780 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11781 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11782 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11783 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11784 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11787 cmd_reconfig_device_queue(res->port_id, 1, 1);
11790 cmdline_parse_token_string_t cmd_flow_director_mask =
11791 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11792 flow_director_mask, "flow_director_mask");
11793 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11794 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11796 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11797 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11799 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11800 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11801 vlan_mask, UINT16);
11802 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11803 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11804 src_mask, "src_mask");
11805 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11806 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11808 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11809 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11811 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11812 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11814 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11815 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11816 dst_mask, "dst_mask");
11817 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11818 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11820 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11821 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11823 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11824 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11827 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11830 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11831 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11833 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11835 mode_value, "MAC-VLAN");
11836 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11838 mode_value, "Tunnel");
11839 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11842 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11843 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11844 mac_addr_byte_mask, UINT8);
11845 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11846 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11847 tunnel_type, "tunnel-type");
11848 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11849 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11850 tunnel_type_mask, UINT8);
11851 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11853 tunnel_id, "tunnel-id");
11854 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11855 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11856 tunnel_id_mask, UINT32);
11858 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11859 .f = cmd_flow_director_mask_parsed,
11861 .help_str = "flow_director_mask ... : "
11862 "Set IP mode flow director's mask on NIC",
11864 (void *)&cmd_flow_director_mask,
11865 (void *)&cmd_flow_director_mask_port_id,
11866 (void *)&cmd_flow_director_mask_mode,
11867 (void *)&cmd_flow_director_mask_mode_ip,
11868 (void *)&cmd_flow_director_mask_vlan,
11869 (void *)&cmd_flow_director_mask_vlan_value,
11870 (void *)&cmd_flow_director_mask_src,
11871 (void *)&cmd_flow_director_mask_ipv4_src,
11872 (void *)&cmd_flow_director_mask_ipv6_src,
11873 (void *)&cmd_flow_director_mask_port_src,
11874 (void *)&cmd_flow_director_mask_dst,
11875 (void *)&cmd_flow_director_mask_ipv4_dst,
11876 (void *)&cmd_flow_director_mask_ipv6_dst,
11877 (void *)&cmd_flow_director_mask_port_dst,
11882 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11883 .f = cmd_flow_director_mask_parsed,
11885 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11886 "flow director's mask on NIC",
11888 (void *)&cmd_flow_director_mask,
11889 (void *)&cmd_flow_director_mask_port_id,
11890 (void *)&cmd_flow_director_mask_mode,
11891 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11892 (void *)&cmd_flow_director_mask_vlan,
11893 (void *)&cmd_flow_director_mask_vlan_value,
11898 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11899 .f = cmd_flow_director_mask_parsed,
11901 .help_str = "flow_director_mask ... : Set tunnel mode "
11902 "flow director's mask on NIC",
11904 (void *)&cmd_flow_director_mask,
11905 (void *)&cmd_flow_director_mask_port_id,
11906 (void *)&cmd_flow_director_mask_mode,
11907 (void *)&cmd_flow_director_mask_mode_tunnel,
11908 (void *)&cmd_flow_director_mask_vlan,
11909 (void *)&cmd_flow_director_mask_vlan_value,
11910 (void *)&cmd_flow_director_mask_mac,
11911 (void *)&cmd_flow_director_mask_mac_value,
11912 (void *)&cmd_flow_director_mask_tunnel_type,
11913 (void *)&cmd_flow_director_mask_tunnel_type_value,
11914 (void *)&cmd_flow_director_mask_tunnel_id,
11915 (void *)&cmd_flow_director_mask_tunnel_id_value,
11920 /* *** deal with flow director mask on flexible payload *** */
11921 struct cmd_flow_director_flex_mask_result {
11922 cmdline_fixed_string_t flow_director_flexmask;
11924 cmdline_fixed_string_t flow;
11925 cmdline_fixed_string_t flow_type;
11926 cmdline_fixed_string_t mask;
11930 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11931 __rte_unused struct cmdline *cl,
11932 __rte_unused void *data)
11934 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11935 struct rte_eth_fdir_info fdir_info;
11936 struct rte_eth_fdir_flex_mask flex_mask;
11937 struct rte_port *port;
11938 uint64_t flow_type_mask;
11942 port = &ports[res->port_id];
11943 /** Check if the port is not started **/
11944 if (port->port_status != RTE_PORT_STOPPED) {
11945 printf("Please stop port %d first\n", res->port_id);
11949 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11950 ret = parse_flexbytes(res->mask,
11952 RTE_ETH_FDIR_MAX_FLEXLEN);
11954 printf("error: Cannot parse mask input.\n");
11958 memset(&fdir_info, 0, sizeof(fdir_info));
11959 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11960 RTE_ETH_FILTER_INFO, &fdir_info);
11962 printf("Cannot get FDir filter info\n");
11966 if (!strcmp(res->flow_type, "none")) {
11967 /* means don't specify the flow type */
11968 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11969 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11970 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11971 0, sizeof(struct rte_eth_fdir_flex_mask));
11972 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11973 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11975 sizeof(struct rte_eth_fdir_flex_mask));
11976 cmd_reconfig_device_queue(res->port_id, 1, 1);
11979 flow_type_mask = fdir_info.flow_types_mask[0];
11980 if (!strcmp(res->flow_type, "all")) {
11981 if (!flow_type_mask) {
11982 printf("No flow type supported\n");
11985 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11986 if (flow_type_mask & (1ULL << i)) {
11987 flex_mask.flow_type = i;
11988 fdir_set_flex_mask(res->port_id, &flex_mask);
11991 cmd_reconfig_device_queue(res->port_id, 1, 1);
11994 flex_mask.flow_type = str2flowtype(res->flow_type);
11995 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11996 printf("Flow type %s not supported on port %d\n",
11997 res->flow_type, res->port_id);
12000 fdir_set_flex_mask(res->port_id, &flex_mask);
12001 cmd_reconfig_device_queue(res->port_id, 1, 1);
12004 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12005 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12006 flow_director_flexmask,
12007 "flow_director_flex_mask");
12008 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12009 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12011 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12012 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12014 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12015 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12016 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12017 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12018 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12019 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12022 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12023 .f = cmd_flow_director_flex_mask_parsed,
12025 .help_str = "flow_director_flex_mask ... : "
12026 "Set flow director's flex mask on NIC",
12028 (void *)&cmd_flow_director_flexmask,
12029 (void *)&cmd_flow_director_flexmask_port_id,
12030 (void *)&cmd_flow_director_flexmask_flow,
12031 (void *)&cmd_flow_director_flexmask_flow_type,
12032 (void *)&cmd_flow_director_flexmask_mask,
12037 /* *** deal with flow director flexible payload configuration *** */
12038 struct cmd_flow_director_flexpayload_result {
12039 cmdline_fixed_string_t flow_director_flexpayload;
12041 cmdline_fixed_string_t payload_layer;
12042 cmdline_fixed_string_t payload_cfg;
12046 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12049 const char *p, *p0 = q_arg;
12051 unsigned long int_fld;
12052 char *str_fld[max_num];
12057 p = strchr(p0, '(');
12061 p0 = strchr(p, ')');
12066 if (size >= sizeof(s))
12069 snprintf(s, sizeof(s), "%.*s", size, p);
12070 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12071 if (ret < 0 || ret > max_num)
12073 for (i = 0; i < ret; i++) {
12075 int_fld = strtoul(str_fld[i], &end, 0);
12076 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12078 offsets[i] = (uint16_t)int_fld;
12084 cmd_flow_director_flxpld_parsed(void *parsed_result,
12085 __rte_unused struct cmdline *cl,
12086 __rte_unused void *data)
12088 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12089 struct rte_eth_flex_payload_cfg flex_cfg;
12090 struct rte_port *port;
12093 port = &ports[res->port_id];
12094 /** Check if the port is not started **/
12095 if (port->port_status != RTE_PORT_STOPPED) {
12096 printf("Please stop port %d first\n", res->port_id);
12100 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12102 if (!strcmp(res->payload_layer, "raw"))
12103 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12104 else if (!strcmp(res->payload_layer, "l2"))
12105 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12106 else if (!strcmp(res->payload_layer, "l3"))
12107 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12108 else if (!strcmp(res->payload_layer, "l4"))
12109 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12111 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12112 RTE_ETH_FDIR_MAX_FLEXLEN);
12114 printf("error: Cannot parse flex payload input.\n");
12118 fdir_set_flex_payload(res->port_id, &flex_cfg);
12119 cmd_reconfig_device_queue(res->port_id, 1, 1);
12122 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12123 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12124 flow_director_flexpayload,
12125 "flow_director_flex_payload");
12126 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12127 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12129 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12131 payload_layer, "raw#l2#l3#l4");
12132 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12133 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12134 payload_cfg, NULL);
12136 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12137 .f = cmd_flow_director_flxpld_parsed,
12139 .help_str = "flow_director_flexpayload ... : "
12140 "Set flow director's flex payload on NIC",
12142 (void *)&cmd_flow_director_flexpayload,
12143 (void *)&cmd_flow_director_flexpayload_port_id,
12144 (void *)&cmd_flow_director_flexpayload_payload_layer,
12145 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12150 /* Generic flow interface command. */
12151 extern cmdline_parse_inst_t cmd_flow;
12153 /* *** Classification Filters Control *** */
12154 /* *** Get symmetric hash enable per port *** */
12155 struct cmd_get_sym_hash_ena_per_port_result {
12156 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12161 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12162 __rte_unused struct cmdline *cl,
12163 __rte_unused void *data)
12165 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12166 struct rte_eth_hash_filter_info info;
12169 if (rte_eth_dev_filter_supported(res->port_id,
12170 RTE_ETH_FILTER_HASH) < 0) {
12171 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12176 memset(&info, 0, sizeof(info));
12177 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12178 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12179 RTE_ETH_FILTER_GET, &info);
12182 printf("Cannot get symmetric hash enable per port "
12183 "on port %u\n", res->port_id);
12187 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12188 "enabled" : "disabled", res->port_id);
12191 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12192 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12193 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12194 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12195 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12198 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12199 .f = cmd_get_sym_hash_per_port_parsed,
12201 .help_str = "get_sym_hash_ena_per_port <port_id>",
12203 (void *)&cmd_get_sym_hash_ena_per_port_all,
12204 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12209 /* *** Set symmetric hash enable per port *** */
12210 struct cmd_set_sym_hash_ena_per_port_result {
12211 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12212 cmdline_fixed_string_t enable;
12217 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12218 __rte_unused struct cmdline *cl,
12219 __rte_unused void *data)
12221 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12222 struct rte_eth_hash_filter_info info;
12225 if (rte_eth_dev_filter_supported(res->port_id,
12226 RTE_ETH_FILTER_HASH) < 0) {
12227 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12232 memset(&info, 0, sizeof(info));
12233 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12234 if (!strcmp(res->enable, "enable"))
12235 info.info.enable = 1;
12236 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12237 RTE_ETH_FILTER_SET, &info);
12239 printf("Cannot set symmetric hash enable per port on "
12240 "port %u\n", res->port_id);
12243 printf("Symmetric hash has been set to %s on port %u\n",
12244 res->enable, res->port_id);
12247 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12248 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12249 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12250 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12251 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12253 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12254 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12255 enable, "enable#disable");
12257 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12258 .f = cmd_set_sym_hash_per_port_parsed,
12260 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12262 (void *)&cmd_set_sym_hash_ena_per_port_all,
12263 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12264 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12269 /* Get global config of hash function */
12270 struct cmd_get_hash_global_config_result {
12271 cmdline_fixed_string_t get_hash_global_config;
12276 flowtype_to_str(uint16_t ftype)
12282 } ftype_table[] = {
12283 {"ipv4", RTE_ETH_FLOW_IPV4},
12284 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12285 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12286 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12287 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12288 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12289 {"ipv6", RTE_ETH_FLOW_IPV6},
12290 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12291 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12292 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12293 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12294 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12295 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12296 {"port", RTE_ETH_FLOW_PORT},
12297 {"vxlan", RTE_ETH_FLOW_VXLAN},
12298 {"geneve", RTE_ETH_FLOW_GENEVE},
12299 {"nvgre", RTE_ETH_FLOW_NVGRE},
12300 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12303 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12304 if (ftype_table[i].ftype == ftype)
12305 return ftype_table[i].str;
12312 cmd_get_hash_global_config_parsed(void *parsed_result,
12313 __rte_unused struct cmdline *cl,
12314 __rte_unused void *data)
12316 struct cmd_get_hash_global_config_result *res = parsed_result;
12317 struct rte_eth_hash_filter_info info;
12318 uint32_t idx, offset;
12323 if (rte_eth_dev_filter_supported(res->port_id,
12324 RTE_ETH_FILTER_HASH) < 0) {
12325 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12330 memset(&info, 0, sizeof(info));
12331 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12332 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12333 RTE_ETH_FILTER_GET, &info);
12335 printf("Cannot get hash global configurations by port %d\n",
12340 switch (info.info.global_conf.hash_func) {
12341 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12342 printf("Hash function is Toeplitz\n");
12344 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12345 printf("Hash function is Simple XOR\n");
12347 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12348 printf("Hash function is Symmetric Toeplitz\n");
12351 printf("Unknown hash function\n");
12355 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12356 idx = i / UINT64_BIT;
12357 offset = i % UINT64_BIT;
12358 if (!(info.info.global_conf.valid_bit_mask[idx] &
12361 str = flowtype_to_str(i);
12364 printf("Symmetric hash is %s globally for flow type %s "
12366 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12367 (1ULL << offset)) ? "enabled" : "disabled"), str,
12372 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12373 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12374 get_hash_global_config, "get_hash_global_config");
12375 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12376 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12379 cmdline_parse_inst_t cmd_get_hash_global_config = {
12380 .f = cmd_get_hash_global_config_parsed,
12382 .help_str = "get_hash_global_config <port_id>",
12384 (void *)&cmd_get_hash_global_config_all,
12385 (void *)&cmd_get_hash_global_config_port_id,
12390 /* Set global config of hash function */
12391 struct cmd_set_hash_global_config_result {
12392 cmdline_fixed_string_t set_hash_global_config;
12394 cmdline_fixed_string_t hash_func;
12395 cmdline_fixed_string_t flow_type;
12396 cmdline_fixed_string_t enable;
12400 cmd_set_hash_global_config_parsed(void *parsed_result,
12401 __rte_unused struct cmdline *cl,
12402 __rte_unused void *data)
12404 struct cmd_set_hash_global_config_result *res = parsed_result;
12405 struct rte_eth_hash_filter_info info;
12406 uint32_t ftype, idx, offset;
12409 if (rte_eth_dev_filter_supported(res->port_id,
12410 RTE_ETH_FILTER_HASH) < 0) {
12411 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12415 memset(&info, 0, sizeof(info));
12416 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12417 if (!strcmp(res->hash_func, "toeplitz"))
12418 info.info.global_conf.hash_func =
12419 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12420 else if (!strcmp(res->hash_func, "simple_xor"))
12421 info.info.global_conf.hash_func =
12422 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12423 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12424 info.info.global_conf.hash_func =
12425 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12426 else if (!strcmp(res->hash_func, "default"))
12427 info.info.global_conf.hash_func =
12428 RTE_ETH_HASH_FUNCTION_DEFAULT;
12430 ftype = str2flowtype(res->flow_type);
12431 idx = ftype / UINT64_BIT;
12432 offset = ftype % UINT64_BIT;
12433 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12434 if (!strcmp(res->enable, "enable"))
12435 info.info.global_conf.sym_hash_enable_mask[idx] |=
12437 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12438 RTE_ETH_FILTER_SET, &info);
12440 printf("Cannot set global hash configurations by port %d\n",
12443 printf("Global hash configurations have been set "
12444 "successfully by port %d\n", res->port_id);
12447 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12448 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12449 set_hash_global_config, "set_hash_global_config");
12450 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12451 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12453 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12454 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12455 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12456 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12457 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12459 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12460 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12461 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12462 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12463 enable, "enable#disable");
12465 cmdline_parse_inst_t cmd_set_hash_global_config = {
12466 .f = cmd_set_hash_global_config_parsed,
12468 .help_str = "set_hash_global_config <port_id> "
12469 "toeplitz|simple_xor|symmetric_toeplitz|default "
12470 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12471 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12472 "l2_payload enable|disable",
12474 (void *)&cmd_set_hash_global_config_all,
12475 (void *)&cmd_set_hash_global_config_port_id,
12476 (void *)&cmd_set_hash_global_config_hash_func,
12477 (void *)&cmd_set_hash_global_config_flow_type,
12478 (void *)&cmd_set_hash_global_config_enable,
12483 /* Set hash input set */
12484 struct cmd_set_hash_input_set_result {
12485 cmdline_fixed_string_t set_hash_input_set;
12487 cmdline_fixed_string_t flow_type;
12488 cmdline_fixed_string_t inset_field;
12489 cmdline_fixed_string_t select;
12492 static enum rte_eth_input_set_field
12493 str2inset(char *string)
12497 static const struct {
12499 enum rte_eth_input_set_field inset;
12500 } inset_table[] = {
12501 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12502 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12503 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12504 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12505 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12506 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12507 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12508 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12509 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12510 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12511 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12512 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12513 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12514 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12515 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12516 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12517 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12518 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12519 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12520 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12521 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12522 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12523 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12524 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12525 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12526 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12527 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12528 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12529 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12530 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12531 {"none", RTE_ETH_INPUT_SET_NONE},
12534 for (i = 0; i < RTE_DIM(inset_table); i++) {
12535 if (!strcmp(string, inset_table[i].str))
12536 return inset_table[i].inset;
12539 return RTE_ETH_INPUT_SET_UNKNOWN;
12543 cmd_set_hash_input_set_parsed(void *parsed_result,
12544 __rte_unused struct cmdline *cl,
12545 __rte_unused void *data)
12547 struct cmd_set_hash_input_set_result *res = parsed_result;
12548 struct rte_eth_hash_filter_info info;
12550 memset(&info, 0, sizeof(info));
12551 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12552 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12553 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12554 info.info.input_set_conf.inset_size = 1;
12555 if (!strcmp(res->select, "select"))
12556 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12557 else if (!strcmp(res->select, "add"))
12558 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12559 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12560 RTE_ETH_FILTER_SET, &info);
12563 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12564 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12565 set_hash_input_set, "set_hash_input_set");
12566 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12567 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12569 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12570 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12572 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12573 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12575 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12576 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12577 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12578 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12579 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12581 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12582 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12583 select, "select#add");
12585 cmdline_parse_inst_t cmd_set_hash_input_set = {
12586 .f = cmd_set_hash_input_set_parsed,
12588 .help_str = "set_hash_input_set <port_id> "
12589 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12590 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12591 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12592 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12593 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12594 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12595 "fld-7th|fld-8th|none select|add",
12597 (void *)&cmd_set_hash_input_set_cmd,
12598 (void *)&cmd_set_hash_input_set_port_id,
12599 (void *)&cmd_set_hash_input_set_flow_type,
12600 (void *)&cmd_set_hash_input_set_field,
12601 (void *)&cmd_set_hash_input_set_select,
12606 /* Set flow director input set */
12607 struct cmd_set_fdir_input_set_result {
12608 cmdline_fixed_string_t set_fdir_input_set;
12610 cmdline_fixed_string_t flow_type;
12611 cmdline_fixed_string_t inset_field;
12612 cmdline_fixed_string_t select;
12616 cmd_set_fdir_input_set_parsed(void *parsed_result,
12617 __rte_unused struct cmdline *cl,
12618 __rte_unused void *data)
12620 struct cmd_set_fdir_input_set_result *res = parsed_result;
12621 struct rte_eth_fdir_filter_info info;
12623 memset(&info, 0, sizeof(info));
12624 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12625 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12626 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12627 info.info.input_set_conf.inset_size = 1;
12628 if (!strcmp(res->select, "select"))
12629 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12630 else if (!strcmp(res->select, "add"))
12631 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12632 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12633 RTE_ETH_FILTER_SET, &info);
12636 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12637 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12638 set_fdir_input_set, "set_fdir_input_set");
12639 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12640 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12642 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12643 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12645 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12646 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12647 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12648 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12650 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12651 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12652 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12653 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12654 "sctp-veri-tag#none");
12655 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12656 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12657 select, "select#add");
12659 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12660 .f = cmd_set_fdir_input_set_parsed,
12662 .help_str = "set_fdir_input_set <port_id> "
12663 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12664 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12665 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12666 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12667 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12668 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12669 "sctp-veri-tag|none select|add",
12671 (void *)&cmd_set_fdir_input_set_cmd,
12672 (void *)&cmd_set_fdir_input_set_port_id,
12673 (void *)&cmd_set_fdir_input_set_flow_type,
12674 (void *)&cmd_set_fdir_input_set_field,
12675 (void *)&cmd_set_fdir_input_set_select,
12680 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12681 struct cmd_mcast_addr_result {
12682 cmdline_fixed_string_t mcast_addr_cmd;
12683 cmdline_fixed_string_t what;
12685 struct rte_ether_addr mc_addr;
12688 static void cmd_mcast_addr_parsed(void *parsed_result,
12689 __rte_unused struct cmdline *cl,
12690 __rte_unused void *data)
12692 struct cmd_mcast_addr_result *res = parsed_result;
12694 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12695 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12696 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12697 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12698 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12701 if (strcmp(res->what, "add") == 0)
12702 mcast_addr_add(res->port_num, &res->mc_addr);
12704 mcast_addr_remove(res->port_num, &res->mc_addr);
12707 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12708 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12709 mcast_addr_cmd, "mcast_addr");
12710 cmdline_parse_token_string_t cmd_mcast_addr_what =
12711 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12713 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12714 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12715 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12716 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12718 cmdline_parse_inst_t cmd_mcast_addr = {
12719 .f = cmd_mcast_addr_parsed,
12721 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12722 "Add/Remove multicast MAC address on port_id",
12724 (void *)&cmd_mcast_addr_cmd,
12725 (void *)&cmd_mcast_addr_what,
12726 (void *)&cmd_mcast_addr_portnum,
12727 (void *)&cmd_mcast_addr_addr,
12732 /* l2 tunnel config
12733 * only support E-tag now.
12736 /* Ether type config */
12737 struct cmd_config_l2_tunnel_eth_type_result {
12738 cmdline_fixed_string_t port;
12739 cmdline_fixed_string_t config;
12740 cmdline_fixed_string_t all;
12742 cmdline_fixed_string_t l2_tunnel;
12743 cmdline_fixed_string_t l2_tunnel_type;
12744 cmdline_fixed_string_t eth_type;
12745 uint16_t eth_type_val;
12748 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12749 TOKEN_STRING_INITIALIZER
12750 (struct cmd_config_l2_tunnel_eth_type_result,
12752 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12753 TOKEN_STRING_INITIALIZER
12754 (struct cmd_config_l2_tunnel_eth_type_result,
12756 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12757 TOKEN_STRING_INITIALIZER
12758 (struct cmd_config_l2_tunnel_eth_type_result,
12760 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12761 TOKEN_NUM_INITIALIZER
12762 (struct cmd_config_l2_tunnel_eth_type_result,
12764 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12765 TOKEN_STRING_INITIALIZER
12766 (struct cmd_config_l2_tunnel_eth_type_result,
12767 l2_tunnel, "l2-tunnel");
12768 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12769 TOKEN_STRING_INITIALIZER
12770 (struct cmd_config_l2_tunnel_eth_type_result,
12771 l2_tunnel_type, "E-tag");
12772 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12773 TOKEN_STRING_INITIALIZER
12774 (struct cmd_config_l2_tunnel_eth_type_result,
12775 eth_type, "ether-type");
12776 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12777 TOKEN_NUM_INITIALIZER
12778 (struct cmd_config_l2_tunnel_eth_type_result,
12779 eth_type_val, UINT16);
12781 static enum rte_eth_tunnel_type
12782 str2fdir_l2_tunnel_type(char *string)
12786 static const struct {
12788 enum rte_eth_tunnel_type type;
12789 } l2_tunnel_type_str[] = {
12790 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12793 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12794 if (!strcmp(l2_tunnel_type_str[i].str, string))
12795 return l2_tunnel_type_str[i].type;
12797 return RTE_TUNNEL_TYPE_NONE;
12800 /* ether type config for all ports */
12802 cmd_config_l2_tunnel_eth_type_all_parsed
12803 (void *parsed_result,
12804 __rte_unused struct cmdline *cl,
12805 __rte_unused void *data)
12807 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12808 struct rte_eth_l2_tunnel_conf entry;
12811 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12812 entry.ether_type = res->eth_type_val;
12814 RTE_ETH_FOREACH_DEV(pid) {
12815 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12819 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12820 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12822 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12824 (void *)&cmd_config_l2_tunnel_eth_type_port,
12825 (void *)&cmd_config_l2_tunnel_eth_type_config,
12826 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12827 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12828 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12829 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12830 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12835 /* ether type config for a specific port */
12837 cmd_config_l2_tunnel_eth_type_specific_parsed(
12838 void *parsed_result,
12839 __rte_unused struct cmdline *cl,
12840 __rte_unused void *data)
12842 struct cmd_config_l2_tunnel_eth_type_result *res =
12844 struct rte_eth_l2_tunnel_conf entry;
12846 if (port_id_is_invalid(res->id, ENABLED_WARN))
12849 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12850 entry.ether_type = res->eth_type_val;
12852 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12855 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12856 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12858 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12860 (void *)&cmd_config_l2_tunnel_eth_type_port,
12861 (void *)&cmd_config_l2_tunnel_eth_type_config,
12862 (void *)&cmd_config_l2_tunnel_eth_type_id,
12863 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12864 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12865 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12866 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12871 /* Enable/disable l2 tunnel */
12872 struct cmd_config_l2_tunnel_en_dis_result {
12873 cmdline_fixed_string_t port;
12874 cmdline_fixed_string_t config;
12875 cmdline_fixed_string_t all;
12877 cmdline_fixed_string_t l2_tunnel;
12878 cmdline_fixed_string_t l2_tunnel_type;
12879 cmdline_fixed_string_t en_dis;
12882 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12883 TOKEN_STRING_INITIALIZER
12884 (struct cmd_config_l2_tunnel_en_dis_result,
12886 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12887 TOKEN_STRING_INITIALIZER
12888 (struct cmd_config_l2_tunnel_en_dis_result,
12890 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12891 TOKEN_STRING_INITIALIZER
12892 (struct cmd_config_l2_tunnel_en_dis_result,
12894 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12895 TOKEN_NUM_INITIALIZER
12896 (struct cmd_config_l2_tunnel_en_dis_result,
12898 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12899 TOKEN_STRING_INITIALIZER
12900 (struct cmd_config_l2_tunnel_en_dis_result,
12901 l2_tunnel, "l2-tunnel");
12902 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12903 TOKEN_STRING_INITIALIZER
12904 (struct cmd_config_l2_tunnel_en_dis_result,
12905 l2_tunnel_type, "E-tag");
12906 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12907 TOKEN_STRING_INITIALIZER
12908 (struct cmd_config_l2_tunnel_en_dis_result,
12909 en_dis, "enable#disable");
12911 /* enable/disable l2 tunnel for all ports */
12913 cmd_config_l2_tunnel_en_dis_all_parsed(
12914 void *parsed_result,
12915 __rte_unused struct cmdline *cl,
12916 __rte_unused void *data)
12918 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12919 struct rte_eth_l2_tunnel_conf entry;
12923 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12925 if (!strcmp("enable", res->en_dis))
12930 RTE_ETH_FOREACH_DEV(pid) {
12931 rte_eth_dev_l2_tunnel_offload_set(pid,
12933 ETH_L2_TUNNEL_ENABLE_MASK,
12938 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12939 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12941 .help_str = "port config all l2-tunnel E-tag enable|disable",
12943 (void *)&cmd_config_l2_tunnel_en_dis_port,
12944 (void *)&cmd_config_l2_tunnel_en_dis_config,
12945 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12946 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12947 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12948 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12953 /* enable/disable l2 tunnel for a port */
12955 cmd_config_l2_tunnel_en_dis_specific_parsed(
12956 void *parsed_result,
12957 __rte_unused struct cmdline *cl,
12958 __rte_unused void *data)
12960 struct cmd_config_l2_tunnel_en_dis_result *res =
12962 struct rte_eth_l2_tunnel_conf entry;
12964 if (port_id_is_invalid(res->id, ENABLED_WARN))
12967 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12969 if (!strcmp("enable", res->en_dis))
12970 rte_eth_dev_l2_tunnel_offload_set(res->id,
12972 ETH_L2_TUNNEL_ENABLE_MASK,
12975 rte_eth_dev_l2_tunnel_offload_set(res->id,
12977 ETH_L2_TUNNEL_ENABLE_MASK,
12981 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12982 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12984 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12986 (void *)&cmd_config_l2_tunnel_en_dis_port,
12987 (void *)&cmd_config_l2_tunnel_en_dis_config,
12988 (void *)&cmd_config_l2_tunnel_en_dis_id,
12989 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12990 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12991 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12996 /* E-tag configuration */
12998 /* Common result structure for all E-tag configuration */
12999 struct cmd_config_e_tag_result {
13000 cmdline_fixed_string_t e_tag;
13001 cmdline_fixed_string_t set;
13002 cmdline_fixed_string_t insertion;
13003 cmdline_fixed_string_t stripping;
13004 cmdline_fixed_string_t forwarding;
13005 cmdline_fixed_string_t filter;
13006 cmdline_fixed_string_t add;
13007 cmdline_fixed_string_t del;
13008 cmdline_fixed_string_t on;
13009 cmdline_fixed_string_t off;
13010 cmdline_fixed_string_t on_off;
13011 cmdline_fixed_string_t port_tag_id;
13012 uint32_t port_tag_id_val;
13013 cmdline_fixed_string_t e_tag_id;
13014 uint16_t e_tag_id_val;
13015 cmdline_fixed_string_t dst_pool;
13016 uint8_t dst_pool_val;
13017 cmdline_fixed_string_t port;
13019 cmdline_fixed_string_t vf;
13023 /* Common CLI fields for all E-tag configuration */
13024 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13025 TOKEN_STRING_INITIALIZER
13026 (struct cmd_config_e_tag_result,
13028 cmdline_parse_token_string_t cmd_config_e_tag_set =
13029 TOKEN_STRING_INITIALIZER
13030 (struct cmd_config_e_tag_result,
13032 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13033 TOKEN_STRING_INITIALIZER
13034 (struct cmd_config_e_tag_result,
13035 insertion, "insertion");
13036 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13037 TOKEN_STRING_INITIALIZER
13038 (struct cmd_config_e_tag_result,
13039 stripping, "stripping");
13040 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13041 TOKEN_STRING_INITIALIZER
13042 (struct cmd_config_e_tag_result,
13043 forwarding, "forwarding");
13044 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13045 TOKEN_STRING_INITIALIZER
13046 (struct cmd_config_e_tag_result,
13048 cmdline_parse_token_string_t cmd_config_e_tag_add =
13049 TOKEN_STRING_INITIALIZER
13050 (struct cmd_config_e_tag_result,
13052 cmdline_parse_token_string_t cmd_config_e_tag_del =
13053 TOKEN_STRING_INITIALIZER
13054 (struct cmd_config_e_tag_result,
13056 cmdline_parse_token_string_t cmd_config_e_tag_on =
13057 TOKEN_STRING_INITIALIZER
13058 (struct cmd_config_e_tag_result,
13060 cmdline_parse_token_string_t cmd_config_e_tag_off =
13061 TOKEN_STRING_INITIALIZER
13062 (struct cmd_config_e_tag_result,
13064 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13065 TOKEN_STRING_INITIALIZER
13066 (struct cmd_config_e_tag_result,
13068 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13069 TOKEN_STRING_INITIALIZER
13070 (struct cmd_config_e_tag_result,
13071 port_tag_id, "port-tag-id");
13072 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13073 TOKEN_NUM_INITIALIZER
13074 (struct cmd_config_e_tag_result,
13075 port_tag_id_val, UINT32);
13076 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13077 TOKEN_STRING_INITIALIZER
13078 (struct cmd_config_e_tag_result,
13079 e_tag_id, "e-tag-id");
13080 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13081 TOKEN_NUM_INITIALIZER
13082 (struct cmd_config_e_tag_result,
13083 e_tag_id_val, UINT16);
13084 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13085 TOKEN_STRING_INITIALIZER
13086 (struct cmd_config_e_tag_result,
13087 dst_pool, "dst-pool");
13088 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13089 TOKEN_NUM_INITIALIZER
13090 (struct cmd_config_e_tag_result,
13091 dst_pool_val, UINT8);
13092 cmdline_parse_token_string_t cmd_config_e_tag_port =
13093 TOKEN_STRING_INITIALIZER
13094 (struct cmd_config_e_tag_result,
13096 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13097 TOKEN_NUM_INITIALIZER
13098 (struct cmd_config_e_tag_result,
13100 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13101 TOKEN_STRING_INITIALIZER
13102 (struct cmd_config_e_tag_result,
13104 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13105 TOKEN_NUM_INITIALIZER
13106 (struct cmd_config_e_tag_result,
13109 /* E-tag insertion configuration */
13111 cmd_config_e_tag_insertion_en_parsed(
13112 void *parsed_result,
13113 __rte_unused struct cmdline *cl,
13114 __rte_unused void *data)
13116 struct cmd_config_e_tag_result *res =
13118 struct rte_eth_l2_tunnel_conf entry;
13120 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13123 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13124 entry.tunnel_id = res->port_tag_id_val;
13125 entry.vf_id = res->vf_id;
13126 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13128 ETH_L2_TUNNEL_INSERTION_MASK,
13133 cmd_config_e_tag_insertion_dis_parsed(
13134 void *parsed_result,
13135 __rte_unused struct cmdline *cl,
13136 __rte_unused void *data)
13138 struct cmd_config_e_tag_result *res =
13140 struct rte_eth_l2_tunnel_conf entry;
13142 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13145 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13146 entry.vf_id = res->vf_id;
13148 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13150 ETH_L2_TUNNEL_INSERTION_MASK,
13154 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13155 .f = cmd_config_e_tag_insertion_en_parsed,
13157 .help_str = "E-tag ... : E-tag insertion enable",
13159 (void *)&cmd_config_e_tag_e_tag,
13160 (void *)&cmd_config_e_tag_set,
13161 (void *)&cmd_config_e_tag_insertion,
13162 (void *)&cmd_config_e_tag_on,
13163 (void *)&cmd_config_e_tag_port_tag_id,
13164 (void *)&cmd_config_e_tag_port_tag_id_val,
13165 (void *)&cmd_config_e_tag_port,
13166 (void *)&cmd_config_e_tag_port_id,
13167 (void *)&cmd_config_e_tag_vf,
13168 (void *)&cmd_config_e_tag_vf_id,
13173 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13174 .f = cmd_config_e_tag_insertion_dis_parsed,
13176 .help_str = "E-tag ... : E-tag insertion disable",
13178 (void *)&cmd_config_e_tag_e_tag,
13179 (void *)&cmd_config_e_tag_set,
13180 (void *)&cmd_config_e_tag_insertion,
13181 (void *)&cmd_config_e_tag_off,
13182 (void *)&cmd_config_e_tag_port,
13183 (void *)&cmd_config_e_tag_port_id,
13184 (void *)&cmd_config_e_tag_vf,
13185 (void *)&cmd_config_e_tag_vf_id,
13190 /* E-tag stripping configuration */
13192 cmd_config_e_tag_stripping_parsed(
13193 void *parsed_result,
13194 __rte_unused struct cmdline *cl,
13195 __rte_unused void *data)
13197 struct cmd_config_e_tag_result *res =
13199 struct rte_eth_l2_tunnel_conf entry;
13201 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13204 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13206 if (!strcmp(res->on_off, "on"))
13207 rte_eth_dev_l2_tunnel_offload_set
13210 ETH_L2_TUNNEL_STRIPPING_MASK,
13213 rte_eth_dev_l2_tunnel_offload_set
13216 ETH_L2_TUNNEL_STRIPPING_MASK,
13220 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13221 .f = cmd_config_e_tag_stripping_parsed,
13223 .help_str = "E-tag ... : E-tag stripping enable/disable",
13225 (void *)&cmd_config_e_tag_e_tag,
13226 (void *)&cmd_config_e_tag_set,
13227 (void *)&cmd_config_e_tag_stripping,
13228 (void *)&cmd_config_e_tag_on_off,
13229 (void *)&cmd_config_e_tag_port,
13230 (void *)&cmd_config_e_tag_port_id,
13235 /* E-tag forwarding configuration */
13237 cmd_config_e_tag_forwarding_parsed(
13238 void *parsed_result,
13239 __rte_unused struct cmdline *cl,
13240 __rte_unused void *data)
13242 struct cmd_config_e_tag_result *res = parsed_result;
13243 struct rte_eth_l2_tunnel_conf entry;
13245 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13248 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13250 if (!strcmp(res->on_off, "on"))
13251 rte_eth_dev_l2_tunnel_offload_set
13254 ETH_L2_TUNNEL_FORWARDING_MASK,
13257 rte_eth_dev_l2_tunnel_offload_set
13260 ETH_L2_TUNNEL_FORWARDING_MASK,
13264 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13265 .f = cmd_config_e_tag_forwarding_parsed,
13267 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13269 (void *)&cmd_config_e_tag_e_tag,
13270 (void *)&cmd_config_e_tag_set,
13271 (void *)&cmd_config_e_tag_forwarding,
13272 (void *)&cmd_config_e_tag_on_off,
13273 (void *)&cmd_config_e_tag_port,
13274 (void *)&cmd_config_e_tag_port_id,
13279 /* E-tag filter configuration */
13281 cmd_config_e_tag_filter_add_parsed(
13282 void *parsed_result,
13283 __rte_unused struct cmdline *cl,
13284 __rte_unused void *data)
13286 struct cmd_config_e_tag_result *res = parsed_result;
13287 struct rte_eth_l2_tunnel_conf entry;
13290 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13293 if (res->e_tag_id_val > 0x3fff) {
13294 printf("e-tag-id must be equal or less than 0x3fff.\n");
13298 ret = rte_eth_dev_filter_supported(res->port_id,
13299 RTE_ETH_FILTER_L2_TUNNEL);
13301 printf("E-tag filter is not supported on port %u.\n",
13306 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13307 entry.tunnel_id = res->e_tag_id_val;
13308 entry.pool = res->dst_pool_val;
13310 ret = rte_eth_dev_filter_ctrl(res->port_id,
13311 RTE_ETH_FILTER_L2_TUNNEL,
13312 RTE_ETH_FILTER_ADD,
13315 printf("E-tag filter programming error: (%s)\n",
13319 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13320 .f = cmd_config_e_tag_filter_add_parsed,
13322 .help_str = "E-tag ... : E-tag filter add",
13324 (void *)&cmd_config_e_tag_e_tag,
13325 (void *)&cmd_config_e_tag_set,
13326 (void *)&cmd_config_e_tag_filter,
13327 (void *)&cmd_config_e_tag_add,
13328 (void *)&cmd_config_e_tag_e_tag_id,
13329 (void *)&cmd_config_e_tag_e_tag_id_val,
13330 (void *)&cmd_config_e_tag_dst_pool,
13331 (void *)&cmd_config_e_tag_dst_pool_val,
13332 (void *)&cmd_config_e_tag_port,
13333 (void *)&cmd_config_e_tag_port_id,
13339 cmd_config_e_tag_filter_del_parsed(
13340 void *parsed_result,
13341 __rte_unused struct cmdline *cl,
13342 __rte_unused void *data)
13344 struct cmd_config_e_tag_result *res = parsed_result;
13345 struct rte_eth_l2_tunnel_conf entry;
13348 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13351 if (res->e_tag_id_val > 0x3fff) {
13352 printf("e-tag-id must be less than 0x3fff.\n");
13356 ret = rte_eth_dev_filter_supported(res->port_id,
13357 RTE_ETH_FILTER_L2_TUNNEL);
13359 printf("E-tag filter is not supported on port %u.\n",
13364 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13365 entry.tunnel_id = res->e_tag_id_val;
13367 ret = rte_eth_dev_filter_ctrl(res->port_id,
13368 RTE_ETH_FILTER_L2_TUNNEL,
13369 RTE_ETH_FILTER_DELETE,
13372 printf("E-tag filter programming error: (%s)\n",
13376 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13377 .f = cmd_config_e_tag_filter_del_parsed,
13379 .help_str = "E-tag ... : E-tag filter delete",
13381 (void *)&cmd_config_e_tag_e_tag,
13382 (void *)&cmd_config_e_tag_set,
13383 (void *)&cmd_config_e_tag_filter,
13384 (void *)&cmd_config_e_tag_del,
13385 (void *)&cmd_config_e_tag_e_tag_id,
13386 (void *)&cmd_config_e_tag_e_tag_id_val,
13387 (void *)&cmd_config_e_tag_port,
13388 (void *)&cmd_config_e_tag_port_id,
13393 /* vf vlan anti spoof configuration */
13395 /* Common result structure for vf vlan anti spoof */
13396 struct cmd_vf_vlan_anti_spoof_result {
13397 cmdline_fixed_string_t set;
13398 cmdline_fixed_string_t vf;
13399 cmdline_fixed_string_t vlan;
13400 cmdline_fixed_string_t antispoof;
13403 cmdline_fixed_string_t on_off;
13406 /* Common CLI fields for vf vlan anti spoof enable disable */
13407 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13408 TOKEN_STRING_INITIALIZER
13409 (struct cmd_vf_vlan_anti_spoof_result,
13411 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13412 TOKEN_STRING_INITIALIZER
13413 (struct cmd_vf_vlan_anti_spoof_result,
13415 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13416 TOKEN_STRING_INITIALIZER
13417 (struct cmd_vf_vlan_anti_spoof_result,
13419 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13420 TOKEN_STRING_INITIALIZER
13421 (struct cmd_vf_vlan_anti_spoof_result,
13422 antispoof, "antispoof");
13423 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13424 TOKEN_NUM_INITIALIZER
13425 (struct cmd_vf_vlan_anti_spoof_result,
13427 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13428 TOKEN_NUM_INITIALIZER
13429 (struct cmd_vf_vlan_anti_spoof_result,
13431 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13432 TOKEN_STRING_INITIALIZER
13433 (struct cmd_vf_vlan_anti_spoof_result,
13437 cmd_set_vf_vlan_anti_spoof_parsed(
13438 void *parsed_result,
13439 __rte_unused struct cmdline *cl,
13440 __rte_unused void *data)
13442 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13443 int ret = -ENOTSUP;
13445 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13447 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13450 #ifdef RTE_LIBRTE_IXGBE_PMD
13451 if (ret == -ENOTSUP)
13452 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13453 res->vf_id, is_on);
13455 #ifdef RTE_LIBRTE_I40E_PMD
13456 if (ret == -ENOTSUP)
13457 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13458 res->vf_id, is_on);
13460 #ifdef RTE_LIBRTE_BNXT_PMD
13461 if (ret == -ENOTSUP)
13462 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13463 res->vf_id, is_on);
13470 printf("invalid vf_id %d\n", res->vf_id);
13473 printf("invalid port_id %d\n", res->port_id);
13476 printf("function not implemented\n");
13479 printf("programming error: (%s)\n", strerror(-ret));
13483 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13484 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13486 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13488 (void *)&cmd_vf_vlan_anti_spoof_set,
13489 (void *)&cmd_vf_vlan_anti_spoof_vf,
13490 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13491 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13492 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13493 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13494 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13499 /* vf mac anti spoof configuration */
13501 /* Common result structure for vf mac anti spoof */
13502 struct cmd_vf_mac_anti_spoof_result {
13503 cmdline_fixed_string_t set;
13504 cmdline_fixed_string_t vf;
13505 cmdline_fixed_string_t mac;
13506 cmdline_fixed_string_t antispoof;
13509 cmdline_fixed_string_t on_off;
13512 /* Common CLI fields for vf mac anti spoof enable disable */
13513 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13514 TOKEN_STRING_INITIALIZER
13515 (struct cmd_vf_mac_anti_spoof_result,
13517 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13518 TOKEN_STRING_INITIALIZER
13519 (struct cmd_vf_mac_anti_spoof_result,
13521 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13522 TOKEN_STRING_INITIALIZER
13523 (struct cmd_vf_mac_anti_spoof_result,
13525 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13526 TOKEN_STRING_INITIALIZER
13527 (struct cmd_vf_mac_anti_spoof_result,
13528 antispoof, "antispoof");
13529 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13530 TOKEN_NUM_INITIALIZER
13531 (struct cmd_vf_mac_anti_spoof_result,
13533 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13534 TOKEN_NUM_INITIALIZER
13535 (struct cmd_vf_mac_anti_spoof_result,
13537 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13538 TOKEN_STRING_INITIALIZER
13539 (struct cmd_vf_mac_anti_spoof_result,
13543 cmd_set_vf_mac_anti_spoof_parsed(
13544 void *parsed_result,
13545 __rte_unused struct cmdline *cl,
13546 __rte_unused void *data)
13548 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13549 int ret = -ENOTSUP;
13551 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13553 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13556 #ifdef RTE_LIBRTE_IXGBE_PMD
13557 if (ret == -ENOTSUP)
13558 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13559 res->vf_id, is_on);
13561 #ifdef RTE_LIBRTE_I40E_PMD
13562 if (ret == -ENOTSUP)
13563 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13564 res->vf_id, is_on);
13566 #ifdef RTE_LIBRTE_BNXT_PMD
13567 if (ret == -ENOTSUP)
13568 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13569 res->vf_id, is_on);
13576 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13579 printf("invalid port_id %d\n", res->port_id);
13582 printf("function not implemented\n");
13585 printf("programming error: (%s)\n", strerror(-ret));
13589 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13590 .f = cmd_set_vf_mac_anti_spoof_parsed,
13592 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13594 (void *)&cmd_vf_mac_anti_spoof_set,
13595 (void *)&cmd_vf_mac_anti_spoof_vf,
13596 (void *)&cmd_vf_mac_anti_spoof_mac,
13597 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13598 (void *)&cmd_vf_mac_anti_spoof_port_id,
13599 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13600 (void *)&cmd_vf_mac_anti_spoof_on_off,
13605 /* vf vlan strip queue configuration */
13607 /* Common result structure for vf mac anti spoof */
13608 struct cmd_vf_vlan_stripq_result {
13609 cmdline_fixed_string_t set;
13610 cmdline_fixed_string_t vf;
13611 cmdline_fixed_string_t vlan;
13612 cmdline_fixed_string_t stripq;
13615 cmdline_fixed_string_t on_off;
13618 /* Common CLI fields for vf vlan strip enable disable */
13619 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13620 TOKEN_STRING_INITIALIZER
13621 (struct cmd_vf_vlan_stripq_result,
13623 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13624 TOKEN_STRING_INITIALIZER
13625 (struct cmd_vf_vlan_stripq_result,
13627 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13628 TOKEN_STRING_INITIALIZER
13629 (struct cmd_vf_vlan_stripq_result,
13631 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13632 TOKEN_STRING_INITIALIZER
13633 (struct cmd_vf_vlan_stripq_result,
13635 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13636 TOKEN_NUM_INITIALIZER
13637 (struct cmd_vf_vlan_stripq_result,
13639 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13640 TOKEN_NUM_INITIALIZER
13641 (struct cmd_vf_vlan_stripq_result,
13643 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13644 TOKEN_STRING_INITIALIZER
13645 (struct cmd_vf_vlan_stripq_result,
13649 cmd_set_vf_vlan_stripq_parsed(
13650 void *parsed_result,
13651 __rte_unused struct cmdline *cl,
13652 __rte_unused void *data)
13654 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13655 int ret = -ENOTSUP;
13657 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13659 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13662 #ifdef RTE_LIBRTE_IXGBE_PMD
13663 if (ret == -ENOTSUP)
13664 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13665 res->vf_id, is_on);
13667 #ifdef RTE_LIBRTE_I40E_PMD
13668 if (ret == -ENOTSUP)
13669 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13670 res->vf_id, is_on);
13672 #ifdef RTE_LIBRTE_BNXT_PMD
13673 if (ret == -ENOTSUP)
13674 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13675 res->vf_id, is_on);
13682 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13685 printf("invalid port_id %d\n", res->port_id);
13688 printf("function not implemented\n");
13691 printf("programming error: (%s)\n", strerror(-ret));
13695 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13696 .f = cmd_set_vf_vlan_stripq_parsed,
13698 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13700 (void *)&cmd_vf_vlan_stripq_set,
13701 (void *)&cmd_vf_vlan_stripq_vf,
13702 (void *)&cmd_vf_vlan_stripq_vlan,
13703 (void *)&cmd_vf_vlan_stripq_stripq,
13704 (void *)&cmd_vf_vlan_stripq_port_id,
13705 (void *)&cmd_vf_vlan_stripq_vf_id,
13706 (void *)&cmd_vf_vlan_stripq_on_off,
13711 /* vf vlan insert configuration */
13713 /* Common result structure for vf vlan insert */
13714 struct cmd_vf_vlan_insert_result {
13715 cmdline_fixed_string_t set;
13716 cmdline_fixed_string_t vf;
13717 cmdline_fixed_string_t vlan;
13718 cmdline_fixed_string_t insert;
13724 /* Common CLI fields for vf vlan insert enable disable */
13725 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13726 TOKEN_STRING_INITIALIZER
13727 (struct cmd_vf_vlan_insert_result,
13729 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13730 TOKEN_STRING_INITIALIZER
13731 (struct cmd_vf_vlan_insert_result,
13733 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13734 TOKEN_STRING_INITIALIZER
13735 (struct cmd_vf_vlan_insert_result,
13737 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13738 TOKEN_STRING_INITIALIZER
13739 (struct cmd_vf_vlan_insert_result,
13741 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13742 TOKEN_NUM_INITIALIZER
13743 (struct cmd_vf_vlan_insert_result,
13745 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13746 TOKEN_NUM_INITIALIZER
13747 (struct cmd_vf_vlan_insert_result,
13749 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13750 TOKEN_NUM_INITIALIZER
13751 (struct cmd_vf_vlan_insert_result,
13755 cmd_set_vf_vlan_insert_parsed(
13756 void *parsed_result,
13757 __rte_unused struct cmdline *cl,
13758 __rte_unused void *data)
13760 struct cmd_vf_vlan_insert_result *res = parsed_result;
13761 int ret = -ENOTSUP;
13763 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13766 #ifdef RTE_LIBRTE_IXGBE_PMD
13767 if (ret == -ENOTSUP)
13768 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13771 #ifdef RTE_LIBRTE_I40E_PMD
13772 if (ret == -ENOTSUP)
13773 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13776 #ifdef RTE_LIBRTE_BNXT_PMD
13777 if (ret == -ENOTSUP)
13778 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13786 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13789 printf("invalid port_id %d\n", res->port_id);
13792 printf("function not implemented\n");
13795 printf("programming error: (%s)\n", strerror(-ret));
13799 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13800 .f = cmd_set_vf_vlan_insert_parsed,
13802 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13804 (void *)&cmd_vf_vlan_insert_set,
13805 (void *)&cmd_vf_vlan_insert_vf,
13806 (void *)&cmd_vf_vlan_insert_vlan,
13807 (void *)&cmd_vf_vlan_insert_insert,
13808 (void *)&cmd_vf_vlan_insert_port_id,
13809 (void *)&cmd_vf_vlan_insert_vf_id,
13810 (void *)&cmd_vf_vlan_insert_vlan_id,
13815 /* tx loopback configuration */
13817 /* Common result structure for tx loopback */
13818 struct cmd_tx_loopback_result {
13819 cmdline_fixed_string_t set;
13820 cmdline_fixed_string_t tx;
13821 cmdline_fixed_string_t loopback;
13823 cmdline_fixed_string_t on_off;
13826 /* Common CLI fields for tx loopback enable disable */
13827 cmdline_parse_token_string_t cmd_tx_loopback_set =
13828 TOKEN_STRING_INITIALIZER
13829 (struct cmd_tx_loopback_result,
13831 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13832 TOKEN_STRING_INITIALIZER
13833 (struct cmd_tx_loopback_result,
13835 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13836 TOKEN_STRING_INITIALIZER
13837 (struct cmd_tx_loopback_result,
13838 loopback, "loopback");
13839 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13840 TOKEN_NUM_INITIALIZER
13841 (struct cmd_tx_loopback_result,
13843 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13844 TOKEN_STRING_INITIALIZER
13845 (struct cmd_tx_loopback_result,
13849 cmd_set_tx_loopback_parsed(
13850 void *parsed_result,
13851 __rte_unused struct cmdline *cl,
13852 __rte_unused void *data)
13854 struct cmd_tx_loopback_result *res = parsed_result;
13855 int ret = -ENOTSUP;
13857 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13859 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13862 #ifdef RTE_LIBRTE_IXGBE_PMD
13863 if (ret == -ENOTSUP)
13864 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13866 #ifdef RTE_LIBRTE_I40E_PMD
13867 if (ret == -ENOTSUP)
13868 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13870 #ifdef RTE_LIBRTE_BNXT_PMD
13871 if (ret == -ENOTSUP)
13872 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13874 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13875 if (ret == -ENOTSUP)
13876 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13883 printf("invalid is_on %d\n", is_on);
13886 printf("invalid port_id %d\n", res->port_id);
13889 printf("function not implemented\n");
13892 printf("programming error: (%s)\n", strerror(-ret));
13896 cmdline_parse_inst_t cmd_set_tx_loopback = {
13897 .f = cmd_set_tx_loopback_parsed,
13899 .help_str = "set tx loopback <port_id> on|off",
13901 (void *)&cmd_tx_loopback_set,
13902 (void *)&cmd_tx_loopback_tx,
13903 (void *)&cmd_tx_loopback_loopback,
13904 (void *)&cmd_tx_loopback_port_id,
13905 (void *)&cmd_tx_loopback_on_off,
13910 /* all queues drop enable configuration */
13912 /* Common result structure for all queues drop enable */
13913 struct cmd_all_queues_drop_en_result {
13914 cmdline_fixed_string_t set;
13915 cmdline_fixed_string_t all;
13916 cmdline_fixed_string_t queues;
13917 cmdline_fixed_string_t drop;
13919 cmdline_fixed_string_t on_off;
13922 /* Common CLI fields for tx loopback enable disable */
13923 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13924 TOKEN_STRING_INITIALIZER
13925 (struct cmd_all_queues_drop_en_result,
13927 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13928 TOKEN_STRING_INITIALIZER
13929 (struct cmd_all_queues_drop_en_result,
13931 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13932 TOKEN_STRING_INITIALIZER
13933 (struct cmd_all_queues_drop_en_result,
13935 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13936 TOKEN_STRING_INITIALIZER
13937 (struct cmd_all_queues_drop_en_result,
13939 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13940 TOKEN_NUM_INITIALIZER
13941 (struct cmd_all_queues_drop_en_result,
13943 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13944 TOKEN_STRING_INITIALIZER
13945 (struct cmd_all_queues_drop_en_result,
13949 cmd_set_all_queues_drop_en_parsed(
13950 void *parsed_result,
13951 __rte_unused struct cmdline *cl,
13952 __rte_unused void *data)
13954 struct cmd_all_queues_drop_en_result *res = parsed_result;
13955 int ret = -ENOTSUP;
13956 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13958 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13961 #ifdef RTE_LIBRTE_IXGBE_PMD
13962 if (ret == -ENOTSUP)
13963 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13965 #ifdef RTE_LIBRTE_BNXT_PMD
13966 if (ret == -ENOTSUP)
13967 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13973 printf("invalid is_on %d\n", is_on);
13976 printf("invalid port_id %d\n", res->port_id);
13979 printf("function not implemented\n");
13982 printf("programming error: (%s)\n", strerror(-ret));
13986 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13987 .f = cmd_set_all_queues_drop_en_parsed,
13989 .help_str = "set all queues drop <port_id> on|off",
13991 (void *)&cmd_all_queues_drop_en_set,
13992 (void *)&cmd_all_queues_drop_en_all,
13993 (void *)&cmd_all_queues_drop_en_queues,
13994 (void *)&cmd_all_queues_drop_en_drop,
13995 (void *)&cmd_all_queues_drop_en_port_id,
13996 (void *)&cmd_all_queues_drop_en_on_off,
14001 /* vf split drop enable configuration */
14003 /* Common result structure for vf split drop enable */
14004 struct cmd_vf_split_drop_en_result {
14005 cmdline_fixed_string_t set;
14006 cmdline_fixed_string_t vf;
14007 cmdline_fixed_string_t split;
14008 cmdline_fixed_string_t drop;
14011 cmdline_fixed_string_t on_off;
14014 /* Common CLI fields for vf split drop enable disable */
14015 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14016 TOKEN_STRING_INITIALIZER
14017 (struct cmd_vf_split_drop_en_result,
14019 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14020 TOKEN_STRING_INITIALIZER
14021 (struct cmd_vf_split_drop_en_result,
14023 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14024 TOKEN_STRING_INITIALIZER
14025 (struct cmd_vf_split_drop_en_result,
14027 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14028 TOKEN_STRING_INITIALIZER
14029 (struct cmd_vf_split_drop_en_result,
14031 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14032 TOKEN_NUM_INITIALIZER
14033 (struct cmd_vf_split_drop_en_result,
14035 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14036 TOKEN_NUM_INITIALIZER
14037 (struct cmd_vf_split_drop_en_result,
14039 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14040 TOKEN_STRING_INITIALIZER
14041 (struct cmd_vf_split_drop_en_result,
14045 cmd_set_vf_split_drop_en_parsed(
14046 void *parsed_result,
14047 __rte_unused struct cmdline *cl,
14048 __rte_unused void *data)
14050 struct cmd_vf_split_drop_en_result *res = parsed_result;
14051 int ret = -ENOTSUP;
14052 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14054 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14057 #ifdef RTE_LIBRTE_IXGBE_PMD
14058 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14065 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14068 printf("invalid port_id %d\n", res->port_id);
14071 printf("not supported on port %d\n", res->port_id);
14074 printf("programming error: (%s)\n", strerror(-ret));
14078 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14079 .f = cmd_set_vf_split_drop_en_parsed,
14081 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14083 (void *)&cmd_vf_split_drop_en_set,
14084 (void *)&cmd_vf_split_drop_en_vf,
14085 (void *)&cmd_vf_split_drop_en_split,
14086 (void *)&cmd_vf_split_drop_en_drop,
14087 (void *)&cmd_vf_split_drop_en_port_id,
14088 (void *)&cmd_vf_split_drop_en_vf_id,
14089 (void *)&cmd_vf_split_drop_en_on_off,
14094 /* vf mac address configuration */
14096 /* Common result structure for vf mac address */
14097 struct cmd_set_vf_mac_addr_result {
14098 cmdline_fixed_string_t set;
14099 cmdline_fixed_string_t vf;
14100 cmdline_fixed_string_t mac;
14101 cmdline_fixed_string_t addr;
14104 struct rte_ether_addr mac_addr;
14108 /* Common CLI fields for vf split drop enable disable */
14109 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14110 TOKEN_STRING_INITIALIZER
14111 (struct cmd_set_vf_mac_addr_result,
14113 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14114 TOKEN_STRING_INITIALIZER
14115 (struct cmd_set_vf_mac_addr_result,
14117 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14118 TOKEN_STRING_INITIALIZER
14119 (struct cmd_set_vf_mac_addr_result,
14121 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14122 TOKEN_STRING_INITIALIZER
14123 (struct cmd_set_vf_mac_addr_result,
14125 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14126 TOKEN_NUM_INITIALIZER
14127 (struct cmd_set_vf_mac_addr_result,
14129 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14130 TOKEN_NUM_INITIALIZER
14131 (struct cmd_set_vf_mac_addr_result,
14133 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14134 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14138 cmd_set_vf_mac_addr_parsed(
14139 void *parsed_result,
14140 __rte_unused struct cmdline *cl,
14141 __rte_unused void *data)
14143 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14144 int ret = -ENOTSUP;
14146 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14149 #ifdef RTE_LIBRTE_IXGBE_PMD
14150 if (ret == -ENOTSUP)
14151 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14154 #ifdef RTE_LIBRTE_I40E_PMD
14155 if (ret == -ENOTSUP)
14156 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14159 #ifdef RTE_LIBRTE_BNXT_PMD
14160 if (ret == -ENOTSUP)
14161 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14169 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14172 printf("invalid port_id %d\n", res->port_id);
14175 printf("function not implemented\n");
14178 printf("programming error: (%s)\n", strerror(-ret));
14182 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14183 .f = cmd_set_vf_mac_addr_parsed,
14185 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14187 (void *)&cmd_set_vf_mac_addr_set,
14188 (void *)&cmd_set_vf_mac_addr_vf,
14189 (void *)&cmd_set_vf_mac_addr_mac,
14190 (void *)&cmd_set_vf_mac_addr_addr,
14191 (void *)&cmd_set_vf_mac_addr_port_id,
14192 (void *)&cmd_set_vf_mac_addr_vf_id,
14193 (void *)&cmd_set_vf_mac_addr_mac_addr,
14198 /* MACsec configuration */
14200 /* Common result structure for MACsec offload enable */
14201 struct cmd_macsec_offload_on_result {
14202 cmdline_fixed_string_t set;
14203 cmdline_fixed_string_t macsec;
14204 cmdline_fixed_string_t offload;
14206 cmdline_fixed_string_t on;
14207 cmdline_fixed_string_t encrypt;
14208 cmdline_fixed_string_t en_on_off;
14209 cmdline_fixed_string_t replay_protect;
14210 cmdline_fixed_string_t rp_on_off;
14213 /* Common CLI fields for MACsec offload disable */
14214 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14215 TOKEN_STRING_INITIALIZER
14216 (struct cmd_macsec_offload_on_result,
14218 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14219 TOKEN_STRING_INITIALIZER
14220 (struct cmd_macsec_offload_on_result,
14222 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14223 TOKEN_STRING_INITIALIZER
14224 (struct cmd_macsec_offload_on_result,
14225 offload, "offload");
14226 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14227 TOKEN_NUM_INITIALIZER
14228 (struct cmd_macsec_offload_on_result,
14230 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14231 TOKEN_STRING_INITIALIZER
14232 (struct cmd_macsec_offload_on_result,
14234 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14235 TOKEN_STRING_INITIALIZER
14236 (struct cmd_macsec_offload_on_result,
14237 encrypt, "encrypt");
14238 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14239 TOKEN_STRING_INITIALIZER
14240 (struct cmd_macsec_offload_on_result,
14241 en_on_off, "on#off");
14242 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14243 TOKEN_STRING_INITIALIZER
14244 (struct cmd_macsec_offload_on_result,
14245 replay_protect, "replay-protect");
14246 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14247 TOKEN_STRING_INITIALIZER
14248 (struct cmd_macsec_offload_on_result,
14249 rp_on_off, "on#off");
14252 cmd_set_macsec_offload_on_parsed(
14253 void *parsed_result,
14254 __rte_unused struct cmdline *cl,
14255 __rte_unused void *data)
14257 struct cmd_macsec_offload_on_result *res = parsed_result;
14258 int ret = -ENOTSUP;
14259 portid_t port_id = res->port_id;
14260 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14261 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14262 struct rte_eth_dev_info dev_info;
14264 if (port_id_is_invalid(port_id, ENABLED_WARN))
14266 if (!port_is_stopped(port_id)) {
14267 printf("Please stop port %d first\n", port_id);
14271 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14275 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14276 #ifdef RTE_LIBRTE_IXGBE_PMD
14277 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14285 ports[port_id].dev_conf.txmode.offloads |=
14286 DEV_TX_OFFLOAD_MACSEC_INSERT;
14287 cmd_reconfig_device_queue(port_id, 1, 1);
14290 printf("invalid port_id %d\n", port_id);
14293 printf("not supported on port %d\n", port_id);
14296 printf("programming error: (%s)\n", strerror(-ret));
14300 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14301 .f = cmd_set_macsec_offload_on_parsed,
14303 .help_str = "set macsec offload <port_id> on "
14304 "encrypt on|off replay-protect on|off",
14306 (void *)&cmd_macsec_offload_on_set,
14307 (void *)&cmd_macsec_offload_on_macsec,
14308 (void *)&cmd_macsec_offload_on_offload,
14309 (void *)&cmd_macsec_offload_on_port_id,
14310 (void *)&cmd_macsec_offload_on_on,
14311 (void *)&cmd_macsec_offload_on_encrypt,
14312 (void *)&cmd_macsec_offload_on_en_on_off,
14313 (void *)&cmd_macsec_offload_on_replay_protect,
14314 (void *)&cmd_macsec_offload_on_rp_on_off,
14319 /* Common result structure for MACsec offload disable */
14320 struct cmd_macsec_offload_off_result {
14321 cmdline_fixed_string_t set;
14322 cmdline_fixed_string_t macsec;
14323 cmdline_fixed_string_t offload;
14325 cmdline_fixed_string_t off;
14328 /* Common CLI fields for MACsec offload disable */
14329 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14330 TOKEN_STRING_INITIALIZER
14331 (struct cmd_macsec_offload_off_result,
14333 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14334 TOKEN_STRING_INITIALIZER
14335 (struct cmd_macsec_offload_off_result,
14337 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14338 TOKEN_STRING_INITIALIZER
14339 (struct cmd_macsec_offload_off_result,
14340 offload, "offload");
14341 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14342 TOKEN_NUM_INITIALIZER
14343 (struct cmd_macsec_offload_off_result,
14345 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14346 TOKEN_STRING_INITIALIZER
14347 (struct cmd_macsec_offload_off_result,
14351 cmd_set_macsec_offload_off_parsed(
14352 void *parsed_result,
14353 __rte_unused struct cmdline *cl,
14354 __rte_unused void *data)
14356 struct cmd_macsec_offload_off_result *res = parsed_result;
14357 int ret = -ENOTSUP;
14358 struct rte_eth_dev_info dev_info;
14359 portid_t port_id = res->port_id;
14361 if (port_id_is_invalid(port_id, ENABLED_WARN))
14363 if (!port_is_stopped(port_id)) {
14364 printf("Please stop port %d first\n", port_id);
14368 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14372 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14373 #ifdef RTE_LIBRTE_IXGBE_PMD
14374 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14379 ports[port_id].dev_conf.txmode.offloads &=
14380 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14381 cmd_reconfig_device_queue(port_id, 1, 1);
14384 printf("invalid port_id %d\n", port_id);
14387 printf("not supported on port %d\n", port_id);
14390 printf("programming error: (%s)\n", strerror(-ret));
14394 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14395 .f = cmd_set_macsec_offload_off_parsed,
14397 .help_str = "set macsec offload <port_id> off",
14399 (void *)&cmd_macsec_offload_off_set,
14400 (void *)&cmd_macsec_offload_off_macsec,
14401 (void *)&cmd_macsec_offload_off_offload,
14402 (void *)&cmd_macsec_offload_off_port_id,
14403 (void *)&cmd_macsec_offload_off_off,
14408 /* Common result structure for MACsec secure connection configure */
14409 struct cmd_macsec_sc_result {
14410 cmdline_fixed_string_t set;
14411 cmdline_fixed_string_t macsec;
14412 cmdline_fixed_string_t sc;
14413 cmdline_fixed_string_t tx_rx;
14415 struct rte_ether_addr mac;
14419 /* Common CLI fields for MACsec secure connection configure */
14420 cmdline_parse_token_string_t cmd_macsec_sc_set =
14421 TOKEN_STRING_INITIALIZER
14422 (struct cmd_macsec_sc_result,
14424 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14425 TOKEN_STRING_INITIALIZER
14426 (struct cmd_macsec_sc_result,
14428 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14429 TOKEN_STRING_INITIALIZER
14430 (struct cmd_macsec_sc_result,
14432 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14433 TOKEN_STRING_INITIALIZER
14434 (struct cmd_macsec_sc_result,
14436 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14437 TOKEN_NUM_INITIALIZER
14438 (struct cmd_macsec_sc_result,
14440 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14441 TOKEN_ETHERADDR_INITIALIZER
14442 (struct cmd_macsec_sc_result,
14444 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14445 TOKEN_NUM_INITIALIZER
14446 (struct cmd_macsec_sc_result,
14450 cmd_set_macsec_sc_parsed(
14451 void *parsed_result,
14452 __rte_unused struct cmdline *cl,
14453 __rte_unused void *data)
14455 struct cmd_macsec_sc_result *res = parsed_result;
14456 int ret = -ENOTSUP;
14457 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14459 #ifdef RTE_LIBRTE_IXGBE_PMD
14461 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14462 res->mac.addr_bytes) :
14463 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14464 res->mac.addr_bytes, res->pi);
14466 RTE_SET_USED(is_tx);
14472 printf("invalid port_id %d\n", res->port_id);
14475 printf("not supported on port %d\n", res->port_id);
14478 printf("programming error: (%s)\n", strerror(-ret));
14482 cmdline_parse_inst_t cmd_set_macsec_sc = {
14483 .f = cmd_set_macsec_sc_parsed,
14485 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14487 (void *)&cmd_macsec_sc_set,
14488 (void *)&cmd_macsec_sc_macsec,
14489 (void *)&cmd_macsec_sc_sc,
14490 (void *)&cmd_macsec_sc_tx_rx,
14491 (void *)&cmd_macsec_sc_port_id,
14492 (void *)&cmd_macsec_sc_mac,
14493 (void *)&cmd_macsec_sc_pi,
14498 /* Common result structure for MACsec secure connection configure */
14499 struct cmd_macsec_sa_result {
14500 cmdline_fixed_string_t set;
14501 cmdline_fixed_string_t macsec;
14502 cmdline_fixed_string_t sa;
14503 cmdline_fixed_string_t tx_rx;
14508 cmdline_fixed_string_t key;
14511 /* Common CLI fields for MACsec secure connection configure */
14512 cmdline_parse_token_string_t cmd_macsec_sa_set =
14513 TOKEN_STRING_INITIALIZER
14514 (struct cmd_macsec_sa_result,
14516 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14517 TOKEN_STRING_INITIALIZER
14518 (struct cmd_macsec_sa_result,
14520 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14521 TOKEN_STRING_INITIALIZER
14522 (struct cmd_macsec_sa_result,
14524 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14525 TOKEN_STRING_INITIALIZER
14526 (struct cmd_macsec_sa_result,
14528 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14529 TOKEN_NUM_INITIALIZER
14530 (struct cmd_macsec_sa_result,
14532 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14533 TOKEN_NUM_INITIALIZER
14534 (struct cmd_macsec_sa_result,
14536 cmdline_parse_token_num_t cmd_macsec_sa_an =
14537 TOKEN_NUM_INITIALIZER
14538 (struct cmd_macsec_sa_result,
14540 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14541 TOKEN_NUM_INITIALIZER
14542 (struct cmd_macsec_sa_result,
14544 cmdline_parse_token_string_t cmd_macsec_sa_key =
14545 TOKEN_STRING_INITIALIZER
14546 (struct cmd_macsec_sa_result,
14550 cmd_set_macsec_sa_parsed(
14551 void *parsed_result,
14552 __rte_unused struct cmdline *cl,
14553 __rte_unused void *data)
14555 struct cmd_macsec_sa_result *res = parsed_result;
14556 int ret = -ENOTSUP;
14557 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14558 uint8_t key[16] = { 0 };
14564 key_len = strlen(res->key) / 2;
14568 for (i = 0; i < key_len; i++) {
14569 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14572 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14575 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14578 #ifdef RTE_LIBRTE_IXGBE_PMD
14580 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14581 res->idx, res->an, res->pn, key) :
14582 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14583 res->idx, res->an, res->pn, key);
14585 RTE_SET_USED(is_tx);
14592 printf("invalid idx %d or an %d\n", res->idx, res->an);
14595 printf("invalid port_id %d\n", res->port_id);
14598 printf("not supported on port %d\n", res->port_id);
14601 printf("programming error: (%s)\n", strerror(-ret));
14605 cmdline_parse_inst_t cmd_set_macsec_sa = {
14606 .f = cmd_set_macsec_sa_parsed,
14608 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14610 (void *)&cmd_macsec_sa_set,
14611 (void *)&cmd_macsec_sa_macsec,
14612 (void *)&cmd_macsec_sa_sa,
14613 (void *)&cmd_macsec_sa_tx_rx,
14614 (void *)&cmd_macsec_sa_port_id,
14615 (void *)&cmd_macsec_sa_idx,
14616 (void *)&cmd_macsec_sa_an,
14617 (void *)&cmd_macsec_sa_pn,
14618 (void *)&cmd_macsec_sa_key,
14623 /* VF unicast promiscuous mode configuration */
14625 /* Common result structure for VF unicast promiscuous mode */
14626 struct cmd_vf_promisc_result {
14627 cmdline_fixed_string_t set;
14628 cmdline_fixed_string_t vf;
14629 cmdline_fixed_string_t promisc;
14632 cmdline_fixed_string_t on_off;
14635 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14636 cmdline_parse_token_string_t cmd_vf_promisc_set =
14637 TOKEN_STRING_INITIALIZER
14638 (struct cmd_vf_promisc_result,
14640 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14641 TOKEN_STRING_INITIALIZER
14642 (struct cmd_vf_promisc_result,
14644 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14645 TOKEN_STRING_INITIALIZER
14646 (struct cmd_vf_promisc_result,
14647 promisc, "promisc");
14648 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14649 TOKEN_NUM_INITIALIZER
14650 (struct cmd_vf_promisc_result,
14652 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14653 TOKEN_NUM_INITIALIZER
14654 (struct cmd_vf_promisc_result,
14656 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14657 TOKEN_STRING_INITIALIZER
14658 (struct cmd_vf_promisc_result,
14662 cmd_set_vf_promisc_parsed(
14663 void *parsed_result,
14664 __rte_unused struct cmdline *cl,
14665 __rte_unused void *data)
14667 struct cmd_vf_promisc_result *res = parsed_result;
14668 int ret = -ENOTSUP;
14670 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14672 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14675 #ifdef RTE_LIBRTE_I40E_PMD
14676 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14677 res->vf_id, is_on);
14684 printf("invalid vf_id %d\n", res->vf_id);
14687 printf("invalid port_id %d\n", res->port_id);
14690 printf("function not implemented\n");
14693 printf("programming error: (%s)\n", strerror(-ret));
14697 cmdline_parse_inst_t cmd_set_vf_promisc = {
14698 .f = cmd_set_vf_promisc_parsed,
14700 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14701 "Set unicast promiscuous mode for a VF from the PF",
14703 (void *)&cmd_vf_promisc_set,
14704 (void *)&cmd_vf_promisc_vf,
14705 (void *)&cmd_vf_promisc_promisc,
14706 (void *)&cmd_vf_promisc_port_id,
14707 (void *)&cmd_vf_promisc_vf_id,
14708 (void *)&cmd_vf_promisc_on_off,
14713 /* VF multicast promiscuous mode configuration */
14715 /* Common result structure for VF multicast promiscuous mode */
14716 struct cmd_vf_allmulti_result {
14717 cmdline_fixed_string_t set;
14718 cmdline_fixed_string_t vf;
14719 cmdline_fixed_string_t allmulti;
14722 cmdline_fixed_string_t on_off;
14725 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14726 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14727 TOKEN_STRING_INITIALIZER
14728 (struct cmd_vf_allmulti_result,
14730 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14731 TOKEN_STRING_INITIALIZER
14732 (struct cmd_vf_allmulti_result,
14734 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14735 TOKEN_STRING_INITIALIZER
14736 (struct cmd_vf_allmulti_result,
14737 allmulti, "allmulti");
14738 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14739 TOKEN_NUM_INITIALIZER
14740 (struct cmd_vf_allmulti_result,
14742 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14743 TOKEN_NUM_INITIALIZER
14744 (struct cmd_vf_allmulti_result,
14746 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14747 TOKEN_STRING_INITIALIZER
14748 (struct cmd_vf_allmulti_result,
14752 cmd_set_vf_allmulti_parsed(
14753 void *parsed_result,
14754 __rte_unused struct cmdline *cl,
14755 __rte_unused void *data)
14757 struct cmd_vf_allmulti_result *res = parsed_result;
14758 int ret = -ENOTSUP;
14760 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14762 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14765 #ifdef RTE_LIBRTE_I40E_PMD
14766 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14767 res->vf_id, is_on);
14774 printf("invalid vf_id %d\n", res->vf_id);
14777 printf("invalid port_id %d\n", res->port_id);
14780 printf("function not implemented\n");
14783 printf("programming error: (%s)\n", strerror(-ret));
14787 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14788 .f = cmd_set_vf_allmulti_parsed,
14790 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14791 "Set multicast promiscuous mode for a VF from the PF",
14793 (void *)&cmd_vf_allmulti_set,
14794 (void *)&cmd_vf_allmulti_vf,
14795 (void *)&cmd_vf_allmulti_allmulti,
14796 (void *)&cmd_vf_allmulti_port_id,
14797 (void *)&cmd_vf_allmulti_vf_id,
14798 (void *)&cmd_vf_allmulti_on_off,
14803 /* vf broadcast mode configuration */
14805 /* Common result structure for vf broadcast */
14806 struct cmd_set_vf_broadcast_result {
14807 cmdline_fixed_string_t set;
14808 cmdline_fixed_string_t vf;
14809 cmdline_fixed_string_t broadcast;
14812 cmdline_fixed_string_t on_off;
14815 /* Common CLI fields for vf broadcast enable disable */
14816 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14817 TOKEN_STRING_INITIALIZER
14818 (struct cmd_set_vf_broadcast_result,
14820 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14821 TOKEN_STRING_INITIALIZER
14822 (struct cmd_set_vf_broadcast_result,
14824 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14825 TOKEN_STRING_INITIALIZER
14826 (struct cmd_set_vf_broadcast_result,
14827 broadcast, "broadcast");
14828 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14829 TOKEN_NUM_INITIALIZER
14830 (struct cmd_set_vf_broadcast_result,
14832 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14833 TOKEN_NUM_INITIALIZER
14834 (struct cmd_set_vf_broadcast_result,
14836 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14837 TOKEN_STRING_INITIALIZER
14838 (struct cmd_set_vf_broadcast_result,
14842 cmd_set_vf_broadcast_parsed(
14843 void *parsed_result,
14844 __rte_unused struct cmdline *cl,
14845 __rte_unused void *data)
14847 struct cmd_set_vf_broadcast_result *res = parsed_result;
14848 int ret = -ENOTSUP;
14850 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14852 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14855 #ifdef RTE_LIBRTE_I40E_PMD
14856 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14857 res->vf_id, is_on);
14864 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14867 printf("invalid port_id %d\n", res->port_id);
14870 printf("function not implemented\n");
14873 printf("programming error: (%s)\n", strerror(-ret));
14877 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14878 .f = cmd_set_vf_broadcast_parsed,
14880 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14882 (void *)&cmd_set_vf_broadcast_set,
14883 (void *)&cmd_set_vf_broadcast_vf,
14884 (void *)&cmd_set_vf_broadcast_broadcast,
14885 (void *)&cmd_set_vf_broadcast_port_id,
14886 (void *)&cmd_set_vf_broadcast_vf_id,
14887 (void *)&cmd_set_vf_broadcast_on_off,
14892 /* vf vlan tag configuration */
14894 /* Common result structure for vf vlan tag */
14895 struct cmd_set_vf_vlan_tag_result {
14896 cmdline_fixed_string_t set;
14897 cmdline_fixed_string_t vf;
14898 cmdline_fixed_string_t vlan;
14899 cmdline_fixed_string_t tag;
14902 cmdline_fixed_string_t on_off;
14905 /* Common CLI fields for vf vlan tag enable disable */
14906 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14907 TOKEN_STRING_INITIALIZER
14908 (struct cmd_set_vf_vlan_tag_result,
14910 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14911 TOKEN_STRING_INITIALIZER
14912 (struct cmd_set_vf_vlan_tag_result,
14914 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14915 TOKEN_STRING_INITIALIZER
14916 (struct cmd_set_vf_vlan_tag_result,
14918 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14919 TOKEN_STRING_INITIALIZER
14920 (struct cmd_set_vf_vlan_tag_result,
14922 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14923 TOKEN_NUM_INITIALIZER
14924 (struct cmd_set_vf_vlan_tag_result,
14926 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14927 TOKEN_NUM_INITIALIZER
14928 (struct cmd_set_vf_vlan_tag_result,
14930 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14931 TOKEN_STRING_INITIALIZER
14932 (struct cmd_set_vf_vlan_tag_result,
14936 cmd_set_vf_vlan_tag_parsed(
14937 void *parsed_result,
14938 __rte_unused struct cmdline *cl,
14939 __rte_unused void *data)
14941 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14942 int ret = -ENOTSUP;
14944 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14946 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14949 #ifdef RTE_LIBRTE_I40E_PMD
14950 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14951 res->vf_id, is_on);
14958 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14961 printf("invalid port_id %d\n", res->port_id);
14964 printf("function not implemented\n");
14967 printf("programming error: (%s)\n", strerror(-ret));
14971 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14972 .f = cmd_set_vf_vlan_tag_parsed,
14974 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14976 (void *)&cmd_set_vf_vlan_tag_set,
14977 (void *)&cmd_set_vf_vlan_tag_vf,
14978 (void *)&cmd_set_vf_vlan_tag_vlan,
14979 (void *)&cmd_set_vf_vlan_tag_tag,
14980 (void *)&cmd_set_vf_vlan_tag_port_id,
14981 (void *)&cmd_set_vf_vlan_tag_vf_id,
14982 (void *)&cmd_set_vf_vlan_tag_on_off,
14987 /* Common definition of VF and TC TX bandwidth configuration */
14988 struct cmd_vf_tc_bw_result {
14989 cmdline_fixed_string_t set;
14990 cmdline_fixed_string_t vf;
14991 cmdline_fixed_string_t tc;
14992 cmdline_fixed_string_t tx;
14993 cmdline_fixed_string_t min_bw;
14994 cmdline_fixed_string_t max_bw;
14995 cmdline_fixed_string_t strict_link_prio;
15000 cmdline_fixed_string_t bw_list;
15004 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15005 TOKEN_STRING_INITIALIZER
15006 (struct cmd_vf_tc_bw_result,
15008 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15009 TOKEN_STRING_INITIALIZER
15010 (struct cmd_vf_tc_bw_result,
15012 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15013 TOKEN_STRING_INITIALIZER
15014 (struct cmd_vf_tc_bw_result,
15016 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15017 TOKEN_STRING_INITIALIZER
15018 (struct cmd_vf_tc_bw_result,
15020 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15021 TOKEN_STRING_INITIALIZER
15022 (struct cmd_vf_tc_bw_result,
15023 strict_link_prio, "strict-link-priority");
15024 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15025 TOKEN_STRING_INITIALIZER
15026 (struct cmd_vf_tc_bw_result,
15027 min_bw, "min-bandwidth");
15028 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15029 TOKEN_STRING_INITIALIZER
15030 (struct cmd_vf_tc_bw_result,
15031 max_bw, "max-bandwidth");
15032 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15033 TOKEN_NUM_INITIALIZER
15034 (struct cmd_vf_tc_bw_result,
15036 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15037 TOKEN_NUM_INITIALIZER
15038 (struct cmd_vf_tc_bw_result,
15040 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15041 TOKEN_NUM_INITIALIZER
15042 (struct cmd_vf_tc_bw_result,
15044 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15045 TOKEN_NUM_INITIALIZER
15046 (struct cmd_vf_tc_bw_result,
15048 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15049 TOKEN_STRING_INITIALIZER
15050 (struct cmd_vf_tc_bw_result,
15052 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15053 TOKEN_NUM_INITIALIZER
15054 (struct cmd_vf_tc_bw_result,
15057 /* VF max bandwidth setting */
15059 cmd_vf_max_bw_parsed(
15060 void *parsed_result,
15061 __rte_unused struct cmdline *cl,
15062 __rte_unused void *data)
15064 struct cmd_vf_tc_bw_result *res = parsed_result;
15065 int ret = -ENOTSUP;
15067 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15070 #ifdef RTE_LIBRTE_I40E_PMD
15071 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15072 res->vf_id, res->bw);
15079 printf("invalid vf_id %d or bandwidth %d\n",
15080 res->vf_id, res->bw);
15083 printf("invalid port_id %d\n", res->port_id);
15086 printf("function not implemented\n");
15089 printf("programming error: (%s)\n", strerror(-ret));
15093 cmdline_parse_inst_t cmd_vf_max_bw = {
15094 .f = cmd_vf_max_bw_parsed,
15096 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15098 (void *)&cmd_vf_tc_bw_set,
15099 (void *)&cmd_vf_tc_bw_vf,
15100 (void *)&cmd_vf_tc_bw_tx,
15101 (void *)&cmd_vf_tc_bw_max_bw,
15102 (void *)&cmd_vf_tc_bw_port_id,
15103 (void *)&cmd_vf_tc_bw_vf_id,
15104 (void *)&cmd_vf_tc_bw_bw,
15110 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15115 const char *p, *p0 = str;
15122 p = strchr(p0, '(');
15124 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15128 p0 = strchr(p, ')');
15130 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15134 if (size >= sizeof(s)) {
15135 printf("The string size exceeds the internal buffer size\n");
15138 snprintf(s, sizeof(s), "%.*s", size, p);
15139 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15141 printf("Failed to get the bandwidth list. ");
15145 for (i = 0; i < ret; i++)
15146 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15151 /* TC min bandwidth setting */
15153 cmd_vf_tc_min_bw_parsed(
15154 void *parsed_result,
15155 __rte_unused struct cmdline *cl,
15156 __rte_unused void *data)
15158 struct cmd_vf_tc_bw_result *res = parsed_result;
15161 int ret = -ENOTSUP;
15163 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15166 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15170 #ifdef RTE_LIBRTE_I40E_PMD
15171 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15179 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15182 printf("invalid port_id %d\n", res->port_id);
15185 printf("function not implemented\n");
15188 printf("programming error: (%s)\n", strerror(-ret));
15192 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15193 .f = cmd_vf_tc_min_bw_parsed,
15195 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15196 " <bw1, bw2, ...>",
15198 (void *)&cmd_vf_tc_bw_set,
15199 (void *)&cmd_vf_tc_bw_vf,
15200 (void *)&cmd_vf_tc_bw_tc,
15201 (void *)&cmd_vf_tc_bw_tx,
15202 (void *)&cmd_vf_tc_bw_min_bw,
15203 (void *)&cmd_vf_tc_bw_port_id,
15204 (void *)&cmd_vf_tc_bw_vf_id,
15205 (void *)&cmd_vf_tc_bw_bw_list,
15211 cmd_tc_min_bw_parsed(
15212 void *parsed_result,
15213 __rte_unused struct cmdline *cl,
15214 __rte_unused void *data)
15216 struct cmd_vf_tc_bw_result *res = parsed_result;
15217 struct rte_port *port;
15220 int ret = -ENOTSUP;
15222 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15225 port = &ports[res->port_id];
15226 /** Check if the port is not started **/
15227 if (port->port_status != RTE_PORT_STOPPED) {
15228 printf("Please stop port %d first\n", res->port_id);
15232 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15236 #ifdef RTE_LIBRTE_IXGBE_PMD
15237 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15244 printf("invalid bandwidth\n");
15247 printf("invalid port_id %d\n", res->port_id);
15250 printf("function not implemented\n");
15253 printf("programming error: (%s)\n", strerror(-ret));
15257 cmdline_parse_inst_t cmd_tc_min_bw = {
15258 .f = cmd_tc_min_bw_parsed,
15260 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15262 (void *)&cmd_vf_tc_bw_set,
15263 (void *)&cmd_vf_tc_bw_tc,
15264 (void *)&cmd_vf_tc_bw_tx,
15265 (void *)&cmd_vf_tc_bw_min_bw,
15266 (void *)&cmd_vf_tc_bw_port_id,
15267 (void *)&cmd_vf_tc_bw_bw_list,
15272 /* TC max bandwidth setting */
15274 cmd_vf_tc_max_bw_parsed(
15275 void *parsed_result,
15276 __rte_unused struct cmdline *cl,
15277 __rte_unused void *data)
15279 struct cmd_vf_tc_bw_result *res = parsed_result;
15280 int ret = -ENOTSUP;
15282 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15285 #ifdef RTE_LIBRTE_I40E_PMD
15286 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15287 res->tc_no, res->bw);
15294 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15295 res->vf_id, res->tc_no, res->bw);
15298 printf("invalid port_id %d\n", res->port_id);
15301 printf("function not implemented\n");
15304 printf("programming error: (%s)\n", strerror(-ret));
15308 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15309 .f = cmd_vf_tc_max_bw_parsed,
15311 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15314 (void *)&cmd_vf_tc_bw_set,
15315 (void *)&cmd_vf_tc_bw_vf,
15316 (void *)&cmd_vf_tc_bw_tc,
15317 (void *)&cmd_vf_tc_bw_tx,
15318 (void *)&cmd_vf_tc_bw_max_bw,
15319 (void *)&cmd_vf_tc_bw_port_id,
15320 (void *)&cmd_vf_tc_bw_vf_id,
15321 (void *)&cmd_vf_tc_bw_tc_no,
15322 (void *)&cmd_vf_tc_bw_bw,
15328 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15330 /* *** Set Port default Traffic Management Hierarchy *** */
15331 struct cmd_set_port_tm_hierarchy_default_result {
15332 cmdline_fixed_string_t set;
15333 cmdline_fixed_string_t port;
15334 cmdline_fixed_string_t tm;
15335 cmdline_fixed_string_t hierarchy;
15336 cmdline_fixed_string_t def;
15340 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15341 TOKEN_STRING_INITIALIZER(
15342 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15343 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15344 TOKEN_STRING_INITIALIZER(
15345 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15346 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15347 TOKEN_STRING_INITIALIZER(
15348 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15349 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15350 TOKEN_STRING_INITIALIZER(
15351 struct cmd_set_port_tm_hierarchy_default_result,
15352 hierarchy, "hierarchy");
15353 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15354 TOKEN_STRING_INITIALIZER(
15355 struct cmd_set_port_tm_hierarchy_default_result,
15357 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15358 TOKEN_NUM_INITIALIZER(
15359 struct cmd_set_port_tm_hierarchy_default_result,
15362 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15363 __rte_unused struct cmdline *cl,
15364 __rte_unused void *data)
15366 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15367 struct rte_port *p;
15368 portid_t port_id = res->port_id;
15370 if (port_id_is_invalid(port_id, ENABLED_WARN))
15373 p = &ports[port_id];
15375 /* Forward mode: tm */
15376 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15377 printf(" softnicfwd mode not enabled(error)\n");
15381 /* Set the default tm hierarchy */
15382 p->softport.default_tm_hierarchy_enable = 1;
15385 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15386 .f = cmd_set_port_tm_hierarchy_default_parsed,
15388 .help_str = "set port tm hierarchy default <port_id>",
15390 (void *)&cmd_set_port_tm_hierarchy_default_set,
15391 (void *)&cmd_set_port_tm_hierarchy_default_port,
15392 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15393 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15394 (void *)&cmd_set_port_tm_hierarchy_default_default,
15395 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15401 /** Set VXLAN encapsulation details */
15402 struct cmd_set_vxlan_result {
15403 cmdline_fixed_string_t set;
15404 cmdline_fixed_string_t vxlan;
15405 cmdline_fixed_string_t pos_token;
15406 cmdline_fixed_string_t ip_version;
15407 uint32_t vlan_present:1;
15411 cmdline_ipaddr_t ip_src;
15412 cmdline_ipaddr_t ip_dst;
15416 struct rte_ether_addr eth_src;
15417 struct rte_ether_addr eth_dst;
15420 cmdline_parse_token_string_t cmd_set_vxlan_set =
15421 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15422 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15423 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15424 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15425 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15427 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15428 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15429 "vxlan-with-vlan");
15430 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15431 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15433 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15434 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15436 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15437 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15439 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15440 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15441 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15442 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15444 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15445 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15446 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15447 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15449 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15450 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15451 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15452 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15454 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15455 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15456 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15457 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15459 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15460 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15461 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15462 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15464 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15465 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15466 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15467 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15469 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15470 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15471 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15472 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15474 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15475 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15476 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15477 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15479 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15480 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15481 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15482 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15484 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15485 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15487 static void cmd_set_vxlan_parsed(void *parsed_result,
15488 __rte_unused struct cmdline *cl,
15489 __rte_unused void *data)
15491 struct cmd_set_vxlan_result *res = parsed_result;
15496 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15499 vxlan_encap_conf.select_tos_ttl = 0;
15500 if (strcmp(res->vxlan, "vxlan") == 0)
15501 vxlan_encap_conf.select_vlan = 0;
15502 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15503 vxlan_encap_conf.select_vlan = 1;
15504 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15505 vxlan_encap_conf.select_vlan = 0;
15506 vxlan_encap_conf.select_tos_ttl = 1;
15508 if (strcmp(res->ip_version, "ipv4") == 0)
15509 vxlan_encap_conf.select_ipv4 = 1;
15510 else if (strcmp(res->ip_version, "ipv6") == 0)
15511 vxlan_encap_conf.select_ipv4 = 0;
15514 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15515 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15516 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15517 vxlan_encap_conf.ip_tos = res->tos;
15518 vxlan_encap_conf.ip_ttl = res->ttl;
15519 if (vxlan_encap_conf.select_ipv4) {
15520 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15521 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15523 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15524 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15526 if (vxlan_encap_conf.select_vlan)
15527 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15528 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15529 RTE_ETHER_ADDR_LEN);
15530 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15531 RTE_ETHER_ADDR_LEN);
15534 cmdline_parse_inst_t cmd_set_vxlan = {
15535 .f = cmd_set_vxlan_parsed,
15537 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15538 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15539 " eth-src <eth-src> eth-dst <eth-dst>",
15541 (void *)&cmd_set_vxlan_set,
15542 (void *)&cmd_set_vxlan_vxlan,
15543 (void *)&cmd_set_vxlan_ip_version,
15544 (void *)&cmd_set_vxlan_ip_version_value,
15545 (void *)&cmd_set_vxlan_vni,
15546 (void *)&cmd_set_vxlan_vni_value,
15547 (void *)&cmd_set_vxlan_udp_src,
15548 (void *)&cmd_set_vxlan_udp_src_value,
15549 (void *)&cmd_set_vxlan_udp_dst,
15550 (void *)&cmd_set_vxlan_udp_dst_value,
15551 (void *)&cmd_set_vxlan_ip_src,
15552 (void *)&cmd_set_vxlan_ip_src_value,
15553 (void *)&cmd_set_vxlan_ip_dst,
15554 (void *)&cmd_set_vxlan_ip_dst_value,
15555 (void *)&cmd_set_vxlan_eth_src,
15556 (void *)&cmd_set_vxlan_eth_src_value,
15557 (void *)&cmd_set_vxlan_eth_dst,
15558 (void *)&cmd_set_vxlan_eth_dst_value,
15563 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15564 .f = cmd_set_vxlan_parsed,
15566 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15567 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15568 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15569 " eth-dst <eth-dst>",
15571 (void *)&cmd_set_vxlan_set,
15572 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15573 (void *)&cmd_set_vxlan_ip_version,
15574 (void *)&cmd_set_vxlan_ip_version_value,
15575 (void *)&cmd_set_vxlan_vni,
15576 (void *)&cmd_set_vxlan_vni_value,
15577 (void *)&cmd_set_vxlan_udp_src,
15578 (void *)&cmd_set_vxlan_udp_src_value,
15579 (void *)&cmd_set_vxlan_udp_dst,
15580 (void *)&cmd_set_vxlan_udp_dst_value,
15581 (void *)&cmd_set_vxlan_ip_tos,
15582 (void *)&cmd_set_vxlan_ip_tos_value,
15583 (void *)&cmd_set_vxlan_ip_ttl,
15584 (void *)&cmd_set_vxlan_ip_ttl_value,
15585 (void *)&cmd_set_vxlan_ip_src,
15586 (void *)&cmd_set_vxlan_ip_src_value,
15587 (void *)&cmd_set_vxlan_ip_dst,
15588 (void *)&cmd_set_vxlan_ip_dst_value,
15589 (void *)&cmd_set_vxlan_eth_src,
15590 (void *)&cmd_set_vxlan_eth_src_value,
15591 (void *)&cmd_set_vxlan_eth_dst,
15592 (void *)&cmd_set_vxlan_eth_dst_value,
15597 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15598 .f = cmd_set_vxlan_parsed,
15600 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15601 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15602 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15605 (void *)&cmd_set_vxlan_set,
15606 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15607 (void *)&cmd_set_vxlan_ip_version,
15608 (void *)&cmd_set_vxlan_ip_version_value,
15609 (void *)&cmd_set_vxlan_vni,
15610 (void *)&cmd_set_vxlan_vni_value,
15611 (void *)&cmd_set_vxlan_udp_src,
15612 (void *)&cmd_set_vxlan_udp_src_value,
15613 (void *)&cmd_set_vxlan_udp_dst,
15614 (void *)&cmd_set_vxlan_udp_dst_value,
15615 (void *)&cmd_set_vxlan_ip_src,
15616 (void *)&cmd_set_vxlan_ip_src_value,
15617 (void *)&cmd_set_vxlan_ip_dst,
15618 (void *)&cmd_set_vxlan_ip_dst_value,
15619 (void *)&cmd_set_vxlan_vlan,
15620 (void *)&cmd_set_vxlan_vlan_value,
15621 (void *)&cmd_set_vxlan_eth_src,
15622 (void *)&cmd_set_vxlan_eth_src_value,
15623 (void *)&cmd_set_vxlan_eth_dst,
15624 (void *)&cmd_set_vxlan_eth_dst_value,
15629 /** Set NVGRE encapsulation details */
15630 struct cmd_set_nvgre_result {
15631 cmdline_fixed_string_t set;
15632 cmdline_fixed_string_t nvgre;
15633 cmdline_fixed_string_t pos_token;
15634 cmdline_fixed_string_t ip_version;
15636 cmdline_ipaddr_t ip_src;
15637 cmdline_ipaddr_t ip_dst;
15639 struct rte_ether_addr eth_src;
15640 struct rte_ether_addr eth_dst;
15643 cmdline_parse_token_string_t cmd_set_nvgre_set =
15644 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15645 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15646 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15647 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15648 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15649 "nvgre-with-vlan");
15650 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15651 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15653 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15654 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15656 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15657 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15659 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15660 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15661 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15662 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15664 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15665 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15666 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15667 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15669 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15670 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15671 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15672 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15674 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15675 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15676 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15677 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15679 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15680 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15681 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15682 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15684 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15685 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15687 static void cmd_set_nvgre_parsed(void *parsed_result,
15688 __rte_unused struct cmdline *cl,
15689 __rte_unused void *data)
15691 struct cmd_set_nvgre_result *res = parsed_result;
15693 uint32_t nvgre_tni;
15696 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15699 if (strcmp(res->nvgre, "nvgre") == 0)
15700 nvgre_encap_conf.select_vlan = 0;
15701 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15702 nvgre_encap_conf.select_vlan = 1;
15703 if (strcmp(res->ip_version, "ipv4") == 0)
15704 nvgre_encap_conf.select_ipv4 = 1;
15705 else if (strcmp(res->ip_version, "ipv6") == 0)
15706 nvgre_encap_conf.select_ipv4 = 0;
15709 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15710 if (nvgre_encap_conf.select_ipv4) {
15711 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15712 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15714 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15715 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15717 if (nvgre_encap_conf.select_vlan)
15718 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15719 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15720 RTE_ETHER_ADDR_LEN);
15721 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15722 RTE_ETHER_ADDR_LEN);
15725 cmdline_parse_inst_t cmd_set_nvgre = {
15726 .f = cmd_set_nvgre_parsed,
15728 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15729 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15730 " eth-dst <eth-dst>",
15732 (void *)&cmd_set_nvgre_set,
15733 (void *)&cmd_set_nvgre_nvgre,
15734 (void *)&cmd_set_nvgre_ip_version,
15735 (void *)&cmd_set_nvgre_ip_version_value,
15736 (void *)&cmd_set_nvgre_tni,
15737 (void *)&cmd_set_nvgre_tni_value,
15738 (void *)&cmd_set_nvgre_ip_src,
15739 (void *)&cmd_set_nvgre_ip_src_value,
15740 (void *)&cmd_set_nvgre_ip_dst,
15741 (void *)&cmd_set_nvgre_ip_dst_value,
15742 (void *)&cmd_set_nvgre_eth_src,
15743 (void *)&cmd_set_nvgre_eth_src_value,
15744 (void *)&cmd_set_nvgre_eth_dst,
15745 (void *)&cmd_set_nvgre_eth_dst_value,
15750 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15751 .f = cmd_set_nvgre_parsed,
15753 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15754 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15755 " eth-src <eth-src> eth-dst <eth-dst>",
15757 (void *)&cmd_set_nvgre_set,
15758 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15759 (void *)&cmd_set_nvgre_ip_version,
15760 (void *)&cmd_set_nvgre_ip_version_value,
15761 (void *)&cmd_set_nvgre_tni,
15762 (void *)&cmd_set_nvgre_tni_value,
15763 (void *)&cmd_set_nvgre_ip_src,
15764 (void *)&cmd_set_nvgre_ip_src_value,
15765 (void *)&cmd_set_nvgre_ip_dst,
15766 (void *)&cmd_set_nvgre_ip_dst_value,
15767 (void *)&cmd_set_nvgre_vlan,
15768 (void *)&cmd_set_nvgre_vlan_value,
15769 (void *)&cmd_set_nvgre_eth_src,
15770 (void *)&cmd_set_nvgre_eth_src_value,
15771 (void *)&cmd_set_nvgre_eth_dst,
15772 (void *)&cmd_set_nvgre_eth_dst_value,
15777 /** Set L2 encapsulation details */
15778 struct cmd_set_l2_encap_result {
15779 cmdline_fixed_string_t set;
15780 cmdline_fixed_string_t l2_encap;
15781 cmdline_fixed_string_t pos_token;
15782 cmdline_fixed_string_t ip_version;
15783 uint32_t vlan_present:1;
15785 struct rte_ether_addr eth_src;
15786 struct rte_ether_addr eth_dst;
15789 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15790 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15791 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15792 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15793 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15794 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15795 "l2_encap-with-vlan");
15796 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15797 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15799 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15800 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15802 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15803 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15805 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15806 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15807 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15808 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15810 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15811 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15812 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15813 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15815 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15816 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15818 static void cmd_set_l2_encap_parsed(void *parsed_result,
15819 __rte_unused struct cmdline *cl,
15820 __rte_unused void *data)
15822 struct cmd_set_l2_encap_result *res = parsed_result;
15824 if (strcmp(res->l2_encap, "l2_encap") == 0)
15825 l2_encap_conf.select_vlan = 0;
15826 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15827 l2_encap_conf.select_vlan = 1;
15828 if (strcmp(res->ip_version, "ipv4") == 0)
15829 l2_encap_conf.select_ipv4 = 1;
15830 else if (strcmp(res->ip_version, "ipv6") == 0)
15831 l2_encap_conf.select_ipv4 = 0;
15834 if (l2_encap_conf.select_vlan)
15835 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15836 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15837 RTE_ETHER_ADDR_LEN);
15838 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15839 RTE_ETHER_ADDR_LEN);
15842 cmdline_parse_inst_t cmd_set_l2_encap = {
15843 .f = cmd_set_l2_encap_parsed,
15845 .help_str = "set l2_encap ip-version ipv4|ipv6"
15846 " eth-src <eth-src> eth-dst <eth-dst>",
15848 (void *)&cmd_set_l2_encap_set,
15849 (void *)&cmd_set_l2_encap_l2_encap,
15850 (void *)&cmd_set_l2_encap_ip_version,
15851 (void *)&cmd_set_l2_encap_ip_version_value,
15852 (void *)&cmd_set_l2_encap_eth_src,
15853 (void *)&cmd_set_l2_encap_eth_src_value,
15854 (void *)&cmd_set_l2_encap_eth_dst,
15855 (void *)&cmd_set_l2_encap_eth_dst_value,
15860 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15861 .f = cmd_set_l2_encap_parsed,
15863 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15864 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15866 (void *)&cmd_set_l2_encap_set,
15867 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15868 (void *)&cmd_set_l2_encap_ip_version,
15869 (void *)&cmd_set_l2_encap_ip_version_value,
15870 (void *)&cmd_set_l2_encap_vlan,
15871 (void *)&cmd_set_l2_encap_vlan_value,
15872 (void *)&cmd_set_l2_encap_eth_src,
15873 (void *)&cmd_set_l2_encap_eth_src_value,
15874 (void *)&cmd_set_l2_encap_eth_dst,
15875 (void *)&cmd_set_l2_encap_eth_dst_value,
15880 /** Set L2 decapsulation details */
15881 struct cmd_set_l2_decap_result {
15882 cmdline_fixed_string_t set;
15883 cmdline_fixed_string_t l2_decap;
15884 cmdline_fixed_string_t pos_token;
15885 uint32_t vlan_present:1;
15888 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15889 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15890 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15891 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15893 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15894 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15895 "l2_decap-with-vlan");
15897 static void cmd_set_l2_decap_parsed(void *parsed_result,
15898 __rte_unused struct cmdline *cl,
15899 __rte_unused void *data)
15901 struct cmd_set_l2_decap_result *res = parsed_result;
15903 if (strcmp(res->l2_decap, "l2_decap") == 0)
15904 l2_decap_conf.select_vlan = 0;
15905 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15906 l2_decap_conf.select_vlan = 1;
15909 cmdline_parse_inst_t cmd_set_l2_decap = {
15910 .f = cmd_set_l2_decap_parsed,
15912 .help_str = "set l2_decap",
15914 (void *)&cmd_set_l2_decap_set,
15915 (void *)&cmd_set_l2_decap_l2_decap,
15920 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15921 .f = cmd_set_l2_decap_parsed,
15923 .help_str = "set l2_decap-with-vlan",
15925 (void *)&cmd_set_l2_decap_set,
15926 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15931 /** Set MPLSoGRE encapsulation details */
15932 struct cmd_set_mplsogre_encap_result {
15933 cmdline_fixed_string_t set;
15934 cmdline_fixed_string_t mplsogre;
15935 cmdline_fixed_string_t pos_token;
15936 cmdline_fixed_string_t ip_version;
15937 uint32_t vlan_present:1;
15939 cmdline_ipaddr_t ip_src;
15940 cmdline_ipaddr_t ip_dst;
15942 struct rte_ether_addr eth_src;
15943 struct rte_ether_addr eth_dst;
15946 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15947 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15949 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15950 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15952 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15953 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15954 mplsogre, "mplsogre_encap-with-vlan");
15955 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15956 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15957 pos_token, "ip-version");
15958 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15959 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15960 ip_version, "ipv4#ipv6");
15961 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15962 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15963 pos_token, "label");
15964 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15965 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15967 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15968 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15969 pos_token, "ip-src");
15970 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15971 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15972 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15973 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15974 pos_token, "ip-dst");
15975 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15976 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15977 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15978 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15979 pos_token, "vlan-tci");
15980 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15981 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15983 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15984 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15985 pos_token, "eth-src");
15986 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15987 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15989 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15990 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15991 pos_token, "eth-dst");
15992 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15993 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15996 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15997 __rte_unused struct cmdline *cl,
15998 __rte_unused void *data)
16000 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16002 uint32_t mplsogre_label;
16005 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16008 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16009 mplsogre_encap_conf.select_vlan = 0;
16010 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16011 mplsogre_encap_conf.select_vlan = 1;
16012 if (strcmp(res->ip_version, "ipv4") == 0)
16013 mplsogre_encap_conf.select_ipv4 = 1;
16014 else if (strcmp(res->ip_version, "ipv6") == 0)
16015 mplsogre_encap_conf.select_ipv4 = 0;
16018 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16019 if (mplsogre_encap_conf.select_ipv4) {
16020 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16021 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16023 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16024 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16026 if (mplsogre_encap_conf.select_vlan)
16027 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16028 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16029 RTE_ETHER_ADDR_LEN);
16030 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16031 RTE_ETHER_ADDR_LEN);
16034 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16035 .f = cmd_set_mplsogre_encap_parsed,
16037 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16038 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16039 " eth-dst <eth-dst>",
16041 (void *)&cmd_set_mplsogre_encap_set,
16042 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16043 (void *)&cmd_set_mplsogre_encap_ip_version,
16044 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16045 (void *)&cmd_set_mplsogre_encap_label,
16046 (void *)&cmd_set_mplsogre_encap_label_value,
16047 (void *)&cmd_set_mplsogre_encap_ip_src,
16048 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16049 (void *)&cmd_set_mplsogre_encap_ip_dst,
16050 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16051 (void *)&cmd_set_mplsogre_encap_eth_src,
16052 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16053 (void *)&cmd_set_mplsogre_encap_eth_dst,
16054 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16059 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16060 .f = cmd_set_mplsogre_encap_parsed,
16062 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16063 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16064 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16066 (void *)&cmd_set_mplsogre_encap_set,
16067 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16068 (void *)&cmd_set_mplsogre_encap_ip_version,
16069 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16070 (void *)&cmd_set_mplsogre_encap_label,
16071 (void *)&cmd_set_mplsogre_encap_label_value,
16072 (void *)&cmd_set_mplsogre_encap_ip_src,
16073 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16074 (void *)&cmd_set_mplsogre_encap_ip_dst,
16075 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16076 (void *)&cmd_set_mplsogre_encap_vlan,
16077 (void *)&cmd_set_mplsogre_encap_vlan_value,
16078 (void *)&cmd_set_mplsogre_encap_eth_src,
16079 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16080 (void *)&cmd_set_mplsogre_encap_eth_dst,
16081 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16086 /** Set MPLSoGRE decapsulation details */
16087 struct cmd_set_mplsogre_decap_result {
16088 cmdline_fixed_string_t set;
16089 cmdline_fixed_string_t mplsogre;
16090 cmdline_fixed_string_t pos_token;
16091 cmdline_fixed_string_t ip_version;
16092 uint32_t vlan_present:1;
16095 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16096 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16098 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16099 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16101 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16102 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16103 mplsogre, "mplsogre_decap-with-vlan");
16104 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16105 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16106 pos_token, "ip-version");
16107 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16108 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16109 ip_version, "ipv4#ipv6");
16111 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16112 __rte_unused struct cmdline *cl,
16113 __rte_unused void *data)
16115 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16117 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16118 mplsogre_decap_conf.select_vlan = 0;
16119 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16120 mplsogre_decap_conf.select_vlan = 1;
16121 if (strcmp(res->ip_version, "ipv4") == 0)
16122 mplsogre_decap_conf.select_ipv4 = 1;
16123 else if (strcmp(res->ip_version, "ipv6") == 0)
16124 mplsogre_decap_conf.select_ipv4 = 0;
16127 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16128 .f = cmd_set_mplsogre_decap_parsed,
16130 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16132 (void *)&cmd_set_mplsogre_decap_set,
16133 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16134 (void *)&cmd_set_mplsogre_decap_ip_version,
16135 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16140 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16141 .f = cmd_set_mplsogre_decap_parsed,
16143 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16145 (void *)&cmd_set_mplsogre_decap_set,
16146 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16147 (void *)&cmd_set_mplsogre_decap_ip_version,
16148 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16153 /** Set MPLSoUDP encapsulation details */
16154 struct cmd_set_mplsoudp_encap_result {
16155 cmdline_fixed_string_t set;
16156 cmdline_fixed_string_t mplsoudp;
16157 cmdline_fixed_string_t pos_token;
16158 cmdline_fixed_string_t ip_version;
16159 uint32_t vlan_present:1;
16163 cmdline_ipaddr_t ip_src;
16164 cmdline_ipaddr_t ip_dst;
16166 struct rte_ether_addr eth_src;
16167 struct rte_ether_addr eth_dst;
16170 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16171 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16173 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16174 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16176 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16177 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16178 mplsoudp, "mplsoudp_encap-with-vlan");
16179 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16180 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16181 pos_token, "ip-version");
16182 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16183 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16184 ip_version, "ipv4#ipv6");
16185 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16186 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16187 pos_token, "label");
16188 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16189 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16191 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16192 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16193 pos_token, "udp-src");
16194 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16195 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16197 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16198 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16199 pos_token, "udp-dst");
16200 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16201 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16203 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16204 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16205 pos_token, "ip-src");
16206 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16207 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16208 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16209 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16210 pos_token, "ip-dst");
16211 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16212 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16213 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16214 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16215 pos_token, "vlan-tci");
16216 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16217 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16219 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16220 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16221 pos_token, "eth-src");
16222 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16223 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16225 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16226 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16227 pos_token, "eth-dst");
16228 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16229 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16232 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16233 __rte_unused struct cmdline *cl,
16234 __rte_unused void *data)
16236 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16238 uint32_t mplsoudp_label;
16241 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16244 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16245 mplsoudp_encap_conf.select_vlan = 0;
16246 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16247 mplsoudp_encap_conf.select_vlan = 1;
16248 if (strcmp(res->ip_version, "ipv4") == 0)
16249 mplsoudp_encap_conf.select_ipv4 = 1;
16250 else if (strcmp(res->ip_version, "ipv6") == 0)
16251 mplsoudp_encap_conf.select_ipv4 = 0;
16254 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16255 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16256 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16257 if (mplsoudp_encap_conf.select_ipv4) {
16258 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16259 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16261 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16262 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16264 if (mplsoudp_encap_conf.select_vlan)
16265 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16266 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16267 RTE_ETHER_ADDR_LEN);
16268 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16269 RTE_ETHER_ADDR_LEN);
16272 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16273 .f = cmd_set_mplsoudp_encap_parsed,
16275 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16276 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16277 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16279 (void *)&cmd_set_mplsoudp_encap_set,
16280 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16281 (void *)&cmd_set_mplsoudp_encap_ip_version,
16282 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16283 (void *)&cmd_set_mplsoudp_encap_label,
16284 (void *)&cmd_set_mplsoudp_encap_label_value,
16285 (void *)&cmd_set_mplsoudp_encap_udp_src,
16286 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16287 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16288 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16289 (void *)&cmd_set_mplsoudp_encap_ip_src,
16290 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16291 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16292 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16293 (void *)&cmd_set_mplsoudp_encap_eth_src,
16294 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16295 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16296 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16301 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16302 .f = cmd_set_mplsoudp_encap_parsed,
16304 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16305 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16306 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16307 " eth-src <eth-src> eth-dst <eth-dst>",
16309 (void *)&cmd_set_mplsoudp_encap_set,
16310 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16311 (void *)&cmd_set_mplsoudp_encap_ip_version,
16312 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16313 (void *)&cmd_set_mplsoudp_encap_label,
16314 (void *)&cmd_set_mplsoudp_encap_label_value,
16315 (void *)&cmd_set_mplsoudp_encap_udp_src,
16316 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16317 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16318 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16319 (void *)&cmd_set_mplsoudp_encap_ip_src,
16320 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16321 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16322 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16323 (void *)&cmd_set_mplsoudp_encap_vlan,
16324 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16325 (void *)&cmd_set_mplsoudp_encap_eth_src,
16326 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16327 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16328 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16333 /** Set MPLSoUDP decapsulation details */
16334 struct cmd_set_mplsoudp_decap_result {
16335 cmdline_fixed_string_t set;
16336 cmdline_fixed_string_t mplsoudp;
16337 cmdline_fixed_string_t pos_token;
16338 cmdline_fixed_string_t ip_version;
16339 uint32_t vlan_present:1;
16342 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16343 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16345 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16346 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16348 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16349 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16350 mplsoudp, "mplsoudp_decap-with-vlan");
16351 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16352 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16353 pos_token, "ip-version");
16354 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16355 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16356 ip_version, "ipv4#ipv6");
16358 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16359 __rte_unused struct cmdline *cl,
16360 __rte_unused void *data)
16362 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16364 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16365 mplsoudp_decap_conf.select_vlan = 0;
16366 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16367 mplsoudp_decap_conf.select_vlan = 1;
16368 if (strcmp(res->ip_version, "ipv4") == 0)
16369 mplsoudp_decap_conf.select_ipv4 = 1;
16370 else if (strcmp(res->ip_version, "ipv6") == 0)
16371 mplsoudp_decap_conf.select_ipv4 = 0;
16374 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16375 .f = cmd_set_mplsoudp_decap_parsed,
16377 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16379 (void *)&cmd_set_mplsoudp_decap_set,
16380 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16381 (void *)&cmd_set_mplsoudp_decap_ip_version,
16382 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16387 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16388 .f = cmd_set_mplsoudp_decap_parsed,
16390 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16392 (void *)&cmd_set_mplsoudp_decap_set,
16393 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16394 (void *)&cmd_set_mplsoudp_decap_ip_version,
16395 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16400 /* Strict link priority scheduling mode setting */
16402 cmd_strict_link_prio_parsed(
16403 void *parsed_result,
16404 __rte_unused struct cmdline *cl,
16405 __rte_unused void *data)
16407 struct cmd_vf_tc_bw_result *res = parsed_result;
16408 int ret = -ENOTSUP;
16410 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16413 #ifdef RTE_LIBRTE_I40E_PMD
16414 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16421 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16424 printf("invalid port_id %d\n", res->port_id);
16427 printf("function not implemented\n");
16430 printf("programming error: (%s)\n", strerror(-ret));
16434 cmdline_parse_inst_t cmd_strict_link_prio = {
16435 .f = cmd_strict_link_prio_parsed,
16437 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16439 (void *)&cmd_vf_tc_bw_set,
16440 (void *)&cmd_vf_tc_bw_tx,
16441 (void *)&cmd_vf_tc_bw_strict_link_prio,
16442 (void *)&cmd_vf_tc_bw_port_id,
16443 (void *)&cmd_vf_tc_bw_tc_map,
16448 /* Load dynamic device personalization*/
16449 struct cmd_ddp_add_result {
16450 cmdline_fixed_string_t ddp;
16451 cmdline_fixed_string_t add;
16456 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16457 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16458 cmdline_parse_token_string_t cmd_ddp_add_add =
16459 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16460 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16461 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16462 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16463 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16466 cmd_ddp_add_parsed(
16467 void *parsed_result,
16468 __rte_unused struct cmdline *cl,
16469 __rte_unused void *data)
16471 struct cmd_ddp_add_result *res = parsed_result;
16477 int ret = -ENOTSUP;
16479 if (!all_ports_stopped()) {
16480 printf("Please stop all ports first\n");
16484 filepath = strdup(res->filepath);
16485 if (filepath == NULL) {
16486 printf("Failed to allocate memory\n");
16489 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16491 buff = open_file(file_fld[0], &size);
16493 free((void *)filepath);
16497 #ifdef RTE_LIBRTE_I40E_PMD
16498 if (ret == -ENOTSUP)
16499 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16501 RTE_PMD_I40E_PKG_OP_WR_ADD);
16504 if (ret == -EEXIST)
16505 printf("Profile has already existed.\n");
16507 printf("Failed to load profile.\n");
16508 else if (file_num == 2)
16509 save_file(file_fld[1], buff, size);
16512 free((void *)filepath);
16515 cmdline_parse_inst_t cmd_ddp_add = {
16516 .f = cmd_ddp_add_parsed,
16518 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16520 (void *)&cmd_ddp_add_ddp,
16521 (void *)&cmd_ddp_add_add,
16522 (void *)&cmd_ddp_add_port_id,
16523 (void *)&cmd_ddp_add_filepath,
16528 /* Delete dynamic device personalization*/
16529 struct cmd_ddp_del_result {
16530 cmdline_fixed_string_t ddp;
16531 cmdline_fixed_string_t del;
16536 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16537 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16538 cmdline_parse_token_string_t cmd_ddp_del_del =
16539 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16540 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16541 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16542 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16543 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16546 cmd_ddp_del_parsed(
16547 void *parsed_result,
16548 __rte_unused struct cmdline *cl,
16549 __rte_unused void *data)
16551 struct cmd_ddp_del_result *res = parsed_result;
16554 int ret = -ENOTSUP;
16556 if (!all_ports_stopped()) {
16557 printf("Please stop all ports first\n");
16561 buff = open_file(res->filepath, &size);
16565 #ifdef RTE_LIBRTE_I40E_PMD
16566 if (ret == -ENOTSUP)
16567 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16569 RTE_PMD_I40E_PKG_OP_WR_DEL);
16572 if (ret == -EACCES)
16573 printf("Profile does not exist.\n");
16575 printf("Failed to delete profile.\n");
16580 cmdline_parse_inst_t cmd_ddp_del = {
16581 .f = cmd_ddp_del_parsed,
16583 .help_str = "ddp del <port_id> <backup_profile_path>",
16585 (void *)&cmd_ddp_del_ddp,
16586 (void *)&cmd_ddp_del_del,
16587 (void *)&cmd_ddp_del_port_id,
16588 (void *)&cmd_ddp_del_filepath,
16593 /* Get dynamic device personalization profile info */
16594 struct cmd_ddp_info_result {
16595 cmdline_fixed_string_t ddp;
16596 cmdline_fixed_string_t get;
16597 cmdline_fixed_string_t info;
16601 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16602 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16603 cmdline_parse_token_string_t cmd_ddp_info_get =
16604 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16605 cmdline_parse_token_string_t cmd_ddp_info_info =
16606 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16607 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16608 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16611 cmd_ddp_info_parsed(
16612 void *parsed_result,
16613 __rte_unused struct cmdline *cl,
16614 __rte_unused void *data)
16616 struct cmd_ddp_info_result *res = parsed_result;
16619 int ret = -ENOTSUP;
16620 #ifdef RTE_LIBRTE_I40E_PMD
16623 uint32_t buff_size = 0;
16624 struct rte_pmd_i40e_profile_info info;
16625 uint32_t dev_num = 0;
16626 struct rte_pmd_i40e_ddp_device_id *devs;
16627 uint32_t proto_num = 0;
16628 struct rte_pmd_i40e_proto_info *proto = NULL;
16629 uint32_t pctype_num = 0;
16630 struct rte_pmd_i40e_ptype_info *pctype;
16631 uint32_t ptype_num = 0;
16632 struct rte_pmd_i40e_ptype_info *ptype;
16637 pkg = open_file(res->filepath, &pkg_size);
16641 #ifdef RTE_LIBRTE_I40E_PMD
16642 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16643 (uint8_t *)&info, sizeof(info),
16644 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16646 printf("Global Track id: 0x%x\n", info.track_id);
16647 printf("Global Version: %d.%d.%d.%d\n",
16648 info.version.major,
16649 info.version.minor,
16650 info.version.update,
16651 info.version.draft);
16652 printf("Global Package name: %s\n\n", info.name);
16655 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16656 (uint8_t *)&info, sizeof(info),
16657 RTE_PMD_I40E_PKG_INFO_HEADER);
16659 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16660 printf("i40e Profile Version: %d.%d.%d.%d\n",
16661 info.version.major,
16662 info.version.minor,
16663 info.version.update,
16664 info.version.draft);
16665 printf("i40e Profile name: %s\n\n", info.name);
16668 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16669 (uint8_t *)&buff_size, sizeof(buff_size),
16670 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16671 if (!ret && buff_size) {
16672 buff = (uint8_t *)malloc(buff_size);
16674 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16676 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16678 printf("Package Notes:\n%s\n\n", buff);
16683 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16684 (uint8_t *)&dev_num, sizeof(dev_num),
16685 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16686 if (!ret && dev_num) {
16687 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16688 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16690 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16691 (uint8_t *)devs, buff_size,
16692 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16694 printf("List of supported devices:\n");
16695 for (i = 0; i < dev_num; i++) {
16696 printf(" %04X:%04X %04X:%04X\n",
16697 devs[i].vendor_dev_id >> 16,
16698 devs[i].vendor_dev_id & 0xFFFF,
16699 devs[i].sub_vendor_dev_id >> 16,
16700 devs[i].sub_vendor_dev_id & 0xFFFF);
16708 /* get information about protocols and packet types */
16709 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16710 (uint8_t *)&proto_num, sizeof(proto_num),
16711 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16712 if (ret || !proto_num)
16713 goto no_print_return;
16715 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16716 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16718 goto no_print_return;
16720 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16722 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16724 printf("List of used protocols:\n");
16725 for (i = 0; i < proto_num; i++)
16726 printf(" %2u: %s\n", proto[i].proto_id,
16730 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16731 (uint8_t *)&pctype_num, sizeof(pctype_num),
16732 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16733 if (ret || !pctype_num)
16734 goto no_print_pctypes;
16736 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16737 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16739 goto no_print_pctypes;
16741 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16743 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16746 goto no_print_pctypes;
16749 printf("List of defined packet classification types:\n");
16750 for (i = 0; i < pctype_num; i++) {
16751 printf(" %2u:", pctype[i].ptype_id);
16752 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16753 proto_id = pctype[i].protocols[j];
16754 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16755 for (n = 0; n < proto_num; n++) {
16756 if (proto[n].proto_id == proto_id) {
16757 printf(" %s", proto[n].name);
16770 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16772 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16773 if (ret || !ptype_num)
16774 goto no_print_return;
16776 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16777 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16779 goto no_print_return;
16781 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16783 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16786 goto no_print_return;
16788 printf("List of defined packet types:\n");
16789 for (i = 0; i < ptype_num; i++) {
16790 printf(" %2u:", ptype[i].ptype_id);
16791 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16792 proto_id = ptype[i].protocols[j];
16793 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16794 for (n = 0; n < proto_num; n++) {
16795 if (proto[n].proto_id == proto_id) {
16796 printf(" %s", proto[n].name);
16812 if (ret == -ENOTSUP)
16813 printf("Function not supported in PMD driver\n");
16817 cmdline_parse_inst_t cmd_ddp_get_info = {
16818 .f = cmd_ddp_info_parsed,
16820 .help_str = "ddp get info <profile_path>",
16822 (void *)&cmd_ddp_info_ddp,
16823 (void *)&cmd_ddp_info_get,
16824 (void *)&cmd_ddp_info_info,
16825 (void *)&cmd_ddp_info_filepath,
16830 /* Get dynamic device personalization profile info list*/
16831 #define PROFILE_INFO_SIZE 48
16832 #define MAX_PROFILE_NUM 16
16834 struct cmd_ddp_get_list_result {
16835 cmdline_fixed_string_t ddp;
16836 cmdline_fixed_string_t get;
16837 cmdline_fixed_string_t list;
16841 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16842 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16843 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16844 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16845 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16846 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16847 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16848 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16851 cmd_ddp_get_list_parsed(
16852 __rte_unused void *parsed_result,
16853 __rte_unused struct cmdline *cl,
16854 __rte_unused void *data)
16856 #ifdef RTE_LIBRTE_I40E_PMD
16857 struct cmd_ddp_get_list_result *res = parsed_result;
16858 struct rte_pmd_i40e_profile_list *p_list;
16859 struct rte_pmd_i40e_profile_info *p_info;
16864 int ret = -ENOTSUP;
16866 #ifdef RTE_LIBRTE_I40E_PMD
16867 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16868 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16870 printf("%s: Failed to malloc buffer\n", __func__);
16872 if (ret == -ENOTSUP)
16873 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16874 (uint8_t *)p_list, size);
16877 p_num = p_list->p_count;
16878 printf("Profile number is: %d\n\n", p_num);
16880 for (i = 0; i < p_num; i++) {
16881 p_info = &p_list->p_info[i];
16882 printf("Profile %d:\n", i);
16883 printf("Track id: 0x%x\n", p_info->track_id);
16884 printf("Version: %d.%d.%d.%d\n",
16885 p_info->version.major,
16886 p_info->version.minor,
16887 p_info->version.update,
16888 p_info->version.draft);
16889 printf("Profile name: %s\n\n", p_info->name);
16897 printf("Failed to get ddp list\n");
16900 cmdline_parse_inst_t cmd_ddp_get_list = {
16901 .f = cmd_ddp_get_list_parsed,
16903 .help_str = "ddp get list <port_id>",
16905 (void *)&cmd_ddp_get_list_ddp,
16906 (void *)&cmd_ddp_get_list_get,
16907 (void *)&cmd_ddp_get_list_list,
16908 (void *)&cmd_ddp_get_list_port_id,
16913 /* Configure input set */
16914 struct cmd_cfg_input_set_result {
16915 cmdline_fixed_string_t port;
16916 cmdline_fixed_string_t cfg;
16918 cmdline_fixed_string_t pctype;
16920 cmdline_fixed_string_t inset_type;
16921 cmdline_fixed_string_t opt;
16922 cmdline_fixed_string_t field;
16927 cmd_cfg_input_set_parsed(
16928 __rte_unused void *parsed_result,
16929 __rte_unused struct cmdline *cl,
16930 __rte_unused void *data)
16932 #ifdef RTE_LIBRTE_I40E_PMD
16933 struct cmd_cfg_input_set_result *res = parsed_result;
16934 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16935 struct rte_pmd_i40e_inset inset;
16937 int ret = -ENOTSUP;
16939 if (!all_ports_stopped()) {
16940 printf("Please stop all ports first\n");
16944 #ifdef RTE_LIBRTE_I40E_PMD
16945 if (!strcmp(res->inset_type, "hash_inset"))
16946 inset_type = INSET_HASH;
16947 else if (!strcmp(res->inset_type, "fdir_inset"))
16948 inset_type = INSET_FDIR;
16949 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16950 inset_type = INSET_FDIR_FLX;
16951 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16952 &inset, inset_type);
16954 printf("Failed to get input set.\n");
16958 if (!strcmp(res->opt, "get")) {
16959 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16962 printf("Field index %d is enabled.\n", res->field_idx);
16964 printf("Field index %d is disabled.\n", res->field_idx);
16966 } else if (!strcmp(res->opt, "set"))
16967 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16969 else if (!strcmp(res->opt, "clear"))
16970 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16973 printf("Failed to configure input set field.\n");
16977 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16978 &inset, inset_type);
16980 printf("Failed to set input set.\n");
16985 if (ret == -ENOTSUP)
16986 printf("Function not supported\n");
16989 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16990 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16992 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16993 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16995 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16996 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16998 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16999 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17001 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17002 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17004 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17005 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17007 "hash_inset#fdir_inset#fdir_flx_inset");
17008 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17009 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17010 opt, "get#set#clear");
17011 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17012 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17014 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17015 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17018 cmdline_parse_inst_t cmd_cfg_input_set = {
17019 .f = cmd_cfg_input_set_parsed,
17021 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17022 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17024 (void *)&cmd_cfg_input_set_port,
17025 (void *)&cmd_cfg_input_set_cfg,
17026 (void *)&cmd_cfg_input_set_port_id,
17027 (void *)&cmd_cfg_input_set_pctype,
17028 (void *)&cmd_cfg_input_set_pctype_id,
17029 (void *)&cmd_cfg_input_set_inset_type,
17030 (void *)&cmd_cfg_input_set_opt,
17031 (void *)&cmd_cfg_input_set_field,
17032 (void *)&cmd_cfg_input_set_field_idx,
17037 /* Clear input set */
17038 struct cmd_clear_input_set_result {
17039 cmdline_fixed_string_t port;
17040 cmdline_fixed_string_t cfg;
17042 cmdline_fixed_string_t pctype;
17044 cmdline_fixed_string_t inset_type;
17045 cmdline_fixed_string_t clear;
17046 cmdline_fixed_string_t all;
17050 cmd_clear_input_set_parsed(
17051 __rte_unused void *parsed_result,
17052 __rte_unused struct cmdline *cl,
17053 __rte_unused void *data)
17055 #ifdef RTE_LIBRTE_I40E_PMD
17056 struct cmd_clear_input_set_result *res = parsed_result;
17057 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17058 struct rte_pmd_i40e_inset inset;
17060 int ret = -ENOTSUP;
17062 if (!all_ports_stopped()) {
17063 printf("Please stop all ports first\n");
17067 #ifdef RTE_LIBRTE_I40E_PMD
17068 if (!strcmp(res->inset_type, "hash_inset"))
17069 inset_type = INSET_HASH;
17070 else if (!strcmp(res->inset_type, "fdir_inset"))
17071 inset_type = INSET_FDIR;
17072 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17073 inset_type = INSET_FDIR_FLX;
17075 memset(&inset, 0, sizeof(inset));
17077 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17078 &inset, inset_type);
17080 printf("Failed to clear input set.\n");
17086 if (ret == -ENOTSUP)
17087 printf("Function not supported\n");
17090 cmdline_parse_token_string_t cmd_clear_input_set_port =
17091 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17093 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17094 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17096 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17097 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17099 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17100 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17102 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17103 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17105 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17106 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17108 "hash_inset#fdir_inset#fdir_flx_inset");
17109 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17110 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17112 cmdline_parse_token_string_t cmd_clear_input_set_all =
17113 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17116 cmdline_parse_inst_t cmd_clear_input_set = {
17117 .f = cmd_clear_input_set_parsed,
17119 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17120 "fdir_inset|fdir_flx_inset clear all",
17122 (void *)&cmd_clear_input_set_port,
17123 (void *)&cmd_clear_input_set_cfg,
17124 (void *)&cmd_clear_input_set_port_id,
17125 (void *)&cmd_clear_input_set_pctype,
17126 (void *)&cmd_clear_input_set_pctype_id,
17127 (void *)&cmd_clear_input_set_inset_type,
17128 (void *)&cmd_clear_input_set_clear,
17129 (void *)&cmd_clear_input_set_all,
17134 /* show vf stats */
17136 /* Common result structure for show vf stats */
17137 struct cmd_show_vf_stats_result {
17138 cmdline_fixed_string_t show;
17139 cmdline_fixed_string_t vf;
17140 cmdline_fixed_string_t stats;
17145 /* Common CLI fields show vf stats*/
17146 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17147 TOKEN_STRING_INITIALIZER
17148 (struct cmd_show_vf_stats_result,
17150 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17151 TOKEN_STRING_INITIALIZER
17152 (struct cmd_show_vf_stats_result,
17154 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17155 TOKEN_STRING_INITIALIZER
17156 (struct cmd_show_vf_stats_result,
17158 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17159 TOKEN_NUM_INITIALIZER
17160 (struct cmd_show_vf_stats_result,
17162 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17163 TOKEN_NUM_INITIALIZER
17164 (struct cmd_show_vf_stats_result,
17168 cmd_show_vf_stats_parsed(
17169 void *parsed_result,
17170 __rte_unused struct cmdline *cl,
17171 __rte_unused void *data)
17173 struct cmd_show_vf_stats_result *res = parsed_result;
17174 struct rte_eth_stats stats;
17175 int ret = -ENOTSUP;
17176 static const char *nic_stats_border = "########################";
17178 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17181 memset(&stats, 0, sizeof(stats));
17183 #ifdef RTE_LIBRTE_I40E_PMD
17184 if (ret == -ENOTSUP)
17185 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17189 #ifdef RTE_LIBRTE_BNXT_PMD
17190 if (ret == -ENOTSUP)
17191 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17200 printf("invalid vf_id %d\n", res->vf_id);
17203 printf("invalid port_id %d\n", res->port_id);
17206 printf("function not implemented\n");
17209 printf("programming error: (%s)\n", strerror(-ret));
17212 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17213 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17215 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17217 stats.ipackets, stats.imissed, stats.ibytes);
17218 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17219 printf(" RX-nombuf: %-10"PRIu64"\n",
17221 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17223 stats.opackets, stats.oerrors, stats.obytes);
17225 printf(" %s############################%s\n",
17226 nic_stats_border, nic_stats_border);
17229 cmdline_parse_inst_t cmd_show_vf_stats = {
17230 .f = cmd_show_vf_stats_parsed,
17232 .help_str = "show vf stats <port_id> <vf_id>",
17234 (void *)&cmd_show_vf_stats_show,
17235 (void *)&cmd_show_vf_stats_vf,
17236 (void *)&cmd_show_vf_stats_stats,
17237 (void *)&cmd_show_vf_stats_port_id,
17238 (void *)&cmd_show_vf_stats_vf_id,
17243 /* clear vf stats */
17245 /* Common result structure for clear vf stats */
17246 struct cmd_clear_vf_stats_result {
17247 cmdline_fixed_string_t clear;
17248 cmdline_fixed_string_t vf;
17249 cmdline_fixed_string_t stats;
17254 /* Common CLI fields clear vf stats*/
17255 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17256 TOKEN_STRING_INITIALIZER
17257 (struct cmd_clear_vf_stats_result,
17259 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17260 TOKEN_STRING_INITIALIZER
17261 (struct cmd_clear_vf_stats_result,
17263 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17264 TOKEN_STRING_INITIALIZER
17265 (struct cmd_clear_vf_stats_result,
17267 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17268 TOKEN_NUM_INITIALIZER
17269 (struct cmd_clear_vf_stats_result,
17271 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17272 TOKEN_NUM_INITIALIZER
17273 (struct cmd_clear_vf_stats_result,
17277 cmd_clear_vf_stats_parsed(
17278 void *parsed_result,
17279 __rte_unused struct cmdline *cl,
17280 __rte_unused void *data)
17282 struct cmd_clear_vf_stats_result *res = parsed_result;
17283 int ret = -ENOTSUP;
17285 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17288 #ifdef RTE_LIBRTE_I40E_PMD
17289 if (ret == -ENOTSUP)
17290 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17293 #ifdef RTE_LIBRTE_BNXT_PMD
17294 if (ret == -ENOTSUP)
17295 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17303 printf("invalid vf_id %d\n", res->vf_id);
17306 printf("invalid port_id %d\n", res->port_id);
17309 printf("function not implemented\n");
17312 printf("programming error: (%s)\n", strerror(-ret));
17316 cmdline_parse_inst_t cmd_clear_vf_stats = {
17317 .f = cmd_clear_vf_stats_parsed,
17319 .help_str = "clear vf stats <port_id> <vf_id>",
17321 (void *)&cmd_clear_vf_stats_clear,
17322 (void *)&cmd_clear_vf_stats_vf,
17323 (void *)&cmd_clear_vf_stats_stats,
17324 (void *)&cmd_clear_vf_stats_port_id,
17325 (void *)&cmd_clear_vf_stats_vf_id,
17330 /* port config pctype mapping reset */
17332 /* Common result structure for port config pctype mapping reset */
17333 struct cmd_pctype_mapping_reset_result {
17334 cmdline_fixed_string_t port;
17335 cmdline_fixed_string_t config;
17337 cmdline_fixed_string_t pctype;
17338 cmdline_fixed_string_t mapping;
17339 cmdline_fixed_string_t reset;
17342 /* Common CLI fields for port config pctype mapping reset*/
17343 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17344 TOKEN_STRING_INITIALIZER
17345 (struct cmd_pctype_mapping_reset_result,
17347 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17348 TOKEN_STRING_INITIALIZER
17349 (struct cmd_pctype_mapping_reset_result,
17351 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17352 TOKEN_NUM_INITIALIZER
17353 (struct cmd_pctype_mapping_reset_result,
17355 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17356 TOKEN_STRING_INITIALIZER
17357 (struct cmd_pctype_mapping_reset_result,
17359 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17360 TOKEN_STRING_INITIALIZER
17361 (struct cmd_pctype_mapping_reset_result,
17362 mapping, "mapping");
17363 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17364 TOKEN_STRING_INITIALIZER
17365 (struct cmd_pctype_mapping_reset_result,
17369 cmd_pctype_mapping_reset_parsed(
17370 void *parsed_result,
17371 __rte_unused struct cmdline *cl,
17372 __rte_unused void *data)
17374 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17375 int ret = -ENOTSUP;
17377 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17380 #ifdef RTE_LIBRTE_I40E_PMD
17381 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17388 printf("invalid port_id %d\n", res->port_id);
17391 printf("function not implemented\n");
17394 printf("programming error: (%s)\n", strerror(-ret));
17398 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17399 .f = cmd_pctype_mapping_reset_parsed,
17401 .help_str = "port config <port_id> pctype mapping reset",
17403 (void *)&cmd_pctype_mapping_reset_port,
17404 (void *)&cmd_pctype_mapping_reset_config,
17405 (void *)&cmd_pctype_mapping_reset_port_id,
17406 (void *)&cmd_pctype_mapping_reset_pctype,
17407 (void *)&cmd_pctype_mapping_reset_mapping,
17408 (void *)&cmd_pctype_mapping_reset_reset,
17413 /* show port pctype mapping */
17415 /* Common result structure for show port pctype mapping */
17416 struct cmd_pctype_mapping_get_result {
17417 cmdline_fixed_string_t show;
17418 cmdline_fixed_string_t port;
17420 cmdline_fixed_string_t pctype;
17421 cmdline_fixed_string_t mapping;
17424 /* Common CLI fields for pctype mapping get */
17425 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17426 TOKEN_STRING_INITIALIZER
17427 (struct cmd_pctype_mapping_get_result,
17429 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17430 TOKEN_STRING_INITIALIZER
17431 (struct cmd_pctype_mapping_get_result,
17433 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17434 TOKEN_NUM_INITIALIZER
17435 (struct cmd_pctype_mapping_get_result,
17437 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17438 TOKEN_STRING_INITIALIZER
17439 (struct cmd_pctype_mapping_get_result,
17441 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17442 TOKEN_STRING_INITIALIZER
17443 (struct cmd_pctype_mapping_get_result,
17444 mapping, "mapping");
17447 cmd_pctype_mapping_get_parsed(
17448 void *parsed_result,
17449 __rte_unused struct cmdline *cl,
17450 __rte_unused void *data)
17452 struct cmd_pctype_mapping_get_result *res = parsed_result;
17453 int ret = -ENOTSUP;
17454 #ifdef RTE_LIBRTE_I40E_PMD
17455 struct rte_pmd_i40e_flow_type_mapping
17456 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17457 int i, j, first_pctype;
17460 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17463 #ifdef RTE_LIBRTE_I40E_PMD
17464 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17471 printf("invalid port_id %d\n", res->port_id);
17474 printf("function not implemented\n");
17477 printf("programming error: (%s)\n", strerror(-ret));
17481 #ifdef RTE_LIBRTE_I40E_PMD
17482 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17483 if (mapping[i].pctype != 0ULL) {
17486 printf("pctype: ");
17487 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17488 if (mapping[i].pctype & (1ULL << j)) {
17489 printf(first_pctype ?
17490 "%02d" : ",%02d", j);
17494 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17500 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17501 .f = cmd_pctype_mapping_get_parsed,
17503 .help_str = "show port <port_id> pctype mapping",
17505 (void *)&cmd_pctype_mapping_get_show,
17506 (void *)&cmd_pctype_mapping_get_port,
17507 (void *)&cmd_pctype_mapping_get_port_id,
17508 (void *)&cmd_pctype_mapping_get_pctype,
17509 (void *)&cmd_pctype_mapping_get_mapping,
17514 /* port config pctype mapping update */
17516 /* Common result structure for port config pctype mapping update */
17517 struct cmd_pctype_mapping_update_result {
17518 cmdline_fixed_string_t port;
17519 cmdline_fixed_string_t config;
17521 cmdline_fixed_string_t pctype;
17522 cmdline_fixed_string_t mapping;
17523 cmdline_fixed_string_t update;
17524 cmdline_fixed_string_t pctype_list;
17525 uint16_t flow_type;
17528 /* Common CLI fields for pctype mapping update*/
17529 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17530 TOKEN_STRING_INITIALIZER
17531 (struct cmd_pctype_mapping_update_result,
17533 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17534 TOKEN_STRING_INITIALIZER
17535 (struct cmd_pctype_mapping_update_result,
17537 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17538 TOKEN_NUM_INITIALIZER
17539 (struct cmd_pctype_mapping_update_result,
17541 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17542 TOKEN_STRING_INITIALIZER
17543 (struct cmd_pctype_mapping_update_result,
17545 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17546 TOKEN_STRING_INITIALIZER
17547 (struct cmd_pctype_mapping_update_result,
17548 mapping, "mapping");
17549 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17550 TOKEN_STRING_INITIALIZER
17551 (struct cmd_pctype_mapping_update_result,
17553 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17554 TOKEN_STRING_INITIALIZER
17555 (struct cmd_pctype_mapping_update_result,
17556 pctype_list, NULL);
17557 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17558 TOKEN_NUM_INITIALIZER
17559 (struct cmd_pctype_mapping_update_result,
17560 flow_type, UINT16);
17563 cmd_pctype_mapping_update_parsed(
17564 void *parsed_result,
17565 __rte_unused struct cmdline *cl,
17566 __rte_unused void *data)
17568 struct cmd_pctype_mapping_update_result *res = parsed_result;
17569 int ret = -ENOTSUP;
17570 #ifdef RTE_LIBRTE_I40E_PMD
17571 struct rte_pmd_i40e_flow_type_mapping mapping;
17573 unsigned int nb_item;
17574 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17577 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17580 #ifdef RTE_LIBRTE_I40E_PMD
17581 nb_item = parse_item_list(res->pctype_list, "pctypes",
17582 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17583 mapping.flow_type = res->flow_type;
17584 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17585 mapping.pctype |= (1ULL << pctype_list[i]);
17586 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17596 printf("invalid pctype or flow type\n");
17599 printf("invalid port_id %d\n", res->port_id);
17602 printf("function not implemented\n");
17605 printf("programming error: (%s)\n", strerror(-ret));
17609 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17610 .f = cmd_pctype_mapping_update_parsed,
17612 .help_str = "port config <port_id> pctype mapping update"
17613 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17615 (void *)&cmd_pctype_mapping_update_port,
17616 (void *)&cmd_pctype_mapping_update_config,
17617 (void *)&cmd_pctype_mapping_update_port_id,
17618 (void *)&cmd_pctype_mapping_update_pctype,
17619 (void *)&cmd_pctype_mapping_update_mapping,
17620 (void *)&cmd_pctype_mapping_update_update,
17621 (void *)&cmd_pctype_mapping_update_pc_type,
17622 (void *)&cmd_pctype_mapping_update_flow_type,
17627 /* ptype mapping get */
17629 /* Common result structure for ptype mapping get */
17630 struct cmd_ptype_mapping_get_result {
17631 cmdline_fixed_string_t ptype;
17632 cmdline_fixed_string_t mapping;
17633 cmdline_fixed_string_t get;
17635 uint8_t valid_only;
17638 /* Common CLI fields for ptype mapping get */
17639 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17640 TOKEN_STRING_INITIALIZER
17641 (struct cmd_ptype_mapping_get_result,
17643 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17644 TOKEN_STRING_INITIALIZER
17645 (struct cmd_ptype_mapping_get_result,
17646 mapping, "mapping");
17647 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17648 TOKEN_STRING_INITIALIZER
17649 (struct cmd_ptype_mapping_get_result,
17651 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17652 TOKEN_NUM_INITIALIZER
17653 (struct cmd_ptype_mapping_get_result,
17655 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17656 TOKEN_NUM_INITIALIZER
17657 (struct cmd_ptype_mapping_get_result,
17658 valid_only, UINT8);
17661 cmd_ptype_mapping_get_parsed(
17662 void *parsed_result,
17663 __rte_unused struct cmdline *cl,
17664 __rte_unused void *data)
17666 struct cmd_ptype_mapping_get_result *res = parsed_result;
17667 int ret = -ENOTSUP;
17668 #ifdef RTE_LIBRTE_I40E_PMD
17669 int max_ptype_num = 256;
17670 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17675 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17678 #ifdef RTE_LIBRTE_I40E_PMD
17679 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17690 printf("invalid port_id %d\n", res->port_id);
17693 printf("function not implemented\n");
17696 printf("programming error: (%s)\n", strerror(-ret));
17699 #ifdef RTE_LIBRTE_I40E_PMD
17701 for (i = 0; i < count; i++)
17702 printf("%3d\t0x%08x\n",
17703 mapping[i].hw_ptype, mapping[i].sw_ptype);
17708 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17709 .f = cmd_ptype_mapping_get_parsed,
17711 .help_str = "ptype mapping get <port_id> <valid_only>",
17713 (void *)&cmd_ptype_mapping_get_ptype,
17714 (void *)&cmd_ptype_mapping_get_mapping,
17715 (void *)&cmd_ptype_mapping_get_get,
17716 (void *)&cmd_ptype_mapping_get_port_id,
17717 (void *)&cmd_ptype_mapping_get_valid_only,
17722 /* ptype mapping replace */
17724 /* Common result structure for ptype mapping replace */
17725 struct cmd_ptype_mapping_replace_result {
17726 cmdline_fixed_string_t ptype;
17727 cmdline_fixed_string_t mapping;
17728 cmdline_fixed_string_t replace;
17735 /* Common CLI fields for ptype mapping replace */
17736 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17737 TOKEN_STRING_INITIALIZER
17738 (struct cmd_ptype_mapping_replace_result,
17740 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17741 TOKEN_STRING_INITIALIZER
17742 (struct cmd_ptype_mapping_replace_result,
17743 mapping, "mapping");
17744 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17745 TOKEN_STRING_INITIALIZER
17746 (struct cmd_ptype_mapping_replace_result,
17747 replace, "replace");
17748 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17749 TOKEN_NUM_INITIALIZER
17750 (struct cmd_ptype_mapping_replace_result,
17752 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17753 TOKEN_NUM_INITIALIZER
17754 (struct cmd_ptype_mapping_replace_result,
17756 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17757 TOKEN_NUM_INITIALIZER
17758 (struct cmd_ptype_mapping_replace_result,
17760 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17761 TOKEN_NUM_INITIALIZER
17762 (struct cmd_ptype_mapping_replace_result,
17766 cmd_ptype_mapping_replace_parsed(
17767 void *parsed_result,
17768 __rte_unused struct cmdline *cl,
17769 __rte_unused void *data)
17771 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17772 int ret = -ENOTSUP;
17774 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17777 #ifdef RTE_LIBRTE_I40E_PMD
17778 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17788 printf("invalid ptype 0x%8x or 0x%8x\n",
17789 res->target, res->pkt_type);
17792 printf("invalid port_id %d\n", res->port_id);
17795 printf("function not implemented\n");
17798 printf("programming error: (%s)\n", strerror(-ret));
17802 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17803 .f = cmd_ptype_mapping_replace_parsed,
17806 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17808 (void *)&cmd_ptype_mapping_replace_ptype,
17809 (void *)&cmd_ptype_mapping_replace_mapping,
17810 (void *)&cmd_ptype_mapping_replace_replace,
17811 (void *)&cmd_ptype_mapping_replace_port_id,
17812 (void *)&cmd_ptype_mapping_replace_target,
17813 (void *)&cmd_ptype_mapping_replace_mask,
17814 (void *)&cmd_ptype_mapping_replace_pkt_type,
17819 /* ptype mapping reset */
17821 /* Common result structure for ptype mapping reset */
17822 struct cmd_ptype_mapping_reset_result {
17823 cmdline_fixed_string_t ptype;
17824 cmdline_fixed_string_t mapping;
17825 cmdline_fixed_string_t reset;
17829 /* Common CLI fields for ptype mapping reset*/
17830 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17831 TOKEN_STRING_INITIALIZER
17832 (struct cmd_ptype_mapping_reset_result,
17834 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17835 TOKEN_STRING_INITIALIZER
17836 (struct cmd_ptype_mapping_reset_result,
17837 mapping, "mapping");
17838 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17839 TOKEN_STRING_INITIALIZER
17840 (struct cmd_ptype_mapping_reset_result,
17842 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17843 TOKEN_NUM_INITIALIZER
17844 (struct cmd_ptype_mapping_reset_result,
17848 cmd_ptype_mapping_reset_parsed(
17849 void *parsed_result,
17850 __rte_unused struct cmdline *cl,
17851 __rte_unused void *data)
17853 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17854 int ret = -ENOTSUP;
17856 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17859 #ifdef RTE_LIBRTE_I40E_PMD
17860 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17867 printf("invalid port_id %d\n", res->port_id);
17870 printf("function not implemented\n");
17873 printf("programming error: (%s)\n", strerror(-ret));
17877 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17878 .f = cmd_ptype_mapping_reset_parsed,
17880 .help_str = "ptype mapping reset <port_id>",
17882 (void *)&cmd_ptype_mapping_reset_ptype,
17883 (void *)&cmd_ptype_mapping_reset_mapping,
17884 (void *)&cmd_ptype_mapping_reset_reset,
17885 (void *)&cmd_ptype_mapping_reset_port_id,
17890 /* ptype mapping update */
17892 /* Common result structure for ptype mapping update */
17893 struct cmd_ptype_mapping_update_result {
17894 cmdline_fixed_string_t ptype;
17895 cmdline_fixed_string_t mapping;
17896 cmdline_fixed_string_t reset;
17902 /* Common CLI fields for ptype mapping update*/
17903 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17904 TOKEN_STRING_INITIALIZER
17905 (struct cmd_ptype_mapping_update_result,
17907 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17908 TOKEN_STRING_INITIALIZER
17909 (struct cmd_ptype_mapping_update_result,
17910 mapping, "mapping");
17911 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17912 TOKEN_STRING_INITIALIZER
17913 (struct cmd_ptype_mapping_update_result,
17915 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17916 TOKEN_NUM_INITIALIZER
17917 (struct cmd_ptype_mapping_update_result,
17919 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17920 TOKEN_NUM_INITIALIZER
17921 (struct cmd_ptype_mapping_update_result,
17923 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17924 TOKEN_NUM_INITIALIZER
17925 (struct cmd_ptype_mapping_update_result,
17929 cmd_ptype_mapping_update_parsed(
17930 void *parsed_result,
17931 __rte_unused struct cmdline *cl,
17932 __rte_unused void *data)
17934 struct cmd_ptype_mapping_update_result *res = parsed_result;
17935 int ret = -ENOTSUP;
17936 #ifdef RTE_LIBRTE_I40E_PMD
17937 struct rte_pmd_i40e_ptype_mapping mapping;
17939 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17942 #ifdef RTE_LIBRTE_I40E_PMD
17943 mapping.hw_ptype = res->hw_ptype;
17944 mapping.sw_ptype = res->sw_ptype;
17945 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17955 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17958 printf("invalid port_id %d\n", res->port_id);
17961 printf("function not implemented\n");
17964 printf("programming error: (%s)\n", strerror(-ret));
17968 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17969 .f = cmd_ptype_mapping_update_parsed,
17971 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17973 (void *)&cmd_ptype_mapping_update_ptype,
17974 (void *)&cmd_ptype_mapping_update_mapping,
17975 (void *)&cmd_ptype_mapping_update_update,
17976 (void *)&cmd_ptype_mapping_update_port_id,
17977 (void *)&cmd_ptype_mapping_update_hw_ptype,
17978 (void *)&cmd_ptype_mapping_update_sw_ptype,
17983 /* Common result structure for file commands */
17984 struct cmd_cmdfile_result {
17985 cmdline_fixed_string_t load;
17986 cmdline_fixed_string_t filename;
17989 /* Common CLI fields for file commands */
17990 cmdline_parse_token_string_t cmd_load_cmdfile =
17991 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17992 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17993 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17996 cmd_load_from_file_parsed(
17997 void *parsed_result,
17998 __rte_unused struct cmdline *cl,
17999 __rte_unused void *data)
18001 struct cmd_cmdfile_result *res = parsed_result;
18003 cmdline_read_from_file(res->filename);
18006 cmdline_parse_inst_t cmd_load_from_file = {
18007 .f = cmd_load_from_file_parsed,
18009 .help_str = "load <filename>",
18011 (void *)&cmd_load_cmdfile,
18012 (void *)&cmd_load_cmdfile_filename,
18017 /* Get Rx offloads capabilities */
18018 struct cmd_rx_offload_get_capa_result {
18019 cmdline_fixed_string_t show;
18020 cmdline_fixed_string_t port;
18022 cmdline_fixed_string_t rx_offload;
18023 cmdline_fixed_string_t capabilities;
18026 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18027 TOKEN_STRING_INITIALIZER
18028 (struct cmd_rx_offload_get_capa_result,
18030 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18031 TOKEN_STRING_INITIALIZER
18032 (struct cmd_rx_offload_get_capa_result,
18034 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18035 TOKEN_NUM_INITIALIZER
18036 (struct cmd_rx_offload_get_capa_result,
18038 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18039 TOKEN_STRING_INITIALIZER
18040 (struct cmd_rx_offload_get_capa_result,
18041 rx_offload, "rx_offload");
18042 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18043 TOKEN_STRING_INITIALIZER
18044 (struct cmd_rx_offload_get_capa_result,
18045 capabilities, "capabilities");
18048 print_rx_offloads(uint64_t offloads)
18050 uint64_t single_offload;
18058 begin = __builtin_ctzll(offloads);
18059 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18061 single_offload = 1ULL << begin;
18062 for (bit = begin; bit < end; bit++) {
18063 if (offloads & single_offload)
18065 rte_eth_dev_rx_offload_name(single_offload));
18066 single_offload <<= 1;
18071 cmd_rx_offload_get_capa_parsed(
18072 void *parsed_result,
18073 __rte_unused struct cmdline *cl,
18074 __rte_unused void *data)
18076 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18077 struct rte_eth_dev_info dev_info;
18078 portid_t port_id = res->port_id;
18079 uint64_t queue_offloads;
18080 uint64_t port_offloads;
18083 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18087 queue_offloads = dev_info.rx_queue_offload_capa;
18088 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18090 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18091 printf(" Per Queue :");
18092 print_rx_offloads(queue_offloads);
18095 printf(" Per Port :");
18096 print_rx_offloads(port_offloads);
18100 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18101 .f = cmd_rx_offload_get_capa_parsed,
18103 .help_str = "show port <port_id> rx_offload capabilities",
18105 (void *)&cmd_rx_offload_get_capa_show,
18106 (void *)&cmd_rx_offload_get_capa_port,
18107 (void *)&cmd_rx_offload_get_capa_port_id,
18108 (void *)&cmd_rx_offload_get_capa_rx_offload,
18109 (void *)&cmd_rx_offload_get_capa_capabilities,
18114 /* Get Rx offloads configuration */
18115 struct cmd_rx_offload_get_configuration_result {
18116 cmdline_fixed_string_t show;
18117 cmdline_fixed_string_t port;
18119 cmdline_fixed_string_t rx_offload;
18120 cmdline_fixed_string_t configuration;
18123 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18124 TOKEN_STRING_INITIALIZER
18125 (struct cmd_rx_offload_get_configuration_result,
18127 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18128 TOKEN_STRING_INITIALIZER
18129 (struct cmd_rx_offload_get_configuration_result,
18131 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18132 TOKEN_NUM_INITIALIZER
18133 (struct cmd_rx_offload_get_configuration_result,
18135 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18136 TOKEN_STRING_INITIALIZER
18137 (struct cmd_rx_offload_get_configuration_result,
18138 rx_offload, "rx_offload");
18139 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18140 TOKEN_STRING_INITIALIZER
18141 (struct cmd_rx_offload_get_configuration_result,
18142 configuration, "configuration");
18145 cmd_rx_offload_get_configuration_parsed(
18146 void *parsed_result,
18147 __rte_unused struct cmdline *cl,
18148 __rte_unused void *data)
18150 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18151 struct rte_eth_dev_info dev_info;
18152 portid_t port_id = res->port_id;
18153 struct rte_port *port = &ports[port_id];
18154 uint64_t port_offloads;
18155 uint64_t queue_offloads;
18156 uint16_t nb_rx_queues;
18160 printf("Rx Offloading Configuration of port %d :\n", port_id);
18162 port_offloads = port->dev_conf.rxmode.offloads;
18164 print_rx_offloads(port_offloads);
18167 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18171 nb_rx_queues = dev_info.nb_rx_queues;
18172 for (q = 0; q < nb_rx_queues; q++) {
18173 queue_offloads = port->rx_conf[q].offloads;
18174 printf(" Queue[%2d] :", q);
18175 print_rx_offloads(queue_offloads);
18181 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18182 .f = cmd_rx_offload_get_configuration_parsed,
18184 .help_str = "show port <port_id> rx_offload configuration",
18186 (void *)&cmd_rx_offload_get_configuration_show,
18187 (void *)&cmd_rx_offload_get_configuration_port,
18188 (void *)&cmd_rx_offload_get_configuration_port_id,
18189 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18190 (void *)&cmd_rx_offload_get_configuration_configuration,
18195 /* Enable/Disable a per port offloading */
18196 struct cmd_config_per_port_rx_offload_result {
18197 cmdline_fixed_string_t port;
18198 cmdline_fixed_string_t config;
18200 cmdline_fixed_string_t rx_offload;
18201 cmdline_fixed_string_t offload;
18202 cmdline_fixed_string_t on_off;
18205 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18206 TOKEN_STRING_INITIALIZER
18207 (struct cmd_config_per_port_rx_offload_result,
18209 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18210 TOKEN_STRING_INITIALIZER
18211 (struct cmd_config_per_port_rx_offload_result,
18213 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18214 TOKEN_NUM_INITIALIZER
18215 (struct cmd_config_per_port_rx_offload_result,
18217 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18218 TOKEN_STRING_INITIALIZER
18219 (struct cmd_config_per_port_rx_offload_result,
18220 rx_offload, "rx_offload");
18221 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18222 TOKEN_STRING_INITIALIZER
18223 (struct cmd_config_per_port_rx_offload_result,
18224 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18225 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18226 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18227 "scatter#timestamp#security#keep_crc#rss_hash");
18228 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18229 TOKEN_STRING_INITIALIZER
18230 (struct cmd_config_per_port_rx_offload_result,
18234 search_rx_offload(const char *name)
18236 uint64_t single_offload;
18237 const char *single_name;
18241 single_offload = 1;
18242 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18243 single_name = rte_eth_dev_rx_offload_name(single_offload);
18244 if (!strcasecmp(single_name, name)) {
18248 single_offload <<= 1;
18252 return single_offload;
18258 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18259 __rte_unused struct cmdline *cl,
18260 __rte_unused void *data)
18262 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18263 portid_t port_id = res->port_id;
18264 struct rte_eth_dev_info dev_info;
18265 struct rte_port *port = &ports[port_id];
18266 uint64_t single_offload;
18267 uint16_t nb_rx_queues;
18271 if (port->port_status != RTE_PORT_STOPPED) {
18272 printf("Error: Can't config offload when Port %d "
18273 "is not stopped\n", port_id);
18277 single_offload = search_rx_offload(res->offload);
18278 if (single_offload == 0) {
18279 printf("Unknown offload name: %s\n", res->offload);
18283 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18287 nb_rx_queues = dev_info.nb_rx_queues;
18288 if (!strcmp(res->on_off, "on")) {
18289 port->dev_conf.rxmode.offloads |= single_offload;
18290 for (q = 0; q < nb_rx_queues; q++)
18291 port->rx_conf[q].offloads |= single_offload;
18293 port->dev_conf.rxmode.offloads &= ~single_offload;
18294 for (q = 0; q < nb_rx_queues; q++)
18295 port->rx_conf[q].offloads &= ~single_offload;
18298 cmd_reconfig_device_queue(port_id, 1, 1);
18301 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18302 .f = cmd_config_per_port_rx_offload_parsed,
18304 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18305 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18306 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18307 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18310 (void *)&cmd_config_per_port_rx_offload_result_port,
18311 (void *)&cmd_config_per_port_rx_offload_result_config,
18312 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18313 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18314 (void *)&cmd_config_per_port_rx_offload_result_offload,
18315 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18320 /* Enable/Disable a per queue offloading */
18321 struct cmd_config_per_queue_rx_offload_result {
18322 cmdline_fixed_string_t port;
18324 cmdline_fixed_string_t rxq;
18326 cmdline_fixed_string_t rx_offload;
18327 cmdline_fixed_string_t offload;
18328 cmdline_fixed_string_t on_off;
18331 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18332 TOKEN_STRING_INITIALIZER
18333 (struct cmd_config_per_queue_rx_offload_result,
18335 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18336 TOKEN_NUM_INITIALIZER
18337 (struct cmd_config_per_queue_rx_offload_result,
18339 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18340 TOKEN_STRING_INITIALIZER
18341 (struct cmd_config_per_queue_rx_offload_result,
18343 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18344 TOKEN_NUM_INITIALIZER
18345 (struct cmd_config_per_queue_rx_offload_result,
18347 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18348 TOKEN_STRING_INITIALIZER
18349 (struct cmd_config_per_queue_rx_offload_result,
18350 rx_offload, "rx_offload");
18351 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18352 TOKEN_STRING_INITIALIZER
18353 (struct cmd_config_per_queue_rx_offload_result,
18354 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18355 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18356 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18357 "scatter#timestamp#security#keep_crc");
18358 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18359 TOKEN_STRING_INITIALIZER
18360 (struct cmd_config_per_queue_rx_offload_result,
18364 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18365 __rte_unused struct cmdline *cl,
18366 __rte_unused void *data)
18368 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18369 struct rte_eth_dev_info dev_info;
18370 portid_t port_id = res->port_id;
18371 uint16_t queue_id = res->queue_id;
18372 struct rte_port *port = &ports[port_id];
18373 uint64_t single_offload;
18376 if (port->port_status != RTE_PORT_STOPPED) {
18377 printf("Error: Can't config offload when Port %d "
18378 "is not stopped\n", port_id);
18382 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18386 if (queue_id >= dev_info.nb_rx_queues) {
18387 printf("Error: input queue_id should be 0 ... "
18388 "%d\n", dev_info.nb_rx_queues - 1);
18392 single_offload = search_rx_offload(res->offload);
18393 if (single_offload == 0) {
18394 printf("Unknown offload name: %s\n", res->offload);
18398 if (!strcmp(res->on_off, "on"))
18399 port->rx_conf[queue_id].offloads |= single_offload;
18401 port->rx_conf[queue_id].offloads &= ~single_offload;
18403 cmd_reconfig_device_queue(port_id, 1, 1);
18406 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18407 .f = cmd_config_per_queue_rx_offload_parsed,
18409 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18410 "vlan_strip|ipv4_cksum|"
18411 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18412 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18413 "jumbo_frame|scatter|timestamp|security|keep_crc "
18416 (void *)&cmd_config_per_queue_rx_offload_result_port,
18417 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18418 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18419 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18420 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18421 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18422 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18427 /* Get Tx offloads capabilities */
18428 struct cmd_tx_offload_get_capa_result {
18429 cmdline_fixed_string_t show;
18430 cmdline_fixed_string_t port;
18432 cmdline_fixed_string_t tx_offload;
18433 cmdline_fixed_string_t capabilities;
18436 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18437 TOKEN_STRING_INITIALIZER
18438 (struct cmd_tx_offload_get_capa_result,
18440 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18441 TOKEN_STRING_INITIALIZER
18442 (struct cmd_tx_offload_get_capa_result,
18444 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18445 TOKEN_NUM_INITIALIZER
18446 (struct cmd_tx_offload_get_capa_result,
18448 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18449 TOKEN_STRING_INITIALIZER
18450 (struct cmd_tx_offload_get_capa_result,
18451 tx_offload, "tx_offload");
18452 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18453 TOKEN_STRING_INITIALIZER
18454 (struct cmd_tx_offload_get_capa_result,
18455 capabilities, "capabilities");
18458 print_tx_offloads(uint64_t offloads)
18460 uint64_t single_offload;
18468 begin = __builtin_ctzll(offloads);
18469 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18471 single_offload = 1ULL << begin;
18472 for (bit = begin; bit < end; bit++) {
18473 if (offloads & single_offload)
18475 rte_eth_dev_tx_offload_name(single_offload));
18476 single_offload <<= 1;
18481 cmd_tx_offload_get_capa_parsed(
18482 void *parsed_result,
18483 __rte_unused struct cmdline *cl,
18484 __rte_unused void *data)
18486 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18487 struct rte_eth_dev_info dev_info;
18488 portid_t port_id = res->port_id;
18489 uint64_t queue_offloads;
18490 uint64_t port_offloads;
18493 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18497 queue_offloads = dev_info.tx_queue_offload_capa;
18498 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18500 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18501 printf(" Per Queue :");
18502 print_tx_offloads(queue_offloads);
18505 printf(" Per Port :");
18506 print_tx_offloads(port_offloads);
18510 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18511 .f = cmd_tx_offload_get_capa_parsed,
18513 .help_str = "show port <port_id> tx_offload capabilities",
18515 (void *)&cmd_tx_offload_get_capa_show,
18516 (void *)&cmd_tx_offload_get_capa_port,
18517 (void *)&cmd_tx_offload_get_capa_port_id,
18518 (void *)&cmd_tx_offload_get_capa_tx_offload,
18519 (void *)&cmd_tx_offload_get_capa_capabilities,
18524 /* Get Tx offloads configuration */
18525 struct cmd_tx_offload_get_configuration_result {
18526 cmdline_fixed_string_t show;
18527 cmdline_fixed_string_t port;
18529 cmdline_fixed_string_t tx_offload;
18530 cmdline_fixed_string_t configuration;
18533 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18534 TOKEN_STRING_INITIALIZER
18535 (struct cmd_tx_offload_get_configuration_result,
18537 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18538 TOKEN_STRING_INITIALIZER
18539 (struct cmd_tx_offload_get_configuration_result,
18541 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18542 TOKEN_NUM_INITIALIZER
18543 (struct cmd_tx_offload_get_configuration_result,
18545 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18546 TOKEN_STRING_INITIALIZER
18547 (struct cmd_tx_offload_get_configuration_result,
18548 tx_offload, "tx_offload");
18549 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18550 TOKEN_STRING_INITIALIZER
18551 (struct cmd_tx_offload_get_configuration_result,
18552 configuration, "configuration");
18555 cmd_tx_offload_get_configuration_parsed(
18556 void *parsed_result,
18557 __rte_unused struct cmdline *cl,
18558 __rte_unused void *data)
18560 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18561 struct rte_eth_dev_info dev_info;
18562 portid_t port_id = res->port_id;
18563 struct rte_port *port = &ports[port_id];
18564 uint64_t port_offloads;
18565 uint64_t queue_offloads;
18566 uint16_t nb_tx_queues;
18570 printf("Tx Offloading Configuration of port %d :\n", port_id);
18572 port_offloads = port->dev_conf.txmode.offloads;
18574 print_tx_offloads(port_offloads);
18577 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18581 nb_tx_queues = dev_info.nb_tx_queues;
18582 for (q = 0; q < nb_tx_queues; q++) {
18583 queue_offloads = port->tx_conf[q].offloads;
18584 printf(" Queue[%2d] :", q);
18585 print_tx_offloads(queue_offloads);
18591 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18592 .f = cmd_tx_offload_get_configuration_parsed,
18594 .help_str = "show port <port_id> tx_offload configuration",
18596 (void *)&cmd_tx_offload_get_configuration_show,
18597 (void *)&cmd_tx_offload_get_configuration_port,
18598 (void *)&cmd_tx_offload_get_configuration_port_id,
18599 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18600 (void *)&cmd_tx_offload_get_configuration_configuration,
18605 /* Enable/Disable a per port offloading */
18606 struct cmd_config_per_port_tx_offload_result {
18607 cmdline_fixed_string_t port;
18608 cmdline_fixed_string_t config;
18610 cmdline_fixed_string_t tx_offload;
18611 cmdline_fixed_string_t offload;
18612 cmdline_fixed_string_t on_off;
18615 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18616 TOKEN_STRING_INITIALIZER
18617 (struct cmd_config_per_port_tx_offload_result,
18619 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18620 TOKEN_STRING_INITIALIZER
18621 (struct cmd_config_per_port_tx_offload_result,
18623 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18624 TOKEN_NUM_INITIALIZER
18625 (struct cmd_config_per_port_tx_offload_result,
18627 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18628 TOKEN_STRING_INITIALIZER
18629 (struct cmd_config_per_port_tx_offload_result,
18630 tx_offload, "tx_offload");
18631 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18632 TOKEN_STRING_INITIALIZER
18633 (struct cmd_config_per_port_tx_offload_result,
18634 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18635 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18636 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18637 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18638 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18639 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18640 TOKEN_STRING_INITIALIZER
18641 (struct cmd_config_per_port_tx_offload_result,
18645 search_tx_offload(const char *name)
18647 uint64_t single_offload;
18648 const char *single_name;
18652 single_offload = 1;
18653 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18654 single_name = rte_eth_dev_tx_offload_name(single_offload);
18655 if (single_name == NULL)
18657 if (!strcasecmp(single_name, name)) {
18660 } else if (!strcasecmp(single_name, "UNKNOWN"))
18662 single_offload <<= 1;
18666 return single_offload;
18672 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18673 __rte_unused struct cmdline *cl,
18674 __rte_unused void *data)
18676 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18677 portid_t port_id = res->port_id;
18678 struct rte_eth_dev_info dev_info;
18679 struct rte_port *port = &ports[port_id];
18680 uint64_t single_offload;
18681 uint16_t nb_tx_queues;
18685 if (port->port_status != RTE_PORT_STOPPED) {
18686 printf("Error: Can't config offload when Port %d "
18687 "is not stopped\n", port_id);
18691 single_offload = search_tx_offload(res->offload);
18692 if (single_offload == 0) {
18693 printf("Unknown offload name: %s\n", res->offload);
18697 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18701 nb_tx_queues = dev_info.nb_tx_queues;
18702 if (!strcmp(res->on_off, "on")) {
18703 port->dev_conf.txmode.offloads |= single_offload;
18704 for (q = 0; q < nb_tx_queues; q++)
18705 port->tx_conf[q].offloads |= single_offload;
18707 port->dev_conf.txmode.offloads &= ~single_offload;
18708 for (q = 0; q < nb_tx_queues; q++)
18709 port->tx_conf[q].offloads &= ~single_offload;
18712 cmd_reconfig_device_queue(port_id, 1, 1);
18715 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18716 .f = cmd_config_per_port_tx_offload_parsed,
18718 .help_str = "port config <port_id> tx_offload "
18719 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18720 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18721 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18722 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18723 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18725 (void *)&cmd_config_per_port_tx_offload_result_port,
18726 (void *)&cmd_config_per_port_tx_offload_result_config,
18727 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18728 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18729 (void *)&cmd_config_per_port_tx_offload_result_offload,
18730 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18735 /* Enable/Disable a per queue offloading */
18736 struct cmd_config_per_queue_tx_offload_result {
18737 cmdline_fixed_string_t port;
18739 cmdline_fixed_string_t txq;
18741 cmdline_fixed_string_t tx_offload;
18742 cmdline_fixed_string_t offload;
18743 cmdline_fixed_string_t on_off;
18746 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18747 TOKEN_STRING_INITIALIZER
18748 (struct cmd_config_per_queue_tx_offload_result,
18750 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18751 TOKEN_NUM_INITIALIZER
18752 (struct cmd_config_per_queue_tx_offload_result,
18754 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18755 TOKEN_STRING_INITIALIZER
18756 (struct cmd_config_per_queue_tx_offload_result,
18758 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18759 TOKEN_NUM_INITIALIZER
18760 (struct cmd_config_per_queue_tx_offload_result,
18762 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18763 TOKEN_STRING_INITIALIZER
18764 (struct cmd_config_per_queue_tx_offload_result,
18765 tx_offload, "tx_offload");
18766 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18767 TOKEN_STRING_INITIALIZER
18768 (struct cmd_config_per_queue_tx_offload_result,
18769 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18770 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18771 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18772 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18773 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18774 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18775 TOKEN_STRING_INITIALIZER
18776 (struct cmd_config_per_queue_tx_offload_result,
18780 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18781 __rte_unused struct cmdline *cl,
18782 __rte_unused void *data)
18784 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18785 struct rte_eth_dev_info dev_info;
18786 portid_t port_id = res->port_id;
18787 uint16_t queue_id = res->queue_id;
18788 struct rte_port *port = &ports[port_id];
18789 uint64_t single_offload;
18792 if (port->port_status != RTE_PORT_STOPPED) {
18793 printf("Error: Can't config offload when Port %d "
18794 "is not stopped\n", port_id);
18798 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18802 if (queue_id >= dev_info.nb_tx_queues) {
18803 printf("Error: input queue_id should be 0 ... "
18804 "%d\n", dev_info.nb_tx_queues - 1);
18808 single_offload = search_tx_offload(res->offload);
18809 if (single_offload == 0) {
18810 printf("Unknown offload name: %s\n", res->offload);
18814 if (!strcmp(res->on_off, "on"))
18815 port->tx_conf[queue_id].offloads |= single_offload;
18817 port->tx_conf[queue_id].offloads &= ~single_offload;
18819 cmd_reconfig_device_queue(port_id, 1, 1);
18822 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18823 .f = cmd_config_per_queue_tx_offload_parsed,
18825 .help_str = "port <port_id> txq <queue_id> tx_offload "
18826 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18827 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18828 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18829 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18830 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18833 (void *)&cmd_config_per_queue_tx_offload_result_port,
18834 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18835 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18836 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18837 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18838 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18839 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18844 /* *** configure tx_metadata for specific port *** */
18845 struct cmd_config_tx_metadata_specific_result {
18846 cmdline_fixed_string_t port;
18847 cmdline_fixed_string_t keyword;
18849 cmdline_fixed_string_t item;
18854 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18855 __rte_unused struct cmdline *cl,
18856 __rte_unused void *data)
18858 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18860 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18862 ports[res->port_id].tx_metadata = res->value;
18863 /* Add/remove callback to insert valid metadata in every Tx packet. */
18864 if (ports[res->port_id].tx_metadata)
18865 add_tx_md_callback(res->port_id);
18867 remove_tx_md_callback(res->port_id);
18868 rte_flow_dynf_metadata_register();
18871 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18872 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18874 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18875 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18876 keyword, "config");
18877 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18878 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18880 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18881 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18882 item, "tx_metadata");
18883 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18884 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18887 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18888 .f = cmd_config_tx_metadata_specific_parsed,
18890 .help_str = "port config <port_id> tx_metadata <value>",
18892 (void *)&cmd_config_tx_metadata_specific_port,
18893 (void *)&cmd_config_tx_metadata_specific_keyword,
18894 (void *)&cmd_config_tx_metadata_specific_id,
18895 (void *)&cmd_config_tx_metadata_specific_item,
18896 (void *)&cmd_config_tx_metadata_specific_value,
18901 /* *** set dynf *** */
18902 struct cmd_config_tx_dynf_specific_result {
18903 cmdline_fixed_string_t port;
18904 cmdline_fixed_string_t keyword;
18906 cmdline_fixed_string_t item;
18907 cmdline_fixed_string_t name;
18908 cmdline_fixed_string_t value;
18912 cmd_config_dynf_specific_parsed(void *parsed_result,
18913 __rte_unused struct cmdline *cl,
18914 __rte_unused void *data)
18916 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18917 struct rte_mbuf_dynflag desc_flag;
18919 uint64_t old_port_flags;
18921 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18923 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18925 if (strlcpy(desc_flag.name, res->name,
18926 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18927 printf("Flag name too long\n");
18930 desc_flag.flags = 0;
18931 flag = rte_mbuf_dynflag_register(&desc_flag);
18933 printf("Can't register flag\n");
18936 strcpy(dynf_names[flag], desc_flag.name);
18938 old_port_flags = ports[res->port_id].mbuf_dynf;
18939 if (!strcmp(res->value, "set")) {
18940 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18941 if (old_port_flags == 0)
18942 add_tx_dynf_callback(res->port_id);
18944 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18945 if (ports[res->port_id].mbuf_dynf == 0)
18946 remove_tx_dynf_callback(res->port_id);
18950 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18951 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18953 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18954 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18955 keyword, "config");
18956 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18957 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18959 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18960 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18962 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18963 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18965 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18966 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18967 value, "set#clear");
18969 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18970 .f = cmd_config_dynf_specific_parsed,
18972 .help_str = "port config <port id> dynf <name> set|clear",
18974 (void *)&cmd_config_tx_dynf_specific_port,
18975 (void *)&cmd_config_tx_dynf_specific_keyword,
18976 (void *)&cmd_config_tx_dynf_specific_port_id,
18977 (void *)&cmd_config_tx_dynf_specific_item,
18978 (void *)&cmd_config_tx_dynf_specific_name,
18979 (void *)&cmd_config_tx_dynf_specific_value,
18984 /* *** display tx_metadata per port configuration *** */
18985 struct cmd_show_tx_metadata_result {
18986 cmdline_fixed_string_t cmd_show;
18987 cmdline_fixed_string_t cmd_port;
18988 cmdline_fixed_string_t cmd_keyword;
18993 cmd_show_tx_metadata_parsed(void *parsed_result,
18994 __rte_unused struct cmdline *cl,
18995 __rte_unused void *data)
18997 struct cmd_show_tx_metadata_result *res = parsed_result;
18999 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19000 printf("invalid port id %u\n", res->cmd_pid);
19003 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19004 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19005 ports[res->cmd_pid].tx_metadata);
19009 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19010 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19012 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19013 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19015 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19016 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19018 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19019 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19020 cmd_keyword, "tx_metadata");
19022 cmdline_parse_inst_t cmd_show_tx_metadata = {
19023 .f = cmd_show_tx_metadata_parsed,
19025 .help_str = "show port <port_id> tx_metadata",
19027 (void *)&cmd_show_tx_metadata_show,
19028 (void *)&cmd_show_tx_metadata_port,
19029 (void *)&cmd_show_tx_metadata_pid,
19030 (void *)&cmd_show_tx_metadata_keyword,
19035 /* show port supported ptypes */
19037 /* Common result structure for show port ptypes */
19038 struct cmd_show_port_supported_ptypes_result {
19039 cmdline_fixed_string_t show;
19040 cmdline_fixed_string_t port;
19042 cmdline_fixed_string_t ptypes;
19045 /* Common CLI fields for show port ptypes */
19046 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19047 TOKEN_STRING_INITIALIZER
19048 (struct cmd_show_port_supported_ptypes_result,
19050 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19051 TOKEN_STRING_INITIALIZER
19052 (struct cmd_show_port_supported_ptypes_result,
19054 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19055 TOKEN_NUM_INITIALIZER
19056 (struct cmd_show_port_supported_ptypes_result,
19058 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19059 TOKEN_STRING_INITIALIZER
19060 (struct cmd_show_port_supported_ptypes_result,
19064 cmd_show_port_supported_ptypes_parsed(
19065 void *parsed_result,
19066 __rte_unused struct cmdline *cl,
19067 __rte_unused void *data)
19069 #define RSVD_PTYPE_MASK 0xf0000000
19070 #define MAX_PTYPES_PER_LAYER 16
19071 #define LTYPE_NAMESIZE 32
19072 #define PTYPE_NAMESIZE 256
19073 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19074 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19075 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19076 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19077 uint16_t port_id = res->port_id;
19080 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19084 while (ptype_mask != RSVD_PTYPE_MASK) {
19086 switch (ptype_mask) {
19087 case RTE_PTYPE_L2_MASK:
19088 strlcpy(ltype, "L2", sizeof(ltype));
19090 case RTE_PTYPE_L3_MASK:
19091 strlcpy(ltype, "L3", sizeof(ltype));
19093 case RTE_PTYPE_L4_MASK:
19094 strlcpy(ltype, "L4", sizeof(ltype));
19096 case RTE_PTYPE_TUNNEL_MASK:
19097 strlcpy(ltype, "Tunnel", sizeof(ltype));
19099 case RTE_PTYPE_INNER_L2_MASK:
19100 strlcpy(ltype, "Inner L2", sizeof(ltype));
19102 case RTE_PTYPE_INNER_L3_MASK:
19103 strlcpy(ltype, "Inner L3", sizeof(ltype));
19105 case RTE_PTYPE_INNER_L4_MASK:
19106 strlcpy(ltype, "Inner L4", sizeof(ltype));
19112 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19113 ptype_mask, ptypes,
19114 MAX_PTYPES_PER_LAYER);
19117 printf("Supported %s ptypes:\n", ltype);
19119 printf("%s ptypes unsupported\n", ltype);
19121 for (i = 0; i < ret; ++i) {
19122 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19123 printf("%s\n", buf);
19130 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19131 .f = cmd_show_port_supported_ptypes_parsed,
19133 .help_str = "show port <port_id> ptypes",
19135 (void *)&cmd_show_port_supported_ptypes_show,
19136 (void *)&cmd_show_port_supported_ptypes_port,
19137 (void *)&cmd_show_port_supported_ptypes_port_id,
19138 (void *)&cmd_show_port_supported_ptypes_ptypes,
19143 /* *** display rx/tx descriptor status *** */
19144 struct cmd_show_rx_tx_desc_status_result {
19145 cmdline_fixed_string_t cmd_show;
19146 cmdline_fixed_string_t cmd_port;
19147 cmdline_fixed_string_t cmd_keyword;
19148 cmdline_fixed_string_t cmd_desc;
19149 cmdline_fixed_string_t cmd_status;
19156 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19157 __rte_unused struct cmdline *cl,
19158 __rte_unused void *data)
19160 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19163 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19164 printf("invalid port id %u\n", res->cmd_pid);
19168 if (!strcmp(res->cmd_keyword, "rxq")) {
19169 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19172 printf("Invalid queueid = %d\n", res->cmd_qid);
19175 if (rc == RTE_ETH_RX_DESC_AVAIL)
19176 printf("Desc status = AVAILABLE\n");
19177 else if (rc == RTE_ETH_RX_DESC_DONE)
19178 printf("Desc status = DONE\n");
19180 printf("Desc status = UNAVAILABLE\n");
19181 } else if (!strcmp(res->cmd_keyword, "txq")) {
19182 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19185 printf("Invalid queueid = %d\n", res->cmd_qid);
19188 if (rc == RTE_ETH_TX_DESC_FULL)
19189 printf("Desc status = FULL\n");
19190 else if (rc == RTE_ETH_TX_DESC_DONE)
19191 printf("Desc status = DONE\n");
19193 printf("Desc status = UNAVAILABLE\n");
19197 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19198 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19200 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19201 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19203 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19204 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19206 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19207 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19208 cmd_keyword, "rxq#txq");
19209 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19210 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19212 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19213 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19215 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19216 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19218 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19219 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19220 cmd_status, "status");
19221 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19222 .f = cmd_show_rx_tx_desc_status_parsed,
19224 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19227 (void *)&cmd_show_rx_tx_desc_status_show,
19228 (void *)&cmd_show_rx_tx_desc_status_port,
19229 (void *)&cmd_show_rx_tx_desc_status_pid,
19230 (void *)&cmd_show_rx_tx_desc_status_keyword,
19231 (void *)&cmd_show_rx_tx_desc_status_qid,
19232 (void *)&cmd_show_rx_tx_desc_status_desc,
19233 (void *)&cmd_show_rx_tx_desc_status_did,
19234 (void *)&cmd_show_rx_tx_desc_status_status,
19239 /* Common result structure for set port ptypes */
19240 struct cmd_set_port_ptypes_result {
19241 cmdline_fixed_string_t set;
19242 cmdline_fixed_string_t port;
19244 cmdline_fixed_string_t ptype_mask;
19248 /* Common CLI fields for set port ptypes */
19249 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19250 TOKEN_STRING_INITIALIZER
19251 (struct cmd_set_port_ptypes_result,
19253 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19254 TOKEN_STRING_INITIALIZER
19255 (struct cmd_set_port_ptypes_result,
19257 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19258 TOKEN_NUM_INITIALIZER
19259 (struct cmd_set_port_ptypes_result,
19261 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19262 TOKEN_STRING_INITIALIZER
19263 (struct cmd_set_port_ptypes_result,
19264 ptype_mask, "ptype_mask");
19265 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19266 TOKEN_NUM_INITIALIZER
19267 (struct cmd_set_port_ptypes_result,
19271 cmd_set_port_ptypes_parsed(
19272 void *parsed_result,
19273 __rte_unused struct cmdline *cl,
19274 __rte_unused void *data)
19276 struct cmd_set_port_ptypes_result *res = parsed_result;
19277 #define PTYPE_NAMESIZE 256
19278 char ptype_name[PTYPE_NAMESIZE];
19279 uint16_t port_id = res->port_id;
19280 uint32_t ptype_mask = res->mask;
19283 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19286 printf("Port %d doesn't support any ptypes.\n", port_id);
19290 uint32_t ptypes[ret];
19292 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19294 printf("Unable to set requested ptypes for Port %d\n", port_id);
19298 printf("Successfully set following ptypes for Port %d\n", port_id);
19299 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19300 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19301 printf("%s\n", ptype_name);
19304 clear_ptypes = false;
19307 cmdline_parse_inst_t cmd_set_port_ptypes = {
19308 .f = cmd_set_port_ptypes_parsed,
19310 .help_str = "set port <port_id> ptype_mask <mask>",
19312 (void *)&cmd_set_port_ptypes_set,
19313 (void *)&cmd_set_port_ptypes_port,
19314 (void *)&cmd_set_port_ptypes_port_id,
19315 (void *)&cmd_set_port_ptypes_mask_str,
19316 (void *)&cmd_set_port_ptypes_mask_u32,
19321 /* *** display mac addresses added to a port *** */
19322 struct cmd_showport_macs_result {
19323 cmdline_fixed_string_t cmd_show;
19324 cmdline_fixed_string_t cmd_port;
19325 cmdline_fixed_string_t cmd_keyword;
19330 cmd_showport_macs_parsed(void *parsed_result,
19331 __rte_unused struct cmdline *cl,
19332 __rte_unused void *data)
19334 struct cmd_showport_macs_result *res = parsed_result;
19336 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19339 if (!strcmp(res->cmd_keyword, "macs"))
19340 show_macs(res->cmd_pid);
19341 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19342 show_mcast_macs(res->cmd_pid);
19345 cmdline_parse_token_string_t cmd_showport_macs_show =
19346 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19348 cmdline_parse_token_string_t cmd_showport_macs_port =
19349 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19351 cmdline_parse_token_num_t cmd_showport_macs_pid =
19352 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19354 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19355 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19356 cmd_keyword, "macs#mcast_macs");
19358 cmdline_parse_inst_t cmd_showport_macs = {
19359 .f = cmd_showport_macs_parsed,
19361 .help_str = "show port <port_id> macs|mcast_macs",
19363 (void *)&cmd_showport_macs_show,
19364 (void *)&cmd_showport_macs_port,
19365 (void *)&cmd_showport_macs_pid,
19366 (void *)&cmd_showport_macs_keyword,
19371 /* ******************************************************************************** */
19373 /* list of instructions */
19374 cmdline_parse_ctx_t main_ctx[] = {
19375 (cmdline_parse_inst_t *)&cmd_help_brief,
19376 (cmdline_parse_inst_t *)&cmd_help_long,
19377 (cmdline_parse_inst_t *)&cmd_quit,
19378 (cmdline_parse_inst_t *)&cmd_load_from_file,
19379 (cmdline_parse_inst_t *)&cmd_showport,
19380 (cmdline_parse_inst_t *)&cmd_showqueue,
19381 (cmdline_parse_inst_t *)&cmd_showportall,
19382 (cmdline_parse_inst_t *)&cmd_showdevice,
19383 (cmdline_parse_inst_t *)&cmd_showcfg,
19384 (cmdline_parse_inst_t *)&cmd_showfwdall,
19385 (cmdline_parse_inst_t *)&cmd_start,
19386 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19387 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19388 (cmdline_parse_inst_t *)&cmd_set_link_up,
19389 (cmdline_parse_inst_t *)&cmd_set_link_down,
19390 (cmdline_parse_inst_t *)&cmd_reset,
19391 (cmdline_parse_inst_t *)&cmd_set_numbers,
19392 (cmdline_parse_inst_t *)&cmd_set_log,
19393 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19394 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19395 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19396 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19397 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19398 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19399 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19400 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19401 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19402 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19403 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19404 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19405 (cmdline_parse_inst_t *)&cmd_set_link_check,
19406 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19407 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19408 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19409 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19410 #ifdef RTE_LIBRTE_PMD_BOND
19411 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19412 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19413 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19414 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19415 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19416 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19417 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19418 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19419 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19420 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19421 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19423 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19424 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19425 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19426 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19427 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19428 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19429 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19430 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19431 (cmdline_parse_inst_t *)&cmd_csum_set,
19432 (cmdline_parse_inst_t *)&cmd_csum_show,
19433 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19434 (cmdline_parse_inst_t *)&cmd_tso_set,
19435 (cmdline_parse_inst_t *)&cmd_tso_show,
19436 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19437 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19438 (cmdline_parse_inst_t *)&cmd_gro_enable,
19439 (cmdline_parse_inst_t *)&cmd_gro_flush,
19440 (cmdline_parse_inst_t *)&cmd_gro_show,
19441 (cmdline_parse_inst_t *)&cmd_gso_enable,
19442 (cmdline_parse_inst_t *)&cmd_gso_size,
19443 (cmdline_parse_inst_t *)&cmd_gso_show,
19444 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19445 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19446 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19447 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19448 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19449 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19450 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19451 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19452 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19453 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19454 (cmdline_parse_inst_t *)&cmd_config_dcb,
19455 (cmdline_parse_inst_t *)&cmd_read_reg,
19456 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19457 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19458 (cmdline_parse_inst_t *)&cmd_write_reg,
19459 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19460 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19461 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19462 (cmdline_parse_inst_t *)&cmd_stop,
19463 (cmdline_parse_inst_t *)&cmd_mac_addr,
19464 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19465 (cmdline_parse_inst_t *)&cmd_set_qmap,
19466 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19467 (cmdline_parse_inst_t *)&cmd_operate_port,
19468 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19469 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19470 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19471 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19472 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19473 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19474 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19475 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19476 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19477 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19478 (cmdline_parse_inst_t *)&cmd_config_mtu,
19479 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19480 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19481 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19482 (cmdline_parse_inst_t *)&cmd_config_rss,
19483 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19484 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19485 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19486 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19487 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19488 (cmdline_parse_inst_t *)&cmd_showport_reta,
19489 (cmdline_parse_inst_t *)&cmd_showport_macs,
19490 (cmdline_parse_inst_t *)&cmd_config_burst,
19491 (cmdline_parse_inst_t *)&cmd_config_thresh,
19492 (cmdline_parse_inst_t *)&cmd_config_threshold,
19493 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19494 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19495 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19496 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19497 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19498 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19499 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19500 (cmdline_parse_inst_t *)&cmd_global_config,
19501 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19502 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19503 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19504 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19505 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19506 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19507 (cmdline_parse_inst_t *)&cmd_dump,
19508 (cmdline_parse_inst_t *)&cmd_dump_one,
19509 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19510 (cmdline_parse_inst_t *)&cmd_syn_filter,
19511 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19512 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19513 (cmdline_parse_inst_t *)&cmd_flex_filter,
19514 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19515 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19516 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19517 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19518 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19519 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19520 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19521 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19522 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19523 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19524 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19525 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19526 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19527 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19528 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19529 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19530 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19531 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19532 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19533 (cmdline_parse_inst_t *)&cmd_flow,
19534 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19535 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19536 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19537 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19538 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19539 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19540 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19541 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19542 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19543 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19544 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19545 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19546 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19547 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19548 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19549 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19550 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19551 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19552 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19553 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19554 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19555 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19556 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19557 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19558 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19559 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19560 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19561 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19562 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19563 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19564 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19565 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19566 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19567 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19568 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19569 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19570 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19571 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19572 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19573 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19574 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19575 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19576 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19577 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19578 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19579 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19580 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19581 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19582 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19583 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19584 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19586 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19587 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19588 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19589 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19590 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19591 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19592 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19593 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19594 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19595 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19596 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19597 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19598 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19599 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19600 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19601 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19602 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19603 (cmdline_parse_inst_t *)&cmd_ddp_add,
19604 (cmdline_parse_inst_t *)&cmd_ddp_del,
19605 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19606 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19607 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19608 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19609 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19610 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19611 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19612 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19613 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19614 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19615 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19616 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19618 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19619 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19620 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19621 (cmdline_parse_inst_t *)&cmd_queue_region,
19622 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19623 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19624 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19625 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19626 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19627 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19628 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19629 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19630 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19631 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19632 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19633 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19634 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19635 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19636 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19637 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19638 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19639 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19640 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19641 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19642 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19643 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19644 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19645 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19646 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19647 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19648 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19649 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19650 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19651 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19652 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19653 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19654 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19655 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19656 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19657 #ifdef RTE_LIBRTE_BPF
19658 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19659 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19661 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19662 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19663 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19664 (cmdline_parse_inst_t *)&cmd_set_raw,
19665 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19666 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19667 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19671 /* read cmdline commands from file */
19673 cmdline_read_from_file(const char *filename)
19675 struct cmdline *cl;
19677 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19679 printf("Failed to create file based cmdline context: %s\n",
19684 cmdline_interact(cl);
19689 printf("Read CLI commands from %s\n", filename);
19692 /* prompt function, called from main on MASTER lcore */
19696 /* initialize non-constant commands */
19697 cmd_set_fwd_mode_init();
19698 cmd_set_fwd_retry_mode_init();
19700 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19701 if (testpmd_cl == NULL)
19703 cmdline_interact(testpmd_cl);
19704 cmdline_stdin_exit(testpmd_cl);
19710 if (testpmd_cl != NULL)
19711 cmdline_quit(testpmd_cl);
19715 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19717 if (id == (portid_t)RTE_PORT_ALL) {
19720 RTE_ETH_FOREACH_DEV(pid) {
19721 /* check if need_reconfig has been set to 1 */
19722 if (ports[pid].need_reconfig == 0)
19723 ports[pid].need_reconfig = dev;
19724 /* check if need_reconfig_queues has been set to 1 */
19725 if (ports[pid].need_reconfig_queues == 0)
19726 ports[pid].need_reconfig_queues = queue;
19728 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19729 /* check if need_reconfig has been set to 1 */
19730 if (ports[id].need_reconfig == 0)
19731 ports[id].need_reconfig = dev;
19732 /* check if need_reconfig_queues has been set to 1 */
19733 if (ports[id].need_reconfig_queues == 0)
19734 ports[id].need_reconfig_queues = queue;