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 commands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|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|200000|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 "flow aged {port_id} [destroy]\n"
1129 " List and destroy aged flows"
1132 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1133 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1134 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1135 " Configure the VXLAN encapsulation for flows.\n\n"
1137 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1138 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1139 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1140 " eth-dst (eth-dst)\n"
1141 " Configure the VXLAN encapsulation for flows.\n\n"
1143 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1144 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1145 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1146 " eth-dst (eth-dst)\n"
1147 " Configure the VXLAN encapsulation for flows.\n\n"
1149 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1150 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1152 " Configure the NVGRE encapsulation for flows.\n\n"
1154 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1155 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1156 " eth-src (eth-src) eth-dst (eth-dst)\n"
1157 " Configure the NVGRE encapsulation for flows.\n\n"
1159 "set raw_encap {flow items}\n"
1160 " Configure the encapsulation with raw data.\n\n"
1162 "set raw_decap {flow items}\n"
1163 " Configure the decapsulation with raw data.\n\n"
1168 if (show_all || !strcmp(res->section, "traffic_management")) {
1172 "Traffic Management:\n"
1174 "show port tm cap (port_id)\n"
1175 " Display the port TM capability.\n\n"
1177 "show port tm level cap (port_id) (level_id)\n"
1178 " Display the port TM hierarchical level capability.\n\n"
1180 "show port tm node cap (port_id) (node_id)\n"
1181 " Display the port TM node capability.\n\n"
1183 "show port tm node type (port_id) (node_id)\n"
1184 " Display the port TM node type.\n\n"
1186 "show port tm node stats (port_id) (node_id) (clear)\n"
1187 " Display the port TM node stats.\n\n"
1189 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1190 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1191 " (packet_length_adjust)\n"
1192 " Add port tm node private shaper profile.\n\n"
1194 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1195 " Delete port tm node private shaper profile.\n\n"
1197 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1198 " (shaper_profile_id)\n"
1199 " Add/update port tm node shared shaper.\n\n"
1201 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1202 " Delete port tm node shared shaper.\n\n"
1204 "set port tm node shaper profile (port_id) (node_id)"
1205 " (shaper_profile_id)\n"
1206 " Set port tm node shaper profile.\n\n"
1208 "add port tm node wred profile (port_id) (wred_profile_id)"
1209 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1210 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1211 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1212 " Add port tm node wred profile.\n\n"
1214 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1215 " Delete port tm node wred profile.\n\n"
1217 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1218 " (priority) (weight) (level_id) (shaper_profile_id)"
1219 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1220 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1221 " Add port tm nonleaf node.\n\n"
1223 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1224 " (priority) (weight) (level_id) (shaper_profile_id)"
1225 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1226 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1227 " Add port tm leaf node.\n\n"
1229 "del port tm node (port_id) (node_id)\n"
1230 " Delete port tm node.\n\n"
1232 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1233 " (priority) (weight)\n"
1234 " Set port tm node parent.\n\n"
1236 "suspend port tm node (port_id) (node_id)"
1237 " Suspend tm node.\n\n"
1239 "resume port tm node (port_id) (node_id)"
1240 " Resume tm node.\n\n"
1242 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1243 " Commit tm hierarchy.\n\n"
1245 "set port tm mark ip_ecn (port) (green) (yellow)"
1247 " Enables/Disables the traffic management marking"
1248 " for IP ECN (Explicit Congestion Notification)"
1249 " packets on a given port\n\n"
1251 "set port tm mark ip_dscp (port) (green) (yellow)"
1253 " Enables/Disables the traffic management marking"
1254 " on the port for IP dscp packets\n\n"
1256 "set port tm mark vlan_dei (port) (green) (yellow)"
1258 " Enables/Disables the traffic management marking"
1259 " on the port for VLAN packets with DEI enabled\n\n"
1263 if (show_all || !strcmp(res->section, "devices")) {
1267 "Device Operations:\n"
1269 "device detach (identifier)\n"
1270 " Detach device by identifier.\n\n"
1276 cmdline_parse_token_string_t cmd_help_long_help =
1277 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1279 cmdline_parse_token_string_t cmd_help_long_section =
1280 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1281 "all#control#display#config#"
1282 "ports#registers#filters#traffic_management#devices");
1284 cmdline_parse_inst_t cmd_help_long = {
1285 .f = cmd_help_long_parsed,
1287 .help_str = "help all|control|display|config|ports|register|"
1288 "filters|traffic_management|devices: "
1291 (void *)&cmd_help_long_help,
1292 (void *)&cmd_help_long_section,
1298 /* *** start/stop/close all ports *** */
1299 struct cmd_operate_port_result {
1300 cmdline_fixed_string_t keyword;
1301 cmdline_fixed_string_t name;
1302 cmdline_fixed_string_t value;
1305 static void cmd_operate_port_parsed(void *parsed_result,
1306 __rte_unused struct cmdline *cl,
1307 __rte_unused void *data)
1309 struct cmd_operate_port_result *res = parsed_result;
1311 if (!strcmp(res->name, "start"))
1312 start_port(RTE_PORT_ALL);
1313 else if (!strcmp(res->name, "stop"))
1314 stop_port(RTE_PORT_ALL);
1315 else if (!strcmp(res->name, "close"))
1316 close_port(RTE_PORT_ALL);
1317 else if (!strcmp(res->name, "reset"))
1318 reset_port(RTE_PORT_ALL);
1320 printf("Unknown parameter\n");
1323 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1324 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1326 cmdline_parse_token_string_t cmd_operate_port_all_port =
1327 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1328 "start#stop#close#reset");
1329 cmdline_parse_token_string_t cmd_operate_port_all_all =
1330 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1332 cmdline_parse_inst_t cmd_operate_port = {
1333 .f = cmd_operate_port_parsed,
1335 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1337 (void *)&cmd_operate_port_all_cmd,
1338 (void *)&cmd_operate_port_all_port,
1339 (void *)&cmd_operate_port_all_all,
1344 /* *** start/stop/close specific port *** */
1345 struct cmd_operate_specific_port_result {
1346 cmdline_fixed_string_t keyword;
1347 cmdline_fixed_string_t name;
1351 static void cmd_operate_specific_port_parsed(void *parsed_result,
1352 __rte_unused struct cmdline *cl,
1353 __rte_unused void *data)
1355 struct cmd_operate_specific_port_result *res = parsed_result;
1357 if (!strcmp(res->name, "start"))
1358 start_port(res->value);
1359 else if (!strcmp(res->name, "stop"))
1360 stop_port(res->value);
1361 else if (!strcmp(res->name, "close"))
1362 close_port(res->value);
1363 else if (!strcmp(res->name, "reset"))
1364 reset_port(res->value);
1366 printf("Unknown parameter\n");
1369 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1370 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1372 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1373 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1374 name, "start#stop#close#reset");
1375 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1376 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1379 cmdline_parse_inst_t cmd_operate_specific_port = {
1380 .f = cmd_operate_specific_port_parsed,
1382 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1384 (void *)&cmd_operate_specific_port_cmd,
1385 (void *)&cmd_operate_specific_port_port,
1386 (void *)&cmd_operate_specific_port_id,
1391 /* *** enable port setup (after attach) via iterator or event *** */
1392 struct cmd_set_port_setup_on_result {
1393 cmdline_fixed_string_t set;
1394 cmdline_fixed_string_t port;
1395 cmdline_fixed_string_t setup;
1396 cmdline_fixed_string_t on;
1397 cmdline_fixed_string_t mode;
1400 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1401 __rte_unused struct cmdline *cl,
1402 __rte_unused void *data)
1404 struct cmd_set_port_setup_on_result *res = parsed_result;
1406 if (strcmp(res->mode, "event") == 0)
1407 setup_on_probe_event = true;
1408 else if (strcmp(res->mode, "iterator") == 0)
1409 setup_on_probe_event = false;
1411 printf("Unknown mode\n");
1414 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1415 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1417 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1418 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1420 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1421 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1423 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1424 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1426 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1427 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1428 mode, "iterator#event");
1430 cmdline_parse_inst_t cmd_set_port_setup_on = {
1431 .f = cmd_set_port_setup_on_parsed,
1433 .help_str = "set port setup on iterator|event",
1435 (void *)&cmd_set_port_setup_on_set,
1436 (void *)&cmd_set_port_setup_on_port,
1437 (void *)&cmd_set_port_setup_on_setup,
1438 (void *)&cmd_set_port_setup_on_on,
1439 (void *)&cmd_set_port_setup_on_mode,
1444 /* *** attach a specified port *** */
1445 struct cmd_operate_attach_port_result {
1446 cmdline_fixed_string_t port;
1447 cmdline_fixed_string_t keyword;
1448 cmdline_multi_string_t identifier;
1451 static void cmd_operate_attach_port_parsed(void *parsed_result,
1452 __rte_unused struct cmdline *cl,
1453 __rte_unused void *data)
1455 struct cmd_operate_attach_port_result *res = parsed_result;
1457 if (!strcmp(res->keyword, "attach"))
1458 attach_port(res->identifier);
1460 printf("Unknown parameter\n");
1463 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1464 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1466 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1467 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1469 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1470 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1471 identifier, TOKEN_STRING_MULTI);
1473 cmdline_parse_inst_t cmd_operate_attach_port = {
1474 .f = cmd_operate_attach_port_parsed,
1476 .help_str = "port attach <identifier>: "
1477 "(identifier: pci address or virtual dev name)",
1479 (void *)&cmd_operate_attach_port_port,
1480 (void *)&cmd_operate_attach_port_keyword,
1481 (void *)&cmd_operate_attach_port_identifier,
1486 /* *** detach a specified port *** */
1487 struct cmd_operate_detach_port_result {
1488 cmdline_fixed_string_t port;
1489 cmdline_fixed_string_t keyword;
1493 static void cmd_operate_detach_port_parsed(void *parsed_result,
1494 __rte_unused struct cmdline *cl,
1495 __rte_unused void *data)
1497 struct cmd_operate_detach_port_result *res = parsed_result;
1499 if (!strcmp(res->keyword, "detach")) {
1500 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1501 detach_port_device(res->port_id);
1503 printf("Unknown parameter\n");
1507 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1508 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1510 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1511 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1513 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1514 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1517 cmdline_parse_inst_t cmd_operate_detach_port = {
1518 .f = cmd_operate_detach_port_parsed,
1520 .help_str = "port detach <port_id>",
1522 (void *)&cmd_operate_detach_port_port,
1523 (void *)&cmd_operate_detach_port_keyword,
1524 (void *)&cmd_operate_detach_port_port_id,
1529 /* *** detach device by identifier *** */
1530 struct cmd_operate_detach_device_result {
1531 cmdline_fixed_string_t device;
1532 cmdline_fixed_string_t keyword;
1533 cmdline_fixed_string_t identifier;
1536 static void cmd_operate_detach_device_parsed(void *parsed_result,
1537 __rte_unused struct cmdline *cl,
1538 __rte_unused void *data)
1540 struct cmd_operate_detach_device_result *res = parsed_result;
1542 if (!strcmp(res->keyword, "detach"))
1543 detach_devargs(res->identifier);
1545 printf("Unknown parameter\n");
1548 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1549 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1551 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1552 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1554 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1555 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1558 cmdline_parse_inst_t cmd_operate_detach_device = {
1559 .f = cmd_operate_detach_device_parsed,
1561 .help_str = "device detach <identifier>:"
1562 "(identifier: pci address or virtual dev name)",
1564 (void *)&cmd_operate_detach_device_device,
1565 (void *)&cmd_operate_detach_device_keyword,
1566 (void *)&cmd_operate_detach_device_identifier,
1570 /* *** configure speed for all ports *** */
1571 struct cmd_config_speed_all {
1572 cmdline_fixed_string_t port;
1573 cmdline_fixed_string_t keyword;
1574 cmdline_fixed_string_t all;
1575 cmdline_fixed_string_t item1;
1576 cmdline_fixed_string_t item2;
1577 cmdline_fixed_string_t value1;
1578 cmdline_fixed_string_t value2;
1582 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1587 if (!strcmp(duplexstr, "half")) {
1588 duplex = ETH_LINK_HALF_DUPLEX;
1589 } else if (!strcmp(duplexstr, "full")) {
1590 duplex = ETH_LINK_FULL_DUPLEX;
1591 } else if (!strcmp(duplexstr, "auto")) {
1592 duplex = ETH_LINK_FULL_DUPLEX;
1594 printf("Unknown duplex parameter\n");
1598 if (!strcmp(speedstr, "10")) {
1599 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1600 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1601 } else if (!strcmp(speedstr, "100")) {
1602 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1603 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1605 if (duplex != ETH_LINK_FULL_DUPLEX) {
1606 printf("Invalid speed/duplex parameters\n");
1609 if (!strcmp(speedstr, "1000")) {
1610 *speed = ETH_LINK_SPEED_1G;
1611 } else if (!strcmp(speedstr, "10000")) {
1612 *speed = ETH_LINK_SPEED_10G;
1613 } else if (!strcmp(speedstr, "25000")) {
1614 *speed = ETH_LINK_SPEED_25G;
1615 } else if (!strcmp(speedstr, "40000")) {
1616 *speed = ETH_LINK_SPEED_40G;
1617 } else if (!strcmp(speedstr, "50000")) {
1618 *speed = ETH_LINK_SPEED_50G;
1619 } else if (!strcmp(speedstr, "100000")) {
1620 *speed = ETH_LINK_SPEED_100G;
1621 } else if (!strcmp(speedstr, "200000")) {
1622 *speed = ETH_LINK_SPEED_200G;
1623 } else if (!strcmp(speedstr, "auto")) {
1624 *speed = ETH_LINK_SPEED_AUTONEG;
1626 printf("Unknown speed parameter\n");
1635 cmd_config_speed_all_parsed(void *parsed_result,
1636 __rte_unused struct cmdline *cl,
1637 __rte_unused void *data)
1639 struct cmd_config_speed_all *res = parsed_result;
1640 uint32_t link_speed;
1643 if (!all_ports_stopped()) {
1644 printf("Please stop all ports first\n");
1648 if (parse_and_check_speed_duplex(res->value1, res->value2,
1652 RTE_ETH_FOREACH_DEV(pid) {
1653 ports[pid].dev_conf.link_speeds = link_speed;
1656 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1659 cmdline_parse_token_string_t cmd_config_speed_all_port =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1661 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1664 cmdline_parse_token_string_t cmd_config_speed_all_all =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1666 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1667 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1668 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1669 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1670 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1671 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1673 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1677 cmdline_parse_inst_t cmd_config_speed_all = {
1678 .f = cmd_config_speed_all_parsed,
1680 .help_str = "port config all speed "
1681 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1684 (void *)&cmd_config_speed_all_port,
1685 (void *)&cmd_config_speed_all_keyword,
1686 (void *)&cmd_config_speed_all_all,
1687 (void *)&cmd_config_speed_all_item1,
1688 (void *)&cmd_config_speed_all_value1,
1689 (void *)&cmd_config_speed_all_item2,
1690 (void *)&cmd_config_speed_all_value2,
1695 /* *** configure speed for specific port *** */
1696 struct cmd_config_speed_specific {
1697 cmdline_fixed_string_t port;
1698 cmdline_fixed_string_t keyword;
1700 cmdline_fixed_string_t item1;
1701 cmdline_fixed_string_t item2;
1702 cmdline_fixed_string_t value1;
1703 cmdline_fixed_string_t value2;
1707 cmd_config_speed_specific_parsed(void *parsed_result,
1708 __rte_unused struct cmdline *cl,
1709 __rte_unused void *data)
1711 struct cmd_config_speed_specific *res = parsed_result;
1712 uint32_t link_speed;
1714 if (!all_ports_stopped()) {
1715 printf("Please stop all ports first\n");
1719 if (port_id_is_invalid(res->id, ENABLED_WARN))
1722 if (parse_and_check_speed_duplex(res->value1, res->value2,
1726 ports[res->id].dev_conf.link_speeds = link_speed;
1728 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1732 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1733 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1735 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1736 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1738 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1739 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1740 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1741 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1743 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1744 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1745 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1746 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1747 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1749 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1750 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1753 cmdline_parse_inst_t cmd_config_speed_specific = {
1754 .f = cmd_config_speed_specific_parsed,
1756 .help_str = "port config <port_id> speed "
1757 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1760 (void *)&cmd_config_speed_specific_port,
1761 (void *)&cmd_config_speed_specific_keyword,
1762 (void *)&cmd_config_speed_specific_id,
1763 (void *)&cmd_config_speed_specific_item1,
1764 (void *)&cmd_config_speed_specific_value1,
1765 (void *)&cmd_config_speed_specific_item2,
1766 (void *)&cmd_config_speed_specific_value2,
1771 /* *** configure loopback for all ports *** */
1772 struct cmd_config_loopback_all {
1773 cmdline_fixed_string_t port;
1774 cmdline_fixed_string_t keyword;
1775 cmdline_fixed_string_t all;
1776 cmdline_fixed_string_t item;
1781 cmd_config_loopback_all_parsed(void *parsed_result,
1782 __rte_unused struct cmdline *cl,
1783 __rte_unused void *data)
1785 struct cmd_config_loopback_all *res = parsed_result;
1788 if (!all_ports_stopped()) {
1789 printf("Please stop all ports first\n");
1793 RTE_ETH_FOREACH_DEV(pid) {
1794 ports[pid].dev_conf.lpbk_mode = res->mode;
1797 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1800 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1801 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1802 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1803 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1805 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1806 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1807 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1808 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1810 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1811 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1813 cmdline_parse_inst_t cmd_config_loopback_all = {
1814 .f = cmd_config_loopback_all_parsed,
1816 .help_str = "port config all loopback <mode>",
1818 (void *)&cmd_config_loopback_all_port,
1819 (void *)&cmd_config_loopback_all_keyword,
1820 (void *)&cmd_config_loopback_all_all,
1821 (void *)&cmd_config_loopback_all_item,
1822 (void *)&cmd_config_loopback_all_mode,
1827 /* *** configure loopback for specific port *** */
1828 struct cmd_config_loopback_specific {
1829 cmdline_fixed_string_t port;
1830 cmdline_fixed_string_t keyword;
1832 cmdline_fixed_string_t item;
1837 cmd_config_loopback_specific_parsed(void *parsed_result,
1838 __rte_unused struct cmdline *cl,
1839 __rte_unused void *data)
1841 struct cmd_config_loopback_specific *res = parsed_result;
1843 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1846 if (!port_is_stopped(res->port_id)) {
1847 printf("Please stop port %u first\n", res->port_id);
1851 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1853 cmd_reconfig_device_queue(res->port_id, 1, 1);
1857 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1860 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1863 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1864 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1866 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1867 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1869 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1870 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1873 cmdline_parse_inst_t cmd_config_loopback_specific = {
1874 .f = cmd_config_loopback_specific_parsed,
1876 .help_str = "port config <port_id> loopback <mode>",
1878 (void *)&cmd_config_loopback_specific_port,
1879 (void *)&cmd_config_loopback_specific_keyword,
1880 (void *)&cmd_config_loopback_specific_id,
1881 (void *)&cmd_config_loopback_specific_item,
1882 (void *)&cmd_config_loopback_specific_mode,
1887 /* *** configure txq/rxq, txd/rxd *** */
1888 struct cmd_config_rx_tx {
1889 cmdline_fixed_string_t port;
1890 cmdline_fixed_string_t keyword;
1891 cmdline_fixed_string_t all;
1892 cmdline_fixed_string_t name;
1897 cmd_config_rx_tx_parsed(void *parsed_result,
1898 __rte_unused struct cmdline *cl,
1899 __rte_unused void *data)
1901 struct cmd_config_rx_tx *res = parsed_result;
1903 if (!all_ports_stopped()) {
1904 printf("Please stop all ports first\n");
1907 if (!strcmp(res->name, "rxq")) {
1908 if (!res->value && !nb_txq) {
1909 printf("Warning: Either rx or tx queues should be non zero\n");
1912 if (check_nb_rxq(res->value) != 0)
1914 nb_rxq = res->value;
1916 else if (!strcmp(res->name, "txq")) {
1917 if (!res->value && !nb_rxq) {
1918 printf("Warning: Either rx or tx queues should be non zero\n");
1921 if (check_nb_txq(res->value) != 0)
1923 nb_txq = res->value;
1925 else if (!strcmp(res->name, "rxd")) {
1926 if (check_nb_rxd(res->value) != 0)
1928 nb_rxd = res->value;
1929 } else if (!strcmp(res->name, "txd")) {
1930 if (check_nb_txd(res->value) != 0)
1933 nb_txd = res->value;
1935 printf("Unknown parameter\n");
1943 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1946 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1947 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1948 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1949 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1950 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1952 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1953 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1955 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1956 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1958 cmdline_parse_inst_t cmd_config_rx_tx = {
1959 .f = cmd_config_rx_tx_parsed,
1961 .help_str = "port config all rxq|txq|rxd|txd <value>",
1963 (void *)&cmd_config_rx_tx_port,
1964 (void *)&cmd_config_rx_tx_keyword,
1965 (void *)&cmd_config_rx_tx_all,
1966 (void *)&cmd_config_rx_tx_name,
1967 (void *)&cmd_config_rx_tx_value,
1972 /* *** config max packet length *** */
1973 struct cmd_config_max_pkt_len_result {
1974 cmdline_fixed_string_t port;
1975 cmdline_fixed_string_t keyword;
1976 cmdline_fixed_string_t all;
1977 cmdline_fixed_string_t name;
1982 cmd_config_max_pkt_len_parsed(void *parsed_result,
1983 __rte_unused struct cmdline *cl,
1984 __rte_unused void *data)
1986 struct cmd_config_max_pkt_len_result *res = parsed_result;
1989 if (!all_ports_stopped()) {
1990 printf("Please stop all ports first\n");
1994 RTE_ETH_FOREACH_DEV(pid) {
1995 struct rte_port *port = &ports[pid];
1996 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1998 if (!strcmp(res->name, "max-pkt-len")) {
1999 if (res->value < RTE_ETHER_MIN_LEN) {
2000 printf("max-pkt-len can not be less than %d\n",
2004 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2007 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2008 if (res->value > RTE_ETHER_MAX_LEN)
2009 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2011 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2012 port->dev_conf.rxmode.offloads = rx_offloads;
2014 printf("Unknown parameter\n");
2021 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2024 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2025 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2027 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2028 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2030 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2031 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2033 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2034 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2036 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2037 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2040 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2041 .f = cmd_config_max_pkt_len_parsed,
2043 .help_str = "port config all max-pkt-len <value>",
2045 (void *)&cmd_config_max_pkt_len_port,
2046 (void *)&cmd_config_max_pkt_len_keyword,
2047 (void *)&cmd_config_max_pkt_len_all,
2048 (void *)&cmd_config_max_pkt_len_name,
2049 (void *)&cmd_config_max_pkt_len_value,
2054 /* *** config max LRO aggregated packet size *** */
2055 struct cmd_config_max_lro_pkt_size_result {
2056 cmdline_fixed_string_t port;
2057 cmdline_fixed_string_t keyword;
2058 cmdline_fixed_string_t all;
2059 cmdline_fixed_string_t name;
2064 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2065 __rte_unused struct cmdline *cl,
2066 __rte_unused void *data)
2068 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2071 if (!all_ports_stopped()) {
2072 printf("Please stop all ports first\n");
2076 RTE_ETH_FOREACH_DEV(pid) {
2077 struct rte_port *port = &ports[pid];
2079 if (!strcmp(res->name, "max-lro-pkt-size")) {
2081 port->dev_conf.rxmode.max_lro_pkt_size)
2084 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2086 printf("Unknown parameter\n");
2093 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2096 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2097 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2099 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2100 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2102 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2103 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2105 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2106 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2107 name, "max-lro-pkt-size");
2108 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2109 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2112 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2113 .f = cmd_config_max_lro_pkt_size_parsed,
2115 .help_str = "port config all max-lro-pkt-size <value>",
2117 (void *)&cmd_config_max_lro_pkt_size_port,
2118 (void *)&cmd_config_max_lro_pkt_size_keyword,
2119 (void *)&cmd_config_max_lro_pkt_size_all,
2120 (void *)&cmd_config_max_lro_pkt_size_name,
2121 (void *)&cmd_config_max_lro_pkt_size_value,
2126 /* *** configure port MTU *** */
2127 struct cmd_config_mtu_result {
2128 cmdline_fixed_string_t port;
2129 cmdline_fixed_string_t keyword;
2130 cmdline_fixed_string_t mtu;
2136 cmd_config_mtu_parsed(void *parsed_result,
2137 __rte_unused struct cmdline *cl,
2138 __rte_unused void *data)
2140 struct cmd_config_mtu_result *res = parsed_result;
2142 if (res->value < RTE_ETHER_MIN_LEN) {
2143 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2146 port_mtu_set(res->port_id, res->value);
2149 cmdline_parse_token_string_t cmd_config_mtu_port =
2150 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2152 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2153 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2155 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2156 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2158 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2159 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2160 cmdline_parse_token_num_t cmd_config_mtu_value =
2161 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2163 cmdline_parse_inst_t cmd_config_mtu = {
2164 .f = cmd_config_mtu_parsed,
2166 .help_str = "port config mtu <port_id> <value>",
2168 (void *)&cmd_config_mtu_port,
2169 (void *)&cmd_config_mtu_keyword,
2170 (void *)&cmd_config_mtu_mtu,
2171 (void *)&cmd_config_mtu_port_id,
2172 (void *)&cmd_config_mtu_value,
2177 /* *** configure rx mode *** */
2178 struct cmd_config_rx_mode_flag {
2179 cmdline_fixed_string_t port;
2180 cmdline_fixed_string_t keyword;
2181 cmdline_fixed_string_t all;
2182 cmdline_fixed_string_t name;
2183 cmdline_fixed_string_t value;
2187 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2188 __rte_unused struct cmdline *cl,
2189 __rte_unused void *data)
2191 struct cmd_config_rx_mode_flag *res = parsed_result;
2193 if (!all_ports_stopped()) {
2194 printf("Please stop all ports first\n");
2198 if (!strcmp(res->name, "drop-en")) {
2199 if (!strcmp(res->value, "on"))
2201 else if (!strcmp(res->value, "off"))
2204 printf("Unknown parameter\n");
2208 printf("Unknown parameter\n");
2214 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2217 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2218 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2219 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2220 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2222 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2223 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2224 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2225 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2227 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2228 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2231 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2232 .f = cmd_config_rx_mode_flag_parsed,
2234 .help_str = "port config all drop-en on|off",
2236 (void *)&cmd_config_rx_mode_flag_port,
2237 (void *)&cmd_config_rx_mode_flag_keyword,
2238 (void *)&cmd_config_rx_mode_flag_all,
2239 (void *)&cmd_config_rx_mode_flag_name,
2240 (void *)&cmd_config_rx_mode_flag_value,
2245 /* *** configure rss *** */
2246 struct cmd_config_rss {
2247 cmdline_fixed_string_t port;
2248 cmdline_fixed_string_t keyword;
2249 cmdline_fixed_string_t all;
2250 cmdline_fixed_string_t name;
2251 cmdline_fixed_string_t value;
2255 cmd_config_rss_parsed(void *parsed_result,
2256 __rte_unused struct cmdline *cl,
2257 __rte_unused void *data)
2259 struct cmd_config_rss *res = parsed_result;
2260 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2261 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2262 int use_default = 0;
2263 int all_updated = 1;
2268 if (!strcmp(res->value, "all"))
2269 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2270 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2271 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2272 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2273 else if (!strcmp(res->value, "eth"))
2274 rss_conf.rss_hf = ETH_RSS_ETH;
2275 else if (!strcmp(res->value, "vlan"))
2276 rss_conf.rss_hf = ETH_RSS_VLAN;
2277 else if (!strcmp(res->value, "ip"))
2278 rss_conf.rss_hf = ETH_RSS_IP;
2279 else if (!strcmp(res->value, "udp"))
2280 rss_conf.rss_hf = ETH_RSS_UDP;
2281 else if (!strcmp(res->value, "tcp"))
2282 rss_conf.rss_hf = ETH_RSS_TCP;
2283 else if (!strcmp(res->value, "sctp"))
2284 rss_conf.rss_hf = ETH_RSS_SCTP;
2285 else if (!strcmp(res->value, "ether"))
2286 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2287 else if (!strcmp(res->value, "port"))
2288 rss_conf.rss_hf = ETH_RSS_PORT;
2289 else if (!strcmp(res->value, "vxlan"))
2290 rss_conf.rss_hf = ETH_RSS_VXLAN;
2291 else if (!strcmp(res->value, "geneve"))
2292 rss_conf.rss_hf = ETH_RSS_GENEVE;
2293 else if (!strcmp(res->value, "nvgre"))
2294 rss_conf.rss_hf = ETH_RSS_NVGRE;
2295 else if (!strcmp(res->value, "l3-pre32"))
2296 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2297 else if (!strcmp(res->value, "l3-pre40"))
2298 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2299 else if (!strcmp(res->value, "l3-pre48"))
2300 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2301 else if (!strcmp(res->value, "l3-pre56"))
2302 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2303 else if (!strcmp(res->value, "l3-pre64"))
2304 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2305 else if (!strcmp(res->value, "l3-pre96"))
2306 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2307 else if (!strcmp(res->value, "l3-src-only"))
2308 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2309 else if (!strcmp(res->value, "l3-dst-only"))
2310 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2311 else if (!strcmp(res->value, "l4-src-only"))
2312 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2313 else if (!strcmp(res->value, "l4-dst-only"))
2314 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2315 else if (!strcmp(res->value, "l2-src-only"))
2316 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2317 else if (!strcmp(res->value, "l2-dst-only"))
2318 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2319 else if (!strcmp(res->value, "l2tpv3"))
2320 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2321 else if (!strcmp(res->value, "esp"))
2322 rss_conf.rss_hf = ETH_RSS_ESP;
2323 else if (!strcmp(res->value, "ah"))
2324 rss_conf.rss_hf = ETH_RSS_AH;
2325 else if (!strcmp(res->value, "pfcp"))
2326 rss_conf.rss_hf = ETH_RSS_PFCP;
2327 else if (!strcmp(res->value, "pppoe"))
2328 rss_conf.rss_hf = ETH_RSS_PPPOE;
2329 else if (!strcmp(res->value, "gtpu"))
2330 rss_conf.rss_hf = ETH_RSS_GTPU;
2331 else if (!strcmp(res->value, "none"))
2332 rss_conf.rss_hf = 0;
2333 else if (!strcmp(res->value, "default"))
2335 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2336 atoi(res->value) < 64)
2337 rss_conf.rss_hf = 1ULL << atoi(res->value);
2339 printf("Unknown parameter\n");
2342 rss_conf.rss_key = NULL;
2343 /* Update global configuration for RSS types. */
2344 RTE_ETH_FOREACH_DEV(i) {
2345 struct rte_eth_rss_conf local_rss_conf;
2347 ret = eth_dev_info_get_print_err(i, &dev_info);
2352 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2354 local_rss_conf = rss_conf;
2355 local_rss_conf.rss_hf = rss_conf.rss_hf &
2356 dev_info.flow_type_rss_offloads;
2357 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2358 printf("Port %u modified RSS hash function based on hardware support,"
2359 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2360 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2362 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2365 printf("Configuration of RSS hash at ethernet port %d "
2366 "failed with error (%d): %s.\n",
2367 i, -diag, strerror(-diag));
2370 if (all_updated && !use_default) {
2371 rss_hf = rss_conf.rss_hf;
2372 printf("rss_hf %#"PRIx64"\n", rss_hf);
2376 cmdline_parse_token_string_t cmd_config_rss_port =
2377 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2378 cmdline_parse_token_string_t cmd_config_rss_keyword =
2379 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2380 cmdline_parse_token_string_t cmd_config_rss_all =
2381 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2382 cmdline_parse_token_string_t cmd_config_rss_name =
2383 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2384 cmdline_parse_token_string_t cmd_config_rss_value =
2385 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2387 cmdline_parse_inst_t cmd_config_rss = {
2388 .f = cmd_config_rss_parsed,
2390 .help_str = "port config all rss "
2391 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2392 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|<flowtype_id>",
2394 (void *)&cmd_config_rss_port,
2395 (void *)&cmd_config_rss_keyword,
2396 (void *)&cmd_config_rss_all,
2397 (void *)&cmd_config_rss_name,
2398 (void *)&cmd_config_rss_value,
2403 /* *** configure rss hash key *** */
2404 struct cmd_config_rss_hash_key {
2405 cmdline_fixed_string_t port;
2406 cmdline_fixed_string_t config;
2408 cmdline_fixed_string_t rss_hash_key;
2409 cmdline_fixed_string_t rss_type;
2410 cmdline_fixed_string_t key;
2414 hexa_digit_to_value(char hexa_digit)
2416 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2417 return (uint8_t) (hexa_digit - '0');
2418 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2419 return (uint8_t) ((hexa_digit - 'a') + 10);
2420 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2421 return (uint8_t) ((hexa_digit - 'A') + 10);
2422 /* Invalid hexa digit */
2427 parse_and_check_key_hexa_digit(char *key, int idx)
2431 hexa_v = hexa_digit_to_value(key[idx]);
2433 printf("invalid key: character %c at position %d is not a "
2434 "valid hexa digit\n", key[idx], idx);
2439 cmd_config_rss_hash_key_parsed(void *parsed_result,
2440 __rte_unused struct cmdline *cl,
2441 __rte_unused void *data)
2443 struct cmd_config_rss_hash_key *res = parsed_result;
2444 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2448 struct rte_eth_dev_info dev_info;
2449 uint8_t hash_key_size;
2453 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2457 if (dev_info.hash_key_size > 0 &&
2458 dev_info.hash_key_size <= sizeof(hash_key))
2459 hash_key_size = dev_info.hash_key_size;
2461 printf("dev_info did not provide a valid hash key size\n");
2464 /* Check the length of the RSS hash key */
2465 key_len = strlen(res->key);
2466 if (key_len != (hash_key_size * 2)) {
2467 printf("key length: %d invalid - key must be a string of %d"
2468 " hexa-decimal numbers\n",
2469 (int) key_len, hash_key_size * 2);
2472 /* Translate RSS hash key into binary representation */
2473 for (i = 0; i < hash_key_size; i++) {
2474 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2477 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2480 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2482 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2486 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2487 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2488 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2489 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2491 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2492 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2493 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2494 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2495 rss_hash_key, "rss-hash-key");
2496 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2497 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2498 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2499 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2500 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2501 "ipv6-tcp-ex#ipv6-udp-ex#"
2502 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2503 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2504 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2505 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2506 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2508 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2509 .f = cmd_config_rss_hash_key_parsed,
2511 .help_str = "port config <port_id> rss-hash-key "
2512 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2513 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2514 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2515 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2516 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2517 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2518 "<string of hex digits (variable length, NIC dependent)>",
2520 (void *)&cmd_config_rss_hash_key_port,
2521 (void *)&cmd_config_rss_hash_key_config,
2522 (void *)&cmd_config_rss_hash_key_port_id,
2523 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2524 (void *)&cmd_config_rss_hash_key_rss_type,
2525 (void *)&cmd_config_rss_hash_key_value,
2530 /* *** configure port rxq/txq ring size *** */
2531 struct cmd_config_rxtx_ring_size {
2532 cmdline_fixed_string_t port;
2533 cmdline_fixed_string_t config;
2535 cmdline_fixed_string_t rxtxq;
2537 cmdline_fixed_string_t rsize;
2542 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2543 __rte_unused struct cmdline *cl,
2544 __rte_unused void *data)
2546 struct cmd_config_rxtx_ring_size *res = parsed_result;
2547 struct rte_port *port;
2550 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2553 if (res->portid == (portid_t)RTE_PORT_ALL) {
2554 printf("Invalid port id\n");
2558 port = &ports[res->portid];
2560 if (!strcmp(res->rxtxq, "rxq"))
2562 else if (!strcmp(res->rxtxq, "txq"))
2565 printf("Unknown parameter\n");
2569 if (isrx && rx_queue_id_is_invalid(res->qid))
2571 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2574 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2575 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2581 port->nb_rx_desc[res->qid] = res->size;
2583 port->nb_tx_desc[res->qid] = res->size;
2585 cmd_reconfig_device_queue(res->portid, 0, 1);
2588 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2589 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2591 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2592 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2594 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2595 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2597 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2598 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2600 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2601 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2603 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2604 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2605 rsize, "ring_size");
2606 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2607 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2610 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2611 .f = cmd_config_rxtx_ring_size_parsed,
2613 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2615 (void *)&cmd_config_rxtx_ring_size_port,
2616 (void *)&cmd_config_rxtx_ring_size_config,
2617 (void *)&cmd_config_rxtx_ring_size_portid,
2618 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2619 (void *)&cmd_config_rxtx_ring_size_qid,
2620 (void *)&cmd_config_rxtx_ring_size_rsize,
2621 (void *)&cmd_config_rxtx_ring_size_size,
2626 /* *** configure port rxq/txq start/stop *** */
2627 struct cmd_config_rxtx_queue {
2628 cmdline_fixed_string_t port;
2630 cmdline_fixed_string_t rxtxq;
2632 cmdline_fixed_string_t opname;
2636 cmd_config_rxtx_queue_parsed(void *parsed_result,
2637 __rte_unused struct cmdline *cl,
2638 __rte_unused void *data)
2640 struct cmd_config_rxtx_queue *res = parsed_result;
2645 if (test_done == 0) {
2646 printf("Please stop forwarding first\n");
2650 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2653 if (port_is_started(res->portid) != 1) {
2654 printf("Please start port %u first\n", res->portid);
2658 if (!strcmp(res->rxtxq, "rxq"))
2660 else if (!strcmp(res->rxtxq, "txq"))
2663 printf("Unknown parameter\n");
2667 if (isrx && rx_queue_id_is_invalid(res->qid))
2669 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2672 if (!strcmp(res->opname, "start"))
2674 else if (!strcmp(res->opname, "stop"))
2677 printf("Unknown parameter\n");
2681 if (isstart && isrx)
2682 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2683 else if (!isstart && isrx)
2684 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2685 else if (isstart && !isrx)
2686 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2688 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2690 if (ret == -ENOTSUP)
2691 printf("Function not supported in PMD driver\n");
2694 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2695 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2696 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2697 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2698 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2699 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2700 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2701 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2702 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2703 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2706 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2707 .f = cmd_config_rxtx_queue_parsed,
2709 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2711 (void *)&cmd_config_rxtx_queue_port,
2712 (void *)&cmd_config_rxtx_queue_portid,
2713 (void *)&cmd_config_rxtx_queue_rxtxq,
2714 (void *)&cmd_config_rxtx_queue_qid,
2715 (void *)&cmd_config_rxtx_queue_opname,
2720 /* *** configure port rxq/txq deferred start on/off *** */
2721 struct cmd_config_deferred_start_rxtx_queue {
2722 cmdline_fixed_string_t port;
2724 cmdline_fixed_string_t rxtxq;
2726 cmdline_fixed_string_t opname;
2727 cmdline_fixed_string_t state;
2731 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2732 __rte_unused struct cmdline *cl,
2733 __rte_unused void *data)
2735 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2736 struct rte_port *port;
2739 uint8_t needreconfig = 0;
2741 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2744 if (port_is_started(res->port_id) != 0) {
2745 printf("Please stop port %u first\n", res->port_id);
2749 port = &ports[res->port_id];
2751 isrx = !strcmp(res->rxtxq, "rxq");
2753 if (isrx && rx_queue_id_is_invalid(res->qid))
2755 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2758 ison = !strcmp(res->state, "on");
2760 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2761 port->rx_conf[res->qid].rx_deferred_start = ison;
2763 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2764 port->tx_conf[res->qid].tx_deferred_start = ison;
2769 cmd_reconfig_device_queue(res->port_id, 0, 1);
2772 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2773 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2775 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2776 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2778 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2779 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2781 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2782 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2784 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2785 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2786 opname, "deferred_start");
2787 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2788 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2791 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2792 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2794 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2796 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2797 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2798 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2799 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2800 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2801 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2806 /* *** configure port rxq/txq setup *** */
2807 struct cmd_setup_rxtx_queue {
2808 cmdline_fixed_string_t port;
2810 cmdline_fixed_string_t rxtxq;
2812 cmdline_fixed_string_t setup;
2815 /* Common CLI fields for queue setup */
2816 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2817 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2818 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2819 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2820 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2821 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2822 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2823 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2824 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2825 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2828 cmd_setup_rxtx_queue_parsed(
2829 void *parsed_result,
2830 __rte_unused struct cmdline *cl,
2831 __rte_unused void *data)
2833 struct cmd_setup_rxtx_queue *res = parsed_result;
2834 struct rte_port *port;
2835 struct rte_mempool *mp;
2836 unsigned int socket_id;
2840 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2843 if (res->portid == (portid_t)RTE_PORT_ALL) {
2844 printf("Invalid port id\n");
2848 if (!strcmp(res->rxtxq, "rxq"))
2850 else if (!strcmp(res->rxtxq, "txq"))
2853 printf("Unknown parameter\n");
2857 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2858 printf("Invalid rx queue\n");
2860 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2861 printf("Invalid tx queue\n");
2865 port = &ports[res->portid];
2867 socket_id = rxring_numa[res->portid];
2868 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2869 socket_id = port->socket_id;
2871 mp = mbuf_pool_find(socket_id);
2873 printf("Failed to setup RX queue: "
2874 "No mempool allocation"
2875 " on the socket %d\n",
2876 rxring_numa[res->portid]);
2879 ret = rte_eth_rx_queue_setup(res->portid,
2881 port->nb_rx_desc[res->qid],
2883 &port->rx_conf[res->qid],
2886 printf("Failed to setup RX queue\n");
2888 socket_id = txring_numa[res->portid];
2889 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2890 socket_id = port->socket_id;
2892 ret = rte_eth_tx_queue_setup(res->portid,
2894 port->nb_tx_desc[res->qid],
2896 &port->tx_conf[res->qid]);
2898 printf("Failed to setup TX queue\n");
2902 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2903 .f = cmd_setup_rxtx_queue_parsed,
2905 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2907 (void *)&cmd_setup_rxtx_queue_port,
2908 (void *)&cmd_setup_rxtx_queue_portid,
2909 (void *)&cmd_setup_rxtx_queue_rxtxq,
2910 (void *)&cmd_setup_rxtx_queue_qid,
2911 (void *)&cmd_setup_rxtx_queue_setup,
2917 /* *** Configure RSS RETA *** */
2918 struct cmd_config_rss_reta {
2919 cmdline_fixed_string_t port;
2920 cmdline_fixed_string_t keyword;
2922 cmdline_fixed_string_t name;
2923 cmdline_fixed_string_t list_name;
2924 cmdline_fixed_string_t list_of_items;
2928 parse_reta_config(const char *str,
2929 struct rte_eth_rss_reta_entry64 *reta_conf,
2930 uint16_t nb_entries)
2934 uint16_t hash_index, idx, shift;
2937 const char *p, *p0 = str;
2944 unsigned long int_fld[_NUM_FLD];
2945 char *str_fld[_NUM_FLD];
2947 while ((p = strchr(p0,'(')) != NULL) {
2949 if((p0 = strchr(p,')')) == NULL)
2953 if(size >= sizeof(s))
2956 snprintf(s, sizeof(s), "%.*s", size, p);
2957 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2959 for (i = 0; i < _NUM_FLD; i++) {
2961 int_fld[i] = strtoul(str_fld[i], &end, 0);
2962 if (errno != 0 || end == str_fld[i] ||
2967 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2968 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2970 if (hash_index >= nb_entries) {
2971 printf("Invalid RETA hash index=%d\n", hash_index);
2975 idx = hash_index / RTE_RETA_GROUP_SIZE;
2976 shift = hash_index % RTE_RETA_GROUP_SIZE;
2977 reta_conf[idx].mask |= (1ULL << shift);
2978 reta_conf[idx].reta[shift] = nb_queue;
2985 cmd_set_rss_reta_parsed(void *parsed_result,
2986 __rte_unused struct cmdline *cl,
2987 __rte_unused void *data)
2990 struct rte_eth_dev_info dev_info;
2991 struct rte_eth_rss_reta_entry64 reta_conf[8];
2992 struct cmd_config_rss_reta *res = parsed_result;
2994 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2998 if (dev_info.reta_size == 0) {
2999 printf("Redirection table size is 0 which is "
3000 "invalid for RSS\n");
3003 printf("The reta size of port %d is %u\n",
3004 res->port_id, dev_info.reta_size);
3005 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3006 printf("Currently do not support more than %u entries of "
3007 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3011 memset(reta_conf, 0, sizeof(reta_conf));
3012 if (!strcmp(res->list_name, "reta")) {
3013 if (parse_reta_config(res->list_of_items, reta_conf,
3014 dev_info.reta_size)) {
3015 printf("Invalid RSS Redirection Table "
3016 "config entered\n");
3019 ret = rte_eth_dev_rss_reta_update(res->port_id,
3020 reta_conf, dev_info.reta_size);
3022 printf("Bad redirection table parameter, "
3023 "return code = %d \n", ret);
3027 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3028 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3029 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3030 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3031 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3032 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3033 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3034 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3035 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3036 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3037 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3038 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3040 cmdline_parse_inst_t cmd_config_rss_reta = {
3041 .f = cmd_set_rss_reta_parsed,
3043 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3045 (void *)&cmd_config_rss_reta_port,
3046 (void *)&cmd_config_rss_reta_keyword,
3047 (void *)&cmd_config_rss_reta_port_id,
3048 (void *)&cmd_config_rss_reta_name,
3049 (void *)&cmd_config_rss_reta_list_name,
3050 (void *)&cmd_config_rss_reta_list_of_items,
3055 /* *** SHOW PORT RETA INFO *** */
3056 struct cmd_showport_reta {
3057 cmdline_fixed_string_t show;
3058 cmdline_fixed_string_t port;
3060 cmdline_fixed_string_t rss;
3061 cmdline_fixed_string_t reta;
3063 cmdline_fixed_string_t list_of_items;
3067 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3068 uint16_t nb_entries,
3072 const char *p, *p0 = str;
3077 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3078 RTE_RETA_GROUP_SIZE;
3081 p = strchr(p0, '(');
3085 p0 = strchr(p, ')');
3089 if (size >= sizeof(s)) {
3090 printf("The string size exceeds the internal buffer size\n");
3093 snprintf(s, sizeof(s), "%.*s", size, p);
3094 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3095 if (ret <= 0 || ret != num) {
3096 printf("The bits of masks do not match the number of "
3097 "reta entries: %u\n", num);
3100 for (i = 0; i < ret; i++)
3101 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3107 cmd_showport_reta_parsed(void *parsed_result,
3108 __rte_unused struct cmdline *cl,
3109 __rte_unused void *data)
3111 struct cmd_showport_reta *res = parsed_result;
3112 struct rte_eth_rss_reta_entry64 reta_conf[8];
3113 struct rte_eth_dev_info dev_info;
3114 uint16_t max_reta_size;
3117 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3121 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3122 if (res->size == 0 || res->size > max_reta_size) {
3123 printf("Invalid redirection table size: %u (1-%u)\n",
3124 res->size, max_reta_size);
3128 memset(reta_conf, 0, sizeof(reta_conf));
3129 if (showport_parse_reta_config(reta_conf, res->size,
3130 res->list_of_items) < 0) {
3131 printf("Invalid string: %s for reta masks\n",
3132 res->list_of_items);
3135 port_rss_reta_info(res->port_id, reta_conf, res->size);
3138 cmdline_parse_token_string_t cmd_showport_reta_show =
3139 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3140 cmdline_parse_token_string_t cmd_showport_reta_port =
3141 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3142 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3143 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3144 cmdline_parse_token_string_t cmd_showport_reta_rss =
3145 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3146 cmdline_parse_token_string_t cmd_showport_reta_reta =
3147 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3148 cmdline_parse_token_num_t cmd_showport_reta_size =
3149 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3150 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3151 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3152 list_of_items, NULL);
3154 cmdline_parse_inst_t cmd_showport_reta = {
3155 .f = cmd_showport_reta_parsed,
3157 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3159 (void *)&cmd_showport_reta_show,
3160 (void *)&cmd_showport_reta_port,
3161 (void *)&cmd_showport_reta_port_id,
3162 (void *)&cmd_showport_reta_rss,
3163 (void *)&cmd_showport_reta_reta,
3164 (void *)&cmd_showport_reta_size,
3165 (void *)&cmd_showport_reta_list_of_items,
3170 /* *** Show RSS hash configuration *** */
3171 struct cmd_showport_rss_hash {
3172 cmdline_fixed_string_t show;
3173 cmdline_fixed_string_t port;
3175 cmdline_fixed_string_t rss_hash;
3176 cmdline_fixed_string_t rss_type;
3177 cmdline_fixed_string_t key; /* optional argument */
3180 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3181 __rte_unused struct cmdline *cl,
3184 struct cmd_showport_rss_hash *res = parsed_result;
3186 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3189 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3190 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3191 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3192 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3193 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3194 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3195 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3196 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3198 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3199 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3201 cmdline_parse_inst_t cmd_showport_rss_hash = {
3202 .f = cmd_showport_rss_hash_parsed,
3204 .help_str = "show port <port_id> rss-hash",
3206 (void *)&cmd_showport_rss_hash_show,
3207 (void *)&cmd_showport_rss_hash_port,
3208 (void *)&cmd_showport_rss_hash_port_id,
3209 (void *)&cmd_showport_rss_hash_rss_hash,
3214 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3215 .f = cmd_showport_rss_hash_parsed,
3217 .help_str = "show port <port_id> rss-hash key",
3219 (void *)&cmd_showport_rss_hash_show,
3220 (void *)&cmd_showport_rss_hash_port,
3221 (void *)&cmd_showport_rss_hash_port_id,
3222 (void *)&cmd_showport_rss_hash_rss_hash,
3223 (void *)&cmd_showport_rss_hash_rss_key,
3228 /* *** Configure DCB *** */
3229 struct cmd_config_dcb {
3230 cmdline_fixed_string_t port;
3231 cmdline_fixed_string_t config;
3233 cmdline_fixed_string_t dcb;
3234 cmdline_fixed_string_t vt;
3235 cmdline_fixed_string_t vt_en;
3237 cmdline_fixed_string_t pfc;
3238 cmdline_fixed_string_t pfc_en;
3242 cmd_config_dcb_parsed(void *parsed_result,
3243 __rte_unused struct cmdline *cl,
3244 __rte_unused void *data)
3246 struct cmd_config_dcb *res = parsed_result;
3247 portid_t port_id = res->port_id;
3248 struct rte_port *port;
3252 port = &ports[port_id];
3253 /** Check if the port is not started **/
3254 if (port->port_status != RTE_PORT_STOPPED) {
3255 printf("Please stop port %d first\n", port_id);
3259 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3260 printf("The invalid number of traffic class,"
3261 " only 4 or 8 allowed.\n");
3265 if (nb_fwd_lcores < res->num_tcs) {
3266 printf("nb_cores shouldn't be less than number of TCs.\n");
3269 if (!strncmp(res->pfc_en, "on", 2))
3274 /* DCB in VT mode */
3275 if (!strncmp(res->vt_en, "on", 2))
3276 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3277 (enum rte_eth_nb_tcs)res->num_tcs,
3280 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3281 (enum rte_eth_nb_tcs)res->num_tcs,
3286 printf("Cannot initialize network ports.\n");
3290 cmd_reconfig_device_queue(port_id, 1, 1);
3293 cmdline_parse_token_string_t cmd_config_dcb_port =
3294 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3295 cmdline_parse_token_string_t cmd_config_dcb_config =
3296 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3297 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3298 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3299 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3300 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3301 cmdline_parse_token_string_t cmd_config_dcb_vt =
3302 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3303 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3304 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3305 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3306 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3307 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3308 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3309 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3310 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3312 cmdline_parse_inst_t cmd_config_dcb = {
3313 .f = cmd_config_dcb_parsed,
3315 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3317 (void *)&cmd_config_dcb_port,
3318 (void *)&cmd_config_dcb_config,
3319 (void *)&cmd_config_dcb_port_id,
3320 (void *)&cmd_config_dcb_dcb,
3321 (void *)&cmd_config_dcb_vt,
3322 (void *)&cmd_config_dcb_vt_en,
3323 (void *)&cmd_config_dcb_num_tcs,
3324 (void *)&cmd_config_dcb_pfc,
3325 (void *)&cmd_config_dcb_pfc_en,
3330 /* *** configure number of packets per burst *** */
3331 struct cmd_config_burst {
3332 cmdline_fixed_string_t port;
3333 cmdline_fixed_string_t keyword;
3334 cmdline_fixed_string_t all;
3335 cmdline_fixed_string_t name;
3340 cmd_config_burst_parsed(void *parsed_result,
3341 __rte_unused struct cmdline *cl,
3342 __rte_unused void *data)
3344 struct cmd_config_burst *res = parsed_result;
3345 struct rte_eth_dev_info dev_info;
3346 uint16_t rec_nb_pkts;
3349 if (!all_ports_stopped()) {
3350 printf("Please stop all ports first\n");
3354 if (!strcmp(res->name, "burst")) {
3355 if (res->value == 0) {
3356 /* If user gives a value of zero, query the PMD for
3357 * its recommended Rx burst size. Testpmd uses a single
3358 * size for all ports, so assume all ports are the same
3359 * NIC model and use the values from Port 0.
3361 ret = eth_dev_info_get_print_err(0, &dev_info);
3365 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3367 if (rec_nb_pkts == 0) {
3368 printf("PMD does not recommend a burst size.\n"
3369 "User provided value must be between"
3370 " 1 and %d\n", MAX_PKT_BURST);
3372 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3373 printf("PMD recommended burst size of %d"
3374 " exceeds maximum value of %d\n",
3375 rec_nb_pkts, MAX_PKT_BURST);
3378 printf("Using PMD-provided burst value of %d\n",
3380 nb_pkt_per_burst = rec_nb_pkts;
3381 } else if (res->value > MAX_PKT_BURST) {
3382 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3385 nb_pkt_per_burst = res->value;
3387 printf("Unknown parameter\n");
3393 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3396 cmdline_parse_token_string_t cmd_config_burst_port =
3397 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3398 cmdline_parse_token_string_t cmd_config_burst_keyword =
3399 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3400 cmdline_parse_token_string_t cmd_config_burst_all =
3401 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3402 cmdline_parse_token_string_t cmd_config_burst_name =
3403 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3404 cmdline_parse_token_num_t cmd_config_burst_value =
3405 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3407 cmdline_parse_inst_t cmd_config_burst = {
3408 .f = cmd_config_burst_parsed,
3410 .help_str = "port config all burst <value>",
3412 (void *)&cmd_config_burst_port,
3413 (void *)&cmd_config_burst_keyword,
3414 (void *)&cmd_config_burst_all,
3415 (void *)&cmd_config_burst_name,
3416 (void *)&cmd_config_burst_value,
3421 /* *** configure rx/tx queues *** */
3422 struct cmd_config_thresh {
3423 cmdline_fixed_string_t port;
3424 cmdline_fixed_string_t keyword;
3425 cmdline_fixed_string_t all;
3426 cmdline_fixed_string_t name;
3431 cmd_config_thresh_parsed(void *parsed_result,
3432 __rte_unused struct cmdline *cl,
3433 __rte_unused void *data)
3435 struct cmd_config_thresh *res = parsed_result;
3437 if (!all_ports_stopped()) {
3438 printf("Please stop all ports first\n");
3442 if (!strcmp(res->name, "txpt"))
3443 tx_pthresh = res->value;
3444 else if(!strcmp(res->name, "txht"))
3445 tx_hthresh = res->value;
3446 else if(!strcmp(res->name, "txwt"))
3447 tx_wthresh = res->value;
3448 else if(!strcmp(res->name, "rxpt"))
3449 rx_pthresh = res->value;
3450 else if(!strcmp(res->name, "rxht"))
3451 rx_hthresh = res->value;
3452 else if(!strcmp(res->name, "rxwt"))
3453 rx_wthresh = res->value;
3455 printf("Unknown parameter\n");
3461 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3464 cmdline_parse_token_string_t cmd_config_thresh_port =
3465 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3466 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3467 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3468 cmdline_parse_token_string_t cmd_config_thresh_all =
3469 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3470 cmdline_parse_token_string_t cmd_config_thresh_name =
3471 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3472 "txpt#txht#txwt#rxpt#rxht#rxwt");
3473 cmdline_parse_token_num_t cmd_config_thresh_value =
3474 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3476 cmdline_parse_inst_t cmd_config_thresh = {
3477 .f = cmd_config_thresh_parsed,
3479 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3481 (void *)&cmd_config_thresh_port,
3482 (void *)&cmd_config_thresh_keyword,
3483 (void *)&cmd_config_thresh_all,
3484 (void *)&cmd_config_thresh_name,
3485 (void *)&cmd_config_thresh_value,
3490 /* *** configure free/rs threshold *** */
3491 struct cmd_config_threshold {
3492 cmdline_fixed_string_t port;
3493 cmdline_fixed_string_t keyword;
3494 cmdline_fixed_string_t all;
3495 cmdline_fixed_string_t name;
3500 cmd_config_threshold_parsed(void *parsed_result,
3501 __rte_unused struct cmdline *cl,
3502 __rte_unused void *data)
3504 struct cmd_config_threshold *res = parsed_result;
3506 if (!all_ports_stopped()) {
3507 printf("Please stop all ports first\n");
3511 if (!strcmp(res->name, "txfreet"))
3512 tx_free_thresh = res->value;
3513 else if (!strcmp(res->name, "txrst"))
3514 tx_rs_thresh = res->value;
3515 else if (!strcmp(res->name, "rxfreet"))
3516 rx_free_thresh = res->value;
3518 printf("Unknown parameter\n");
3524 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3527 cmdline_parse_token_string_t cmd_config_threshold_port =
3528 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3529 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3530 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3532 cmdline_parse_token_string_t cmd_config_threshold_all =
3533 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3534 cmdline_parse_token_string_t cmd_config_threshold_name =
3535 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3536 "txfreet#txrst#rxfreet");
3537 cmdline_parse_token_num_t cmd_config_threshold_value =
3538 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3540 cmdline_parse_inst_t cmd_config_threshold = {
3541 .f = cmd_config_threshold_parsed,
3543 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3545 (void *)&cmd_config_threshold_port,
3546 (void *)&cmd_config_threshold_keyword,
3547 (void *)&cmd_config_threshold_all,
3548 (void *)&cmd_config_threshold_name,
3549 (void *)&cmd_config_threshold_value,
3555 struct cmd_stop_result {
3556 cmdline_fixed_string_t stop;
3559 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3560 __rte_unused struct cmdline *cl,
3561 __rte_unused void *data)
3563 stop_packet_forwarding();
3566 cmdline_parse_token_string_t cmd_stop_stop =
3567 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3569 cmdline_parse_inst_t cmd_stop = {
3570 .f = cmd_stop_parsed,
3572 .help_str = "stop: Stop packet forwarding",
3574 (void *)&cmd_stop_stop,
3579 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3582 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3583 unsigned int *parsed_items, int check_unique_values)
3585 unsigned int nb_item;
3593 * First parse all items in the list and store their value.
3598 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3600 if ((c >= '0') && (c <= '9')) {
3601 value = (unsigned int) (value * 10 + (c - '0'));
3606 printf("character %c is not a decimal digit\n", c);
3610 printf("No valid value before comma\n");
3613 if (nb_item < max_items) {
3614 parsed_items[nb_item] = value;
3620 if (nb_item >= max_items) {
3621 printf("Number of %s = %u > %u (maximum items)\n",
3622 item_name, nb_item + 1, max_items);
3625 parsed_items[nb_item++] = value;
3626 if (! check_unique_values)
3630 * Then, check that all values in the list are differents.
3631 * No optimization here...
3633 for (i = 0; i < nb_item; i++) {
3634 for (j = i + 1; j < nb_item; j++) {
3635 if (parsed_items[j] == parsed_items[i]) {
3636 printf("duplicated %s %u at index %u and %u\n",
3637 item_name, parsed_items[i], i, j);
3645 struct cmd_set_list_result {
3646 cmdline_fixed_string_t cmd_keyword;
3647 cmdline_fixed_string_t list_name;
3648 cmdline_fixed_string_t list_of_items;
3651 static void cmd_set_list_parsed(void *parsed_result,
3652 __rte_unused struct cmdline *cl,
3653 __rte_unused void *data)
3655 struct cmd_set_list_result *res;
3657 unsigned int lcorelist[RTE_MAX_LCORE];
3658 unsigned int portlist[RTE_MAX_ETHPORTS];
3660 unsigned int nb_item;
3662 if (test_done == 0) {
3663 printf("Please stop forwarding first\n");
3667 res = parsed_result;
3668 if (!strcmp(res->list_name, "corelist")) {
3669 nb_item = parse_item_list(res->list_of_items, "core",
3671 parsed_items.lcorelist, 1);
3673 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3678 if (!strcmp(res->list_name, "portlist")) {
3679 nb_item = parse_item_list(res->list_of_items, "port",
3681 parsed_items.portlist, 1);
3683 set_fwd_ports_list(parsed_items.portlist, nb_item);
3689 cmdline_parse_token_string_t cmd_set_list_keyword =
3690 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3692 cmdline_parse_token_string_t cmd_set_list_name =
3693 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3694 "corelist#portlist");
3695 cmdline_parse_token_string_t cmd_set_list_of_items =
3696 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3699 cmdline_parse_inst_t cmd_set_fwd_list = {
3700 .f = cmd_set_list_parsed,
3702 .help_str = "set corelist|portlist <list0[,list1]*>",
3704 (void *)&cmd_set_list_keyword,
3705 (void *)&cmd_set_list_name,
3706 (void *)&cmd_set_list_of_items,
3711 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3713 struct cmd_setmask_result {
3714 cmdline_fixed_string_t set;
3715 cmdline_fixed_string_t mask;
3719 static void cmd_set_mask_parsed(void *parsed_result,
3720 __rte_unused struct cmdline *cl,
3721 __rte_unused void *data)
3723 struct cmd_setmask_result *res = parsed_result;
3725 if (test_done == 0) {
3726 printf("Please stop forwarding first\n");
3729 if (!strcmp(res->mask, "coremask")) {
3730 set_fwd_lcores_mask(res->hexavalue);
3732 } else if (!strcmp(res->mask, "portmask")) {
3733 set_fwd_ports_mask(res->hexavalue);
3738 cmdline_parse_token_string_t cmd_setmask_set =
3739 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3740 cmdline_parse_token_string_t cmd_setmask_mask =
3741 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3742 "coremask#portmask");
3743 cmdline_parse_token_num_t cmd_setmask_value =
3744 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3746 cmdline_parse_inst_t cmd_set_fwd_mask = {
3747 .f = cmd_set_mask_parsed,
3749 .help_str = "set coremask|portmask <hexadecimal value>",
3751 (void *)&cmd_setmask_set,
3752 (void *)&cmd_setmask_mask,
3753 (void *)&cmd_setmask_value,
3759 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3761 struct cmd_set_result {
3762 cmdline_fixed_string_t set;
3763 cmdline_fixed_string_t what;
3767 static void cmd_set_parsed(void *parsed_result,
3768 __rte_unused struct cmdline *cl,
3769 __rte_unused void *data)
3771 struct cmd_set_result *res = parsed_result;
3772 if (!strcmp(res->what, "nbport")) {
3773 set_fwd_ports_number(res->value);
3775 } else if (!strcmp(res->what, "nbcore")) {
3776 set_fwd_lcores_number(res->value);
3778 } else if (!strcmp(res->what, "burst"))
3779 set_nb_pkt_per_burst(res->value);
3780 else if (!strcmp(res->what, "verbose"))
3781 set_verbose_level(res->value);
3784 cmdline_parse_token_string_t cmd_set_set =
3785 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3786 cmdline_parse_token_string_t cmd_set_what =
3787 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3788 "nbport#nbcore#burst#verbose");
3789 cmdline_parse_token_num_t cmd_set_value =
3790 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3792 cmdline_parse_inst_t cmd_set_numbers = {
3793 .f = cmd_set_parsed,
3795 .help_str = "set nbport|nbcore|burst|verbose <value>",
3797 (void *)&cmd_set_set,
3798 (void *)&cmd_set_what,
3799 (void *)&cmd_set_value,
3804 /* *** SET LOG LEVEL CONFIGURATION *** */
3806 struct cmd_set_log_result {
3807 cmdline_fixed_string_t set;
3808 cmdline_fixed_string_t log;
3809 cmdline_fixed_string_t type;
3814 cmd_set_log_parsed(void *parsed_result,
3815 __rte_unused struct cmdline *cl,
3816 __rte_unused void *data)
3818 struct cmd_set_log_result *res;
3821 res = parsed_result;
3822 if (!strcmp(res->type, "global"))
3823 rte_log_set_global_level(res->level);
3825 ret = rte_log_set_level_regexp(res->type, res->level);
3827 printf("Unable to set log level\n");
3831 cmdline_parse_token_string_t cmd_set_log_set =
3832 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3833 cmdline_parse_token_string_t cmd_set_log_log =
3834 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3835 cmdline_parse_token_string_t cmd_set_log_type =
3836 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3837 cmdline_parse_token_num_t cmd_set_log_level =
3838 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3840 cmdline_parse_inst_t cmd_set_log = {
3841 .f = cmd_set_log_parsed,
3843 .help_str = "set log global|<type> <level>",
3845 (void *)&cmd_set_log_set,
3846 (void *)&cmd_set_log_log,
3847 (void *)&cmd_set_log_type,
3848 (void *)&cmd_set_log_level,
3853 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3855 struct cmd_set_txpkts_result {
3856 cmdline_fixed_string_t cmd_keyword;
3857 cmdline_fixed_string_t txpkts;
3858 cmdline_fixed_string_t seg_lengths;
3862 cmd_set_txpkts_parsed(void *parsed_result,
3863 __rte_unused struct cmdline *cl,
3864 __rte_unused void *data)
3866 struct cmd_set_txpkts_result *res;
3867 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3868 unsigned int nb_segs;
3870 res = parsed_result;
3871 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3872 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3874 set_tx_pkt_segments(seg_lengths, nb_segs);
3877 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3878 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3879 cmd_keyword, "set");
3880 cmdline_parse_token_string_t cmd_set_txpkts_name =
3881 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3883 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3884 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3887 cmdline_parse_inst_t cmd_set_txpkts = {
3888 .f = cmd_set_txpkts_parsed,
3890 .help_str = "set txpkts <len0[,len1]*>",
3892 (void *)&cmd_set_txpkts_keyword,
3893 (void *)&cmd_set_txpkts_name,
3894 (void *)&cmd_set_txpkts_lengths,
3899 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3901 struct cmd_set_txsplit_result {
3902 cmdline_fixed_string_t cmd_keyword;
3903 cmdline_fixed_string_t txsplit;
3904 cmdline_fixed_string_t mode;
3908 cmd_set_txsplit_parsed(void *parsed_result,
3909 __rte_unused struct cmdline *cl,
3910 __rte_unused void *data)
3912 struct cmd_set_txsplit_result *res;
3914 res = parsed_result;
3915 set_tx_pkt_split(res->mode);
3918 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3919 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3920 cmd_keyword, "set");
3921 cmdline_parse_token_string_t cmd_set_txsplit_name =
3922 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3923 txsplit, "txsplit");
3924 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3925 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3928 cmdline_parse_inst_t cmd_set_txsplit = {
3929 .f = cmd_set_txsplit_parsed,
3931 .help_str = "set txsplit on|off|rand",
3933 (void *)&cmd_set_txsplit_keyword,
3934 (void *)&cmd_set_txsplit_name,
3935 (void *)&cmd_set_txsplit_mode,
3940 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3941 struct cmd_rx_vlan_filter_all_result {
3942 cmdline_fixed_string_t rx_vlan;
3943 cmdline_fixed_string_t what;
3944 cmdline_fixed_string_t all;
3949 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3950 __rte_unused struct cmdline *cl,
3951 __rte_unused void *data)
3953 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3955 if (!strcmp(res->what, "add"))
3956 rx_vlan_all_filter_set(res->port_id, 1);
3958 rx_vlan_all_filter_set(res->port_id, 0);
3961 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3962 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3963 rx_vlan, "rx_vlan");
3964 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3965 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3967 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3968 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3970 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3971 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3974 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3975 .f = cmd_rx_vlan_filter_all_parsed,
3977 .help_str = "rx_vlan add|rm all <port_id>: "
3978 "Add/Remove all identifiers to/from the set of VLAN "
3979 "identifiers filtered by a port",
3981 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3982 (void *)&cmd_rx_vlan_filter_all_what,
3983 (void *)&cmd_rx_vlan_filter_all_all,
3984 (void *)&cmd_rx_vlan_filter_all_portid,
3989 /* *** VLAN OFFLOAD SET ON A PORT *** */
3990 struct cmd_vlan_offload_result {
3991 cmdline_fixed_string_t vlan;
3992 cmdline_fixed_string_t set;
3993 cmdline_fixed_string_t vlan_type;
3994 cmdline_fixed_string_t what;
3995 cmdline_fixed_string_t on;
3996 cmdline_fixed_string_t port_id;
4000 cmd_vlan_offload_parsed(void *parsed_result,
4001 __rte_unused struct cmdline *cl,
4002 __rte_unused void *data)
4005 struct cmd_vlan_offload_result *res = parsed_result;
4008 portid_t port_id = 0;
4012 len = strnlen(str, STR_TOKEN_SIZE);
4014 /* Get port_id first */
4022 tmp = strtoul(str, NULL, 0);
4023 /* If port_id greater that what portid_t can represent, return */
4024 if(tmp >= RTE_MAX_ETHPORTS)
4026 port_id = (portid_t)tmp;
4028 if (!strcmp(res->on, "on"))
4033 if (!strcmp(res->what, "strip"))
4034 rx_vlan_strip_set(port_id, on);
4035 else if(!strcmp(res->what, "stripq")){
4036 uint16_t queue_id = 0;
4038 /* No queue_id, return */
4040 printf("must specify (port,queue_id)\n");
4043 tmp = strtoul(str + i + 1, NULL, 0);
4044 /* If queue_id greater that what 16-bits can represent, return */
4048 queue_id = (uint16_t)tmp;
4049 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4051 else if (!strcmp(res->what, "filter"))
4052 rx_vlan_filter_set(port_id, on);
4053 else if (!strcmp(res->what, "qinq_strip"))
4054 rx_vlan_qinq_strip_set(port_id, on);
4056 vlan_extend_set(port_id, on);
4061 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4062 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4064 cmdline_parse_token_string_t cmd_vlan_offload_set =
4065 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4067 cmdline_parse_token_string_t cmd_vlan_offload_what =
4068 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4069 what, "strip#filter#qinq_strip#extend#stripq");
4070 cmdline_parse_token_string_t cmd_vlan_offload_on =
4071 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4073 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4074 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4077 cmdline_parse_inst_t cmd_vlan_offload = {
4078 .f = cmd_vlan_offload_parsed,
4080 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4081 "<port_id[,queue_id]>: "
4082 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4084 (void *)&cmd_vlan_offload_vlan,
4085 (void *)&cmd_vlan_offload_set,
4086 (void *)&cmd_vlan_offload_what,
4087 (void *)&cmd_vlan_offload_on,
4088 (void *)&cmd_vlan_offload_portid,
4093 /* *** VLAN TPID SET ON A PORT *** */
4094 struct cmd_vlan_tpid_result {
4095 cmdline_fixed_string_t vlan;
4096 cmdline_fixed_string_t set;
4097 cmdline_fixed_string_t vlan_type;
4098 cmdline_fixed_string_t what;
4104 cmd_vlan_tpid_parsed(void *parsed_result,
4105 __rte_unused struct cmdline *cl,
4106 __rte_unused void *data)
4108 struct cmd_vlan_tpid_result *res = parsed_result;
4109 enum rte_vlan_type vlan_type;
4111 if (!strcmp(res->vlan_type, "inner"))
4112 vlan_type = ETH_VLAN_TYPE_INNER;
4113 else if (!strcmp(res->vlan_type, "outer"))
4114 vlan_type = ETH_VLAN_TYPE_OUTER;
4116 printf("Unknown vlan type\n");
4119 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4122 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4123 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4125 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4126 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4128 cmdline_parse_token_string_t cmd_vlan_type =
4129 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4130 vlan_type, "inner#outer");
4131 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4132 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4134 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4135 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4137 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4138 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4141 cmdline_parse_inst_t cmd_vlan_tpid = {
4142 .f = cmd_vlan_tpid_parsed,
4144 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4145 "Set the VLAN Ether type",
4147 (void *)&cmd_vlan_tpid_vlan,
4148 (void *)&cmd_vlan_tpid_set,
4149 (void *)&cmd_vlan_type,
4150 (void *)&cmd_vlan_tpid_what,
4151 (void *)&cmd_vlan_tpid_tpid,
4152 (void *)&cmd_vlan_tpid_portid,
4157 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4158 struct cmd_rx_vlan_filter_result {
4159 cmdline_fixed_string_t rx_vlan;
4160 cmdline_fixed_string_t what;
4166 cmd_rx_vlan_filter_parsed(void *parsed_result,
4167 __rte_unused struct cmdline *cl,
4168 __rte_unused void *data)
4170 struct cmd_rx_vlan_filter_result *res = parsed_result;
4172 if (!strcmp(res->what, "add"))
4173 rx_vft_set(res->port_id, res->vlan_id, 1);
4175 rx_vft_set(res->port_id, res->vlan_id, 0);
4178 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4179 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4180 rx_vlan, "rx_vlan");
4181 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4182 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4184 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4185 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4187 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4188 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4191 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4192 .f = cmd_rx_vlan_filter_parsed,
4194 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4195 "Add/Remove a VLAN identifier to/from the set of VLAN "
4196 "identifiers filtered by a port",
4198 (void *)&cmd_rx_vlan_filter_rx_vlan,
4199 (void *)&cmd_rx_vlan_filter_what,
4200 (void *)&cmd_rx_vlan_filter_vlanid,
4201 (void *)&cmd_rx_vlan_filter_portid,
4206 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4207 struct cmd_tx_vlan_set_result {
4208 cmdline_fixed_string_t tx_vlan;
4209 cmdline_fixed_string_t set;
4215 cmd_tx_vlan_set_parsed(void *parsed_result,
4216 __rte_unused struct cmdline *cl,
4217 __rte_unused void *data)
4219 struct cmd_tx_vlan_set_result *res = parsed_result;
4221 if (!port_is_stopped(res->port_id)) {
4222 printf("Please stop port %d first\n", res->port_id);
4226 tx_vlan_set(res->port_id, res->vlan_id);
4228 cmd_reconfig_device_queue(res->port_id, 1, 1);
4231 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4232 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4233 tx_vlan, "tx_vlan");
4234 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4235 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4237 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4238 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4240 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4241 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4244 cmdline_parse_inst_t cmd_tx_vlan_set = {
4245 .f = cmd_tx_vlan_set_parsed,
4247 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4248 "Enable hardware insertion of a single VLAN header "
4249 "with a given TAG Identifier in packets sent on a port",
4251 (void *)&cmd_tx_vlan_set_tx_vlan,
4252 (void *)&cmd_tx_vlan_set_set,
4253 (void *)&cmd_tx_vlan_set_portid,
4254 (void *)&cmd_tx_vlan_set_vlanid,
4259 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4260 struct cmd_tx_vlan_set_qinq_result {
4261 cmdline_fixed_string_t tx_vlan;
4262 cmdline_fixed_string_t set;
4265 uint16_t vlan_id_outer;
4269 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4270 __rte_unused struct cmdline *cl,
4271 __rte_unused void *data)
4273 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4275 if (!port_is_stopped(res->port_id)) {
4276 printf("Please stop port %d first\n", res->port_id);
4280 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4282 cmd_reconfig_device_queue(res->port_id, 1, 1);
4285 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4286 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4287 tx_vlan, "tx_vlan");
4288 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4289 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4291 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4292 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4294 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4295 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4297 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4298 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4299 vlan_id_outer, UINT16);
4301 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4302 .f = cmd_tx_vlan_set_qinq_parsed,
4304 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4305 "Enable hardware insertion of double VLAN header "
4306 "with given TAG Identifiers in packets sent on a port",
4308 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4309 (void *)&cmd_tx_vlan_set_qinq_set,
4310 (void *)&cmd_tx_vlan_set_qinq_portid,
4311 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4312 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4317 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4318 struct cmd_tx_vlan_set_pvid_result {
4319 cmdline_fixed_string_t tx_vlan;
4320 cmdline_fixed_string_t set;
4321 cmdline_fixed_string_t pvid;
4324 cmdline_fixed_string_t mode;
4328 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4329 __rte_unused struct cmdline *cl,
4330 __rte_unused void *data)
4332 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4334 if (strcmp(res->mode, "on") == 0)
4335 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4337 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4340 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4341 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4342 tx_vlan, "tx_vlan");
4343 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4344 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4346 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4347 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4349 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4350 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4352 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4353 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4355 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4356 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4359 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4360 .f = cmd_tx_vlan_set_pvid_parsed,
4362 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4364 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4365 (void *)&cmd_tx_vlan_set_pvid_set,
4366 (void *)&cmd_tx_vlan_set_pvid_pvid,
4367 (void *)&cmd_tx_vlan_set_pvid_port_id,
4368 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4369 (void *)&cmd_tx_vlan_set_pvid_mode,
4374 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4375 struct cmd_tx_vlan_reset_result {
4376 cmdline_fixed_string_t tx_vlan;
4377 cmdline_fixed_string_t reset;
4382 cmd_tx_vlan_reset_parsed(void *parsed_result,
4383 __rte_unused struct cmdline *cl,
4384 __rte_unused void *data)
4386 struct cmd_tx_vlan_reset_result *res = parsed_result;
4388 if (!port_is_stopped(res->port_id)) {
4389 printf("Please stop port %d first\n", res->port_id);
4393 tx_vlan_reset(res->port_id);
4395 cmd_reconfig_device_queue(res->port_id, 1, 1);
4398 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4399 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4400 tx_vlan, "tx_vlan");
4401 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4402 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4404 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4405 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4408 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4409 .f = cmd_tx_vlan_reset_parsed,
4411 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4412 "VLAN header in packets sent on a port",
4414 (void *)&cmd_tx_vlan_reset_tx_vlan,
4415 (void *)&cmd_tx_vlan_reset_reset,
4416 (void *)&cmd_tx_vlan_reset_portid,
4422 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4423 struct cmd_csum_result {
4424 cmdline_fixed_string_t csum;
4425 cmdline_fixed_string_t mode;
4426 cmdline_fixed_string_t proto;
4427 cmdline_fixed_string_t hwsw;
4432 csum_show(int port_id)
4434 struct rte_eth_dev_info dev_info;
4435 uint64_t tx_offloads;
4438 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4439 printf("Parse tunnel is %s\n",
4440 (ports[port_id].parse_tunnel) ? "on" : "off");
4441 printf("IP checksum offload is %s\n",
4442 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4443 printf("UDP checksum offload is %s\n",
4444 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4445 printf("TCP checksum offload is %s\n",
4446 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4447 printf("SCTP checksum offload is %s\n",
4448 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4449 printf("Outer-Ip checksum offload is %s\n",
4450 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4451 printf("Outer-Udp checksum offload is %s\n",
4452 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4454 /* display warnings if configuration is not supported by the NIC */
4455 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4459 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4460 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4461 printf("Warning: hardware IP checksum enabled but not "
4462 "supported by port %d\n", port_id);
4464 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4465 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4466 printf("Warning: hardware UDP checksum enabled but not "
4467 "supported by port %d\n", port_id);
4469 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4470 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4471 printf("Warning: hardware TCP checksum enabled but not "
4472 "supported by port %d\n", port_id);
4474 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4475 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4476 printf("Warning: hardware SCTP checksum enabled but not "
4477 "supported by port %d\n", port_id);
4479 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4480 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4481 printf("Warning: hardware outer IP checksum enabled but not "
4482 "supported by port %d\n", port_id);
4484 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4485 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4487 printf("Warning: hardware outer UDP checksum enabled but not "
4488 "supported by port %d\n", port_id);
4493 cmd_config_queue_tx_offloads(struct rte_port *port)
4497 /* Apply queue tx offloads configuration */
4498 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4499 port->tx_conf[k].offloads =
4500 port->dev_conf.txmode.offloads;
4504 cmd_csum_parsed(void *parsed_result,
4505 __rte_unused struct cmdline *cl,
4506 __rte_unused void *data)
4508 struct cmd_csum_result *res = parsed_result;
4510 uint64_t csum_offloads = 0;
4511 struct rte_eth_dev_info dev_info;
4514 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4515 printf("invalid port %d\n", res->port_id);
4518 if (!port_is_stopped(res->port_id)) {
4519 printf("Please stop port %d first\n", res->port_id);
4523 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4527 if (!strcmp(res->mode, "set")) {
4529 if (!strcmp(res->hwsw, "hw"))
4532 if (!strcmp(res->proto, "ip")) {
4533 if (hw == 0 || (dev_info.tx_offload_capa &
4534 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4535 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4537 printf("IP checksum offload is not supported "
4538 "by port %u\n", res->port_id);
4540 } else if (!strcmp(res->proto, "udp")) {
4541 if (hw == 0 || (dev_info.tx_offload_capa &
4542 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4543 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4545 printf("UDP checksum offload is not supported "
4546 "by port %u\n", res->port_id);
4548 } else if (!strcmp(res->proto, "tcp")) {
4549 if (hw == 0 || (dev_info.tx_offload_capa &
4550 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4551 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4553 printf("TCP checksum offload is not supported "
4554 "by port %u\n", res->port_id);
4556 } else if (!strcmp(res->proto, "sctp")) {
4557 if (hw == 0 || (dev_info.tx_offload_capa &
4558 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4559 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4561 printf("SCTP checksum offload is not supported "
4562 "by port %u\n", res->port_id);
4564 } else if (!strcmp(res->proto, "outer-ip")) {
4565 if (hw == 0 || (dev_info.tx_offload_capa &
4566 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4568 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4570 printf("Outer IP checksum offload is not "
4571 "supported by port %u\n", res->port_id);
4573 } else if (!strcmp(res->proto, "outer-udp")) {
4574 if (hw == 0 || (dev_info.tx_offload_capa &
4575 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4577 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4579 printf("Outer UDP checksum offload is not "
4580 "supported by port %u\n", res->port_id);
4585 ports[res->port_id].dev_conf.txmode.offloads |=
4588 ports[res->port_id].dev_conf.txmode.offloads &=
4591 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4593 csum_show(res->port_id);
4595 cmd_reconfig_device_queue(res->port_id, 1, 1);
4598 cmdline_parse_token_string_t cmd_csum_csum =
4599 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4601 cmdline_parse_token_string_t cmd_csum_mode =
4602 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4604 cmdline_parse_token_string_t cmd_csum_proto =
4605 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4606 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4607 cmdline_parse_token_string_t cmd_csum_hwsw =
4608 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4610 cmdline_parse_token_num_t cmd_csum_portid =
4611 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4614 cmdline_parse_inst_t cmd_csum_set = {
4615 .f = cmd_csum_parsed,
4617 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4618 "Enable/Disable hardware calculation of L3/L4 checksum when "
4619 "using csum forward engine",
4621 (void *)&cmd_csum_csum,
4622 (void *)&cmd_csum_mode,
4623 (void *)&cmd_csum_proto,
4624 (void *)&cmd_csum_hwsw,
4625 (void *)&cmd_csum_portid,
4630 cmdline_parse_token_string_t cmd_csum_mode_show =
4631 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4634 cmdline_parse_inst_t cmd_csum_show = {
4635 .f = cmd_csum_parsed,
4637 .help_str = "csum show <port_id>: Show checksum offload configuration",
4639 (void *)&cmd_csum_csum,
4640 (void *)&cmd_csum_mode_show,
4641 (void *)&cmd_csum_portid,
4646 /* Enable/disable tunnel parsing */
4647 struct cmd_csum_tunnel_result {
4648 cmdline_fixed_string_t csum;
4649 cmdline_fixed_string_t parse;
4650 cmdline_fixed_string_t onoff;
4655 cmd_csum_tunnel_parsed(void *parsed_result,
4656 __rte_unused struct cmdline *cl,
4657 __rte_unused void *data)
4659 struct cmd_csum_tunnel_result *res = parsed_result;
4661 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4664 if (!strcmp(res->onoff, "on"))
4665 ports[res->port_id].parse_tunnel = 1;
4667 ports[res->port_id].parse_tunnel = 0;
4669 csum_show(res->port_id);
4672 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4673 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4675 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4676 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4677 parse, "parse-tunnel");
4678 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4679 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4681 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4682 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4685 cmdline_parse_inst_t cmd_csum_tunnel = {
4686 .f = cmd_csum_tunnel_parsed,
4688 .help_str = "csum parse-tunnel on|off <port_id>: "
4689 "Enable/Disable parsing of tunnels for csum engine",
4691 (void *)&cmd_csum_tunnel_csum,
4692 (void *)&cmd_csum_tunnel_parse,
4693 (void *)&cmd_csum_tunnel_onoff,
4694 (void *)&cmd_csum_tunnel_portid,
4699 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4700 struct cmd_tso_set_result {
4701 cmdline_fixed_string_t tso;
4702 cmdline_fixed_string_t mode;
4708 cmd_tso_set_parsed(void *parsed_result,
4709 __rte_unused struct cmdline *cl,
4710 __rte_unused void *data)
4712 struct cmd_tso_set_result *res = parsed_result;
4713 struct rte_eth_dev_info dev_info;
4716 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4718 if (!port_is_stopped(res->port_id)) {
4719 printf("Please stop port %d first\n", res->port_id);
4723 if (!strcmp(res->mode, "set"))
4724 ports[res->port_id].tso_segsz = res->tso_segsz;
4726 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4730 if ((ports[res->port_id].tso_segsz != 0) &&
4731 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4732 printf("Error: TSO is not supported by port %d\n",
4737 if (ports[res->port_id].tso_segsz == 0) {
4738 ports[res->port_id].dev_conf.txmode.offloads &=
4739 ~DEV_TX_OFFLOAD_TCP_TSO;
4740 printf("TSO for non-tunneled packets is disabled\n");
4742 ports[res->port_id].dev_conf.txmode.offloads |=
4743 DEV_TX_OFFLOAD_TCP_TSO;
4744 printf("TSO segment size for non-tunneled packets is %d\n",
4745 ports[res->port_id].tso_segsz);
4747 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4749 /* display warnings if configuration is not supported by the NIC */
4750 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4754 if ((ports[res->port_id].tso_segsz != 0) &&
4755 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4756 printf("Warning: TSO enabled but not "
4757 "supported by port %d\n", res->port_id);
4760 cmd_reconfig_device_queue(res->port_id, 1, 1);
4763 cmdline_parse_token_string_t cmd_tso_set_tso =
4764 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4766 cmdline_parse_token_string_t cmd_tso_set_mode =
4767 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4769 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4770 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4772 cmdline_parse_token_num_t cmd_tso_set_portid =
4773 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4776 cmdline_parse_inst_t cmd_tso_set = {
4777 .f = cmd_tso_set_parsed,
4779 .help_str = "tso set <tso_segsz> <port_id>: "
4780 "Set TSO segment size of non-tunneled packets for csum engine "
4783 (void *)&cmd_tso_set_tso,
4784 (void *)&cmd_tso_set_mode,
4785 (void *)&cmd_tso_set_tso_segsz,
4786 (void *)&cmd_tso_set_portid,
4791 cmdline_parse_token_string_t cmd_tso_show_mode =
4792 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4796 cmdline_parse_inst_t cmd_tso_show = {
4797 .f = cmd_tso_set_parsed,
4799 .help_str = "tso show <port_id>: "
4800 "Show TSO segment size of non-tunneled packets for csum engine",
4802 (void *)&cmd_tso_set_tso,
4803 (void *)&cmd_tso_show_mode,
4804 (void *)&cmd_tso_set_portid,
4809 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4810 struct cmd_tunnel_tso_set_result {
4811 cmdline_fixed_string_t tso;
4812 cmdline_fixed_string_t mode;
4817 static struct rte_eth_dev_info
4818 check_tunnel_tso_nic_support(portid_t port_id)
4820 struct rte_eth_dev_info dev_info;
4822 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4825 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4826 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4827 "not enabled for port %d\n", port_id);
4828 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4829 printf("Warning: GRE TUNNEL TSO not supported therefore "
4830 "not enabled for port %d\n", port_id);
4831 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4832 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4833 "not enabled for port %d\n", port_id);
4834 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4835 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4836 "not enabled for port %d\n", port_id);
4837 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4838 printf("Warning: IP TUNNEL TSO not supported therefore "
4839 "not enabled for port %d\n", port_id);
4840 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4841 printf("Warning: UDP TUNNEL TSO not supported therefore "
4842 "not enabled for port %d\n", port_id);
4847 cmd_tunnel_tso_set_parsed(void *parsed_result,
4848 __rte_unused struct cmdline *cl,
4849 __rte_unused void *data)
4851 struct cmd_tunnel_tso_set_result *res = parsed_result;
4852 struct rte_eth_dev_info dev_info;
4854 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4856 if (!port_is_stopped(res->port_id)) {
4857 printf("Please stop port %d first\n", res->port_id);
4861 if (!strcmp(res->mode, "set"))
4862 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4864 dev_info = check_tunnel_tso_nic_support(res->port_id);
4865 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4866 ports[res->port_id].dev_conf.txmode.offloads &=
4867 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4868 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4869 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4870 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4871 DEV_TX_OFFLOAD_IP_TNL_TSO |
4872 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4873 printf("TSO for tunneled packets is disabled\n");
4875 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4876 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4877 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4878 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4879 DEV_TX_OFFLOAD_IP_TNL_TSO |
4880 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4882 ports[res->port_id].dev_conf.txmode.offloads |=
4883 (tso_offloads & dev_info.tx_offload_capa);
4884 printf("TSO segment size for tunneled packets is %d\n",
4885 ports[res->port_id].tunnel_tso_segsz);
4887 /* Below conditions are needed to make it work:
4888 * (1) tunnel TSO is supported by the NIC;
4889 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4891 * (3) for tunneled pkts with outer L3 of IPv4,
4892 * "csum set outer-ip" must be set to hw, because after tso,
4893 * total_len of outer IP header is changed, and the checksum
4894 * of outer IP header calculated by sw should be wrong; that
4895 * is not necessary for IPv6 tunneled pkts because there's no
4896 * checksum in IP header anymore.
4899 if (!ports[res->port_id].parse_tunnel)
4900 printf("Warning: csum parse_tunnel must be set "
4901 "so that tunneled packets are recognized\n");
4902 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4903 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4904 printf("Warning: csum set outer-ip must be set to hw "
4905 "if outer L3 is IPv4; not necessary for IPv6\n");
4908 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4909 cmd_reconfig_device_queue(res->port_id, 1, 1);
4912 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4913 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4915 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4916 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4918 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4919 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4921 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4922 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4925 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4926 .f = cmd_tunnel_tso_set_parsed,
4928 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4929 "Set TSO segment size of tunneled packets for csum engine "
4932 (void *)&cmd_tunnel_tso_set_tso,
4933 (void *)&cmd_tunnel_tso_set_mode,
4934 (void *)&cmd_tunnel_tso_set_tso_segsz,
4935 (void *)&cmd_tunnel_tso_set_portid,
4940 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4941 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4945 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4946 .f = cmd_tunnel_tso_set_parsed,
4948 .help_str = "tunnel_tso show <port_id> "
4949 "Show TSO segment size of tunneled packets for csum engine",
4951 (void *)&cmd_tunnel_tso_set_tso,
4952 (void *)&cmd_tunnel_tso_show_mode,
4953 (void *)&cmd_tunnel_tso_set_portid,
4958 /* *** SET GRO FOR A PORT *** */
4959 struct cmd_gro_enable_result {
4960 cmdline_fixed_string_t cmd_set;
4961 cmdline_fixed_string_t cmd_port;
4962 cmdline_fixed_string_t cmd_keyword;
4963 cmdline_fixed_string_t cmd_onoff;
4968 cmd_gro_enable_parsed(void *parsed_result,
4969 __rte_unused struct cmdline *cl,
4970 __rte_unused void *data)
4972 struct cmd_gro_enable_result *res;
4974 res = parsed_result;
4975 if (!strcmp(res->cmd_keyword, "gro"))
4976 setup_gro(res->cmd_onoff, res->cmd_pid);
4979 cmdline_parse_token_string_t cmd_gro_enable_set =
4980 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4982 cmdline_parse_token_string_t cmd_gro_enable_port =
4983 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4984 cmd_keyword, "port");
4985 cmdline_parse_token_num_t cmd_gro_enable_pid =
4986 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4988 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4989 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4990 cmd_keyword, "gro");
4991 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4992 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4993 cmd_onoff, "on#off");
4995 cmdline_parse_inst_t cmd_gro_enable = {
4996 .f = cmd_gro_enable_parsed,
4998 .help_str = "set port <port_id> gro on|off",
5000 (void *)&cmd_gro_enable_set,
5001 (void *)&cmd_gro_enable_port,
5002 (void *)&cmd_gro_enable_pid,
5003 (void *)&cmd_gro_enable_keyword,
5004 (void *)&cmd_gro_enable_onoff,
5009 /* *** DISPLAY GRO CONFIGURATION *** */
5010 struct cmd_gro_show_result {
5011 cmdline_fixed_string_t cmd_show;
5012 cmdline_fixed_string_t cmd_port;
5013 cmdline_fixed_string_t cmd_keyword;
5018 cmd_gro_show_parsed(void *parsed_result,
5019 __rte_unused struct cmdline *cl,
5020 __rte_unused void *data)
5022 struct cmd_gro_show_result *res;
5024 res = parsed_result;
5025 if (!strcmp(res->cmd_keyword, "gro"))
5026 show_gro(res->cmd_pid);
5029 cmdline_parse_token_string_t cmd_gro_show_show =
5030 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5032 cmdline_parse_token_string_t cmd_gro_show_port =
5033 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5035 cmdline_parse_token_num_t cmd_gro_show_pid =
5036 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5038 cmdline_parse_token_string_t cmd_gro_show_keyword =
5039 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5040 cmd_keyword, "gro");
5042 cmdline_parse_inst_t cmd_gro_show = {
5043 .f = cmd_gro_show_parsed,
5045 .help_str = "show port <port_id> gro",
5047 (void *)&cmd_gro_show_show,
5048 (void *)&cmd_gro_show_port,
5049 (void *)&cmd_gro_show_pid,
5050 (void *)&cmd_gro_show_keyword,
5055 /* *** SET FLUSH CYCLES FOR GRO *** */
5056 struct cmd_gro_flush_result {
5057 cmdline_fixed_string_t cmd_set;
5058 cmdline_fixed_string_t cmd_keyword;
5059 cmdline_fixed_string_t cmd_flush;
5064 cmd_gro_flush_parsed(void *parsed_result,
5065 __rte_unused struct cmdline *cl,
5066 __rte_unused void *data)
5068 struct cmd_gro_flush_result *res;
5070 res = parsed_result;
5071 if ((!strcmp(res->cmd_keyword, "gro")) &&
5072 (!strcmp(res->cmd_flush, "flush")))
5073 setup_gro_flush_cycles(res->cmd_cycles);
5076 cmdline_parse_token_string_t cmd_gro_flush_set =
5077 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5079 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5080 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5081 cmd_keyword, "gro");
5082 cmdline_parse_token_string_t cmd_gro_flush_flush =
5083 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5084 cmd_flush, "flush");
5085 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5086 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5089 cmdline_parse_inst_t cmd_gro_flush = {
5090 .f = cmd_gro_flush_parsed,
5092 .help_str = "set gro flush <cycles>",
5094 (void *)&cmd_gro_flush_set,
5095 (void *)&cmd_gro_flush_keyword,
5096 (void *)&cmd_gro_flush_flush,
5097 (void *)&cmd_gro_flush_cycles,
5102 /* *** ENABLE/DISABLE GSO *** */
5103 struct cmd_gso_enable_result {
5104 cmdline_fixed_string_t cmd_set;
5105 cmdline_fixed_string_t cmd_port;
5106 cmdline_fixed_string_t cmd_keyword;
5107 cmdline_fixed_string_t cmd_mode;
5112 cmd_gso_enable_parsed(void *parsed_result,
5113 __rte_unused struct cmdline *cl,
5114 __rte_unused void *data)
5116 struct cmd_gso_enable_result *res;
5118 res = parsed_result;
5119 if (!strcmp(res->cmd_keyword, "gso"))
5120 setup_gso(res->cmd_mode, res->cmd_pid);
5123 cmdline_parse_token_string_t cmd_gso_enable_set =
5124 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5126 cmdline_parse_token_string_t cmd_gso_enable_port =
5127 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5129 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5130 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5131 cmd_keyword, "gso");
5132 cmdline_parse_token_string_t cmd_gso_enable_mode =
5133 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5134 cmd_mode, "on#off");
5135 cmdline_parse_token_num_t cmd_gso_enable_pid =
5136 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5139 cmdline_parse_inst_t cmd_gso_enable = {
5140 .f = cmd_gso_enable_parsed,
5142 .help_str = "set port <port_id> gso on|off",
5144 (void *)&cmd_gso_enable_set,
5145 (void *)&cmd_gso_enable_port,
5146 (void *)&cmd_gso_enable_pid,
5147 (void *)&cmd_gso_enable_keyword,
5148 (void *)&cmd_gso_enable_mode,
5153 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5154 struct cmd_gso_size_result {
5155 cmdline_fixed_string_t cmd_set;
5156 cmdline_fixed_string_t cmd_keyword;
5157 cmdline_fixed_string_t cmd_segsz;
5162 cmd_gso_size_parsed(void *parsed_result,
5163 __rte_unused struct cmdline *cl,
5164 __rte_unused void *data)
5166 struct cmd_gso_size_result *res = parsed_result;
5168 if (test_done == 0) {
5169 printf("Before setting GSO segsz, please first"
5170 " stop forwarding\n");
5174 if (!strcmp(res->cmd_keyword, "gso") &&
5175 !strcmp(res->cmd_segsz, "segsz")) {
5176 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5177 printf("gso_size should be larger than %zu."
5178 " Please input a legal value\n",
5179 RTE_GSO_SEG_SIZE_MIN);
5181 gso_max_segment_size = res->cmd_size;
5185 cmdline_parse_token_string_t cmd_gso_size_set =
5186 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5188 cmdline_parse_token_string_t cmd_gso_size_keyword =
5189 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5190 cmd_keyword, "gso");
5191 cmdline_parse_token_string_t cmd_gso_size_segsz =
5192 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5193 cmd_segsz, "segsz");
5194 cmdline_parse_token_num_t cmd_gso_size_size =
5195 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5198 cmdline_parse_inst_t cmd_gso_size = {
5199 .f = cmd_gso_size_parsed,
5201 .help_str = "set gso segsz <length>",
5203 (void *)&cmd_gso_size_set,
5204 (void *)&cmd_gso_size_keyword,
5205 (void *)&cmd_gso_size_segsz,
5206 (void *)&cmd_gso_size_size,
5211 /* *** SHOW GSO CONFIGURATION *** */
5212 struct cmd_gso_show_result {
5213 cmdline_fixed_string_t cmd_show;
5214 cmdline_fixed_string_t cmd_port;
5215 cmdline_fixed_string_t cmd_keyword;
5220 cmd_gso_show_parsed(void *parsed_result,
5221 __rte_unused struct cmdline *cl,
5222 __rte_unused void *data)
5224 struct cmd_gso_show_result *res = parsed_result;
5226 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5227 printf("invalid port id %u\n", res->cmd_pid);
5230 if (!strcmp(res->cmd_keyword, "gso")) {
5231 if (gso_ports[res->cmd_pid].enable) {
5232 printf("Max GSO'd packet size: %uB\n"
5233 "Supported GSO types: TCP/IPv4, "
5234 "UDP/IPv4, VxLAN with inner "
5235 "TCP/IPv4 packet, GRE with inner "
5236 "TCP/IPv4 packet\n",
5237 gso_max_segment_size);
5239 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5243 cmdline_parse_token_string_t cmd_gso_show_show =
5244 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5246 cmdline_parse_token_string_t cmd_gso_show_port =
5247 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5249 cmdline_parse_token_string_t cmd_gso_show_keyword =
5250 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5251 cmd_keyword, "gso");
5252 cmdline_parse_token_num_t cmd_gso_show_pid =
5253 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5256 cmdline_parse_inst_t cmd_gso_show = {
5257 .f = cmd_gso_show_parsed,
5259 .help_str = "show port <port_id> gso",
5261 (void *)&cmd_gso_show_show,
5262 (void *)&cmd_gso_show_port,
5263 (void *)&cmd_gso_show_pid,
5264 (void *)&cmd_gso_show_keyword,
5269 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5270 struct cmd_set_flush_rx {
5271 cmdline_fixed_string_t set;
5272 cmdline_fixed_string_t flush_rx;
5273 cmdline_fixed_string_t mode;
5277 cmd_set_flush_rx_parsed(void *parsed_result,
5278 __rte_unused struct cmdline *cl,
5279 __rte_unused void *data)
5281 struct cmd_set_flush_rx *res = parsed_result;
5282 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5285 cmdline_parse_token_string_t cmd_setflushrx_set =
5286 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5288 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5289 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5290 flush_rx, "flush_rx");
5291 cmdline_parse_token_string_t cmd_setflushrx_mode =
5292 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5296 cmdline_parse_inst_t cmd_set_flush_rx = {
5297 .f = cmd_set_flush_rx_parsed,
5298 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5301 (void *)&cmd_setflushrx_set,
5302 (void *)&cmd_setflushrx_flush_rx,
5303 (void *)&cmd_setflushrx_mode,
5308 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5309 struct cmd_set_link_check {
5310 cmdline_fixed_string_t set;
5311 cmdline_fixed_string_t link_check;
5312 cmdline_fixed_string_t mode;
5316 cmd_set_link_check_parsed(void *parsed_result,
5317 __rte_unused struct cmdline *cl,
5318 __rte_unused void *data)
5320 struct cmd_set_link_check *res = parsed_result;
5321 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5324 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5325 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5327 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5328 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5329 link_check, "link_check");
5330 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5331 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5335 cmdline_parse_inst_t cmd_set_link_check = {
5336 .f = cmd_set_link_check_parsed,
5337 .help_str = "set link_check on|off: Enable/Disable link status check "
5338 "when starting/stopping a port",
5341 (void *)&cmd_setlinkcheck_set,
5342 (void *)&cmd_setlinkcheck_link_check,
5343 (void *)&cmd_setlinkcheck_mode,
5348 /* *** SET NIC BYPASS MODE *** */
5349 struct cmd_set_bypass_mode_result {
5350 cmdline_fixed_string_t set;
5351 cmdline_fixed_string_t bypass;
5352 cmdline_fixed_string_t mode;
5353 cmdline_fixed_string_t value;
5358 cmd_set_bypass_mode_parsed(void *parsed_result,
5359 __rte_unused struct cmdline *cl,
5360 __rte_unused void *data)
5362 struct cmd_set_bypass_mode_result *res = parsed_result;
5363 portid_t port_id = res->port_id;
5364 int32_t rc = -EINVAL;
5366 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5367 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5369 if (!strcmp(res->value, "bypass"))
5370 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5371 else if (!strcmp(res->value, "isolate"))
5372 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5374 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5376 /* Set the bypass mode for the relevant port. */
5377 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5380 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5383 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5384 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5386 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5387 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5389 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5390 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5392 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5393 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5394 value, "normal#bypass#isolate");
5395 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5396 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5399 cmdline_parse_inst_t cmd_set_bypass_mode = {
5400 .f = cmd_set_bypass_mode_parsed,
5401 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5402 "Set the NIC bypass mode for port_id",
5405 (void *)&cmd_setbypass_mode_set,
5406 (void *)&cmd_setbypass_mode_bypass,
5407 (void *)&cmd_setbypass_mode_mode,
5408 (void *)&cmd_setbypass_mode_value,
5409 (void *)&cmd_setbypass_mode_port,
5414 /* *** SET NIC BYPASS EVENT *** */
5415 struct cmd_set_bypass_event_result {
5416 cmdline_fixed_string_t set;
5417 cmdline_fixed_string_t bypass;
5418 cmdline_fixed_string_t event;
5419 cmdline_fixed_string_t event_value;
5420 cmdline_fixed_string_t mode;
5421 cmdline_fixed_string_t mode_value;
5426 cmd_set_bypass_event_parsed(void *parsed_result,
5427 __rte_unused struct cmdline *cl,
5428 __rte_unused void *data)
5430 int32_t rc = -EINVAL;
5431 struct cmd_set_bypass_event_result *res = parsed_result;
5432 portid_t port_id = res->port_id;
5434 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5435 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5436 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5438 if (!strcmp(res->event_value, "timeout"))
5439 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5440 else if (!strcmp(res->event_value, "os_on"))
5441 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5442 else if (!strcmp(res->event_value, "os_off"))
5443 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5444 else if (!strcmp(res->event_value, "power_on"))
5445 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5446 else if (!strcmp(res->event_value, "power_off"))
5447 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5449 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5451 if (!strcmp(res->mode_value, "bypass"))
5452 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5453 else if (!strcmp(res->mode_value, "isolate"))
5454 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5456 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5458 /* Set the watchdog timeout. */
5459 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5462 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5463 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5467 printf("Failed to set timeout value %u "
5468 "for port %d, errto code: %d.\n",
5469 bypass_timeout, port_id, rc);
5473 /* Set the bypass event to transition to bypass mode. */
5474 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5479 printf("\t Failed to set bypass event for port = %d.\n",
5483 cmdline_parse_token_string_t cmd_setbypass_event_set =
5484 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5486 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5487 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5489 cmdline_parse_token_string_t cmd_setbypass_event_event =
5490 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5492 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5493 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5494 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5495 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5496 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5498 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5499 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5500 mode_value, "normal#bypass#isolate");
5501 cmdline_parse_token_num_t cmd_setbypass_event_port =
5502 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5505 cmdline_parse_inst_t cmd_set_bypass_event = {
5506 .f = cmd_set_bypass_event_parsed,
5507 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5508 "power_off mode normal|bypass|isolate <port_id>: "
5509 "Set the NIC bypass event mode for port_id",
5512 (void *)&cmd_setbypass_event_set,
5513 (void *)&cmd_setbypass_event_bypass,
5514 (void *)&cmd_setbypass_event_event,
5515 (void *)&cmd_setbypass_event_event_value,
5516 (void *)&cmd_setbypass_event_mode,
5517 (void *)&cmd_setbypass_event_mode_value,
5518 (void *)&cmd_setbypass_event_port,
5524 /* *** SET NIC BYPASS TIMEOUT *** */
5525 struct cmd_set_bypass_timeout_result {
5526 cmdline_fixed_string_t set;
5527 cmdline_fixed_string_t bypass;
5528 cmdline_fixed_string_t timeout;
5529 cmdline_fixed_string_t value;
5533 cmd_set_bypass_timeout_parsed(void *parsed_result,
5534 __rte_unused struct cmdline *cl,
5535 __rte_unused void *data)
5537 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5539 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5540 if (!strcmp(res->value, "1.5"))
5541 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5542 else if (!strcmp(res->value, "2"))
5543 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5544 else if (!strcmp(res->value, "3"))
5545 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5546 else if (!strcmp(res->value, "4"))
5547 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5548 else if (!strcmp(res->value, "8"))
5549 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5550 else if (!strcmp(res->value, "16"))
5551 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5552 else if (!strcmp(res->value, "32"))
5553 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5555 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5559 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5560 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5562 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5563 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5565 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5566 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5567 timeout, "timeout");
5568 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5569 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5570 value, "0#1.5#2#3#4#8#16#32");
5572 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5573 .f = cmd_set_bypass_timeout_parsed,
5574 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5575 "Set the NIC bypass watchdog timeout in seconds",
5578 (void *)&cmd_setbypass_timeout_set,
5579 (void *)&cmd_setbypass_timeout_bypass,
5580 (void *)&cmd_setbypass_timeout_timeout,
5581 (void *)&cmd_setbypass_timeout_value,
5586 /* *** SHOW NIC BYPASS MODE *** */
5587 struct cmd_show_bypass_config_result {
5588 cmdline_fixed_string_t show;
5589 cmdline_fixed_string_t bypass;
5590 cmdline_fixed_string_t config;
5595 cmd_show_bypass_config_parsed(void *parsed_result,
5596 __rte_unused struct cmdline *cl,
5597 __rte_unused void *data)
5599 struct cmd_show_bypass_config_result *res = parsed_result;
5600 portid_t port_id = res->port_id;
5602 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5603 uint32_t event_mode;
5604 uint32_t bypass_mode;
5605 uint32_t timeout = bypass_timeout;
5608 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5609 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5610 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5611 {"UNKNOWN", "normal", "bypass", "isolate"};
5612 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5620 /* Display the bypass mode.*/
5621 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5622 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5626 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5627 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5629 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5632 /* Display the bypass timeout.*/
5633 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5634 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5636 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5638 /* Display the bypass events and associated modes. */
5639 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5641 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5642 printf("\tFailed to get bypass mode for event = %s\n",
5645 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5646 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5648 printf("\tbypass event: %-16s = %s\n", events[i],
5654 printf("\tFailed to get bypass configuration for port = %d\n",
5658 cmdline_parse_token_string_t cmd_showbypass_config_show =
5659 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5661 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5662 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5664 cmdline_parse_token_string_t cmd_showbypass_config_config =
5665 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5667 cmdline_parse_token_num_t cmd_showbypass_config_port =
5668 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5671 cmdline_parse_inst_t cmd_show_bypass_config = {
5672 .f = cmd_show_bypass_config_parsed,
5673 .help_str = "show bypass config <port_id>: "
5674 "Show the NIC bypass config for port_id",
5677 (void *)&cmd_showbypass_config_show,
5678 (void *)&cmd_showbypass_config_bypass,
5679 (void *)&cmd_showbypass_config_config,
5680 (void *)&cmd_showbypass_config_port,
5685 #ifdef RTE_LIBRTE_PMD_BOND
5686 /* *** SET BONDING MODE *** */
5687 struct cmd_set_bonding_mode_result {
5688 cmdline_fixed_string_t set;
5689 cmdline_fixed_string_t bonding;
5690 cmdline_fixed_string_t mode;
5695 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5696 __rte_unused struct cmdline *cl,
5697 __rte_unused void *data)
5699 struct cmd_set_bonding_mode_result *res = parsed_result;
5700 portid_t port_id = res->port_id;
5702 /* Set the bonding mode for the relevant port. */
5703 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5704 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5707 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5708 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5710 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5711 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5712 bonding, "bonding");
5713 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5714 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5716 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5717 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5719 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5720 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5723 cmdline_parse_inst_t cmd_set_bonding_mode = {
5724 .f = cmd_set_bonding_mode_parsed,
5725 .help_str = "set bonding mode <mode_value> <port_id>: "
5726 "Set the bonding mode for port_id",
5729 (void *) &cmd_setbonding_mode_set,
5730 (void *) &cmd_setbonding_mode_bonding,
5731 (void *) &cmd_setbonding_mode_mode,
5732 (void *) &cmd_setbonding_mode_value,
5733 (void *) &cmd_setbonding_mode_port,
5738 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5739 struct cmd_set_bonding_lacp_dedicated_queues_result {
5740 cmdline_fixed_string_t set;
5741 cmdline_fixed_string_t bonding;
5742 cmdline_fixed_string_t lacp;
5743 cmdline_fixed_string_t dedicated_queues;
5745 cmdline_fixed_string_t mode;
5748 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5749 __rte_unused struct cmdline *cl,
5750 __rte_unused void *data)
5752 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5753 portid_t port_id = res->port_id;
5754 struct rte_port *port;
5756 port = &ports[port_id];
5758 /** Check if the port is not started **/
5759 if (port->port_status != RTE_PORT_STOPPED) {
5760 printf("Please stop port %d first\n", port_id);
5764 if (!strcmp(res->mode, "enable")) {
5765 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5766 printf("Dedicate queues for LACP control packets"
5769 printf("Enabling dedicate queues for LACP control "
5770 "packets on port %d failed\n", port_id);
5771 } else if (!strcmp(res->mode, "disable")) {
5772 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5773 printf("Dedicated queues for LACP control packets "
5776 printf("Disabling dedicated queues for LACP control "
5777 "traffic on port %d failed\n", port_id);
5781 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5784 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5785 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5786 bonding, "bonding");
5787 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5788 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5790 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5791 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5792 dedicated_queues, "dedicated_queues");
5793 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5794 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5796 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5797 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5798 mode, "enable#disable");
5800 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5801 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5802 .help_str = "set bonding lacp dedicated_queues <port_id> "
5804 "Enable/disable dedicated queues for LACP control traffic for port_id",
5807 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5808 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5809 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5810 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5811 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5812 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5817 /* *** SET BALANCE XMIT POLICY *** */
5818 struct cmd_set_bonding_balance_xmit_policy_result {
5819 cmdline_fixed_string_t set;
5820 cmdline_fixed_string_t bonding;
5821 cmdline_fixed_string_t balance_xmit_policy;
5823 cmdline_fixed_string_t policy;
5826 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5827 __rte_unused struct cmdline *cl,
5828 __rte_unused void *data)
5830 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5831 portid_t port_id = res->port_id;
5834 if (!strcmp(res->policy, "l2")) {
5835 policy = BALANCE_XMIT_POLICY_LAYER2;
5836 } else if (!strcmp(res->policy, "l23")) {
5837 policy = BALANCE_XMIT_POLICY_LAYER23;
5838 } else if (!strcmp(res->policy, "l34")) {
5839 policy = BALANCE_XMIT_POLICY_LAYER34;
5841 printf("\t Invalid xmit policy selection");
5845 /* Set the bonding mode for the relevant port. */
5846 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5847 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5852 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5855 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5856 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5857 bonding, "bonding");
5858 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5859 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5860 balance_xmit_policy, "balance_xmit_policy");
5861 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5862 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5864 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5865 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5866 policy, "l2#l23#l34");
5868 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5869 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5870 .help_str = "set bonding balance_xmit_policy <port_id> "
5872 "Set the bonding balance_xmit_policy for port_id",
5875 (void *)&cmd_setbonding_balance_xmit_policy_set,
5876 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5877 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5878 (void *)&cmd_setbonding_balance_xmit_policy_port,
5879 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5884 /* *** SHOW NIC BONDING CONFIGURATION *** */
5885 struct cmd_show_bonding_config_result {
5886 cmdline_fixed_string_t show;
5887 cmdline_fixed_string_t bonding;
5888 cmdline_fixed_string_t config;
5892 static void cmd_show_bonding_config_parsed(void *parsed_result,
5893 __rte_unused struct cmdline *cl,
5894 __rte_unused void *data)
5896 struct cmd_show_bonding_config_result *res = parsed_result;
5897 int bonding_mode, agg_mode;
5898 portid_t slaves[RTE_MAX_ETHPORTS];
5899 int num_slaves, num_active_slaves;
5902 portid_t port_id = res->port_id;
5904 /* Display the bonding mode.*/
5905 bonding_mode = rte_eth_bond_mode_get(port_id);
5906 if (bonding_mode < 0) {
5907 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5910 printf("\tBonding mode: %d\n", bonding_mode);
5912 if (bonding_mode == BONDING_MODE_BALANCE) {
5913 int balance_xmit_policy;
5915 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5916 if (balance_xmit_policy < 0) {
5917 printf("\tFailed to get balance xmit policy for port = %d\n",
5921 printf("\tBalance Xmit Policy: ");
5923 switch (balance_xmit_policy) {
5924 case BALANCE_XMIT_POLICY_LAYER2:
5925 printf("BALANCE_XMIT_POLICY_LAYER2");
5927 case BALANCE_XMIT_POLICY_LAYER23:
5928 printf("BALANCE_XMIT_POLICY_LAYER23");
5930 case BALANCE_XMIT_POLICY_LAYER34:
5931 printf("BALANCE_XMIT_POLICY_LAYER34");
5938 if (bonding_mode == BONDING_MODE_8023AD) {
5939 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5940 printf("\tIEEE802.3AD Aggregator Mode: ");
5943 printf("bandwidth");
5955 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5957 if (num_slaves < 0) {
5958 printf("\tFailed to get slave list for port = %d\n", port_id);
5961 if (num_slaves > 0) {
5962 printf("\tSlaves (%d): [", num_slaves);
5963 for (i = 0; i < num_slaves - 1; i++)
5964 printf("%d ", slaves[i]);
5966 printf("%d]\n", slaves[num_slaves - 1]);
5968 printf("\tSlaves: []\n");
5972 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5975 if (num_active_slaves < 0) {
5976 printf("\tFailed to get active slave list for port = %d\n", port_id);
5979 if (num_active_slaves > 0) {
5980 printf("\tActive Slaves (%d): [", num_active_slaves);
5981 for (i = 0; i < num_active_slaves - 1; i++)
5982 printf("%d ", slaves[i]);
5984 printf("%d]\n", slaves[num_active_slaves - 1]);
5987 printf("\tActive Slaves: []\n");
5991 primary_id = rte_eth_bond_primary_get(port_id);
5992 if (primary_id < 0) {
5993 printf("\tFailed to get primary slave for port = %d\n", port_id);
5996 printf("\tPrimary: [%d]\n", primary_id);
6000 cmdline_parse_token_string_t cmd_showbonding_config_show =
6001 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6003 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6004 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6005 bonding, "bonding");
6006 cmdline_parse_token_string_t cmd_showbonding_config_config =
6007 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6009 cmdline_parse_token_num_t cmd_showbonding_config_port =
6010 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6013 cmdline_parse_inst_t cmd_show_bonding_config = {
6014 .f = cmd_show_bonding_config_parsed,
6015 .help_str = "show bonding config <port_id>: "
6016 "Show the bonding config for port_id",
6019 (void *)&cmd_showbonding_config_show,
6020 (void *)&cmd_showbonding_config_bonding,
6021 (void *)&cmd_showbonding_config_config,
6022 (void *)&cmd_showbonding_config_port,
6027 /* *** SET BONDING PRIMARY *** */
6028 struct cmd_set_bonding_primary_result {
6029 cmdline_fixed_string_t set;
6030 cmdline_fixed_string_t bonding;
6031 cmdline_fixed_string_t primary;
6036 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6037 __rte_unused struct cmdline *cl,
6038 __rte_unused void *data)
6040 struct cmd_set_bonding_primary_result *res = parsed_result;
6041 portid_t master_port_id = res->port_id;
6042 portid_t slave_port_id = res->slave_id;
6044 /* Set the primary slave for a bonded device. */
6045 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6046 printf("\t Failed to set primary slave for port = %d.\n",
6053 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6054 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6056 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6057 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6058 bonding, "bonding");
6059 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6060 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6061 primary, "primary");
6062 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6063 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6065 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6066 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6069 cmdline_parse_inst_t cmd_set_bonding_primary = {
6070 .f = cmd_set_bonding_primary_parsed,
6071 .help_str = "set bonding primary <slave_id> <port_id>: "
6072 "Set the primary slave for port_id",
6075 (void *)&cmd_setbonding_primary_set,
6076 (void *)&cmd_setbonding_primary_bonding,
6077 (void *)&cmd_setbonding_primary_primary,
6078 (void *)&cmd_setbonding_primary_slave,
6079 (void *)&cmd_setbonding_primary_port,
6084 /* *** ADD SLAVE *** */
6085 struct cmd_add_bonding_slave_result {
6086 cmdline_fixed_string_t add;
6087 cmdline_fixed_string_t bonding;
6088 cmdline_fixed_string_t slave;
6093 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6094 __rte_unused struct cmdline *cl,
6095 __rte_unused void *data)
6097 struct cmd_add_bonding_slave_result *res = parsed_result;
6098 portid_t master_port_id = res->port_id;
6099 portid_t slave_port_id = res->slave_id;
6101 /* add the slave for a bonded device. */
6102 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6103 printf("\t Failed to add slave %d to master port = %d.\n",
6104 slave_port_id, master_port_id);
6108 set_port_slave_flag(slave_port_id);
6111 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6112 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6114 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6115 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6116 bonding, "bonding");
6117 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6118 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6120 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6121 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6123 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6124 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6127 cmdline_parse_inst_t cmd_add_bonding_slave = {
6128 .f = cmd_add_bonding_slave_parsed,
6129 .help_str = "add bonding slave <slave_id> <port_id>: "
6130 "Add a slave device to a bonded device",
6133 (void *)&cmd_addbonding_slave_add,
6134 (void *)&cmd_addbonding_slave_bonding,
6135 (void *)&cmd_addbonding_slave_slave,
6136 (void *)&cmd_addbonding_slave_slaveid,
6137 (void *)&cmd_addbonding_slave_port,
6142 /* *** REMOVE SLAVE *** */
6143 struct cmd_remove_bonding_slave_result {
6144 cmdline_fixed_string_t remove;
6145 cmdline_fixed_string_t bonding;
6146 cmdline_fixed_string_t slave;
6151 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6152 __rte_unused struct cmdline *cl,
6153 __rte_unused void *data)
6155 struct cmd_remove_bonding_slave_result *res = parsed_result;
6156 portid_t master_port_id = res->port_id;
6157 portid_t slave_port_id = res->slave_id;
6159 /* remove the slave from a bonded device. */
6160 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6161 printf("\t Failed to remove slave %d from master port = %d.\n",
6162 slave_port_id, master_port_id);
6166 clear_port_slave_flag(slave_port_id);
6169 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6170 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6172 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6173 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6174 bonding, "bonding");
6175 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6176 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6178 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6179 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6181 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6182 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6185 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6186 .f = cmd_remove_bonding_slave_parsed,
6187 .help_str = "remove bonding slave <slave_id> <port_id>: "
6188 "Remove a slave device from a bonded device",
6191 (void *)&cmd_removebonding_slave_remove,
6192 (void *)&cmd_removebonding_slave_bonding,
6193 (void *)&cmd_removebonding_slave_slave,
6194 (void *)&cmd_removebonding_slave_slaveid,
6195 (void *)&cmd_removebonding_slave_port,
6200 /* *** CREATE BONDED DEVICE *** */
6201 struct cmd_create_bonded_device_result {
6202 cmdline_fixed_string_t create;
6203 cmdline_fixed_string_t bonded;
6204 cmdline_fixed_string_t device;
6209 static int bond_dev_num = 0;
6211 static void cmd_create_bonded_device_parsed(void *parsed_result,
6212 __rte_unused struct cmdline *cl,
6213 __rte_unused void *data)
6215 struct cmd_create_bonded_device_result *res = parsed_result;
6216 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6220 if (test_done == 0) {
6221 printf("Please stop forwarding first\n");
6225 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6228 /* Create a new bonded device. */
6229 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6231 printf("\t Failed to create bonded device.\n");
6234 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6237 /* Update number of ports */
6238 nb_ports = rte_eth_dev_count_avail();
6239 reconfig(port_id, res->socket);
6240 ret = rte_eth_promiscuous_enable(port_id);
6242 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6243 port_id, rte_strerror(-ret));
6245 ports[port_id].need_setup = 0;
6246 ports[port_id].port_status = RTE_PORT_STOPPED;
6251 cmdline_parse_token_string_t cmd_createbonded_device_create =
6252 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6254 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6255 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6257 cmdline_parse_token_string_t cmd_createbonded_device_device =
6258 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6260 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6261 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6263 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6264 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6267 cmdline_parse_inst_t cmd_create_bonded_device = {
6268 .f = cmd_create_bonded_device_parsed,
6269 .help_str = "create bonded device <mode> <socket>: "
6270 "Create a new bonded device with specific bonding mode and socket",
6273 (void *)&cmd_createbonded_device_create,
6274 (void *)&cmd_createbonded_device_bonded,
6275 (void *)&cmd_createbonded_device_device,
6276 (void *)&cmd_createbonded_device_mode,
6277 (void *)&cmd_createbonded_device_socket,
6282 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6283 struct cmd_set_bond_mac_addr_result {
6284 cmdline_fixed_string_t set;
6285 cmdline_fixed_string_t bonding;
6286 cmdline_fixed_string_t mac_addr;
6288 struct rte_ether_addr address;
6291 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6292 __rte_unused struct cmdline *cl,
6293 __rte_unused void *data)
6295 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6298 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6301 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6303 /* check the return value and print it if is < 0 */
6305 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6308 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6309 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6310 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6311 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6313 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6314 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6316 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6317 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6319 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6320 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6322 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6323 .f = cmd_set_bond_mac_addr_parsed,
6325 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6327 (void *)&cmd_set_bond_mac_addr_set,
6328 (void *)&cmd_set_bond_mac_addr_bonding,
6329 (void *)&cmd_set_bond_mac_addr_mac,
6330 (void *)&cmd_set_bond_mac_addr_portnum,
6331 (void *)&cmd_set_bond_mac_addr_addr,
6337 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6338 struct cmd_set_bond_mon_period_result {
6339 cmdline_fixed_string_t set;
6340 cmdline_fixed_string_t bonding;
6341 cmdline_fixed_string_t mon_period;
6346 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6347 __rte_unused struct cmdline *cl,
6348 __rte_unused void *data)
6350 struct cmd_set_bond_mon_period_result *res = parsed_result;
6353 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6355 /* check the return value and print it if is < 0 */
6357 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6360 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6361 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6363 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6364 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6365 bonding, "bonding");
6366 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6367 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6368 mon_period, "mon_period");
6369 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6370 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6372 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6373 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6376 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6377 .f = cmd_set_bond_mon_period_parsed,
6379 .help_str = "set bonding mon_period <port_id> <period_ms>",
6381 (void *)&cmd_set_bond_mon_period_set,
6382 (void *)&cmd_set_bond_mon_period_bonding,
6383 (void *)&cmd_set_bond_mon_period_mon_period,
6384 (void *)&cmd_set_bond_mon_period_portnum,
6385 (void *)&cmd_set_bond_mon_period_period_ms,
6392 struct cmd_set_bonding_agg_mode_policy_result {
6393 cmdline_fixed_string_t set;
6394 cmdline_fixed_string_t bonding;
6395 cmdline_fixed_string_t agg_mode;
6397 cmdline_fixed_string_t policy;
6402 cmd_set_bonding_agg_mode(void *parsed_result,
6403 __rte_unused struct cmdline *cl,
6404 __rte_unused void *data)
6406 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6407 uint8_t policy = AGG_BANDWIDTH;
6409 if (!strcmp(res->policy, "bandwidth"))
6410 policy = AGG_BANDWIDTH;
6411 else if (!strcmp(res->policy, "stable"))
6412 policy = AGG_STABLE;
6413 else if (!strcmp(res->policy, "count"))
6416 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6420 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6421 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6423 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6424 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6425 bonding, "bonding");
6427 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6428 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6429 agg_mode, "agg_mode");
6431 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6432 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6435 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6436 TOKEN_STRING_INITIALIZER(
6437 struct cmd_set_bonding_balance_xmit_policy_result,
6438 policy, "stable#bandwidth#count");
6440 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6441 .f = cmd_set_bonding_agg_mode,
6443 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6445 (void *)&cmd_set_bonding_agg_mode_set,
6446 (void *)&cmd_set_bonding_agg_mode_bonding,
6447 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6448 (void *)&cmd_set_bonding_agg_mode_portnum,
6449 (void *)&cmd_set_bonding_agg_mode_policy_string,
6455 #endif /* RTE_LIBRTE_PMD_BOND */
6457 /* *** SET FORWARDING MODE *** */
6458 struct cmd_set_fwd_mode_result {
6459 cmdline_fixed_string_t set;
6460 cmdline_fixed_string_t fwd;
6461 cmdline_fixed_string_t mode;
6464 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6465 __rte_unused struct cmdline *cl,
6466 __rte_unused void *data)
6468 struct cmd_set_fwd_mode_result *res = parsed_result;
6471 set_pkt_forwarding_mode(res->mode);
6474 cmdline_parse_token_string_t cmd_setfwd_set =
6475 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6476 cmdline_parse_token_string_t cmd_setfwd_fwd =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6478 cmdline_parse_token_string_t cmd_setfwd_mode =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6480 "" /* defined at init */);
6482 cmdline_parse_inst_t cmd_set_fwd_mode = {
6483 .f = cmd_set_fwd_mode_parsed,
6485 .help_str = NULL, /* defined at init */
6487 (void *)&cmd_setfwd_set,
6488 (void *)&cmd_setfwd_fwd,
6489 (void *)&cmd_setfwd_mode,
6494 static void cmd_set_fwd_mode_init(void)
6497 static char token[128];
6498 static char help[256];
6499 cmdline_parse_token_string_t *token_struct;
6501 modes = list_pkt_forwarding_modes();
6502 snprintf(help, sizeof(help), "set fwd %s: "
6503 "Set packet forwarding mode", modes);
6504 cmd_set_fwd_mode.help_str = help;
6506 /* string token separator is # */
6507 for (c = token; *modes != '\0'; modes++)
6512 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6513 token_struct->string_data.str = token;
6516 /* *** SET RETRY FORWARDING MODE *** */
6517 struct cmd_set_fwd_retry_mode_result {
6518 cmdline_fixed_string_t set;
6519 cmdline_fixed_string_t fwd;
6520 cmdline_fixed_string_t mode;
6521 cmdline_fixed_string_t retry;
6524 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6525 __rte_unused struct cmdline *cl,
6526 __rte_unused void *data)
6528 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6531 set_pkt_forwarding_mode(res->mode);
6534 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6535 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6537 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6538 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6540 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6541 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6543 "" /* defined at init */);
6544 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6545 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6548 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6549 .f = cmd_set_fwd_retry_mode_parsed,
6551 .help_str = NULL, /* defined at init */
6553 (void *)&cmd_setfwd_retry_set,
6554 (void *)&cmd_setfwd_retry_fwd,
6555 (void *)&cmd_setfwd_retry_mode,
6556 (void *)&cmd_setfwd_retry_retry,
6561 static void cmd_set_fwd_retry_mode_init(void)
6564 static char token[128];
6565 static char help[256];
6566 cmdline_parse_token_string_t *token_struct;
6568 modes = list_pkt_forwarding_retry_modes();
6569 snprintf(help, sizeof(help), "set fwd %s retry: "
6570 "Set packet forwarding mode with retry", modes);
6571 cmd_set_fwd_retry_mode.help_str = help;
6573 /* string token separator is # */
6574 for (c = token; *modes != '\0'; modes++)
6579 token_struct = (cmdline_parse_token_string_t *)
6580 cmd_set_fwd_retry_mode.tokens[2];
6581 token_struct->string_data.str = token;
6584 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6585 struct cmd_set_burst_tx_retry_result {
6586 cmdline_fixed_string_t set;
6587 cmdline_fixed_string_t burst;
6588 cmdline_fixed_string_t tx;
6589 cmdline_fixed_string_t delay;
6591 cmdline_fixed_string_t retry;
6595 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6596 __rte_unused struct cmdline *cl,
6597 __rte_unused void *data)
6599 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6601 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6602 && !strcmp(res->tx, "tx")) {
6603 if (!strcmp(res->delay, "delay"))
6604 burst_tx_delay_time = res->time;
6605 if (!strcmp(res->retry, "retry"))
6606 burst_tx_retry_num = res->retry_num;
6611 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6612 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6613 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6614 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6616 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6617 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6618 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6619 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6620 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6621 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6622 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6623 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6624 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6625 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6627 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6628 .f = cmd_set_burst_tx_retry_parsed,
6629 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6631 (void *)&cmd_set_burst_tx_retry_set,
6632 (void *)&cmd_set_burst_tx_retry_burst,
6633 (void *)&cmd_set_burst_tx_retry_tx,
6634 (void *)&cmd_set_burst_tx_retry_delay,
6635 (void *)&cmd_set_burst_tx_retry_time,
6636 (void *)&cmd_set_burst_tx_retry_retry,
6637 (void *)&cmd_set_burst_tx_retry_retry_num,
6642 /* *** SET PROMISC MODE *** */
6643 struct cmd_set_promisc_mode_result {
6644 cmdline_fixed_string_t set;
6645 cmdline_fixed_string_t promisc;
6646 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6647 uint16_t port_num; /* valid if "allports" argument == 0 */
6648 cmdline_fixed_string_t mode;
6651 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6652 __rte_unused struct cmdline *cl,
6655 struct cmd_set_promisc_mode_result *res = parsed_result;
6659 if (!strcmp(res->mode, "on"))
6666 RTE_ETH_FOREACH_DEV(i)
6667 eth_set_promisc_mode(i, enable);
6669 eth_set_promisc_mode(res->port_num, enable);
6673 cmdline_parse_token_string_t cmd_setpromisc_set =
6674 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6675 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6676 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6678 cmdline_parse_token_string_t cmd_setpromisc_portall =
6679 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6681 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6682 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6684 cmdline_parse_token_string_t cmd_setpromisc_mode =
6685 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6688 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6689 .f = cmd_set_promisc_mode_parsed,
6691 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6693 (void *)&cmd_setpromisc_set,
6694 (void *)&cmd_setpromisc_promisc,
6695 (void *)&cmd_setpromisc_portall,
6696 (void *)&cmd_setpromisc_mode,
6701 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6702 .f = cmd_set_promisc_mode_parsed,
6704 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6706 (void *)&cmd_setpromisc_set,
6707 (void *)&cmd_setpromisc_promisc,
6708 (void *)&cmd_setpromisc_portnum,
6709 (void *)&cmd_setpromisc_mode,
6714 /* *** SET ALLMULTI MODE *** */
6715 struct cmd_set_allmulti_mode_result {
6716 cmdline_fixed_string_t set;
6717 cmdline_fixed_string_t allmulti;
6718 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6719 uint16_t port_num; /* valid if "allports" argument == 0 */
6720 cmdline_fixed_string_t mode;
6723 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6724 __rte_unused struct cmdline *cl,
6727 struct cmd_set_allmulti_mode_result *res = parsed_result;
6731 if (!strcmp(res->mode, "on"))
6738 RTE_ETH_FOREACH_DEV(i) {
6739 eth_set_allmulticast_mode(i, enable);
6743 eth_set_allmulticast_mode(res->port_num, enable);
6747 cmdline_parse_token_string_t cmd_setallmulti_set =
6748 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6749 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6750 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6752 cmdline_parse_token_string_t cmd_setallmulti_portall =
6753 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6755 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6756 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6758 cmdline_parse_token_string_t cmd_setallmulti_mode =
6759 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6762 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6763 .f = cmd_set_allmulti_mode_parsed,
6765 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6767 (void *)&cmd_setallmulti_set,
6768 (void *)&cmd_setallmulti_allmulti,
6769 (void *)&cmd_setallmulti_portall,
6770 (void *)&cmd_setallmulti_mode,
6775 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6776 .f = cmd_set_allmulti_mode_parsed,
6778 .help_str = "set allmulti <port_id> on|off: "
6779 "Set allmulti mode on port_id",
6781 (void *)&cmd_setallmulti_set,
6782 (void *)&cmd_setallmulti_allmulti,
6783 (void *)&cmd_setallmulti_portnum,
6784 (void *)&cmd_setallmulti_mode,
6789 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6790 struct cmd_link_flow_ctrl_set_result {
6791 cmdline_fixed_string_t set;
6792 cmdline_fixed_string_t flow_ctrl;
6793 cmdline_fixed_string_t rx;
6794 cmdline_fixed_string_t rx_lfc_mode;
6795 cmdline_fixed_string_t tx;
6796 cmdline_fixed_string_t tx_lfc_mode;
6797 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6798 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6799 cmdline_fixed_string_t autoneg_str;
6800 cmdline_fixed_string_t autoneg;
6801 cmdline_fixed_string_t hw_str;
6802 uint32_t high_water;
6803 cmdline_fixed_string_t lw_str;
6805 cmdline_fixed_string_t pt_str;
6806 uint16_t pause_time;
6807 cmdline_fixed_string_t xon_str;
6812 cmdline_parse_token_string_t cmd_lfc_set_set =
6813 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6815 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6816 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6817 flow_ctrl, "flow_ctrl");
6818 cmdline_parse_token_string_t cmd_lfc_set_rx =
6819 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6821 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6822 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6823 rx_lfc_mode, "on#off");
6824 cmdline_parse_token_string_t cmd_lfc_set_tx =
6825 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6827 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6828 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6829 tx_lfc_mode, "on#off");
6830 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6831 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6832 hw_str, "high_water");
6833 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6834 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6835 high_water, UINT32);
6836 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6837 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6838 lw_str, "low_water");
6839 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6840 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6842 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6843 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6844 pt_str, "pause_time");
6845 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6846 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6847 pause_time, UINT16);
6848 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6849 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6850 xon_str, "send_xon");
6851 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6852 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6854 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6855 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6856 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6857 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6858 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6859 mac_ctrl_frame_fwd_mode, "on#off");
6860 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6861 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6862 autoneg_str, "autoneg");
6863 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6864 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6866 cmdline_parse_token_num_t cmd_lfc_set_portid =
6867 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6870 /* forward declaration */
6872 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6875 cmdline_parse_inst_t cmd_link_flow_control_set = {
6876 .f = cmd_link_flow_ctrl_set_parsed,
6878 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6879 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6880 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6882 (void *)&cmd_lfc_set_set,
6883 (void *)&cmd_lfc_set_flow_ctrl,
6884 (void *)&cmd_lfc_set_rx,
6885 (void *)&cmd_lfc_set_rx_mode,
6886 (void *)&cmd_lfc_set_tx,
6887 (void *)&cmd_lfc_set_tx_mode,
6888 (void *)&cmd_lfc_set_high_water,
6889 (void *)&cmd_lfc_set_low_water,
6890 (void *)&cmd_lfc_set_pause_time,
6891 (void *)&cmd_lfc_set_send_xon,
6892 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6893 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6894 (void *)&cmd_lfc_set_autoneg_str,
6895 (void *)&cmd_lfc_set_autoneg,
6896 (void *)&cmd_lfc_set_portid,
6901 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6902 .f = cmd_link_flow_ctrl_set_parsed,
6903 .data = (void *)&cmd_link_flow_control_set_rx,
6904 .help_str = "set flow_ctrl rx on|off <port_id>: "
6905 "Change rx flow control parameter",
6907 (void *)&cmd_lfc_set_set,
6908 (void *)&cmd_lfc_set_flow_ctrl,
6909 (void *)&cmd_lfc_set_rx,
6910 (void *)&cmd_lfc_set_rx_mode,
6911 (void *)&cmd_lfc_set_portid,
6916 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6917 .f = cmd_link_flow_ctrl_set_parsed,
6918 .data = (void *)&cmd_link_flow_control_set_tx,
6919 .help_str = "set flow_ctrl tx on|off <port_id>: "
6920 "Change tx flow control parameter",
6922 (void *)&cmd_lfc_set_set,
6923 (void *)&cmd_lfc_set_flow_ctrl,
6924 (void *)&cmd_lfc_set_tx,
6925 (void *)&cmd_lfc_set_tx_mode,
6926 (void *)&cmd_lfc_set_portid,
6931 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6932 .f = cmd_link_flow_ctrl_set_parsed,
6933 .data = (void *)&cmd_link_flow_control_set_hw,
6934 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6935 "Change high water flow control parameter",
6937 (void *)&cmd_lfc_set_set,
6938 (void *)&cmd_lfc_set_flow_ctrl,
6939 (void *)&cmd_lfc_set_high_water_str,
6940 (void *)&cmd_lfc_set_high_water,
6941 (void *)&cmd_lfc_set_portid,
6946 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6947 .f = cmd_link_flow_ctrl_set_parsed,
6948 .data = (void *)&cmd_link_flow_control_set_lw,
6949 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6950 "Change low water flow control parameter",
6952 (void *)&cmd_lfc_set_set,
6953 (void *)&cmd_lfc_set_flow_ctrl,
6954 (void *)&cmd_lfc_set_low_water_str,
6955 (void *)&cmd_lfc_set_low_water,
6956 (void *)&cmd_lfc_set_portid,
6961 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6962 .f = cmd_link_flow_ctrl_set_parsed,
6963 .data = (void *)&cmd_link_flow_control_set_pt,
6964 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6965 "Change pause time flow control parameter",
6967 (void *)&cmd_lfc_set_set,
6968 (void *)&cmd_lfc_set_flow_ctrl,
6969 (void *)&cmd_lfc_set_pause_time_str,
6970 (void *)&cmd_lfc_set_pause_time,
6971 (void *)&cmd_lfc_set_portid,
6976 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6977 .f = cmd_link_flow_ctrl_set_parsed,
6978 .data = (void *)&cmd_link_flow_control_set_xon,
6979 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6980 "Change send_xon flow control parameter",
6982 (void *)&cmd_lfc_set_set,
6983 (void *)&cmd_lfc_set_flow_ctrl,
6984 (void *)&cmd_lfc_set_send_xon_str,
6985 (void *)&cmd_lfc_set_send_xon,
6986 (void *)&cmd_lfc_set_portid,
6991 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6992 .f = cmd_link_flow_ctrl_set_parsed,
6993 .data = (void *)&cmd_link_flow_control_set_macfwd,
6994 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6995 "Change mac ctrl fwd flow control parameter",
6997 (void *)&cmd_lfc_set_set,
6998 (void *)&cmd_lfc_set_flow_ctrl,
6999 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7000 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7001 (void *)&cmd_lfc_set_portid,
7006 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7007 .f = cmd_link_flow_ctrl_set_parsed,
7008 .data = (void *)&cmd_link_flow_control_set_autoneg,
7009 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7010 "Change autoneg flow control parameter",
7012 (void *)&cmd_lfc_set_set,
7013 (void *)&cmd_lfc_set_flow_ctrl,
7014 (void *)&cmd_lfc_set_autoneg_str,
7015 (void *)&cmd_lfc_set_autoneg,
7016 (void *)&cmd_lfc_set_portid,
7022 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7023 __rte_unused struct cmdline *cl,
7026 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7027 cmdline_parse_inst_t *cmd = data;
7028 struct rte_eth_fc_conf fc_conf;
7034 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7035 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7036 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7037 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7039 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7040 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7043 /* Partial command line, retrieve current configuration */
7045 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7047 printf("cannot get current flow ctrl parameters, return"
7048 "code = %d\n", ret);
7052 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7053 (fc_conf.mode == RTE_FC_FULL))
7055 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7056 (fc_conf.mode == RTE_FC_FULL))
7060 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7061 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7063 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7064 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7066 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7068 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7069 fc_conf.high_water = res->high_water;
7071 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7072 fc_conf.low_water = res->low_water;
7074 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7075 fc_conf.pause_time = res->pause_time;
7077 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7078 fc_conf.send_xon = res->send_xon;
7080 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7081 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7082 fc_conf.mac_ctrl_frame_fwd = 1;
7084 fc_conf.mac_ctrl_frame_fwd = 0;
7087 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7088 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7090 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7092 printf("bad flow contrl parameter, return code = %d \n", ret);
7095 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7096 struct cmd_priority_flow_ctrl_set_result {
7097 cmdline_fixed_string_t set;
7098 cmdline_fixed_string_t pfc_ctrl;
7099 cmdline_fixed_string_t rx;
7100 cmdline_fixed_string_t rx_pfc_mode;
7101 cmdline_fixed_string_t tx;
7102 cmdline_fixed_string_t tx_pfc_mode;
7103 uint32_t high_water;
7105 uint16_t pause_time;
7111 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7112 __rte_unused struct cmdline *cl,
7113 __rte_unused void *data)
7115 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7116 struct rte_eth_pfc_conf pfc_conf;
7117 int rx_fc_enable, tx_fc_enable;
7121 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7122 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7123 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7124 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7126 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7127 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7130 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7131 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7132 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7133 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7134 pfc_conf.fc.high_water = res->high_water;
7135 pfc_conf.fc.low_water = res->low_water;
7136 pfc_conf.fc.pause_time = res->pause_time;
7137 pfc_conf.priority = res->priority;
7139 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7141 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7144 cmdline_parse_token_string_t cmd_pfc_set_set =
7145 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7147 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7148 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7149 pfc_ctrl, "pfc_ctrl");
7150 cmdline_parse_token_string_t cmd_pfc_set_rx =
7151 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7153 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7154 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7155 rx_pfc_mode, "on#off");
7156 cmdline_parse_token_string_t cmd_pfc_set_tx =
7157 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7159 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7160 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7161 tx_pfc_mode, "on#off");
7162 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7163 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7164 high_water, UINT32);
7165 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7166 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7168 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7169 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7170 pause_time, UINT16);
7171 cmdline_parse_token_num_t cmd_pfc_set_priority =
7172 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7174 cmdline_parse_token_num_t cmd_pfc_set_portid =
7175 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7178 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7179 .f = cmd_priority_flow_ctrl_set_parsed,
7181 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7182 "<pause_time> <priority> <port_id>: "
7183 "Configure the Ethernet priority flow control",
7185 (void *)&cmd_pfc_set_set,
7186 (void *)&cmd_pfc_set_flow_ctrl,
7187 (void *)&cmd_pfc_set_rx,
7188 (void *)&cmd_pfc_set_rx_mode,
7189 (void *)&cmd_pfc_set_tx,
7190 (void *)&cmd_pfc_set_tx_mode,
7191 (void *)&cmd_pfc_set_high_water,
7192 (void *)&cmd_pfc_set_low_water,
7193 (void *)&cmd_pfc_set_pause_time,
7194 (void *)&cmd_pfc_set_priority,
7195 (void *)&cmd_pfc_set_portid,
7200 /* *** RESET CONFIGURATION *** */
7201 struct cmd_reset_result {
7202 cmdline_fixed_string_t reset;
7203 cmdline_fixed_string_t def;
7206 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7208 __rte_unused void *data)
7210 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7211 set_def_fwd_config();
7214 cmdline_parse_token_string_t cmd_reset_set =
7215 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7216 cmdline_parse_token_string_t cmd_reset_def =
7217 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7220 cmdline_parse_inst_t cmd_reset = {
7221 .f = cmd_reset_parsed,
7223 .help_str = "set default: Reset default forwarding configuration",
7225 (void *)&cmd_reset_set,
7226 (void *)&cmd_reset_def,
7231 /* *** START FORWARDING *** */
7232 struct cmd_start_result {
7233 cmdline_fixed_string_t start;
7236 cmdline_parse_token_string_t cmd_start_start =
7237 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7239 static void cmd_start_parsed(__rte_unused void *parsed_result,
7240 __rte_unused struct cmdline *cl,
7241 __rte_unused void *data)
7243 start_packet_forwarding(0);
7246 cmdline_parse_inst_t cmd_start = {
7247 .f = cmd_start_parsed,
7249 .help_str = "start: Start packet forwarding",
7251 (void *)&cmd_start_start,
7256 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7257 struct cmd_start_tx_first_result {
7258 cmdline_fixed_string_t start;
7259 cmdline_fixed_string_t tx_first;
7263 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7264 __rte_unused struct cmdline *cl,
7265 __rte_unused void *data)
7267 start_packet_forwarding(1);
7270 cmdline_parse_token_string_t cmd_start_tx_first_start =
7271 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7273 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7274 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7275 tx_first, "tx_first");
7277 cmdline_parse_inst_t cmd_start_tx_first = {
7278 .f = cmd_start_tx_first_parsed,
7280 .help_str = "start tx_first: Start packet forwarding, "
7281 "after sending 1 burst of packets",
7283 (void *)&cmd_start_tx_first_start,
7284 (void *)&cmd_start_tx_first_tx_first,
7289 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7290 struct cmd_start_tx_first_n_result {
7291 cmdline_fixed_string_t start;
7292 cmdline_fixed_string_t tx_first;
7297 cmd_start_tx_first_n_parsed(void *parsed_result,
7298 __rte_unused struct cmdline *cl,
7299 __rte_unused void *data)
7301 struct cmd_start_tx_first_n_result *res = parsed_result;
7303 start_packet_forwarding(res->tx_num);
7306 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7307 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7309 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7310 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7311 tx_first, "tx_first");
7312 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7313 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7316 cmdline_parse_inst_t cmd_start_tx_first_n = {
7317 .f = cmd_start_tx_first_n_parsed,
7319 .help_str = "start tx_first <num>: "
7320 "packet forwarding, after sending <num> bursts of packets",
7322 (void *)&cmd_start_tx_first_n_start,
7323 (void *)&cmd_start_tx_first_n_tx_first,
7324 (void *)&cmd_start_tx_first_n_tx_num,
7329 /* *** SET LINK UP *** */
7330 struct cmd_set_link_up_result {
7331 cmdline_fixed_string_t set;
7332 cmdline_fixed_string_t link_up;
7333 cmdline_fixed_string_t port;
7337 cmdline_parse_token_string_t cmd_set_link_up_set =
7338 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7339 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7340 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7342 cmdline_parse_token_string_t cmd_set_link_up_port =
7343 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7344 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7345 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7347 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7348 __rte_unused struct cmdline *cl,
7349 __rte_unused void *data)
7351 struct cmd_set_link_up_result *res = parsed_result;
7352 dev_set_link_up(res->port_id);
7355 cmdline_parse_inst_t cmd_set_link_up = {
7356 .f = cmd_set_link_up_parsed,
7358 .help_str = "set link-up port <port id>",
7360 (void *)&cmd_set_link_up_set,
7361 (void *)&cmd_set_link_up_link_up,
7362 (void *)&cmd_set_link_up_port,
7363 (void *)&cmd_set_link_up_port_id,
7368 /* *** SET LINK DOWN *** */
7369 struct cmd_set_link_down_result {
7370 cmdline_fixed_string_t set;
7371 cmdline_fixed_string_t link_down;
7372 cmdline_fixed_string_t port;
7376 cmdline_parse_token_string_t cmd_set_link_down_set =
7377 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7378 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7379 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7381 cmdline_parse_token_string_t cmd_set_link_down_port =
7382 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7383 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7384 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7386 static void cmd_set_link_down_parsed(
7387 __rte_unused void *parsed_result,
7388 __rte_unused struct cmdline *cl,
7389 __rte_unused void *data)
7391 struct cmd_set_link_down_result *res = parsed_result;
7392 dev_set_link_down(res->port_id);
7395 cmdline_parse_inst_t cmd_set_link_down = {
7396 .f = cmd_set_link_down_parsed,
7398 .help_str = "set link-down port <port id>",
7400 (void *)&cmd_set_link_down_set,
7401 (void *)&cmd_set_link_down_link_down,
7402 (void *)&cmd_set_link_down_port,
7403 (void *)&cmd_set_link_down_port_id,
7408 /* *** SHOW CFG *** */
7409 struct cmd_showcfg_result {
7410 cmdline_fixed_string_t show;
7411 cmdline_fixed_string_t cfg;
7412 cmdline_fixed_string_t what;
7415 static void cmd_showcfg_parsed(void *parsed_result,
7416 __rte_unused struct cmdline *cl,
7417 __rte_unused void *data)
7419 struct cmd_showcfg_result *res = parsed_result;
7420 if (!strcmp(res->what, "rxtx"))
7421 rxtx_config_display();
7422 else if (!strcmp(res->what, "cores"))
7423 fwd_lcores_config_display();
7424 else if (!strcmp(res->what, "fwd"))
7425 pkt_fwd_config_display(&cur_fwd_config);
7426 else if (!strcmp(res->what, "txpkts"))
7427 show_tx_pkt_segments();
7430 cmdline_parse_token_string_t cmd_showcfg_show =
7431 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7432 cmdline_parse_token_string_t cmd_showcfg_port =
7433 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7434 cmdline_parse_token_string_t cmd_showcfg_what =
7435 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7436 "rxtx#cores#fwd#txpkts");
7438 cmdline_parse_inst_t cmd_showcfg = {
7439 .f = cmd_showcfg_parsed,
7441 .help_str = "show config rxtx|cores|fwd|txpkts",
7443 (void *)&cmd_showcfg_show,
7444 (void *)&cmd_showcfg_port,
7445 (void *)&cmd_showcfg_what,
7450 /* *** SHOW ALL PORT INFO *** */
7451 struct cmd_showportall_result {
7452 cmdline_fixed_string_t show;
7453 cmdline_fixed_string_t port;
7454 cmdline_fixed_string_t what;
7455 cmdline_fixed_string_t all;
7458 static void cmd_showportall_parsed(void *parsed_result,
7459 __rte_unused struct cmdline *cl,
7460 __rte_unused void *data)
7464 struct cmd_showportall_result *res = parsed_result;
7465 if (!strcmp(res->show, "clear")) {
7466 if (!strcmp(res->what, "stats"))
7467 RTE_ETH_FOREACH_DEV(i)
7469 else if (!strcmp(res->what, "xstats"))
7470 RTE_ETH_FOREACH_DEV(i)
7471 nic_xstats_clear(i);
7472 } else if (!strcmp(res->what, "info"))
7473 RTE_ETH_FOREACH_DEV(i)
7474 port_infos_display(i);
7475 else if (!strcmp(res->what, "summary")) {
7476 port_summary_header_display();
7477 RTE_ETH_FOREACH_DEV(i)
7478 port_summary_display(i);
7480 else if (!strcmp(res->what, "stats"))
7481 RTE_ETH_FOREACH_DEV(i)
7482 nic_stats_display(i);
7483 else if (!strcmp(res->what, "xstats"))
7484 RTE_ETH_FOREACH_DEV(i)
7485 nic_xstats_display(i);
7486 else if (!strcmp(res->what, "fdir"))
7487 RTE_ETH_FOREACH_DEV(i)
7489 else if (!strcmp(res->what, "stat_qmap"))
7490 RTE_ETH_FOREACH_DEV(i)
7491 nic_stats_mapping_display(i);
7492 else if (!strcmp(res->what, "dcb_tc"))
7493 RTE_ETH_FOREACH_DEV(i)
7494 port_dcb_info_display(i);
7495 else if (!strcmp(res->what, "cap"))
7496 RTE_ETH_FOREACH_DEV(i)
7497 port_offload_cap_display(i);
7500 cmdline_parse_token_string_t cmd_showportall_show =
7501 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7503 cmdline_parse_token_string_t cmd_showportall_port =
7504 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7505 cmdline_parse_token_string_t cmd_showportall_what =
7506 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7507 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7508 cmdline_parse_token_string_t cmd_showportall_all =
7509 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7510 cmdline_parse_inst_t cmd_showportall = {
7511 .f = cmd_showportall_parsed,
7513 .help_str = "show|clear port "
7514 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7516 (void *)&cmd_showportall_show,
7517 (void *)&cmd_showportall_port,
7518 (void *)&cmd_showportall_what,
7519 (void *)&cmd_showportall_all,
7524 /* *** SHOW PORT INFO *** */
7525 struct cmd_showport_result {
7526 cmdline_fixed_string_t show;
7527 cmdline_fixed_string_t port;
7528 cmdline_fixed_string_t what;
7532 static void cmd_showport_parsed(void *parsed_result,
7533 __rte_unused struct cmdline *cl,
7534 __rte_unused void *data)
7536 struct cmd_showport_result *res = parsed_result;
7537 if (!strcmp(res->show, "clear")) {
7538 if (!strcmp(res->what, "stats"))
7539 nic_stats_clear(res->portnum);
7540 else if (!strcmp(res->what, "xstats"))
7541 nic_xstats_clear(res->portnum);
7542 } else if (!strcmp(res->what, "info"))
7543 port_infos_display(res->portnum);
7544 else if (!strcmp(res->what, "summary")) {
7545 port_summary_header_display();
7546 port_summary_display(res->portnum);
7548 else if (!strcmp(res->what, "stats"))
7549 nic_stats_display(res->portnum);
7550 else if (!strcmp(res->what, "xstats"))
7551 nic_xstats_display(res->portnum);
7552 else if (!strcmp(res->what, "fdir"))
7553 fdir_get_infos(res->portnum);
7554 else if (!strcmp(res->what, "stat_qmap"))
7555 nic_stats_mapping_display(res->portnum);
7556 else if (!strcmp(res->what, "dcb_tc"))
7557 port_dcb_info_display(res->portnum);
7558 else if (!strcmp(res->what, "cap"))
7559 port_offload_cap_display(res->portnum);
7562 cmdline_parse_token_string_t cmd_showport_show =
7563 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7565 cmdline_parse_token_string_t cmd_showport_port =
7566 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7567 cmdline_parse_token_string_t cmd_showport_what =
7568 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7569 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7570 cmdline_parse_token_num_t cmd_showport_portnum =
7571 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7573 cmdline_parse_inst_t cmd_showport = {
7574 .f = cmd_showport_parsed,
7576 .help_str = "show|clear port "
7577 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7580 (void *)&cmd_showport_show,
7581 (void *)&cmd_showport_port,
7582 (void *)&cmd_showport_what,
7583 (void *)&cmd_showport_portnum,
7588 /* *** SHOW DEVICE INFO *** */
7589 struct cmd_showdevice_result {
7590 cmdline_fixed_string_t show;
7591 cmdline_fixed_string_t device;
7592 cmdline_fixed_string_t what;
7593 cmdline_fixed_string_t identifier;
7596 static void cmd_showdevice_parsed(void *parsed_result,
7597 __rte_unused struct cmdline *cl,
7598 __rte_unused void *data)
7600 struct cmd_showdevice_result *res = parsed_result;
7601 if (!strcmp(res->what, "info")) {
7602 if (!strcmp(res->identifier, "all"))
7603 device_infos_display(NULL);
7605 device_infos_display(res->identifier);
7609 cmdline_parse_token_string_t cmd_showdevice_show =
7610 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7612 cmdline_parse_token_string_t cmd_showdevice_device =
7613 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7614 cmdline_parse_token_string_t cmd_showdevice_what =
7615 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7617 cmdline_parse_token_string_t cmd_showdevice_identifier =
7618 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7621 cmdline_parse_inst_t cmd_showdevice = {
7622 .f = cmd_showdevice_parsed,
7624 .help_str = "show device info <identifier>|all",
7626 (void *)&cmd_showdevice_show,
7627 (void *)&cmd_showdevice_device,
7628 (void *)&cmd_showdevice_what,
7629 (void *)&cmd_showdevice_identifier,
7633 /* *** SHOW QUEUE INFO *** */
7634 struct cmd_showqueue_result {
7635 cmdline_fixed_string_t show;
7636 cmdline_fixed_string_t type;
7637 cmdline_fixed_string_t what;
7643 cmd_showqueue_parsed(void *parsed_result,
7644 __rte_unused struct cmdline *cl,
7645 __rte_unused void *data)
7647 struct cmd_showqueue_result *res = parsed_result;
7649 if (!strcmp(res->type, "rxq"))
7650 rx_queue_infos_display(res->portnum, res->queuenum);
7651 else if (!strcmp(res->type, "txq"))
7652 tx_queue_infos_display(res->portnum, res->queuenum);
7655 cmdline_parse_token_string_t cmd_showqueue_show =
7656 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7657 cmdline_parse_token_string_t cmd_showqueue_type =
7658 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7659 cmdline_parse_token_string_t cmd_showqueue_what =
7660 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7661 cmdline_parse_token_num_t cmd_showqueue_portnum =
7662 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7663 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7664 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7666 cmdline_parse_inst_t cmd_showqueue = {
7667 .f = cmd_showqueue_parsed,
7669 .help_str = "show rxq|txq info <port_id> <queue_id>",
7671 (void *)&cmd_showqueue_show,
7672 (void *)&cmd_showqueue_type,
7673 (void *)&cmd_showqueue_what,
7674 (void *)&cmd_showqueue_portnum,
7675 (void *)&cmd_showqueue_queuenum,
7680 /* show/clear fwd engine statistics */
7682 cmdline_fixed_string_t action;
7683 cmdline_fixed_string_t fwd;
7684 cmdline_fixed_string_t stats;
7685 cmdline_fixed_string_t all;
7688 cmdline_parse_token_string_t cmd_fwd_action =
7689 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7690 cmdline_parse_token_string_t cmd_fwd_fwd =
7691 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7692 cmdline_parse_token_string_t cmd_fwd_stats =
7693 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7694 cmdline_parse_token_string_t cmd_fwd_all =
7695 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7698 cmd_showfwdall_parsed(void *parsed_result,
7699 __rte_unused struct cmdline *cl,
7700 __rte_unused void *data)
7702 struct fwd_result *res = parsed_result;
7704 if (!strcmp(res->action, "show"))
7705 fwd_stats_display();
7710 static cmdline_parse_inst_t cmd_showfwdall = {
7711 .f = cmd_showfwdall_parsed,
7713 .help_str = "show|clear fwd stats all",
7715 (void *)&cmd_fwd_action,
7716 (void *)&cmd_fwd_fwd,
7717 (void *)&cmd_fwd_stats,
7718 (void *)&cmd_fwd_all,
7723 /* *** READ PORT REGISTER *** */
7724 struct cmd_read_reg_result {
7725 cmdline_fixed_string_t read;
7726 cmdline_fixed_string_t reg;
7732 cmd_read_reg_parsed(void *parsed_result,
7733 __rte_unused struct cmdline *cl,
7734 __rte_unused void *data)
7736 struct cmd_read_reg_result *res = parsed_result;
7737 port_reg_display(res->port_id, res->reg_off);
7740 cmdline_parse_token_string_t cmd_read_reg_read =
7741 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7742 cmdline_parse_token_string_t cmd_read_reg_reg =
7743 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7744 cmdline_parse_token_num_t cmd_read_reg_port_id =
7745 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7746 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7747 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7749 cmdline_parse_inst_t cmd_read_reg = {
7750 .f = cmd_read_reg_parsed,
7752 .help_str = "read reg <port_id> <reg_off>",
7754 (void *)&cmd_read_reg_read,
7755 (void *)&cmd_read_reg_reg,
7756 (void *)&cmd_read_reg_port_id,
7757 (void *)&cmd_read_reg_reg_off,
7762 /* *** READ PORT REGISTER BIT FIELD *** */
7763 struct cmd_read_reg_bit_field_result {
7764 cmdline_fixed_string_t read;
7765 cmdline_fixed_string_t regfield;
7773 cmd_read_reg_bit_field_parsed(void *parsed_result,
7774 __rte_unused struct cmdline *cl,
7775 __rte_unused void *data)
7777 struct cmd_read_reg_bit_field_result *res = parsed_result;
7778 port_reg_bit_field_display(res->port_id, res->reg_off,
7779 res->bit1_pos, res->bit2_pos);
7782 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7783 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7785 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7786 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7787 regfield, "regfield");
7788 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7789 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7791 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7792 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7794 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7795 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7797 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7798 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7801 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7802 .f = cmd_read_reg_bit_field_parsed,
7804 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7805 "Read register bit field between bit_x and bit_y included",
7807 (void *)&cmd_read_reg_bit_field_read,
7808 (void *)&cmd_read_reg_bit_field_regfield,
7809 (void *)&cmd_read_reg_bit_field_port_id,
7810 (void *)&cmd_read_reg_bit_field_reg_off,
7811 (void *)&cmd_read_reg_bit_field_bit1_pos,
7812 (void *)&cmd_read_reg_bit_field_bit2_pos,
7817 /* *** READ PORT REGISTER BIT *** */
7818 struct cmd_read_reg_bit_result {
7819 cmdline_fixed_string_t read;
7820 cmdline_fixed_string_t regbit;
7827 cmd_read_reg_bit_parsed(void *parsed_result,
7828 __rte_unused struct cmdline *cl,
7829 __rte_unused void *data)
7831 struct cmd_read_reg_bit_result *res = parsed_result;
7832 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7835 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7836 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7837 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7838 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7840 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7841 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7842 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7843 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7844 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7845 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7847 cmdline_parse_inst_t cmd_read_reg_bit = {
7848 .f = cmd_read_reg_bit_parsed,
7850 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7852 (void *)&cmd_read_reg_bit_read,
7853 (void *)&cmd_read_reg_bit_regbit,
7854 (void *)&cmd_read_reg_bit_port_id,
7855 (void *)&cmd_read_reg_bit_reg_off,
7856 (void *)&cmd_read_reg_bit_bit_pos,
7861 /* *** WRITE PORT REGISTER *** */
7862 struct cmd_write_reg_result {
7863 cmdline_fixed_string_t write;
7864 cmdline_fixed_string_t reg;
7871 cmd_write_reg_parsed(void *parsed_result,
7872 __rte_unused struct cmdline *cl,
7873 __rte_unused void *data)
7875 struct cmd_write_reg_result *res = parsed_result;
7876 port_reg_set(res->port_id, res->reg_off, res->value);
7879 cmdline_parse_token_string_t cmd_write_reg_write =
7880 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7881 cmdline_parse_token_string_t cmd_write_reg_reg =
7882 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7883 cmdline_parse_token_num_t cmd_write_reg_port_id =
7884 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7885 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7886 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7887 cmdline_parse_token_num_t cmd_write_reg_value =
7888 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7890 cmdline_parse_inst_t cmd_write_reg = {
7891 .f = cmd_write_reg_parsed,
7893 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7895 (void *)&cmd_write_reg_write,
7896 (void *)&cmd_write_reg_reg,
7897 (void *)&cmd_write_reg_port_id,
7898 (void *)&cmd_write_reg_reg_off,
7899 (void *)&cmd_write_reg_value,
7904 /* *** WRITE PORT REGISTER BIT FIELD *** */
7905 struct cmd_write_reg_bit_field_result {
7906 cmdline_fixed_string_t write;
7907 cmdline_fixed_string_t regfield;
7916 cmd_write_reg_bit_field_parsed(void *parsed_result,
7917 __rte_unused struct cmdline *cl,
7918 __rte_unused void *data)
7920 struct cmd_write_reg_bit_field_result *res = parsed_result;
7921 port_reg_bit_field_set(res->port_id, res->reg_off,
7922 res->bit1_pos, res->bit2_pos, res->value);
7925 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7926 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7928 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7929 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7930 regfield, "regfield");
7931 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7932 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7934 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7935 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7937 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7938 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7940 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7941 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7943 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7944 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7947 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7948 .f = cmd_write_reg_bit_field_parsed,
7950 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7952 "Set register bit field between bit_x and bit_y included",
7954 (void *)&cmd_write_reg_bit_field_write,
7955 (void *)&cmd_write_reg_bit_field_regfield,
7956 (void *)&cmd_write_reg_bit_field_port_id,
7957 (void *)&cmd_write_reg_bit_field_reg_off,
7958 (void *)&cmd_write_reg_bit_field_bit1_pos,
7959 (void *)&cmd_write_reg_bit_field_bit2_pos,
7960 (void *)&cmd_write_reg_bit_field_value,
7965 /* *** WRITE PORT REGISTER BIT *** */
7966 struct cmd_write_reg_bit_result {
7967 cmdline_fixed_string_t write;
7968 cmdline_fixed_string_t regbit;
7976 cmd_write_reg_bit_parsed(void *parsed_result,
7977 __rte_unused struct cmdline *cl,
7978 __rte_unused void *data)
7980 struct cmd_write_reg_bit_result *res = parsed_result;
7981 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7984 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7985 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7987 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7988 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7990 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7991 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7992 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7993 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7994 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7995 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7996 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7997 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7999 cmdline_parse_inst_t cmd_write_reg_bit = {
8000 .f = cmd_write_reg_bit_parsed,
8002 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8005 (void *)&cmd_write_reg_bit_write,
8006 (void *)&cmd_write_reg_bit_regbit,
8007 (void *)&cmd_write_reg_bit_port_id,
8008 (void *)&cmd_write_reg_bit_reg_off,
8009 (void *)&cmd_write_reg_bit_bit_pos,
8010 (void *)&cmd_write_reg_bit_value,
8015 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8016 struct cmd_read_rxd_txd_result {
8017 cmdline_fixed_string_t read;
8018 cmdline_fixed_string_t rxd_txd;
8025 cmd_read_rxd_txd_parsed(void *parsed_result,
8026 __rte_unused struct cmdline *cl,
8027 __rte_unused void *data)
8029 struct cmd_read_rxd_txd_result *res = parsed_result;
8031 if (!strcmp(res->rxd_txd, "rxd"))
8032 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8033 else if (!strcmp(res->rxd_txd, "txd"))
8034 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8037 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8038 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8039 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8040 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8042 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8043 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8044 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8045 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8046 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8047 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8049 cmdline_parse_inst_t cmd_read_rxd_txd = {
8050 .f = cmd_read_rxd_txd_parsed,
8052 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8054 (void *)&cmd_read_rxd_txd_read,
8055 (void *)&cmd_read_rxd_txd_rxd_txd,
8056 (void *)&cmd_read_rxd_txd_port_id,
8057 (void *)&cmd_read_rxd_txd_queue_id,
8058 (void *)&cmd_read_rxd_txd_desc_id,
8064 struct cmd_quit_result {
8065 cmdline_fixed_string_t quit;
8068 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8070 __rte_unused void *data)
8075 cmdline_parse_token_string_t cmd_quit_quit =
8076 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8078 cmdline_parse_inst_t cmd_quit = {
8079 .f = cmd_quit_parsed,
8081 .help_str = "quit: Exit application",
8083 (void *)&cmd_quit_quit,
8088 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8089 struct cmd_mac_addr_result {
8090 cmdline_fixed_string_t mac_addr_cmd;
8091 cmdline_fixed_string_t what;
8093 struct rte_ether_addr address;
8096 static void cmd_mac_addr_parsed(void *parsed_result,
8097 __rte_unused struct cmdline *cl,
8098 __rte_unused void *data)
8100 struct cmd_mac_addr_result *res = parsed_result;
8103 if (strcmp(res->what, "add") == 0)
8104 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8105 else if (strcmp(res->what, "set") == 0)
8106 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8109 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8111 /* check the return value and print it if is < 0 */
8113 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8117 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8118 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8120 cmdline_parse_token_string_t cmd_mac_addr_what =
8121 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8123 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8124 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8126 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8127 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8129 cmdline_parse_inst_t cmd_mac_addr = {
8130 .f = cmd_mac_addr_parsed,
8132 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8133 "Add/Remove/Set MAC address on port_id",
8135 (void *)&cmd_mac_addr_cmd,
8136 (void *)&cmd_mac_addr_what,
8137 (void *)&cmd_mac_addr_portnum,
8138 (void *)&cmd_mac_addr_addr,
8143 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8144 struct cmd_eth_peer_result {
8145 cmdline_fixed_string_t set;
8146 cmdline_fixed_string_t eth_peer;
8148 cmdline_fixed_string_t peer_addr;
8151 static void cmd_set_eth_peer_parsed(void *parsed_result,
8152 __rte_unused struct cmdline *cl,
8153 __rte_unused void *data)
8155 struct cmd_eth_peer_result *res = parsed_result;
8157 if (test_done == 0) {
8158 printf("Please stop forwarding first\n");
8161 if (!strcmp(res->eth_peer, "eth-peer")) {
8162 set_fwd_eth_peer(res->port_id, res->peer_addr);
8166 cmdline_parse_token_string_t cmd_eth_peer_set =
8167 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8168 cmdline_parse_token_string_t cmd_eth_peer =
8169 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8170 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8171 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8172 cmdline_parse_token_string_t cmd_eth_peer_addr =
8173 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8175 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8176 .f = cmd_set_eth_peer_parsed,
8178 .help_str = "set eth-peer <port_id> <peer_mac>",
8180 (void *)&cmd_eth_peer_set,
8181 (void *)&cmd_eth_peer,
8182 (void *)&cmd_eth_peer_port_id,
8183 (void *)&cmd_eth_peer_addr,
8188 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8189 struct cmd_set_qmap_result {
8190 cmdline_fixed_string_t set;
8191 cmdline_fixed_string_t qmap;
8192 cmdline_fixed_string_t what;
8199 cmd_set_qmap_parsed(void *parsed_result,
8200 __rte_unused struct cmdline *cl,
8201 __rte_unused void *data)
8203 struct cmd_set_qmap_result *res = parsed_result;
8204 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8206 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8209 cmdline_parse_token_string_t cmd_setqmap_set =
8210 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8212 cmdline_parse_token_string_t cmd_setqmap_qmap =
8213 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8215 cmdline_parse_token_string_t cmd_setqmap_what =
8216 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8218 cmdline_parse_token_num_t cmd_setqmap_portid =
8219 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8221 cmdline_parse_token_num_t cmd_setqmap_queueid =
8222 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8224 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8225 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8228 cmdline_parse_inst_t cmd_set_qmap = {
8229 .f = cmd_set_qmap_parsed,
8231 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8232 "Set statistics mapping value on tx|rx queue_id of port_id",
8234 (void *)&cmd_setqmap_set,
8235 (void *)&cmd_setqmap_qmap,
8236 (void *)&cmd_setqmap_what,
8237 (void *)&cmd_setqmap_portid,
8238 (void *)&cmd_setqmap_queueid,
8239 (void *)&cmd_setqmap_mapvalue,
8244 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8245 struct cmd_set_xstats_hide_zero_result {
8246 cmdline_fixed_string_t keyword;
8247 cmdline_fixed_string_t name;
8248 cmdline_fixed_string_t on_off;
8252 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8253 __rte_unused struct cmdline *cl,
8254 __rte_unused void *data)
8256 struct cmd_set_xstats_hide_zero_result *res;
8257 uint16_t on_off = 0;
8259 res = parsed_result;
8260 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8261 set_xstats_hide_zero(on_off);
8264 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8265 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8267 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8268 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8269 name, "xstats-hide-zero");
8270 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8271 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8274 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8275 .f = cmd_set_xstats_hide_zero_parsed,
8277 .help_str = "set xstats-hide-zero on|off",
8279 (void *)&cmd_set_xstats_hide_zero_keyword,
8280 (void *)&cmd_set_xstats_hide_zero_name,
8281 (void *)&cmd_set_xstats_hide_zero_on_off,
8286 /* *** CONFIGURE UNICAST HASH TABLE *** */
8287 struct cmd_set_uc_hash_table {
8288 cmdline_fixed_string_t set;
8289 cmdline_fixed_string_t port;
8291 cmdline_fixed_string_t what;
8292 struct rte_ether_addr address;
8293 cmdline_fixed_string_t mode;
8297 cmd_set_uc_hash_parsed(void *parsed_result,
8298 __rte_unused struct cmdline *cl,
8299 __rte_unused void *data)
8302 struct cmd_set_uc_hash_table *res = parsed_result;
8304 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8306 if (strcmp(res->what, "uta") == 0)
8307 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8308 &res->address,(uint8_t)is_on);
8310 printf("bad unicast hash table parameter, return code = %d \n", ret);
8314 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8315 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8317 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8318 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8320 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8321 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8323 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8324 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8326 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8327 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8329 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8330 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8333 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8334 .f = cmd_set_uc_hash_parsed,
8336 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8338 (void *)&cmd_set_uc_hash_set,
8339 (void *)&cmd_set_uc_hash_port,
8340 (void *)&cmd_set_uc_hash_portid,
8341 (void *)&cmd_set_uc_hash_what,
8342 (void *)&cmd_set_uc_hash_mac,
8343 (void *)&cmd_set_uc_hash_mode,
8348 struct cmd_set_uc_all_hash_table {
8349 cmdline_fixed_string_t set;
8350 cmdline_fixed_string_t port;
8352 cmdline_fixed_string_t what;
8353 cmdline_fixed_string_t value;
8354 cmdline_fixed_string_t mode;
8358 cmd_set_uc_all_hash_parsed(void *parsed_result,
8359 __rte_unused struct cmdline *cl,
8360 __rte_unused void *data)
8363 struct cmd_set_uc_all_hash_table *res = parsed_result;
8365 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8367 if ((strcmp(res->what, "uta") == 0) &&
8368 (strcmp(res->value, "all") == 0))
8369 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8371 printf("bad unicast hash table parameter,"
8372 "return code = %d \n", ret);
8375 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8376 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8378 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8379 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8381 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8382 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8384 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8385 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8387 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8388 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8390 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8391 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8394 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8395 .f = cmd_set_uc_all_hash_parsed,
8397 .help_str = "set port <port_id> uta all on|off",
8399 (void *)&cmd_set_uc_all_hash_set,
8400 (void *)&cmd_set_uc_all_hash_port,
8401 (void *)&cmd_set_uc_all_hash_portid,
8402 (void *)&cmd_set_uc_all_hash_what,
8403 (void *)&cmd_set_uc_all_hash_value,
8404 (void *)&cmd_set_uc_all_hash_mode,
8409 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8410 struct cmd_set_vf_macvlan_filter {
8411 cmdline_fixed_string_t set;
8412 cmdline_fixed_string_t port;
8414 cmdline_fixed_string_t vf;
8416 struct rte_ether_addr address;
8417 cmdline_fixed_string_t filter_type;
8418 cmdline_fixed_string_t mode;
8422 cmd_set_vf_macvlan_parsed(void *parsed_result,
8423 __rte_unused struct cmdline *cl,
8424 __rte_unused void *data)
8427 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8428 struct rte_eth_mac_filter filter;
8430 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8432 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8434 /* set VF MAC filter */
8438 filter.dst_id = res->vf_id;
8440 if (!strcmp(res->filter_type, "exact-mac"))
8441 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8442 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8443 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8444 else if (!strcmp(res->filter_type, "hashmac"))
8445 filter.filter_type = RTE_MAC_HASH_MATCH;
8446 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8447 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8449 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8452 ret = rte_eth_dev_filter_ctrl(res->port_id,
8453 RTE_ETH_FILTER_MACVLAN,
8457 ret = rte_eth_dev_filter_ctrl(res->port_id,
8458 RTE_ETH_FILTER_MACVLAN,
8459 RTE_ETH_FILTER_DELETE,
8463 printf("bad set MAC hash parameter, return code = %d\n", ret);
8467 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8468 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8470 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8471 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8473 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8474 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8476 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8477 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8479 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8480 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8482 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8483 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8485 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8486 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8487 filter_type, "exact-mac#exact-mac-vlan"
8488 "#hashmac#hashmac-vlan");
8489 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8490 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8493 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8494 .f = cmd_set_vf_macvlan_parsed,
8496 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8497 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8498 "Exact match rule: exact match of MAC or MAC and VLAN; "
8499 "hash match rule: hash match of MAC and exact match of VLAN",
8501 (void *)&cmd_set_vf_macvlan_set,
8502 (void *)&cmd_set_vf_macvlan_port,
8503 (void *)&cmd_set_vf_macvlan_portid,
8504 (void *)&cmd_set_vf_macvlan_vf,
8505 (void *)&cmd_set_vf_macvlan_vf_id,
8506 (void *)&cmd_set_vf_macvlan_mac,
8507 (void *)&cmd_set_vf_macvlan_filter_type,
8508 (void *)&cmd_set_vf_macvlan_mode,
8513 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8514 struct cmd_set_vf_traffic {
8515 cmdline_fixed_string_t set;
8516 cmdline_fixed_string_t port;
8518 cmdline_fixed_string_t vf;
8520 cmdline_fixed_string_t what;
8521 cmdline_fixed_string_t mode;
8525 cmd_set_vf_traffic_parsed(void *parsed_result,
8526 __rte_unused struct cmdline *cl,
8527 __rte_unused void *data)
8529 struct cmd_set_vf_traffic *res = parsed_result;
8530 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8531 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8533 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8536 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8537 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8539 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8540 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8542 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8543 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8545 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8546 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8548 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8549 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8551 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8552 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8554 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8555 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8558 cmdline_parse_inst_t cmd_set_vf_traffic = {
8559 .f = cmd_set_vf_traffic_parsed,
8561 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8563 (void *)&cmd_setvf_traffic_set,
8564 (void *)&cmd_setvf_traffic_port,
8565 (void *)&cmd_setvf_traffic_portid,
8566 (void *)&cmd_setvf_traffic_vf,
8567 (void *)&cmd_setvf_traffic_vfid,
8568 (void *)&cmd_setvf_traffic_what,
8569 (void *)&cmd_setvf_traffic_mode,
8574 /* *** CONFIGURE VF RECEIVE MODE *** */
8575 struct cmd_set_vf_rxmode {
8576 cmdline_fixed_string_t set;
8577 cmdline_fixed_string_t port;
8579 cmdline_fixed_string_t vf;
8581 cmdline_fixed_string_t what;
8582 cmdline_fixed_string_t mode;
8583 cmdline_fixed_string_t on;
8587 cmd_set_vf_rxmode_parsed(void *parsed_result,
8588 __rte_unused struct cmdline *cl,
8589 __rte_unused void *data)
8592 uint16_t vf_rxmode = 0;
8593 struct cmd_set_vf_rxmode *res = parsed_result;
8595 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8596 if (!strcmp(res->what,"rxmode")) {
8597 if (!strcmp(res->mode, "AUPE"))
8598 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8599 else if (!strcmp(res->mode, "ROPE"))
8600 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8601 else if (!strcmp(res->mode, "BAM"))
8602 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8603 else if (!strncmp(res->mode, "MPE",3))
8604 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8607 RTE_SET_USED(is_on);
8609 #ifdef RTE_LIBRTE_IXGBE_PMD
8610 if (ret == -ENOTSUP)
8611 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8612 vf_rxmode, (uint8_t)is_on);
8614 #ifdef RTE_LIBRTE_BNXT_PMD
8615 if (ret == -ENOTSUP)
8616 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8617 vf_rxmode, (uint8_t)is_on);
8620 printf("bad VF receive mode parameter, return code = %d \n",
8624 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8625 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8627 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8628 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8630 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8631 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8633 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8634 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8636 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8637 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8639 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8640 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8642 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8643 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8644 mode, "AUPE#ROPE#BAM#MPE");
8645 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8646 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8649 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8650 .f = cmd_set_vf_rxmode_parsed,
8652 .help_str = "set port <port_id> vf <vf_id> rxmode "
8653 "AUPE|ROPE|BAM|MPE on|off",
8655 (void *)&cmd_set_vf_rxmode_set,
8656 (void *)&cmd_set_vf_rxmode_port,
8657 (void *)&cmd_set_vf_rxmode_portid,
8658 (void *)&cmd_set_vf_rxmode_vf,
8659 (void *)&cmd_set_vf_rxmode_vfid,
8660 (void *)&cmd_set_vf_rxmode_what,
8661 (void *)&cmd_set_vf_rxmode_mode,
8662 (void *)&cmd_set_vf_rxmode_on,
8667 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8668 struct cmd_vf_mac_addr_result {
8669 cmdline_fixed_string_t mac_addr_cmd;
8670 cmdline_fixed_string_t what;
8671 cmdline_fixed_string_t port;
8673 cmdline_fixed_string_t vf;
8675 struct rte_ether_addr address;
8678 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8679 __rte_unused struct cmdline *cl,
8680 __rte_unused void *data)
8682 struct cmd_vf_mac_addr_result *res = parsed_result;
8685 if (strcmp(res->what, "add") != 0)
8688 #ifdef RTE_LIBRTE_I40E_PMD
8689 if (ret == -ENOTSUP)
8690 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8693 #ifdef RTE_LIBRTE_BNXT_PMD
8694 if (ret == -ENOTSUP)
8695 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8700 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8704 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8705 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8706 mac_addr_cmd,"mac_addr");
8707 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8708 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8710 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8711 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8713 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8714 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8716 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8717 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8719 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8720 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8722 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8723 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8726 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8727 .f = cmd_vf_mac_addr_parsed,
8729 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8730 "Add MAC address filtering for a VF on port_id",
8732 (void *)&cmd_vf_mac_addr_cmd,
8733 (void *)&cmd_vf_mac_addr_what,
8734 (void *)&cmd_vf_mac_addr_port,
8735 (void *)&cmd_vf_mac_addr_portnum,
8736 (void *)&cmd_vf_mac_addr_vf,
8737 (void *)&cmd_vf_mac_addr_vfnum,
8738 (void *)&cmd_vf_mac_addr_addr,
8743 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8744 struct cmd_vf_rx_vlan_filter {
8745 cmdline_fixed_string_t rx_vlan;
8746 cmdline_fixed_string_t what;
8748 cmdline_fixed_string_t port;
8750 cmdline_fixed_string_t vf;
8755 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8756 __rte_unused struct cmdline *cl,
8757 __rte_unused void *data)
8759 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8762 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8764 #ifdef RTE_LIBRTE_IXGBE_PMD
8765 if (ret == -ENOTSUP)
8766 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8767 res->vlan_id, res->vf_mask, is_add);
8769 #ifdef RTE_LIBRTE_I40E_PMD
8770 if (ret == -ENOTSUP)
8771 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8772 res->vlan_id, res->vf_mask, is_add);
8774 #ifdef RTE_LIBRTE_BNXT_PMD
8775 if (ret == -ENOTSUP)
8776 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8777 res->vlan_id, res->vf_mask, is_add);
8784 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8785 res->vlan_id, res->vf_mask);
8788 printf("invalid port_id %d\n", res->port_id);
8791 printf("function not implemented or supported\n");
8794 printf("programming error: (%s)\n", strerror(-ret));
8798 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8799 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8800 rx_vlan, "rx_vlan");
8801 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8802 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8804 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8805 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8807 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8808 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8810 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8811 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8813 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8814 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8816 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8817 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8820 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8821 .f = cmd_vf_rx_vlan_filter_parsed,
8823 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8824 "(vf_mask = hexadecimal VF mask)",
8826 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8827 (void *)&cmd_vf_rx_vlan_filter_what,
8828 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8829 (void *)&cmd_vf_rx_vlan_filter_port,
8830 (void *)&cmd_vf_rx_vlan_filter_portid,
8831 (void *)&cmd_vf_rx_vlan_filter_vf,
8832 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8837 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8838 struct cmd_queue_rate_limit_result {
8839 cmdline_fixed_string_t set;
8840 cmdline_fixed_string_t port;
8842 cmdline_fixed_string_t queue;
8844 cmdline_fixed_string_t rate;
8848 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8849 __rte_unused struct cmdline *cl,
8850 __rte_unused void *data)
8852 struct cmd_queue_rate_limit_result *res = parsed_result;
8855 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8856 && (strcmp(res->queue, "queue") == 0)
8857 && (strcmp(res->rate, "rate") == 0))
8858 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8861 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8865 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8866 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8868 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8869 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8871 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8872 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8874 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8875 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8877 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8878 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8880 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8881 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8883 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8884 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8887 cmdline_parse_inst_t cmd_queue_rate_limit = {
8888 .f = cmd_queue_rate_limit_parsed,
8890 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8891 "Set rate limit for a queue on port_id",
8893 (void *)&cmd_queue_rate_limit_set,
8894 (void *)&cmd_queue_rate_limit_port,
8895 (void *)&cmd_queue_rate_limit_portnum,
8896 (void *)&cmd_queue_rate_limit_queue,
8897 (void *)&cmd_queue_rate_limit_queuenum,
8898 (void *)&cmd_queue_rate_limit_rate,
8899 (void *)&cmd_queue_rate_limit_ratenum,
8904 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8905 struct cmd_vf_rate_limit_result {
8906 cmdline_fixed_string_t set;
8907 cmdline_fixed_string_t port;
8909 cmdline_fixed_string_t vf;
8911 cmdline_fixed_string_t rate;
8913 cmdline_fixed_string_t q_msk;
8917 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8918 __rte_unused struct cmdline *cl,
8919 __rte_unused void *data)
8921 struct cmd_vf_rate_limit_result *res = parsed_result;
8924 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8925 && (strcmp(res->vf, "vf") == 0)
8926 && (strcmp(res->rate, "rate") == 0)
8927 && (strcmp(res->q_msk, "queue_mask") == 0))
8928 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8929 res->rate_num, res->q_msk_val);
8931 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8935 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8936 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8938 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8939 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8941 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8942 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8944 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8945 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8947 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8948 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8950 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8951 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8953 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8954 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8956 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8957 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8958 q_msk, "queue_mask");
8959 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8960 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8963 cmdline_parse_inst_t cmd_vf_rate_limit = {
8964 .f = cmd_vf_rate_limit_parsed,
8966 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8967 "queue_mask <queue_mask_value>: "
8968 "Set rate limit for queues of VF on port_id",
8970 (void *)&cmd_vf_rate_limit_set,
8971 (void *)&cmd_vf_rate_limit_port,
8972 (void *)&cmd_vf_rate_limit_portnum,
8973 (void *)&cmd_vf_rate_limit_vf,
8974 (void *)&cmd_vf_rate_limit_vfnum,
8975 (void *)&cmd_vf_rate_limit_rate,
8976 (void *)&cmd_vf_rate_limit_ratenum,
8977 (void *)&cmd_vf_rate_limit_q_msk,
8978 (void *)&cmd_vf_rate_limit_q_msk_val,
8983 /* *** ADD TUNNEL FILTER OF A PORT *** */
8984 struct cmd_tunnel_filter_result {
8985 cmdline_fixed_string_t cmd;
8986 cmdline_fixed_string_t what;
8988 struct rte_ether_addr outer_mac;
8989 struct rte_ether_addr inner_mac;
8990 cmdline_ipaddr_t ip_value;
8991 uint16_t inner_vlan;
8992 cmdline_fixed_string_t tunnel_type;
8993 cmdline_fixed_string_t filter_type;
8999 cmd_tunnel_filter_parsed(void *parsed_result,
9000 __rte_unused struct cmdline *cl,
9001 __rte_unused void *data)
9003 struct cmd_tunnel_filter_result *res = parsed_result;
9004 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9007 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9009 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9010 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9011 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9013 if (res->ip_value.family == AF_INET) {
9014 tunnel_filter_conf.ip_addr.ipv4_addr =
9015 res->ip_value.addr.ipv4.s_addr;
9016 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9018 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9019 &(res->ip_value.addr.ipv6),
9020 sizeof(struct in6_addr));
9021 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9024 if (!strcmp(res->filter_type, "imac-ivlan"))
9025 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9026 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9027 tunnel_filter_conf.filter_type =
9028 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9029 else if (!strcmp(res->filter_type, "imac-tenid"))
9030 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9031 else if (!strcmp(res->filter_type, "imac"))
9032 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9033 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9034 tunnel_filter_conf.filter_type =
9035 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9036 else if (!strcmp(res->filter_type, "oip"))
9037 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9038 else if (!strcmp(res->filter_type, "iip"))
9039 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9041 printf("The filter type is not supported");
9045 if (!strcmp(res->tunnel_type, "vxlan"))
9046 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9047 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9048 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9049 else if (!strcmp(res->tunnel_type, "nvgre"))
9050 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9051 else if (!strcmp(res->tunnel_type, "ipingre"))
9052 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9054 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9058 tunnel_filter_conf.tenant_id = res->tenant_id;
9059 tunnel_filter_conf.queue_id = res->queue_num;
9060 if (!strcmp(res->what, "add"))
9061 ret = rte_eth_dev_filter_ctrl(res->port_id,
9062 RTE_ETH_FILTER_TUNNEL,
9064 &tunnel_filter_conf);
9066 ret = rte_eth_dev_filter_ctrl(res->port_id,
9067 RTE_ETH_FILTER_TUNNEL,
9068 RTE_ETH_FILTER_DELETE,
9069 &tunnel_filter_conf);
9071 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9075 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9076 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9077 cmd, "tunnel_filter");
9078 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9079 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9081 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9082 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9084 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9085 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9087 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9088 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9090 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9091 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9092 inner_vlan, UINT16);
9093 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9094 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9096 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9097 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9098 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9100 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9101 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9102 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9103 "imac#omac-imac-tenid");
9104 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9105 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9107 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9108 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9111 cmdline_parse_inst_t cmd_tunnel_filter = {
9112 .f = cmd_tunnel_filter_parsed,
9114 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9115 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9116 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9117 "<queue_id>: Add/Rm tunnel filter of a port",
9119 (void *)&cmd_tunnel_filter_cmd,
9120 (void *)&cmd_tunnel_filter_what,
9121 (void *)&cmd_tunnel_filter_port_id,
9122 (void *)&cmd_tunnel_filter_outer_mac,
9123 (void *)&cmd_tunnel_filter_inner_mac,
9124 (void *)&cmd_tunnel_filter_ip_value,
9125 (void *)&cmd_tunnel_filter_innner_vlan,
9126 (void *)&cmd_tunnel_filter_tunnel_type,
9127 (void *)&cmd_tunnel_filter_filter_type,
9128 (void *)&cmd_tunnel_filter_tenant_id,
9129 (void *)&cmd_tunnel_filter_queue_num,
9134 /* *** CONFIGURE TUNNEL UDP PORT *** */
9135 struct cmd_tunnel_udp_config {
9136 cmdline_fixed_string_t cmd;
9137 cmdline_fixed_string_t what;
9143 cmd_tunnel_udp_config_parsed(void *parsed_result,
9144 __rte_unused struct cmdline *cl,
9145 __rte_unused void *data)
9147 struct cmd_tunnel_udp_config *res = parsed_result;
9148 struct rte_eth_udp_tunnel tunnel_udp;
9151 tunnel_udp.udp_port = res->udp_port;
9153 if (!strcmp(res->cmd, "rx_vxlan_port"))
9154 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9156 if (!strcmp(res->what, "add"))
9157 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9160 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9164 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9167 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9168 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9169 cmd, "rx_vxlan_port");
9170 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9171 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9173 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9174 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9176 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9177 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9180 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9181 .f = cmd_tunnel_udp_config_parsed,
9183 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9184 "Add/Remove a tunneling UDP port filter",
9186 (void *)&cmd_tunnel_udp_config_cmd,
9187 (void *)&cmd_tunnel_udp_config_what,
9188 (void *)&cmd_tunnel_udp_config_udp_port,
9189 (void *)&cmd_tunnel_udp_config_port_id,
9194 struct cmd_config_tunnel_udp_port {
9195 cmdline_fixed_string_t port;
9196 cmdline_fixed_string_t config;
9198 cmdline_fixed_string_t udp_tunnel_port;
9199 cmdline_fixed_string_t action;
9200 cmdline_fixed_string_t tunnel_type;
9205 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9206 __rte_unused struct cmdline *cl,
9207 __rte_unused void *data)
9209 struct cmd_config_tunnel_udp_port *res = parsed_result;
9210 struct rte_eth_udp_tunnel tunnel_udp;
9213 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9216 tunnel_udp.udp_port = res->udp_port;
9218 if (!strcmp(res->tunnel_type, "vxlan")) {
9219 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9220 } else if (!strcmp(res->tunnel_type, "geneve")) {
9221 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9222 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9223 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9225 printf("Invalid tunnel type\n");
9229 if (!strcmp(res->action, "add"))
9230 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9233 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9237 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9240 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9241 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9243 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9244 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9246 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9247 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9249 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9250 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9253 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9254 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9256 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9257 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9258 "vxlan#geneve#vxlan-gpe");
9259 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9260 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9263 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9264 .f = cmd_cfg_tunnel_udp_port_parsed,
9266 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9268 (void *)&cmd_config_tunnel_udp_port_port,
9269 (void *)&cmd_config_tunnel_udp_port_config,
9270 (void *)&cmd_config_tunnel_udp_port_port_id,
9271 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9272 (void *)&cmd_config_tunnel_udp_port_action,
9273 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9274 (void *)&cmd_config_tunnel_udp_port_value,
9279 /* *** GLOBAL CONFIG *** */
9280 struct cmd_global_config_result {
9281 cmdline_fixed_string_t cmd;
9283 cmdline_fixed_string_t cfg_type;
9288 cmd_global_config_parsed(void *parsed_result,
9289 __rte_unused struct cmdline *cl,
9290 __rte_unused void *data)
9292 struct cmd_global_config_result *res = parsed_result;
9293 struct rte_eth_global_cfg conf;
9296 memset(&conf, 0, sizeof(conf));
9297 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9298 conf.cfg.gre_key_len = res->len;
9299 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9300 RTE_ETH_FILTER_SET, &conf);
9301 #ifdef RTE_LIBRTE_I40E_PMD
9302 if (ret == -ENOTSUP)
9303 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9306 printf("Global config error\n");
9309 cmdline_parse_token_string_t cmd_global_config_cmd =
9310 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9312 cmdline_parse_token_num_t cmd_global_config_port_id =
9313 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9315 cmdline_parse_token_string_t cmd_global_config_type =
9316 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9317 cfg_type, "gre-key-len");
9318 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9319 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9322 cmdline_parse_inst_t cmd_global_config = {
9323 .f = cmd_global_config_parsed,
9324 .data = (void *)NULL,
9325 .help_str = "global_config <port_id> gre-key-len <key_len>",
9327 (void *)&cmd_global_config_cmd,
9328 (void *)&cmd_global_config_port_id,
9329 (void *)&cmd_global_config_type,
9330 (void *)&cmd_global_config_gre_key_len,
9335 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9336 struct cmd_set_mirror_mask_result {
9337 cmdline_fixed_string_t set;
9338 cmdline_fixed_string_t port;
9340 cmdline_fixed_string_t mirror;
9342 cmdline_fixed_string_t what;
9343 cmdline_fixed_string_t value;
9344 cmdline_fixed_string_t dstpool;
9346 cmdline_fixed_string_t on;
9349 cmdline_parse_token_string_t cmd_mirror_mask_set =
9350 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9352 cmdline_parse_token_string_t cmd_mirror_mask_port =
9353 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9355 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9356 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9358 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9359 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9360 mirror, "mirror-rule");
9361 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9362 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9364 cmdline_parse_token_string_t cmd_mirror_mask_what =
9365 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9366 what, "pool-mirror-up#pool-mirror-down"
9368 cmdline_parse_token_string_t cmd_mirror_mask_value =
9369 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9371 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9372 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9373 dstpool, "dst-pool");
9374 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9375 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9377 cmdline_parse_token_string_t cmd_mirror_mask_on =
9378 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9382 cmd_set_mirror_mask_parsed(void *parsed_result,
9383 __rte_unused struct cmdline *cl,
9384 __rte_unused void *data)
9387 struct cmd_set_mirror_mask_result *res = parsed_result;
9388 struct rte_eth_mirror_conf mr_conf;
9390 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9392 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9394 mr_conf.dst_pool = res->dstpool_id;
9396 if (!strcmp(res->what, "pool-mirror-up")) {
9397 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9398 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9399 } else if (!strcmp(res->what, "pool-mirror-down")) {
9400 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9401 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9402 } else if (!strcmp(res->what, "vlan-mirror")) {
9403 mr_conf.rule_type = ETH_MIRROR_VLAN;
9404 nb_item = parse_item_list(res->value, "vlan",
9405 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9409 for (i = 0; i < nb_item; i++) {
9410 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9411 printf("Invalid vlan_id: must be < 4096\n");
9415 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9416 mr_conf.vlan.vlan_mask |= 1ULL << i;
9420 if (!strcmp(res->on, "on"))
9421 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9424 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9427 printf("mirror rule add error: (%s)\n", strerror(-ret));
9430 cmdline_parse_inst_t cmd_set_mirror_mask = {
9431 .f = cmd_set_mirror_mask_parsed,
9433 .help_str = "set port <port_id> mirror-rule <rule_id> "
9434 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9435 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9437 (void *)&cmd_mirror_mask_set,
9438 (void *)&cmd_mirror_mask_port,
9439 (void *)&cmd_mirror_mask_portid,
9440 (void *)&cmd_mirror_mask_mirror,
9441 (void *)&cmd_mirror_mask_ruleid,
9442 (void *)&cmd_mirror_mask_what,
9443 (void *)&cmd_mirror_mask_value,
9444 (void *)&cmd_mirror_mask_dstpool,
9445 (void *)&cmd_mirror_mask_poolid,
9446 (void *)&cmd_mirror_mask_on,
9451 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9452 struct cmd_set_mirror_link_result {
9453 cmdline_fixed_string_t set;
9454 cmdline_fixed_string_t port;
9456 cmdline_fixed_string_t mirror;
9458 cmdline_fixed_string_t what;
9459 cmdline_fixed_string_t dstpool;
9461 cmdline_fixed_string_t on;
9464 cmdline_parse_token_string_t cmd_mirror_link_set =
9465 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9467 cmdline_parse_token_string_t cmd_mirror_link_port =
9468 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9470 cmdline_parse_token_num_t cmd_mirror_link_portid =
9471 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9473 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9474 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9475 mirror, "mirror-rule");
9476 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9477 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9479 cmdline_parse_token_string_t cmd_mirror_link_what =
9480 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9481 what, "uplink-mirror#downlink-mirror");
9482 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9483 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9484 dstpool, "dst-pool");
9485 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9486 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9488 cmdline_parse_token_string_t cmd_mirror_link_on =
9489 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9493 cmd_set_mirror_link_parsed(void *parsed_result,
9494 __rte_unused struct cmdline *cl,
9495 __rte_unused void *data)
9498 struct cmd_set_mirror_link_result *res = parsed_result;
9499 struct rte_eth_mirror_conf mr_conf;
9501 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9502 if (!strcmp(res->what, "uplink-mirror"))
9503 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9505 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9507 mr_conf.dst_pool = res->dstpool_id;
9509 if (!strcmp(res->on, "on"))
9510 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9513 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9516 /* check the return value and print it if is < 0 */
9518 printf("mirror rule add error: (%s)\n", strerror(-ret));
9522 cmdline_parse_inst_t cmd_set_mirror_link = {
9523 .f = cmd_set_mirror_link_parsed,
9525 .help_str = "set port <port_id> mirror-rule <rule_id> "
9526 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9528 (void *)&cmd_mirror_link_set,
9529 (void *)&cmd_mirror_link_port,
9530 (void *)&cmd_mirror_link_portid,
9531 (void *)&cmd_mirror_link_mirror,
9532 (void *)&cmd_mirror_link_ruleid,
9533 (void *)&cmd_mirror_link_what,
9534 (void *)&cmd_mirror_link_dstpool,
9535 (void *)&cmd_mirror_link_poolid,
9536 (void *)&cmd_mirror_link_on,
9541 /* *** RESET VM MIRROR RULE *** */
9542 struct cmd_rm_mirror_rule_result {
9543 cmdline_fixed_string_t reset;
9544 cmdline_fixed_string_t port;
9546 cmdline_fixed_string_t mirror;
9550 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9551 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9553 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9554 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9556 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9557 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9559 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9560 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9561 mirror, "mirror-rule");
9562 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9563 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9567 cmd_reset_mirror_rule_parsed(void *parsed_result,
9568 __rte_unused struct cmdline *cl,
9569 __rte_unused void *data)
9572 struct cmd_set_mirror_link_result *res = parsed_result;
9574 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9576 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9579 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9580 .f = cmd_reset_mirror_rule_parsed,
9582 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9584 (void *)&cmd_rm_mirror_rule_reset,
9585 (void *)&cmd_rm_mirror_rule_port,
9586 (void *)&cmd_rm_mirror_rule_portid,
9587 (void *)&cmd_rm_mirror_rule_mirror,
9588 (void *)&cmd_rm_mirror_rule_ruleid,
9593 /* ******************************************************************************** */
9595 struct cmd_dump_result {
9596 cmdline_fixed_string_t dump;
9600 dump_struct_sizes(void)
9602 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9603 DUMP_SIZE(struct rte_mbuf);
9604 DUMP_SIZE(struct rte_mempool);
9605 DUMP_SIZE(struct rte_ring);
9610 /* Dump the socket memory statistics on console */
9612 dump_socket_mem(FILE *f)
9614 struct rte_malloc_socket_stats socket_stats;
9619 unsigned int n_alloc = 0;
9620 unsigned int n_free = 0;
9621 static size_t last_allocs;
9622 static size_t last_total;
9625 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9626 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9627 !socket_stats.heap_totalsz_bytes)
9629 total += socket_stats.heap_totalsz_bytes;
9630 alloc += socket_stats.heap_allocsz_bytes;
9631 free += socket_stats.heap_freesz_bytes;
9632 n_alloc += socket_stats.alloc_count;
9633 n_free += socket_stats.free_count;
9635 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9637 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9638 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9639 (double)socket_stats.heap_allocsz_bytes * 100 /
9640 (double)socket_stats.heap_totalsz_bytes,
9641 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9642 socket_stats.alloc_count,
9643 socket_stats.free_count);
9646 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9647 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9648 (double)alloc * 100 / (double)total,
9649 (double)free / (1024 * 1024),
9652 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9653 ((double)total - (double)last_total) / (1024 * 1024),
9654 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9655 last_allocs = alloc;
9659 static void cmd_dump_parsed(void *parsed_result,
9660 __rte_unused struct cmdline *cl,
9661 __rte_unused void *data)
9663 struct cmd_dump_result *res = parsed_result;
9665 if (!strcmp(res->dump, "dump_physmem"))
9666 rte_dump_physmem_layout(stdout);
9667 else if (!strcmp(res->dump, "dump_socket_mem"))
9668 dump_socket_mem(stdout);
9669 else if (!strcmp(res->dump, "dump_memzone"))
9670 rte_memzone_dump(stdout);
9671 else if (!strcmp(res->dump, "dump_struct_sizes"))
9672 dump_struct_sizes();
9673 else if (!strcmp(res->dump, "dump_ring"))
9674 rte_ring_list_dump(stdout);
9675 else if (!strcmp(res->dump, "dump_mempool"))
9676 rte_mempool_list_dump(stdout);
9677 else if (!strcmp(res->dump, "dump_devargs"))
9678 rte_devargs_dump(stdout);
9679 else if (!strcmp(res->dump, "dump_log_types"))
9680 rte_log_dump(stdout);
9683 cmdline_parse_token_string_t cmd_dump_dump =
9684 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9688 "dump_struct_sizes#"
9694 cmdline_parse_inst_t cmd_dump = {
9695 .f = cmd_dump_parsed, /* function to call */
9696 .data = NULL, /* 2nd arg of func */
9697 .help_str = "Dump status",
9698 .tokens = { /* token list, NULL terminated */
9699 (void *)&cmd_dump_dump,
9704 /* ******************************************************************************** */
9706 struct cmd_dump_one_result {
9707 cmdline_fixed_string_t dump;
9708 cmdline_fixed_string_t name;
9711 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9712 __rte_unused void *data)
9714 struct cmd_dump_one_result *res = parsed_result;
9716 if (!strcmp(res->dump, "dump_ring")) {
9718 r = rte_ring_lookup(res->name);
9720 cmdline_printf(cl, "Cannot find ring\n");
9723 rte_ring_dump(stdout, r);
9724 } else if (!strcmp(res->dump, "dump_mempool")) {
9725 struct rte_mempool *mp;
9726 mp = rte_mempool_lookup(res->name);
9728 cmdline_printf(cl, "Cannot find mempool\n");
9731 rte_mempool_dump(stdout, mp);
9735 cmdline_parse_token_string_t cmd_dump_one_dump =
9736 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9737 "dump_ring#dump_mempool");
9739 cmdline_parse_token_string_t cmd_dump_one_name =
9740 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9742 cmdline_parse_inst_t cmd_dump_one = {
9743 .f = cmd_dump_one_parsed, /* function to call */
9744 .data = NULL, /* 2nd arg of func */
9745 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9746 .tokens = { /* token list, NULL terminated */
9747 (void *)&cmd_dump_one_dump,
9748 (void *)&cmd_dump_one_name,
9753 /* *** Add/Del syn filter *** */
9754 struct cmd_syn_filter_result {
9755 cmdline_fixed_string_t filter;
9757 cmdline_fixed_string_t ops;
9758 cmdline_fixed_string_t priority;
9759 cmdline_fixed_string_t high;
9760 cmdline_fixed_string_t queue;
9765 cmd_syn_filter_parsed(void *parsed_result,
9766 __rte_unused struct cmdline *cl,
9767 __rte_unused void *data)
9769 struct cmd_syn_filter_result *res = parsed_result;
9770 struct rte_eth_syn_filter syn_filter;
9773 ret = rte_eth_dev_filter_supported(res->port_id,
9774 RTE_ETH_FILTER_SYN);
9776 printf("syn filter is not supported on port %u.\n",
9781 memset(&syn_filter, 0, sizeof(syn_filter));
9783 if (!strcmp(res->ops, "add")) {
9784 if (!strcmp(res->high, "high"))
9785 syn_filter.hig_pri = 1;
9787 syn_filter.hig_pri = 0;
9789 syn_filter.queue = res->queue_id;
9790 ret = rte_eth_dev_filter_ctrl(res->port_id,
9795 ret = rte_eth_dev_filter_ctrl(res->port_id,
9797 RTE_ETH_FILTER_DELETE,
9801 printf("syn filter programming error: (%s)\n",
9805 cmdline_parse_token_string_t cmd_syn_filter_filter =
9806 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9807 filter, "syn_filter");
9808 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9809 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9811 cmdline_parse_token_string_t cmd_syn_filter_ops =
9812 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9814 cmdline_parse_token_string_t cmd_syn_filter_priority =
9815 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9816 priority, "priority");
9817 cmdline_parse_token_string_t cmd_syn_filter_high =
9818 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9820 cmdline_parse_token_string_t cmd_syn_filter_queue =
9821 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9823 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9824 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9827 cmdline_parse_inst_t cmd_syn_filter = {
9828 .f = cmd_syn_filter_parsed,
9830 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9831 "<queue_id>: Add/Delete syn filter",
9833 (void *)&cmd_syn_filter_filter,
9834 (void *)&cmd_syn_filter_port_id,
9835 (void *)&cmd_syn_filter_ops,
9836 (void *)&cmd_syn_filter_priority,
9837 (void *)&cmd_syn_filter_high,
9838 (void *)&cmd_syn_filter_queue,
9839 (void *)&cmd_syn_filter_queue_id,
9844 /* *** queue region set *** */
9845 struct cmd_queue_region_result {
9846 cmdline_fixed_string_t set;
9847 cmdline_fixed_string_t port;
9849 cmdline_fixed_string_t cmd;
9850 cmdline_fixed_string_t region;
9852 cmdline_fixed_string_t queue_start_index;
9854 cmdline_fixed_string_t queue_num;
9855 uint8_t queue_num_value;
9859 cmd_queue_region_parsed(void *parsed_result,
9860 __rte_unused struct cmdline *cl,
9861 __rte_unused void *data)
9863 struct cmd_queue_region_result *res = parsed_result;
9865 #ifdef RTE_LIBRTE_I40E_PMD
9866 struct rte_pmd_i40e_queue_region_conf region_conf;
9867 enum rte_pmd_i40e_queue_region_op op_type;
9870 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9873 #ifdef RTE_LIBRTE_I40E_PMD
9874 memset(®ion_conf, 0, sizeof(region_conf));
9875 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9876 region_conf.region_id = res->region_id;
9877 region_conf.queue_num = res->queue_num_value;
9878 region_conf.queue_start_index = res->queue_id;
9880 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9881 op_type, ®ion_conf);
9888 printf("function not implemented or supported\n");
9891 printf("queue region config error: (%s)\n", strerror(-ret));
9895 cmdline_parse_token_string_t cmd_queue_region_set =
9896 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9898 cmdline_parse_token_string_t cmd_queue_region_port =
9899 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9900 cmdline_parse_token_num_t cmd_queue_region_port_id =
9901 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9903 cmdline_parse_token_string_t cmd_queue_region_cmd =
9904 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9905 cmd, "queue-region");
9906 cmdline_parse_token_string_t cmd_queue_region_id =
9907 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9908 region, "region_id");
9909 cmdline_parse_token_num_t cmd_queue_region_index =
9910 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9912 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9913 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9914 queue_start_index, "queue_start_index");
9915 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9916 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9918 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9919 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9920 queue_num, "queue_num");
9921 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9922 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9923 queue_num_value, UINT8);
9925 cmdline_parse_inst_t cmd_queue_region = {
9926 .f = cmd_queue_region_parsed,
9928 .help_str = "set port <port_id> queue-region region_id <value> "
9929 "queue_start_index <value> queue_num <value>: Set a queue region",
9931 (void *)&cmd_queue_region_set,
9932 (void *)&cmd_queue_region_port,
9933 (void *)&cmd_queue_region_port_id,
9934 (void *)&cmd_queue_region_cmd,
9935 (void *)&cmd_queue_region_id,
9936 (void *)&cmd_queue_region_index,
9937 (void *)&cmd_queue_region_queue_start_index,
9938 (void *)&cmd_queue_region_queue_id,
9939 (void *)&cmd_queue_region_queue_num,
9940 (void *)&cmd_queue_region_queue_num_value,
9945 /* *** queue region and flowtype set *** */
9946 struct cmd_region_flowtype_result {
9947 cmdline_fixed_string_t set;
9948 cmdline_fixed_string_t port;
9950 cmdline_fixed_string_t cmd;
9951 cmdline_fixed_string_t region;
9953 cmdline_fixed_string_t flowtype;
9954 uint8_t flowtype_id;
9958 cmd_region_flowtype_parsed(void *parsed_result,
9959 __rte_unused struct cmdline *cl,
9960 __rte_unused void *data)
9962 struct cmd_region_flowtype_result *res = parsed_result;
9964 #ifdef RTE_LIBRTE_I40E_PMD
9965 struct rte_pmd_i40e_queue_region_conf region_conf;
9966 enum rte_pmd_i40e_queue_region_op op_type;
9969 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9972 #ifdef RTE_LIBRTE_I40E_PMD
9973 memset(®ion_conf, 0, sizeof(region_conf));
9975 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9976 region_conf.region_id = res->region_id;
9977 region_conf.hw_flowtype = res->flowtype_id;
9979 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9980 op_type, ®ion_conf);
9987 printf("function not implemented or supported\n");
9990 printf("region flowtype config error: (%s)\n", strerror(-ret));
9994 cmdline_parse_token_string_t cmd_region_flowtype_set =
9995 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9997 cmdline_parse_token_string_t cmd_region_flowtype_port =
9998 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10000 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10001 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10003 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10004 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10005 cmd, "queue-region");
10006 cmdline_parse_token_string_t cmd_region_flowtype_index =
10007 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10008 region, "region_id");
10009 cmdline_parse_token_num_t cmd_region_flowtype_id =
10010 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10012 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10013 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10014 flowtype, "flowtype");
10015 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10016 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10017 flowtype_id, UINT8);
10018 cmdline_parse_inst_t cmd_region_flowtype = {
10019 .f = cmd_region_flowtype_parsed,
10021 .help_str = "set port <port_id> queue-region region_id <value> "
10022 "flowtype <value>: Set a flowtype region index",
10024 (void *)&cmd_region_flowtype_set,
10025 (void *)&cmd_region_flowtype_port,
10026 (void *)&cmd_region_flowtype_port_index,
10027 (void *)&cmd_region_flowtype_cmd,
10028 (void *)&cmd_region_flowtype_index,
10029 (void *)&cmd_region_flowtype_id,
10030 (void *)&cmd_region_flowtype_flow_index,
10031 (void *)&cmd_region_flowtype_flow_id,
10036 /* *** User Priority (UP) to queue region (region_id) set *** */
10037 struct cmd_user_priority_region_result {
10038 cmdline_fixed_string_t set;
10039 cmdline_fixed_string_t port;
10041 cmdline_fixed_string_t cmd;
10042 cmdline_fixed_string_t user_priority;
10043 uint8_t user_priority_id;
10044 cmdline_fixed_string_t region;
10049 cmd_user_priority_region_parsed(void *parsed_result,
10050 __rte_unused struct cmdline *cl,
10051 __rte_unused void *data)
10053 struct cmd_user_priority_region_result *res = parsed_result;
10054 int ret = -ENOTSUP;
10055 #ifdef RTE_LIBRTE_I40E_PMD
10056 struct rte_pmd_i40e_queue_region_conf region_conf;
10057 enum rte_pmd_i40e_queue_region_op op_type;
10060 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10063 #ifdef RTE_LIBRTE_I40E_PMD
10064 memset(®ion_conf, 0, sizeof(region_conf));
10065 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10066 region_conf.user_priority = res->user_priority_id;
10067 region_conf.region_id = res->region_id;
10069 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10070 op_type, ®ion_conf);
10077 printf("function not implemented or supported\n");
10080 printf("user_priority region config error: (%s)\n",
10085 cmdline_parse_token_string_t cmd_user_priority_region_set =
10086 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10088 cmdline_parse_token_string_t cmd_user_priority_region_port =
10089 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10091 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10092 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10094 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10095 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10096 cmd, "queue-region");
10097 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10098 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10099 user_priority, "UP");
10100 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10101 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10102 user_priority_id, UINT8);
10103 cmdline_parse_token_string_t cmd_user_priority_region_region =
10104 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10105 region, "region_id");
10106 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10107 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10110 cmdline_parse_inst_t cmd_user_priority_region = {
10111 .f = cmd_user_priority_region_parsed,
10113 .help_str = "set port <port_id> queue-region UP <value> "
10114 "region_id <value>: Set the mapping of User Priority (UP) "
10115 "to queue region (region_id) ",
10117 (void *)&cmd_user_priority_region_set,
10118 (void *)&cmd_user_priority_region_port,
10119 (void *)&cmd_user_priority_region_port_index,
10120 (void *)&cmd_user_priority_region_cmd,
10121 (void *)&cmd_user_priority_region_UP,
10122 (void *)&cmd_user_priority_region_UP_id,
10123 (void *)&cmd_user_priority_region_region,
10124 (void *)&cmd_user_priority_region_region_id,
10129 /* *** flush all queue region related configuration *** */
10130 struct cmd_flush_queue_region_result {
10131 cmdline_fixed_string_t set;
10132 cmdline_fixed_string_t port;
10134 cmdline_fixed_string_t cmd;
10135 cmdline_fixed_string_t flush;
10136 cmdline_fixed_string_t what;
10140 cmd_flush_queue_region_parsed(void *parsed_result,
10141 __rte_unused struct cmdline *cl,
10142 __rte_unused void *data)
10144 struct cmd_flush_queue_region_result *res = parsed_result;
10145 int ret = -ENOTSUP;
10146 #ifdef RTE_LIBRTE_I40E_PMD
10147 struct rte_pmd_i40e_queue_region_conf region_conf;
10148 enum rte_pmd_i40e_queue_region_op op_type;
10151 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10154 #ifdef RTE_LIBRTE_I40E_PMD
10155 memset(®ion_conf, 0, sizeof(region_conf));
10157 if (strcmp(res->what, "on") == 0)
10158 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10160 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10162 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10163 op_type, ®ion_conf);
10170 printf("function not implemented or supported\n");
10173 printf("queue region config flush error: (%s)\n",
10178 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10179 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10181 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10182 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10184 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10185 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10187 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10188 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10189 cmd, "queue-region");
10190 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10191 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10193 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10194 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10197 cmdline_parse_inst_t cmd_flush_queue_region = {
10198 .f = cmd_flush_queue_region_parsed,
10200 .help_str = "set port <port_id> queue-region flush on|off"
10201 ": flush all queue region related configuration",
10203 (void *)&cmd_flush_queue_region_set,
10204 (void *)&cmd_flush_queue_region_port,
10205 (void *)&cmd_flush_queue_region_port_index,
10206 (void *)&cmd_flush_queue_region_cmd,
10207 (void *)&cmd_flush_queue_region_flush,
10208 (void *)&cmd_flush_queue_region_what,
10213 /* *** get all queue region related configuration info *** */
10214 struct cmd_show_queue_region_info {
10215 cmdline_fixed_string_t show;
10216 cmdline_fixed_string_t port;
10218 cmdline_fixed_string_t cmd;
10222 cmd_show_queue_region_info_parsed(void *parsed_result,
10223 __rte_unused struct cmdline *cl,
10224 __rte_unused void *data)
10226 struct cmd_show_queue_region_info *res = parsed_result;
10227 int ret = -ENOTSUP;
10228 #ifdef RTE_LIBRTE_I40E_PMD
10229 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10230 enum rte_pmd_i40e_queue_region_op op_type;
10233 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10236 #ifdef RTE_LIBRTE_I40E_PMD
10237 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10239 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10241 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10242 op_type, &rte_pmd_regions);
10244 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10251 printf("function not implemented or supported\n");
10254 printf("queue region config info show error: (%s)\n",
10259 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10260 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10262 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10263 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10265 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10266 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10268 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10269 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10270 cmd, "queue-region");
10272 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10273 .f = cmd_show_queue_region_info_parsed,
10275 .help_str = "show port <port_id> queue-region"
10276 ": show all queue region related configuration info",
10278 (void *)&cmd_show_queue_region_info_get,
10279 (void *)&cmd_show_queue_region_info_port,
10280 (void *)&cmd_show_queue_region_info_port_index,
10281 (void *)&cmd_show_queue_region_info_cmd,
10286 /* *** ADD/REMOVE A 2tuple FILTER *** */
10287 struct cmd_2tuple_filter_result {
10288 cmdline_fixed_string_t filter;
10290 cmdline_fixed_string_t ops;
10291 cmdline_fixed_string_t dst_port;
10292 uint16_t dst_port_value;
10293 cmdline_fixed_string_t protocol;
10294 uint8_t protocol_value;
10295 cmdline_fixed_string_t mask;
10296 uint8_t mask_value;
10297 cmdline_fixed_string_t tcp_flags;
10298 uint8_t tcp_flags_value;
10299 cmdline_fixed_string_t priority;
10300 uint8_t priority_value;
10301 cmdline_fixed_string_t queue;
10306 cmd_2tuple_filter_parsed(void *parsed_result,
10307 __rte_unused struct cmdline *cl,
10308 __rte_unused void *data)
10310 struct rte_eth_ntuple_filter filter;
10311 struct cmd_2tuple_filter_result *res = parsed_result;
10314 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10316 printf("ntuple filter is not supported on port %u.\n",
10321 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10323 filter.flags = RTE_2TUPLE_FLAGS;
10324 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10325 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10326 filter.proto = res->protocol_value;
10327 filter.priority = res->priority_value;
10328 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10329 printf("nonzero tcp_flags is only meaningful"
10330 " when protocol is TCP.\n");
10333 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10334 printf("invalid TCP flags.\n");
10338 if (res->tcp_flags_value != 0) {
10339 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10340 filter.tcp_flags = res->tcp_flags_value;
10343 /* need convert to big endian. */
10344 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10345 filter.queue = res->queue_id;
10347 if (!strcmp(res->ops, "add"))
10348 ret = rte_eth_dev_filter_ctrl(res->port_id,
10349 RTE_ETH_FILTER_NTUPLE,
10350 RTE_ETH_FILTER_ADD,
10353 ret = rte_eth_dev_filter_ctrl(res->port_id,
10354 RTE_ETH_FILTER_NTUPLE,
10355 RTE_ETH_FILTER_DELETE,
10358 printf("2tuple filter programming error: (%s)\n",
10363 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10364 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10365 filter, "2tuple_filter");
10366 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10367 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10369 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10370 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10372 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10373 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10374 dst_port, "dst_port");
10375 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10376 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10377 dst_port_value, UINT16);
10378 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10379 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10380 protocol, "protocol");
10381 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10382 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10383 protocol_value, UINT8);
10384 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10385 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10387 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10388 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10390 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10391 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10392 tcp_flags, "tcp_flags");
10393 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10394 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10395 tcp_flags_value, UINT8);
10396 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10397 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10398 priority, "priority");
10399 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10400 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10401 priority_value, UINT8);
10402 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10403 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10405 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10406 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10409 cmdline_parse_inst_t cmd_2tuple_filter = {
10410 .f = cmd_2tuple_filter_parsed,
10412 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10413 "<value> mask <value> tcp_flags <value> priority <value> queue "
10414 "<queue_id>: Add a 2tuple filter",
10416 (void *)&cmd_2tuple_filter_filter,
10417 (void *)&cmd_2tuple_filter_port_id,
10418 (void *)&cmd_2tuple_filter_ops,
10419 (void *)&cmd_2tuple_filter_dst_port,
10420 (void *)&cmd_2tuple_filter_dst_port_value,
10421 (void *)&cmd_2tuple_filter_protocol,
10422 (void *)&cmd_2tuple_filter_protocol_value,
10423 (void *)&cmd_2tuple_filter_mask,
10424 (void *)&cmd_2tuple_filter_mask_value,
10425 (void *)&cmd_2tuple_filter_tcp_flags,
10426 (void *)&cmd_2tuple_filter_tcp_flags_value,
10427 (void *)&cmd_2tuple_filter_priority,
10428 (void *)&cmd_2tuple_filter_priority_value,
10429 (void *)&cmd_2tuple_filter_queue,
10430 (void *)&cmd_2tuple_filter_queue_id,
10435 /* *** ADD/REMOVE A 5tuple FILTER *** */
10436 struct cmd_5tuple_filter_result {
10437 cmdline_fixed_string_t filter;
10439 cmdline_fixed_string_t ops;
10440 cmdline_fixed_string_t dst_ip;
10441 cmdline_ipaddr_t dst_ip_value;
10442 cmdline_fixed_string_t src_ip;
10443 cmdline_ipaddr_t src_ip_value;
10444 cmdline_fixed_string_t dst_port;
10445 uint16_t dst_port_value;
10446 cmdline_fixed_string_t src_port;
10447 uint16_t src_port_value;
10448 cmdline_fixed_string_t protocol;
10449 uint8_t protocol_value;
10450 cmdline_fixed_string_t mask;
10451 uint8_t mask_value;
10452 cmdline_fixed_string_t tcp_flags;
10453 uint8_t tcp_flags_value;
10454 cmdline_fixed_string_t priority;
10455 uint8_t priority_value;
10456 cmdline_fixed_string_t queue;
10461 cmd_5tuple_filter_parsed(void *parsed_result,
10462 __rte_unused struct cmdline *cl,
10463 __rte_unused void *data)
10465 struct rte_eth_ntuple_filter filter;
10466 struct cmd_5tuple_filter_result *res = parsed_result;
10469 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10471 printf("ntuple filter is not supported on port %u.\n",
10476 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10478 filter.flags = RTE_5TUPLE_FLAGS;
10479 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10480 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10481 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10482 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10483 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10484 filter.proto = res->protocol_value;
10485 filter.priority = res->priority_value;
10486 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10487 printf("nonzero tcp_flags is only meaningful"
10488 " when protocol is TCP.\n");
10491 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10492 printf("invalid TCP flags.\n");
10496 if (res->tcp_flags_value != 0) {
10497 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10498 filter.tcp_flags = res->tcp_flags_value;
10501 if (res->dst_ip_value.family == AF_INET)
10502 /* no need to convert, already big endian. */
10503 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10505 if (filter.dst_ip_mask == 0) {
10506 printf("can not support ipv6 involved compare.\n");
10512 if (res->src_ip_value.family == AF_INET)
10513 /* no need to convert, already big endian. */
10514 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10516 if (filter.src_ip_mask == 0) {
10517 printf("can not support ipv6 involved compare.\n");
10522 /* need convert to big endian. */
10523 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10524 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10525 filter.queue = res->queue_id;
10527 if (!strcmp(res->ops, "add"))
10528 ret = rte_eth_dev_filter_ctrl(res->port_id,
10529 RTE_ETH_FILTER_NTUPLE,
10530 RTE_ETH_FILTER_ADD,
10533 ret = rte_eth_dev_filter_ctrl(res->port_id,
10534 RTE_ETH_FILTER_NTUPLE,
10535 RTE_ETH_FILTER_DELETE,
10538 printf("5tuple filter programming error: (%s)\n",
10542 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10543 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10544 filter, "5tuple_filter");
10545 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10546 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10548 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10549 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10551 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10552 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10554 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10555 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10557 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10558 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10560 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10561 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10563 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10564 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10565 dst_port, "dst_port");
10566 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10567 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10568 dst_port_value, UINT16);
10569 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10570 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10571 src_port, "src_port");
10572 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10573 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10574 src_port_value, UINT16);
10575 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10576 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10577 protocol, "protocol");
10578 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10579 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10580 protocol_value, UINT8);
10581 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10582 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10584 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10585 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10587 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10588 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10589 tcp_flags, "tcp_flags");
10590 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10591 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10592 tcp_flags_value, UINT8);
10593 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10594 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10595 priority, "priority");
10596 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10597 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10598 priority_value, UINT8);
10599 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10600 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10602 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10603 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10606 cmdline_parse_inst_t cmd_5tuple_filter = {
10607 .f = cmd_5tuple_filter_parsed,
10609 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10610 "src_ip <value> dst_port <value> src_port <value> "
10611 "protocol <value> mask <value> tcp_flags <value> "
10612 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10614 (void *)&cmd_5tuple_filter_filter,
10615 (void *)&cmd_5tuple_filter_port_id,
10616 (void *)&cmd_5tuple_filter_ops,
10617 (void *)&cmd_5tuple_filter_dst_ip,
10618 (void *)&cmd_5tuple_filter_dst_ip_value,
10619 (void *)&cmd_5tuple_filter_src_ip,
10620 (void *)&cmd_5tuple_filter_src_ip_value,
10621 (void *)&cmd_5tuple_filter_dst_port,
10622 (void *)&cmd_5tuple_filter_dst_port_value,
10623 (void *)&cmd_5tuple_filter_src_port,
10624 (void *)&cmd_5tuple_filter_src_port_value,
10625 (void *)&cmd_5tuple_filter_protocol,
10626 (void *)&cmd_5tuple_filter_protocol_value,
10627 (void *)&cmd_5tuple_filter_mask,
10628 (void *)&cmd_5tuple_filter_mask_value,
10629 (void *)&cmd_5tuple_filter_tcp_flags,
10630 (void *)&cmd_5tuple_filter_tcp_flags_value,
10631 (void *)&cmd_5tuple_filter_priority,
10632 (void *)&cmd_5tuple_filter_priority_value,
10633 (void *)&cmd_5tuple_filter_queue,
10634 (void *)&cmd_5tuple_filter_queue_id,
10639 /* *** ADD/REMOVE A flex FILTER *** */
10640 struct cmd_flex_filter_result {
10641 cmdline_fixed_string_t filter;
10642 cmdline_fixed_string_t ops;
10644 cmdline_fixed_string_t len;
10646 cmdline_fixed_string_t bytes;
10647 cmdline_fixed_string_t bytes_value;
10648 cmdline_fixed_string_t mask;
10649 cmdline_fixed_string_t mask_value;
10650 cmdline_fixed_string_t priority;
10651 uint8_t priority_value;
10652 cmdline_fixed_string_t queue;
10656 static int xdigit2val(unsigned char c)
10661 else if (isupper(c))
10662 val = c - 'A' + 10;
10664 val = c - 'a' + 10;
10669 cmd_flex_filter_parsed(void *parsed_result,
10670 __rte_unused struct cmdline *cl,
10671 __rte_unused void *data)
10674 struct rte_eth_flex_filter filter;
10675 struct cmd_flex_filter_result *res = parsed_result;
10676 char *bytes_ptr, *mask_ptr;
10677 uint16_t len, i, j = 0;
10682 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10683 printf("the len exceed the max length 128\n");
10686 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10687 filter.len = res->len_value;
10688 filter.priority = res->priority_value;
10689 filter.queue = res->queue_id;
10690 bytes_ptr = res->bytes_value;
10691 mask_ptr = res->mask_value;
10693 /* translate bytes string to array. */
10694 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10695 (bytes_ptr[1] == 'X')))
10697 len = strnlen(bytes_ptr, res->len_value * 2);
10698 if (len == 0 || (len % 8 != 0)) {
10699 printf("please check len and bytes input\n");
10702 for (i = 0; i < len; i++) {
10704 if (isxdigit(c) == 0) {
10705 /* invalid characters. */
10706 printf("invalid input\n");
10709 val = xdigit2val(c);
10712 filter.bytes[j] = byte;
10713 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10720 /* translate mask string to uint8_t array. */
10721 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10722 (mask_ptr[1] == 'X')))
10724 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10726 printf("invalid input\n");
10731 for (i = 0; i < len; i++) {
10733 if (isxdigit(c) == 0) {
10734 /* invalid characters. */
10735 printf("invalid input\n");
10738 val = xdigit2val(c);
10741 filter.mask[j] = byte;
10742 printf("mask[%d]:%02x ", j, filter.mask[j]);
10750 if (!strcmp(res->ops, "add"))
10751 ret = rte_eth_dev_filter_ctrl(res->port_id,
10752 RTE_ETH_FILTER_FLEXIBLE,
10753 RTE_ETH_FILTER_ADD,
10756 ret = rte_eth_dev_filter_ctrl(res->port_id,
10757 RTE_ETH_FILTER_FLEXIBLE,
10758 RTE_ETH_FILTER_DELETE,
10762 printf("flex filter setting error: (%s)\n", strerror(-ret));
10765 cmdline_parse_token_string_t cmd_flex_filter_filter =
10766 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10767 filter, "flex_filter");
10768 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10769 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10771 cmdline_parse_token_string_t cmd_flex_filter_ops =
10772 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10774 cmdline_parse_token_string_t cmd_flex_filter_len =
10775 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10777 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10778 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10780 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10781 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10783 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10784 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10785 bytes_value, NULL);
10786 cmdline_parse_token_string_t cmd_flex_filter_mask =
10787 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10789 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10790 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10792 cmdline_parse_token_string_t cmd_flex_filter_priority =
10793 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10794 priority, "priority");
10795 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10796 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10797 priority_value, UINT8);
10798 cmdline_parse_token_string_t cmd_flex_filter_queue =
10799 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10801 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10802 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10804 cmdline_parse_inst_t cmd_flex_filter = {
10805 .f = cmd_flex_filter_parsed,
10807 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10808 "<value> mask <value> priority <value> queue <queue_id>: "
10809 "Add/Del a flex filter",
10811 (void *)&cmd_flex_filter_filter,
10812 (void *)&cmd_flex_filter_port_id,
10813 (void *)&cmd_flex_filter_ops,
10814 (void *)&cmd_flex_filter_len,
10815 (void *)&cmd_flex_filter_len_value,
10816 (void *)&cmd_flex_filter_bytes,
10817 (void *)&cmd_flex_filter_bytes_value,
10818 (void *)&cmd_flex_filter_mask,
10819 (void *)&cmd_flex_filter_mask_value,
10820 (void *)&cmd_flex_filter_priority,
10821 (void *)&cmd_flex_filter_priority_value,
10822 (void *)&cmd_flex_filter_queue,
10823 (void *)&cmd_flex_filter_queue_id,
10828 /* *** Filters Control *** */
10830 /* *** deal with ethertype filter *** */
10831 struct cmd_ethertype_filter_result {
10832 cmdline_fixed_string_t filter;
10834 cmdline_fixed_string_t ops;
10835 cmdline_fixed_string_t mac;
10836 struct rte_ether_addr mac_addr;
10837 cmdline_fixed_string_t ethertype;
10838 uint16_t ethertype_value;
10839 cmdline_fixed_string_t drop;
10840 cmdline_fixed_string_t queue;
10844 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10845 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10846 filter, "ethertype_filter");
10847 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10848 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10850 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10851 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10853 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10854 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10855 mac, "mac_addr#mac_ignr");
10856 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10857 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10859 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10860 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10861 ethertype, "ethertype");
10862 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10863 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10864 ethertype_value, UINT16);
10865 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10866 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10868 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10869 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10871 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10872 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10876 cmd_ethertype_filter_parsed(void *parsed_result,
10877 __rte_unused struct cmdline *cl,
10878 __rte_unused void *data)
10880 struct cmd_ethertype_filter_result *res = parsed_result;
10881 struct rte_eth_ethertype_filter filter;
10884 ret = rte_eth_dev_filter_supported(res->port_id,
10885 RTE_ETH_FILTER_ETHERTYPE);
10887 printf("ethertype filter is not supported on port %u.\n",
10892 memset(&filter, 0, sizeof(filter));
10893 if (!strcmp(res->mac, "mac_addr")) {
10894 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10895 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10896 sizeof(struct rte_ether_addr));
10898 if (!strcmp(res->drop, "drop"))
10899 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10900 filter.ether_type = res->ethertype_value;
10901 filter.queue = res->queue_id;
10903 if (!strcmp(res->ops, "add"))
10904 ret = rte_eth_dev_filter_ctrl(res->port_id,
10905 RTE_ETH_FILTER_ETHERTYPE,
10906 RTE_ETH_FILTER_ADD,
10909 ret = rte_eth_dev_filter_ctrl(res->port_id,
10910 RTE_ETH_FILTER_ETHERTYPE,
10911 RTE_ETH_FILTER_DELETE,
10914 printf("ethertype filter programming error: (%s)\n",
10918 cmdline_parse_inst_t cmd_ethertype_filter = {
10919 .f = cmd_ethertype_filter_parsed,
10921 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10922 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10923 "Add or delete an ethertype filter entry",
10925 (void *)&cmd_ethertype_filter_filter,
10926 (void *)&cmd_ethertype_filter_port_id,
10927 (void *)&cmd_ethertype_filter_ops,
10928 (void *)&cmd_ethertype_filter_mac,
10929 (void *)&cmd_ethertype_filter_mac_addr,
10930 (void *)&cmd_ethertype_filter_ethertype,
10931 (void *)&cmd_ethertype_filter_ethertype_value,
10932 (void *)&cmd_ethertype_filter_drop,
10933 (void *)&cmd_ethertype_filter_queue,
10934 (void *)&cmd_ethertype_filter_queue_id,
10939 /* *** deal with flow director filter *** */
10940 struct cmd_flow_director_result {
10941 cmdline_fixed_string_t flow_director_filter;
10943 cmdline_fixed_string_t mode;
10944 cmdline_fixed_string_t mode_value;
10945 cmdline_fixed_string_t ops;
10946 cmdline_fixed_string_t flow;
10947 cmdline_fixed_string_t flow_type;
10948 cmdline_fixed_string_t ether;
10949 uint16_t ether_type;
10950 cmdline_fixed_string_t src;
10951 cmdline_ipaddr_t ip_src;
10953 cmdline_fixed_string_t dst;
10954 cmdline_ipaddr_t ip_dst;
10956 cmdline_fixed_string_t verify_tag;
10957 uint32_t verify_tag_value;
10958 cmdline_fixed_string_t tos;
10960 cmdline_fixed_string_t proto;
10961 uint8_t proto_value;
10962 cmdline_fixed_string_t ttl;
10964 cmdline_fixed_string_t vlan;
10965 uint16_t vlan_value;
10966 cmdline_fixed_string_t flexbytes;
10967 cmdline_fixed_string_t flexbytes_value;
10968 cmdline_fixed_string_t pf_vf;
10969 cmdline_fixed_string_t drop;
10970 cmdline_fixed_string_t queue;
10972 cmdline_fixed_string_t fd_id;
10973 uint32_t fd_id_value;
10974 cmdline_fixed_string_t mac;
10975 struct rte_ether_addr mac_addr;
10976 cmdline_fixed_string_t tunnel;
10977 cmdline_fixed_string_t tunnel_type;
10978 cmdline_fixed_string_t tunnel_id;
10979 uint32_t tunnel_id_value;
10980 cmdline_fixed_string_t packet;
10985 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10988 const char *p, *p0 = q_arg;
10990 unsigned long int_fld;
10991 char *str_fld[max_num];
10996 p = strchr(p0, '(');
11000 p0 = strchr(p, ')');
11005 if (size >= sizeof(s))
11008 snprintf(s, sizeof(s), "%.*s", size, p);
11009 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11010 if (ret < 0 || ret > max_num)
11012 for (i = 0; i < ret; i++) {
11014 int_fld = strtoul(str_fld[i], &end, 0);
11015 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11017 flexbytes[i] = (uint8_t)int_fld;
11023 str2flowtype(char *string)
11026 static const struct {
11029 } flowtype_str[] = {
11030 {"raw", RTE_ETH_FLOW_RAW},
11031 {"ipv4", RTE_ETH_FLOW_IPV4},
11032 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11033 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11034 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11035 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11036 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11037 {"ipv6", RTE_ETH_FLOW_IPV6},
11038 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11039 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11040 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11041 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11042 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11043 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11046 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11047 if (!strcmp(flowtype_str[i].str, string))
11048 return flowtype_str[i].type;
11051 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11052 return (uint16_t)atoi(string);
11054 return RTE_ETH_FLOW_UNKNOWN;
11057 static enum rte_eth_fdir_tunnel_type
11058 str2fdir_tunneltype(char *string)
11062 static const struct {
11064 enum rte_eth_fdir_tunnel_type type;
11065 } tunneltype_str[] = {
11066 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11067 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11070 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11071 if (!strcmp(tunneltype_str[i].str, string))
11072 return tunneltype_str[i].type;
11074 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11077 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11079 if ((ip_addr).family == AF_INET) \
11080 (ip) = (ip_addr).addr.ipv4.s_addr; \
11082 printf("invalid parameter.\n"); \
11087 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11089 if ((ip_addr).family == AF_INET6) \
11090 rte_memcpy(&(ip), \
11091 &((ip_addr).addr.ipv6), \
11092 sizeof(struct in6_addr)); \
11094 printf("invalid parameter.\n"); \
11100 cmd_flow_director_filter_parsed(void *parsed_result,
11101 __rte_unused struct cmdline *cl,
11102 __rte_unused void *data)
11104 struct cmd_flow_director_result *res = parsed_result;
11105 struct rte_eth_fdir_filter entry;
11106 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11108 unsigned long vf_id;
11111 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11113 printf("flow director is not supported on port %u.\n",
11117 memset(flexbytes, 0, sizeof(flexbytes));
11118 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11120 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11121 if (strcmp(res->mode_value, "MAC-VLAN")) {
11122 printf("Please set mode to MAC-VLAN.\n");
11125 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11126 if (strcmp(res->mode_value, "Tunnel")) {
11127 printf("Please set mode to Tunnel.\n");
11131 if (!strcmp(res->mode_value, "raw")) {
11132 #ifdef RTE_LIBRTE_I40E_PMD
11133 struct rte_pmd_i40e_flow_type_mapping
11134 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11135 struct rte_pmd_i40e_pkt_template_conf conf;
11136 uint16_t flow_type = str2flowtype(res->flow_type);
11137 uint16_t i, port = res->port_id;
11140 memset(&conf, 0, sizeof(conf));
11142 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11143 printf("Invalid flow type specified.\n");
11146 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11150 if (mapping[flow_type].pctype == 0ULL) {
11151 printf("Invalid flow type specified.\n");
11154 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11155 if (mapping[flow_type].pctype & (1ULL << i)) {
11156 conf.input.pctype = i;
11161 conf.input.packet = open_file(res->filepath,
11162 &conf.input.length);
11163 if (!conf.input.packet)
11165 if (!strcmp(res->drop, "drop"))
11166 conf.action.behavior =
11167 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11169 conf.action.behavior =
11170 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11171 conf.action.report_status =
11172 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11173 conf.action.rx_queue = res->queue_id;
11174 conf.soft_id = res->fd_id_value;
11175 add = strcmp(res->ops, "del") ? 1 : 0;
11176 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11180 printf("flow director config error: (%s)\n",
11182 close_file(conf.input.packet);
11185 } else if (strcmp(res->mode_value, "IP")) {
11186 printf("Please set mode to IP or raw.\n");
11189 entry.input.flow_type = str2flowtype(res->flow_type);
11192 ret = parse_flexbytes(res->flexbytes_value,
11194 RTE_ETH_FDIR_MAX_FLEXLEN);
11196 printf("error: Cannot parse flexbytes input.\n");
11200 switch (entry.input.flow_type) {
11201 case RTE_ETH_FLOW_FRAG_IPV4:
11202 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11203 entry.input.flow.ip4_flow.proto = res->proto_value;
11205 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11206 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11207 IPV4_ADDR_TO_UINT(res->ip_dst,
11208 entry.input.flow.ip4_flow.dst_ip);
11209 IPV4_ADDR_TO_UINT(res->ip_src,
11210 entry.input.flow.ip4_flow.src_ip);
11211 entry.input.flow.ip4_flow.tos = res->tos_value;
11212 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11213 /* need convert to big endian. */
11214 entry.input.flow.udp4_flow.dst_port =
11215 rte_cpu_to_be_16(res->port_dst);
11216 entry.input.flow.udp4_flow.src_port =
11217 rte_cpu_to_be_16(res->port_src);
11219 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11220 IPV4_ADDR_TO_UINT(res->ip_dst,
11221 entry.input.flow.sctp4_flow.ip.dst_ip);
11222 IPV4_ADDR_TO_UINT(res->ip_src,
11223 entry.input.flow.sctp4_flow.ip.src_ip);
11224 entry.input.flow.ip4_flow.tos = res->tos_value;
11225 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11226 /* need convert to big endian. */
11227 entry.input.flow.sctp4_flow.dst_port =
11228 rte_cpu_to_be_16(res->port_dst);
11229 entry.input.flow.sctp4_flow.src_port =
11230 rte_cpu_to_be_16(res->port_src);
11231 entry.input.flow.sctp4_flow.verify_tag =
11232 rte_cpu_to_be_32(res->verify_tag_value);
11234 case RTE_ETH_FLOW_FRAG_IPV6:
11235 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11236 entry.input.flow.ipv6_flow.proto = res->proto_value;
11238 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11239 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11240 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11241 entry.input.flow.ipv6_flow.dst_ip);
11242 IPV6_ADDR_TO_ARRAY(res->ip_src,
11243 entry.input.flow.ipv6_flow.src_ip);
11244 entry.input.flow.ipv6_flow.tc = res->tos_value;
11245 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11246 /* need convert to big endian. */
11247 entry.input.flow.udp6_flow.dst_port =
11248 rte_cpu_to_be_16(res->port_dst);
11249 entry.input.flow.udp6_flow.src_port =
11250 rte_cpu_to_be_16(res->port_src);
11252 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11253 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11254 entry.input.flow.sctp6_flow.ip.dst_ip);
11255 IPV6_ADDR_TO_ARRAY(res->ip_src,
11256 entry.input.flow.sctp6_flow.ip.src_ip);
11257 entry.input.flow.ipv6_flow.tc = res->tos_value;
11258 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11259 /* need convert to big endian. */
11260 entry.input.flow.sctp6_flow.dst_port =
11261 rte_cpu_to_be_16(res->port_dst);
11262 entry.input.flow.sctp6_flow.src_port =
11263 rte_cpu_to_be_16(res->port_src);
11264 entry.input.flow.sctp6_flow.verify_tag =
11265 rte_cpu_to_be_32(res->verify_tag_value);
11267 case RTE_ETH_FLOW_L2_PAYLOAD:
11268 entry.input.flow.l2_flow.ether_type =
11269 rte_cpu_to_be_16(res->ether_type);
11275 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11276 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11278 sizeof(struct rte_ether_addr));
11280 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11281 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11283 sizeof(struct rte_ether_addr));
11284 entry.input.flow.tunnel_flow.tunnel_type =
11285 str2fdir_tunneltype(res->tunnel_type);
11286 entry.input.flow.tunnel_flow.tunnel_id =
11287 rte_cpu_to_be_32(res->tunnel_id_value);
11290 rte_memcpy(entry.input.flow_ext.flexbytes,
11292 RTE_ETH_FDIR_MAX_FLEXLEN);
11294 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11296 entry.action.flex_off = 0; /*use 0 by default */
11297 if (!strcmp(res->drop, "drop"))
11298 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11300 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11302 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11303 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11304 if (!strcmp(res->pf_vf, "pf"))
11305 entry.input.flow_ext.is_vf = 0;
11306 else if (!strncmp(res->pf_vf, "vf", 2)) {
11307 struct rte_eth_dev_info dev_info;
11309 ret = eth_dev_info_get_print_err(res->port_id,
11315 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11316 if (errno != 0 || *end != '\0' ||
11317 vf_id >= dev_info.max_vfs) {
11318 printf("invalid parameter %s.\n", res->pf_vf);
11321 entry.input.flow_ext.is_vf = 1;
11322 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11324 printf("invalid parameter %s.\n", res->pf_vf);
11329 /* set to report FD ID by default */
11330 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11331 entry.action.rx_queue = res->queue_id;
11332 entry.soft_id = res->fd_id_value;
11333 if (!strcmp(res->ops, "add"))
11334 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11335 RTE_ETH_FILTER_ADD, &entry);
11336 else if (!strcmp(res->ops, "del"))
11337 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11338 RTE_ETH_FILTER_DELETE, &entry);
11340 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11341 RTE_ETH_FILTER_UPDATE, &entry);
11343 printf("flow director programming error: (%s)\n",
11347 cmdline_parse_token_string_t cmd_flow_director_filter =
11348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11349 flow_director_filter, "flow_director_filter");
11350 cmdline_parse_token_num_t cmd_flow_director_port_id =
11351 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11353 cmdline_parse_token_string_t cmd_flow_director_ops =
11354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11355 ops, "add#del#update");
11356 cmdline_parse_token_string_t cmd_flow_director_flow =
11357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11359 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11360 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11362 cmdline_parse_token_string_t cmd_flow_director_ether =
11363 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11365 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11366 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11367 ether_type, UINT16);
11368 cmdline_parse_token_string_t cmd_flow_director_src =
11369 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11371 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11372 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11374 cmdline_parse_token_num_t cmd_flow_director_port_src =
11375 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11377 cmdline_parse_token_string_t cmd_flow_director_dst =
11378 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11380 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11381 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11383 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11384 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11386 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11387 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11388 verify_tag, "verify_tag");
11389 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11390 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11391 verify_tag_value, UINT32);
11392 cmdline_parse_token_string_t cmd_flow_director_tos =
11393 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11395 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11396 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11398 cmdline_parse_token_string_t cmd_flow_director_proto =
11399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11401 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11402 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11403 proto_value, UINT8);
11404 cmdline_parse_token_string_t cmd_flow_director_ttl =
11405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11407 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11408 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11410 cmdline_parse_token_string_t cmd_flow_director_vlan =
11411 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11413 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11414 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11415 vlan_value, UINT16);
11416 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11417 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11418 flexbytes, "flexbytes");
11419 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11420 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11421 flexbytes_value, NULL);
11422 cmdline_parse_token_string_t cmd_flow_director_drop =
11423 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11425 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11426 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11428 cmdline_parse_token_string_t cmd_flow_director_queue =
11429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11431 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11432 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11434 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11435 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11437 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11438 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11439 fd_id_value, UINT32);
11441 cmdline_parse_token_string_t cmd_flow_director_mode =
11442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11444 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11445 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11447 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11448 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11449 mode_value, "MAC-VLAN");
11450 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11451 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11452 mode_value, "Tunnel");
11453 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11455 mode_value, "raw");
11456 cmdline_parse_token_string_t cmd_flow_director_mac =
11457 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11459 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11460 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11462 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11463 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11465 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11466 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11467 tunnel_type, "NVGRE#VxLAN");
11468 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11469 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11470 tunnel_id, "tunnel-id");
11471 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11472 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11473 tunnel_id_value, UINT32);
11474 cmdline_parse_token_string_t cmd_flow_director_packet =
11475 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11477 cmdline_parse_token_string_t cmd_flow_director_filepath =
11478 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11481 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11482 .f = cmd_flow_director_filter_parsed,
11484 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11485 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11486 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11487 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11488 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11489 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11490 "fd_id <fd_id_value>: "
11491 "Add or delete an ip flow director entry on NIC",
11493 (void *)&cmd_flow_director_filter,
11494 (void *)&cmd_flow_director_port_id,
11495 (void *)&cmd_flow_director_mode,
11496 (void *)&cmd_flow_director_mode_ip,
11497 (void *)&cmd_flow_director_ops,
11498 (void *)&cmd_flow_director_flow,
11499 (void *)&cmd_flow_director_flow_type,
11500 (void *)&cmd_flow_director_src,
11501 (void *)&cmd_flow_director_ip_src,
11502 (void *)&cmd_flow_director_dst,
11503 (void *)&cmd_flow_director_ip_dst,
11504 (void *)&cmd_flow_director_tos,
11505 (void *)&cmd_flow_director_tos_value,
11506 (void *)&cmd_flow_director_proto,
11507 (void *)&cmd_flow_director_proto_value,
11508 (void *)&cmd_flow_director_ttl,
11509 (void *)&cmd_flow_director_ttl_value,
11510 (void *)&cmd_flow_director_vlan,
11511 (void *)&cmd_flow_director_vlan_value,
11512 (void *)&cmd_flow_director_flexbytes,
11513 (void *)&cmd_flow_director_flexbytes_value,
11514 (void *)&cmd_flow_director_drop,
11515 (void *)&cmd_flow_director_pf_vf,
11516 (void *)&cmd_flow_director_queue,
11517 (void *)&cmd_flow_director_queue_id,
11518 (void *)&cmd_flow_director_fd_id,
11519 (void *)&cmd_flow_director_fd_id_value,
11524 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11525 .f = cmd_flow_director_filter_parsed,
11527 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11528 "director entry on NIC",
11530 (void *)&cmd_flow_director_filter,
11531 (void *)&cmd_flow_director_port_id,
11532 (void *)&cmd_flow_director_mode,
11533 (void *)&cmd_flow_director_mode_ip,
11534 (void *)&cmd_flow_director_ops,
11535 (void *)&cmd_flow_director_flow,
11536 (void *)&cmd_flow_director_flow_type,
11537 (void *)&cmd_flow_director_src,
11538 (void *)&cmd_flow_director_ip_src,
11539 (void *)&cmd_flow_director_port_src,
11540 (void *)&cmd_flow_director_dst,
11541 (void *)&cmd_flow_director_ip_dst,
11542 (void *)&cmd_flow_director_port_dst,
11543 (void *)&cmd_flow_director_tos,
11544 (void *)&cmd_flow_director_tos_value,
11545 (void *)&cmd_flow_director_ttl,
11546 (void *)&cmd_flow_director_ttl_value,
11547 (void *)&cmd_flow_director_vlan,
11548 (void *)&cmd_flow_director_vlan_value,
11549 (void *)&cmd_flow_director_flexbytes,
11550 (void *)&cmd_flow_director_flexbytes_value,
11551 (void *)&cmd_flow_director_drop,
11552 (void *)&cmd_flow_director_pf_vf,
11553 (void *)&cmd_flow_director_queue,
11554 (void *)&cmd_flow_director_queue_id,
11555 (void *)&cmd_flow_director_fd_id,
11556 (void *)&cmd_flow_director_fd_id_value,
11561 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11562 .f = cmd_flow_director_filter_parsed,
11564 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11565 "director entry on NIC",
11567 (void *)&cmd_flow_director_filter,
11568 (void *)&cmd_flow_director_port_id,
11569 (void *)&cmd_flow_director_mode,
11570 (void *)&cmd_flow_director_mode_ip,
11571 (void *)&cmd_flow_director_ops,
11572 (void *)&cmd_flow_director_flow,
11573 (void *)&cmd_flow_director_flow_type,
11574 (void *)&cmd_flow_director_src,
11575 (void *)&cmd_flow_director_ip_src,
11576 (void *)&cmd_flow_director_port_src,
11577 (void *)&cmd_flow_director_dst,
11578 (void *)&cmd_flow_director_ip_dst,
11579 (void *)&cmd_flow_director_port_dst,
11580 (void *)&cmd_flow_director_verify_tag,
11581 (void *)&cmd_flow_director_verify_tag_value,
11582 (void *)&cmd_flow_director_tos,
11583 (void *)&cmd_flow_director_tos_value,
11584 (void *)&cmd_flow_director_ttl,
11585 (void *)&cmd_flow_director_ttl_value,
11586 (void *)&cmd_flow_director_vlan,
11587 (void *)&cmd_flow_director_vlan_value,
11588 (void *)&cmd_flow_director_flexbytes,
11589 (void *)&cmd_flow_director_flexbytes_value,
11590 (void *)&cmd_flow_director_drop,
11591 (void *)&cmd_flow_director_pf_vf,
11592 (void *)&cmd_flow_director_queue,
11593 (void *)&cmd_flow_director_queue_id,
11594 (void *)&cmd_flow_director_fd_id,
11595 (void *)&cmd_flow_director_fd_id_value,
11600 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11601 .f = cmd_flow_director_filter_parsed,
11603 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11604 "director entry on NIC",
11606 (void *)&cmd_flow_director_filter,
11607 (void *)&cmd_flow_director_port_id,
11608 (void *)&cmd_flow_director_mode,
11609 (void *)&cmd_flow_director_mode_ip,
11610 (void *)&cmd_flow_director_ops,
11611 (void *)&cmd_flow_director_flow,
11612 (void *)&cmd_flow_director_flow_type,
11613 (void *)&cmd_flow_director_ether,
11614 (void *)&cmd_flow_director_ether_type,
11615 (void *)&cmd_flow_director_flexbytes,
11616 (void *)&cmd_flow_director_flexbytes_value,
11617 (void *)&cmd_flow_director_drop,
11618 (void *)&cmd_flow_director_pf_vf,
11619 (void *)&cmd_flow_director_queue,
11620 (void *)&cmd_flow_director_queue_id,
11621 (void *)&cmd_flow_director_fd_id,
11622 (void *)&cmd_flow_director_fd_id_value,
11627 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11628 .f = cmd_flow_director_filter_parsed,
11630 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11631 "director entry on NIC",
11633 (void *)&cmd_flow_director_filter,
11634 (void *)&cmd_flow_director_port_id,
11635 (void *)&cmd_flow_director_mode,
11636 (void *)&cmd_flow_director_mode_mac_vlan,
11637 (void *)&cmd_flow_director_ops,
11638 (void *)&cmd_flow_director_mac,
11639 (void *)&cmd_flow_director_mac_addr,
11640 (void *)&cmd_flow_director_vlan,
11641 (void *)&cmd_flow_director_vlan_value,
11642 (void *)&cmd_flow_director_flexbytes,
11643 (void *)&cmd_flow_director_flexbytes_value,
11644 (void *)&cmd_flow_director_drop,
11645 (void *)&cmd_flow_director_queue,
11646 (void *)&cmd_flow_director_queue_id,
11647 (void *)&cmd_flow_director_fd_id,
11648 (void *)&cmd_flow_director_fd_id_value,
11653 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11654 .f = cmd_flow_director_filter_parsed,
11656 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11657 "director entry on NIC",
11659 (void *)&cmd_flow_director_filter,
11660 (void *)&cmd_flow_director_port_id,
11661 (void *)&cmd_flow_director_mode,
11662 (void *)&cmd_flow_director_mode_tunnel,
11663 (void *)&cmd_flow_director_ops,
11664 (void *)&cmd_flow_director_mac,
11665 (void *)&cmd_flow_director_mac_addr,
11666 (void *)&cmd_flow_director_vlan,
11667 (void *)&cmd_flow_director_vlan_value,
11668 (void *)&cmd_flow_director_tunnel,
11669 (void *)&cmd_flow_director_tunnel_type,
11670 (void *)&cmd_flow_director_tunnel_id,
11671 (void *)&cmd_flow_director_tunnel_id_value,
11672 (void *)&cmd_flow_director_flexbytes,
11673 (void *)&cmd_flow_director_flexbytes_value,
11674 (void *)&cmd_flow_director_drop,
11675 (void *)&cmd_flow_director_queue,
11676 (void *)&cmd_flow_director_queue_id,
11677 (void *)&cmd_flow_director_fd_id,
11678 (void *)&cmd_flow_director_fd_id_value,
11683 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11684 .f = cmd_flow_director_filter_parsed,
11686 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11687 "director entry on NIC",
11689 (void *)&cmd_flow_director_filter,
11690 (void *)&cmd_flow_director_port_id,
11691 (void *)&cmd_flow_director_mode,
11692 (void *)&cmd_flow_director_mode_raw,
11693 (void *)&cmd_flow_director_ops,
11694 (void *)&cmd_flow_director_flow,
11695 (void *)&cmd_flow_director_flow_type,
11696 (void *)&cmd_flow_director_drop,
11697 (void *)&cmd_flow_director_queue,
11698 (void *)&cmd_flow_director_queue_id,
11699 (void *)&cmd_flow_director_fd_id,
11700 (void *)&cmd_flow_director_fd_id_value,
11701 (void *)&cmd_flow_director_packet,
11702 (void *)&cmd_flow_director_filepath,
11707 struct cmd_flush_flow_director_result {
11708 cmdline_fixed_string_t flush_flow_director;
11712 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11713 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11714 flush_flow_director, "flush_flow_director");
11715 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11716 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11720 cmd_flush_flow_director_parsed(void *parsed_result,
11721 __rte_unused struct cmdline *cl,
11722 __rte_unused void *data)
11724 struct cmd_flow_director_result *res = parsed_result;
11727 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11729 printf("flow director is not supported on port %u.\n",
11734 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11735 RTE_ETH_FILTER_FLUSH, NULL);
11737 printf("flow director table flushing error: (%s)\n",
11741 cmdline_parse_inst_t cmd_flush_flow_director = {
11742 .f = cmd_flush_flow_director_parsed,
11744 .help_str = "flush_flow_director <port_id>: "
11745 "Flush all flow director entries of a device on NIC",
11747 (void *)&cmd_flush_flow_director_flush,
11748 (void *)&cmd_flush_flow_director_port_id,
11753 /* *** deal with flow director mask *** */
11754 struct cmd_flow_director_mask_result {
11755 cmdline_fixed_string_t flow_director_mask;
11757 cmdline_fixed_string_t mode;
11758 cmdline_fixed_string_t mode_value;
11759 cmdline_fixed_string_t vlan;
11760 uint16_t vlan_mask;
11761 cmdline_fixed_string_t src_mask;
11762 cmdline_ipaddr_t ipv4_src;
11763 cmdline_ipaddr_t ipv6_src;
11765 cmdline_fixed_string_t dst_mask;
11766 cmdline_ipaddr_t ipv4_dst;
11767 cmdline_ipaddr_t ipv6_dst;
11769 cmdline_fixed_string_t mac;
11770 uint8_t mac_addr_byte_mask;
11771 cmdline_fixed_string_t tunnel_id;
11772 uint32_t tunnel_id_mask;
11773 cmdline_fixed_string_t tunnel_type;
11774 uint8_t tunnel_type_mask;
11778 cmd_flow_director_mask_parsed(void *parsed_result,
11779 __rte_unused struct cmdline *cl,
11780 __rte_unused void *data)
11782 struct cmd_flow_director_mask_result *res = parsed_result;
11783 struct rte_eth_fdir_masks *mask;
11784 struct rte_port *port;
11786 port = &ports[res->port_id];
11787 /** Check if the port is not started **/
11788 if (port->port_status != RTE_PORT_STOPPED) {
11789 printf("Please stop port %d first\n", res->port_id);
11793 mask = &port->dev_conf.fdir_conf.mask;
11795 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11796 if (strcmp(res->mode_value, "MAC-VLAN")) {
11797 printf("Please set mode to MAC-VLAN.\n");
11801 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11802 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11803 if (strcmp(res->mode_value, "Tunnel")) {
11804 printf("Please set mode to Tunnel.\n");
11808 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11809 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11810 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11811 mask->tunnel_type_mask = res->tunnel_type_mask;
11813 if (strcmp(res->mode_value, "IP")) {
11814 printf("Please set mode to IP.\n");
11818 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11819 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11820 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11821 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11822 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11823 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11824 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11827 cmd_reconfig_device_queue(res->port_id, 1, 1);
11830 cmdline_parse_token_string_t cmd_flow_director_mask =
11831 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11832 flow_director_mask, "flow_director_mask");
11833 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11834 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11836 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11839 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11840 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11841 vlan_mask, UINT16);
11842 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11844 src_mask, "src_mask");
11845 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11846 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11848 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11849 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11851 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11852 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11854 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11856 dst_mask, "dst_mask");
11857 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11858 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11860 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11861 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11863 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11864 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11867 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11870 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11873 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11875 mode_value, "MAC-VLAN");
11876 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11877 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11878 mode_value, "Tunnel");
11879 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11880 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11882 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11883 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11884 mac_addr_byte_mask, UINT8);
11885 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11887 tunnel_type, "tunnel-type");
11888 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11889 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11890 tunnel_type_mask, UINT8);
11891 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11893 tunnel_id, "tunnel-id");
11894 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11895 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11896 tunnel_id_mask, UINT32);
11898 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11899 .f = cmd_flow_director_mask_parsed,
11901 .help_str = "flow_director_mask ... : "
11902 "Set IP mode 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_ip,
11908 (void *)&cmd_flow_director_mask_vlan,
11909 (void *)&cmd_flow_director_mask_vlan_value,
11910 (void *)&cmd_flow_director_mask_src,
11911 (void *)&cmd_flow_director_mask_ipv4_src,
11912 (void *)&cmd_flow_director_mask_ipv6_src,
11913 (void *)&cmd_flow_director_mask_port_src,
11914 (void *)&cmd_flow_director_mask_dst,
11915 (void *)&cmd_flow_director_mask_ipv4_dst,
11916 (void *)&cmd_flow_director_mask_ipv6_dst,
11917 (void *)&cmd_flow_director_mask_port_dst,
11922 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11923 .f = cmd_flow_director_mask_parsed,
11925 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11926 "flow director's mask on NIC",
11928 (void *)&cmd_flow_director_mask,
11929 (void *)&cmd_flow_director_mask_port_id,
11930 (void *)&cmd_flow_director_mask_mode,
11931 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11932 (void *)&cmd_flow_director_mask_vlan,
11933 (void *)&cmd_flow_director_mask_vlan_value,
11938 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11939 .f = cmd_flow_director_mask_parsed,
11941 .help_str = "flow_director_mask ... : Set tunnel mode "
11942 "flow director's mask on NIC",
11944 (void *)&cmd_flow_director_mask,
11945 (void *)&cmd_flow_director_mask_port_id,
11946 (void *)&cmd_flow_director_mask_mode,
11947 (void *)&cmd_flow_director_mask_mode_tunnel,
11948 (void *)&cmd_flow_director_mask_vlan,
11949 (void *)&cmd_flow_director_mask_vlan_value,
11950 (void *)&cmd_flow_director_mask_mac,
11951 (void *)&cmd_flow_director_mask_mac_value,
11952 (void *)&cmd_flow_director_mask_tunnel_type,
11953 (void *)&cmd_flow_director_mask_tunnel_type_value,
11954 (void *)&cmd_flow_director_mask_tunnel_id,
11955 (void *)&cmd_flow_director_mask_tunnel_id_value,
11960 /* *** deal with flow director mask on flexible payload *** */
11961 struct cmd_flow_director_flex_mask_result {
11962 cmdline_fixed_string_t flow_director_flexmask;
11964 cmdline_fixed_string_t flow;
11965 cmdline_fixed_string_t flow_type;
11966 cmdline_fixed_string_t mask;
11970 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11971 __rte_unused struct cmdline *cl,
11972 __rte_unused void *data)
11974 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11975 struct rte_eth_fdir_info fdir_info;
11976 struct rte_eth_fdir_flex_mask flex_mask;
11977 struct rte_port *port;
11978 uint64_t flow_type_mask;
11982 port = &ports[res->port_id];
11983 /** Check if the port is not started **/
11984 if (port->port_status != RTE_PORT_STOPPED) {
11985 printf("Please stop port %d first\n", res->port_id);
11989 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11990 ret = parse_flexbytes(res->mask,
11992 RTE_ETH_FDIR_MAX_FLEXLEN);
11994 printf("error: Cannot parse mask input.\n");
11998 memset(&fdir_info, 0, sizeof(fdir_info));
11999 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12000 RTE_ETH_FILTER_INFO, &fdir_info);
12002 printf("Cannot get FDir filter info\n");
12006 if (!strcmp(res->flow_type, "none")) {
12007 /* means don't specify the flow type */
12008 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12009 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12010 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12011 0, sizeof(struct rte_eth_fdir_flex_mask));
12012 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12013 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12015 sizeof(struct rte_eth_fdir_flex_mask));
12016 cmd_reconfig_device_queue(res->port_id, 1, 1);
12019 flow_type_mask = fdir_info.flow_types_mask[0];
12020 if (!strcmp(res->flow_type, "all")) {
12021 if (!flow_type_mask) {
12022 printf("No flow type supported\n");
12025 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12026 if (flow_type_mask & (1ULL << i)) {
12027 flex_mask.flow_type = i;
12028 fdir_set_flex_mask(res->port_id, &flex_mask);
12031 cmd_reconfig_device_queue(res->port_id, 1, 1);
12034 flex_mask.flow_type = str2flowtype(res->flow_type);
12035 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12036 printf("Flow type %s not supported on port %d\n",
12037 res->flow_type, res->port_id);
12040 fdir_set_flex_mask(res->port_id, &flex_mask);
12041 cmd_reconfig_device_queue(res->port_id, 1, 1);
12044 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12045 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12046 flow_director_flexmask,
12047 "flow_director_flex_mask");
12048 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12049 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12051 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12052 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12054 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12055 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12056 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12057 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12058 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12059 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12062 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12063 .f = cmd_flow_director_flex_mask_parsed,
12065 .help_str = "flow_director_flex_mask ... : "
12066 "Set flow director's flex mask on NIC",
12068 (void *)&cmd_flow_director_flexmask,
12069 (void *)&cmd_flow_director_flexmask_port_id,
12070 (void *)&cmd_flow_director_flexmask_flow,
12071 (void *)&cmd_flow_director_flexmask_flow_type,
12072 (void *)&cmd_flow_director_flexmask_mask,
12077 /* *** deal with flow director flexible payload configuration *** */
12078 struct cmd_flow_director_flexpayload_result {
12079 cmdline_fixed_string_t flow_director_flexpayload;
12081 cmdline_fixed_string_t payload_layer;
12082 cmdline_fixed_string_t payload_cfg;
12086 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12089 const char *p, *p0 = q_arg;
12091 unsigned long int_fld;
12092 char *str_fld[max_num];
12097 p = strchr(p0, '(');
12101 p0 = strchr(p, ')');
12106 if (size >= sizeof(s))
12109 snprintf(s, sizeof(s), "%.*s", size, p);
12110 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12111 if (ret < 0 || ret > max_num)
12113 for (i = 0; i < ret; i++) {
12115 int_fld = strtoul(str_fld[i], &end, 0);
12116 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12118 offsets[i] = (uint16_t)int_fld;
12124 cmd_flow_director_flxpld_parsed(void *parsed_result,
12125 __rte_unused struct cmdline *cl,
12126 __rte_unused void *data)
12128 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12129 struct rte_eth_flex_payload_cfg flex_cfg;
12130 struct rte_port *port;
12133 port = &ports[res->port_id];
12134 /** Check if the port is not started **/
12135 if (port->port_status != RTE_PORT_STOPPED) {
12136 printf("Please stop port %d first\n", res->port_id);
12140 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12142 if (!strcmp(res->payload_layer, "raw"))
12143 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12144 else if (!strcmp(res->payload_layer, "l2"))
12145 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12146 else if (!strcmp(res->payload_layer, "l3"))
12147 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12148 else if (!strcmp(res->payload_layer, "l4"))
12149 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12151 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12152 RTE_ETH_FDIR_MAX_FLEXLEN);
12154 printf("error: Cannot parse flex payload input.\n");
12158 fdir_set_flex_payload(res->port_id, &flex_cfg);
12159 cmd_reconfig_device_queue(res->port_id, 1, 1);
12162 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12163 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12164 flow_director_flexpayload,
12165 "flow_director_flex_payload");
12166 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12167 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12169 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12170 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12171 payload_layer, "raw#l2#l3#l4");
12172 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12173 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12174 payload_cfg, NULL);
12176 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12177 .f = cmd_flow_director_flxpld_parsed,
12179 .help_str = "flow_director_flexpayload ... : "
12180 "Set flow director's flex payload on NIC",
12182 (void *)&cmd_flow_director_flexpayload,
12183 (void *)&cmd_flow_director_flexpayload_port_id,
12184 (void *)&cmd_flow_director_flexpayload_payload_layer,
12185 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12190 /* Generic flow interface command. */
12191 extern cmdline_parse_inst_t cmd_flow;
12193 /* *** Classification Filters Control *** */
12194 /* *** Get symmetric hash enable per port *** */
12195 struct cmd_get_sym_hash_ena_per_port_result {
12196 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12201 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12202 __rte_unused struct cmdline *cl,
12203 __rte_unused void *data)
12205 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12206 struct rte_eth_hash_filter_info info;
12209 if (rte_eth_dev_filter_supported(res->port_id,
12210 RTE_ETH_FILTER_HASH) < 0) {
12211 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12216 memset(&info, 0, sizeof(info));
12217 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12218 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12219 RTE_ETH_FILTER_GET, &info);
12222 printf("Cannot get symmetric hash enable per port "
12223 "on port %u\n", res->port_id);
12227 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12228 "enabled" : "disabled", res->port_id);
12231 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12232 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12233 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12234 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12235 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12238 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12239 .f = cmd_get_sym_hash_per_port_parsed,
12241 .help_str = "get_sym_hash_ena_per_port <port_id>",
12243 (void *)&cmd_get_sym_hash_ena_per_port_all,
12244 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12249 /* *** Set symmetric hash enable per port *** */
12250 struct cmd_set_sym_hash_ena_per_port_result {
12251 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12252 cmdline_fixed_string_t enable;
12257 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12258 __rte_unused struct cmdline *cl,
12259 __rte_unused void *data)
12261 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12262 struct rte_eth_hash_filter_info info;
12265 if (rte_eth_dev_filter_supported(res->port_id,
12266 RTE_ETH_FILTER_HASH) < 0) {
12267 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12272 memset(&info, 0, sizeof(info));
12273 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12274 if (!strcmp(res->enable, "enable"))
12275 info.info.enable = 1;
12276 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12277 RTE_ETH_FILTER_SET, &info);
12279 printf("Cannot set symmetric hash enable per port on "
12280 "port %u\n", res->port_id);
12283 printf("Symmetric hash has been set to %s on port %u\n",
12284 res->enable, res->port_id);
12287 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12288 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12289 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12290 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12291 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12293 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12294 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12295 enable, "enable#disable");
12297 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12298 .f = cmd_set_sym_hash_per_port_parsed,
12300 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12302 (void *)&cmd_set_sym_hash_ena_per_port_all,
12303 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12304 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12309 /* Get global config of hash function */
12310 struct cmd_get_hash_global_config_result {
12311 cmdline_fixed_string_t get_hash_global_config;
12316 flowtype_to_str(uint16_t ftype)
12322 } ftype_table[] = {
12323 {"ipv4", RTE_ETH_FLOW_IPV4},
12324 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12325 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12326 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12327 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12328 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12329 {"ipv6", RTE_ETH_FLOW_IPV6},
12330 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12331 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12332 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12333 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12334 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12335 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12336 {"port", RTE_ETH_FLOW_PORT},
12337 {"vxlan", RTE_ETH_FLOW_VXLAN},
12338 {"geneve", RTE_ETH_FLOW_GENEVE},
12339 {"nvgre", RTE_ETH_FLOW_NVGRE},
12340 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12343 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12344 if (ftype_table[i].ftype == ftype)
12345 return ftype_table[i].str;
12352 cmd_get_hash_global_config_parsed(void *parsed_result,
12353 __rte_unused struct cmdline *cl,
12354 __rte_unused void *data)
12356 struct cmd_get_hash_global_config_result *res = parsed_result;
12357 struct rte_eth_hash_filter_info info;
12358 uint32_t idx, offset;
12363 if (rte_eth_dev_filter_supported(res->port_id,
12364 RTE_ETH_FILTER_HASH) < 0) {
12365 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12370 memset(&info, 0, sizeof(info));
12371 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12372 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12373 RTE_ETH_FILTER_GET, &info);
12375 printf("Cannot get hash global configurations by port %d\n",
12380 switch (info.info.global_conf.hash_func) {
12381 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12382 printf("Hash function is Toeplitz\n");
12384 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12385 printf("Hash function is Simple XOR\n");
12387 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12388 printf("Hash function is Symmetric Toeplitz\n");
12391 printf("Unknown hash function\n");
12395 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12396 idx = i / UINT64_BIT;
12397 offset = i % UINT64_BIT;
12398 if (!(info.info.global_conf.valid_bit_mask[idx] &
12401 str = flowtype_to_str(i);
12404 printf("Symmetric hash is %s globally for flow type %s "
12406 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12407 (1ULL << offset)) ? "enabled" : "disabled"), str,
12412 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12413 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12414 get_hash_global_config, "get_hash_global_config");
12415 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12416 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12419 cmdline_parse_inst_t cmd_get_hash_global_config = {
12420 .f = cmd_get_hash_global_config_parsed,
12422 .help_str = "get_hash_global_config <port_id>",
12424 (void *)&cmd_get_hash_global_config_all,
12425 (void *)&cmd_get_hash_global_config_port_id,
12430 /* Set global config of hash function */
12431 struct cmd_set_hash_global_config_result {
12432 cmdline_fixed_string_t set_hash_global_config;
12434 cmdline_fixed_string_t hash_func;
12435 cmdline_fixed_string_t flow_type;
12436 cmdline_fixed_string_t enable;
12440 cmd_set_hash_global_config_parsed(void *parsed_result,
12441 __rte_unused struct cmdline *cl,
12442 __rte_unused void *data)
12444 struct cmd_set_hash_global_config_result *res = parsed_result;
12445 struct rte_eth_hash_filter_info info;
12446 uint32_t ftype, idx, offset;
12449 if (rte_eth_dev_filter_supported(res->port_id,
12450 RTE_ETH_FILTER_HASH) < 0) {
12451 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12455 memset(&info, 0, sizeof(info));
12456 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12457 if (!strcmp(res->hash_func, "toeplitz"))
12458 info.info.global_conf.hash_func =
12459 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12460 else if (!strcmp(res->hash_func, "simple_xor"))
12461 info.info.global_conf.hash_func =
12462 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12463 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12464 info.info.global_conf.hash_func =
12465 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12466 else if (!strcmp(res->hash_func, "default"))
12467 info.info.global_conf.hash_func =
12468 RTE_ETH_HASH_FUNCTION_DEFAULT;
12470 ftype = str2flowtype(res->flow_type);
12471 idx = ftype / UINT64_BIT;
12472 offset = ftype % UINT64_BIT;
12473 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12474 if (!strcmp(res->enable, "enable"))
12475 info.info.global_conf.sym_hash_enable_mask[idx] |=
12477 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12478 RTE_ETH_FILTER_SET, &info);
12480 printf("Cannot set global hash configurations by port %d\n",
12483 printf("Global hash configurations have been set "
12484 "successfully by port %d\n", res->port_id);
12487 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12488 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12489 set_hash_global_config, "set_hash_global_config");
12490 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12491 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12493 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12494 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12495 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12496 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12497 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12499 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12500 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12501 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12502 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12503 enable, "enable#disable");
12505 cmdline_parse_inst_t cmd_set_hash_global_config = {
12506 .f = cmd_set_hash_global_config_parsed,
12508 .help_str = "set_hash_global_config <port_id> "
12509 "toeplitz|simple_xor|symmetric_toeplitz|default "
12510 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12511 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12512 "l2_payload enable|disable",
12514 (void *)&cmd_set_hash_global_config_all,
12515 (void *)&cmd_set_hash_global_config_port_id,
12516 (void *)&cmd_set_hash_global_config_hash_func,
12517 (void *)&cmd_set_hash_global_config_flow_type,
12518 (void *)&cmd_set_hash_global_config_enable,
12523 /* Set hash input set */
12524 struct cmd_set_hash_input_set_result {
12525 cmdline_fixed_string_t set_hash_input_set;
12527 cmdline_fixed_string_t flow_type;
12528 cmdline_fixed_string_t inset_field;
12529 cmdline_fixed_string_t select;
12532 static enum rte_eth_input_set_field
12533 str2inset(char *string)
12537 static const struct {
12539 enum rte_eth_input_set_field inset;
12540 } inset_table[] = {
12541 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12542 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12543 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12544 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12545 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12546 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12547 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12548 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12549 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12550 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12551 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12552 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12553 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12554 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12555 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12556 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12557 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12558 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12559 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12560 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12561 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12562 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12563 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12564 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12565 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12566 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12567 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12568 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12569 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12570 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12571 {"none", RTE_ETH_INPUT_SET_NONE},
12574 for (i = 0; i < RTE_DIM(inset_table); i++) {
12575 if (!strcmp(string, inset_table[i].str))
12576 return inset_table[i].inset;
12579 return RTE_ETH_INPUT_SET_UNKNOWN;
12583 cmd_set_hash_input_set_parsed(void *parsed_result,
12584 __rte_unused struct cmdline *cl,
12585 __rte_unused void *data)
12587 struct cmd_set_hash_input_set_result *res = parsed_result;
12588 struct rte_eth_hash_filter_info info;
12590 memset(&info, 0, sizeof(info));
12591 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12592 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12593 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12594 info.info.input_set_conf.inset_size = 1;
12595 if (!strcmp(res->select, "select"))
12596 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12597 else if (!strcmp(res->select, "add"))
12598 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12599 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12600 RTE_ETH_FILTER_SET, &info);
12603 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12604 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12605 set_hash_input_set, "set_hash_input_set");
12606 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12607 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12609 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12610 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12612 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12613 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12615 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12616 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12617 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12618 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12619 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12621 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12622 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12623 select, "select#add");
12625 cmdline_parse_inst_t cmd_set_hash_input_set = {
12626 .f = cmd_set_hash_input_set_parsed,
12628 .help_str = "set_hash_input_set <port_id> "
12629 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12630 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12631 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12632 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12633 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12634 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12635 "fld-7th|fld-8th|none select|add",
12637 (void *)&cmd_set_hash_input_set_cmd,
12638 (void *)&cmd_set_hash_input_set_port_id,
12639 (void *)&cmd_set_hash_input_set_flow_type,
12640 (void *)&cmd_set_hash_input_set_field,
12641 (void *)&cmd_set_hash_input_set_select,
12646 /* Set flow director input set */
12647 struct cmd_set_fdir_input_set_result {
12648 cmdline_fixed_string_t set_fdir_input_set;
12650 cmdline_fixed_string_t flow_type;
12651 cmdline_fixed_string_t inset_field;
12652 cmdline_fixed_string_t select;
12656 cmd_set_fdir_input_set_parsed(void *parsed_result,
12657 __rte_unused struct cmdline *cl,
12658 __rte_unused void *data)
12660 struct cmd_set_fdir_input_set_result *res = parsed_result;
12661 struct rte_eth_fdir_filter_info info;
12663 memset(&info, 0, sizeof(info));
12664 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12665 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12666 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12667 info.info.input_set_conf.inset_size = 1;
12668 if (!strcmp(res->select, "select"))
12669 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12670 else if (!strcmp(res->select, "add"))
12671 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12672 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12673 RTE_ETH_FILTER_SET, &info);
12676 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12677 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12678 set_fdir_input_set, "set_fdir_input_set");
12679 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12680 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12682 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12683 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12685 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12686 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12687 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12688 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12690 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12691 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12692 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12693 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12694 "sctp-veri-tag#none");
12695 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12696 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12697 select, "select#add");
12699 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12700 .f = cmd_set_fdir_input_set_parsed,
12702 .help_str = "set_fdir_input_set <port_id> "
12703 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12704 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12705 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12706 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12707 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12708 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12709 "sctp-veri-tag|none select|add",
12711 (void *)&cmd_set_fdir_input_set_cmd,
12712 (void *)&cmd_set_fdir_input_set_port_id,
12713 (void *)&cmd_set_fdir_input_set_flow_type,
12714 (void *)&cmd_set_fdir_input_set_field,
12715 (void *)&cmd_set_fdir_input_set_select,
12720 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12721 struct cmd_mcast_addr_result {
12722 cmdline_fixed_string_t mcast_addr_cmd;
12723 cmdline_fixed_string_t what;
12725 struct rte_ether_addr mc_addr;
12728 static void cmd_mcast_addr_parsed(void *parsed_result,
12729 __rte_unused struct cmdline *cl,
12730 __rte_unused void *data)
12732 struct cmd_mcast_addr_result *res = parsed_result;
12734 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12735 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12736 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12737 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12738 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12741 if (strcmp(res->what, "add") == 0)
12742 mcast_addr_add(res->port_num, &res->mc_addr);
12744 mcast_addr_remove(res->port_num, &res->mc_addr);
12747 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12748 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12749 mcast_addr_cmd, "mcast_addr");
12750 cmdline_parse_token_string_t cmd_mcast_addr_what =
12751 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12753 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12754 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12755 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12756 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12758 cmdline_parse_inst_t cmd_mcast_addr = {
12759 .f = cmd_mcast_addr_parsed,
12761 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12762 "Add/Remove multicast MAC address on port_id",
12764 (void *)&cmd_mcast_addr_cmd,
12765 (void *)&cmd_mcast_addr_what,
12766 (void *)&cmd_mcast_addr_portnum,
12767 (void *)&cmd_mcast_addr_addr,
12772 /* l2 tunnel config
12773 * only support E-tag now.
12776 /* Ether type config */
12777 struct cmd_config_l2_tunnel_eth_type_result {
12778 cmdline_fixed_string_t port;
12779 cmdline_fixed_string_t config;
12780 cmdline_fixed_string_t all;
12782 cmdline_fixed_string_t l2_tunnel;
12783 cmdline_fixed_string_t l2_tunnel_type;
12784 cmdline_fixed_string_t eth_type;
12785 uint16_t eth_type_val;
12788 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12789 TOKEN_STRING_INITIALIZER
12790 (struct cmd_config_l2_tunnel_eth_type_result,
12792 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12793 TOKEN_STRING_INITIALIZER
12794 (struct cmd_config_l2_tunnel_eth_type_result,
12796 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12797 TOKEN_STRING_INITIALIZER
12798 (struct cmd_config_l2_tunnel_eth_type_result,
12800 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12801 TOKEN_NUM_INITIALIZER
12802 (struct cmd_config_l2_tunnel_eth_type_result,
12804 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12805 TOKEN_STRING_INITIALIZER
12806 (struct cmd_config_l2_tunnel_eth_type_result,
12807 l2_tunnel, "l2-tunnel");
12808 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12809 TOKEN_STRING_INITIALIZER
12810 (struct cmd_config_l2_tunnel_eth_type_result,
12811 l2_tunnel_type, "E-tag");
12812 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12813 TOKEN_STRING_INITIALIZER
12814 (struct cmd_config_l2_tunnel_eth_type_result,
12815 eth_type, "ether-type");
12816 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12817 TOKEN_NUM_INITIALIZER
12818 (struct cmd_config_l2_tunnel_eth_type_result,
12819 eth_type_val, UINT16);
12821 static enum rte_eth_tunnel_type
12822 str2fdir_l2_tunnel_type(char *string)
12826 static const struct {
12828 enum rte_eth_tunnel_type type;
12829 } l2_tunnel_type_str[] = {
12830 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12833 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12834 if (!strcmp(l2_tunnel_type_str[i].str, string))
12835 return l2_tunnel_type_str[i].type;
12837 return RTE_TUNNEL_TYPE_NONE;
12840 /* ether type config for all ports */
12842 cmd_config_l2_tunnel_eth_type_all_parsed
12843 (void *parsed_result,
12844 __rte_unused struct cmdline *cl,
12845 __rte_unused void *data)
12847 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12848 struct rte_eth_l2_tunnel_conf entry;
12851 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12852 entry.ether_type = res->eth_type_val;
12854 RTE_ETH_FOREACH_DEV(pid) {
12855 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12859 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12860 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12862 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12864 (void *)&cmd_config_l2_tunnel_eth_type_port,
12865 (void *)&cmd_config_l2_tunnel_eth_type_config,
12866 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12867 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12868 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12869 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12870 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12875 /* ether type config for a specific port */
12877 cmd_config_l2_tunnel_eth_type_specific_parsed(
12878 void *parsed_result,
12879 __rte_unused struct cmdline *cl,
12880 __rte_unused void *data)
12882 struct cmd_config_l2_tunnel_eth_type_result *res =
12884 struct rte_eth_l2_tunnel_conf entry;
12886 if (port_id_is_invalid(res->id, ENABLED_WARN))
12889 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12890 entry.ether_type = res->eth_type_val;
12892 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12895 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12896 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12898 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12900 (void *)&cmd_config_l2_tunnel_eth_type_port,
12901 (void *)&cmd_config_l2_tunnel_eth_type_config,
12902 (void *)&cmd_config_l2_tunnel_eth_type_id,
12903 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12904 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12905 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12906 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12911 /* Enable/disable l2 tunnel */
12912 struct cmd_config_l2_tunnel_en_dis_result {
12913 cmdline_fixed_string_t port;
12914 cmdline_fixed_string_t config;
12915 cmdline_fixed_string_t all;
12917 cmdline_fixed_string_t l2_tunnel;
12918 cmdline_fixed_string_t l2_tunnel_type;
12919 cmdline_fixed_string_t en_dis;
12922 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12923 TOKEN_STRING_INITIALIZER
12924 (struct cmd_config_l2_tunnel_en_dis_result,
12926 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12927 TOKEN_STRING_INITIALIZER
12928 (struct cmd_config_l2_tunnel_en_dis_result,
12930 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12931 TOKEN_STRING_INITIALIZER
12932 (struct cmd_config_l2_tunnel_en_dis_result,
12934 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12935 TOKEN_NUM_INITIALIZER
12936 (struct cmd_config_l2_tunnel_en_dis_result,
12938 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12939 TOKEN_STRING_INITIALIZER
12940 (struct cmd_config_l2_tunnel_en_dis_result,
12941 l2_tunnel, "l2-tunnel");
12942 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12943 TOKEN_STRING_INITIALIZER
12944 (struct cmd_config_l2_tunnel_en_dis_result,
12945 l2_tunnel_type, "E-tag");
12946 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12947 TOKEN_STRING_INITIALIZER
12948 (struct cmd_config_l2_tunnel_en_dis_result,
12949 en_dis, "enable#disable");
12951 /* enable/disable l2 tunnel for all ports */
12953 cmd_config_l2_tunnel_en_dis_all_parsed(
12954 void *parsed_result,
12955 __rte_unused struct cmdline *cl,
12956 __rte_unused void *data)
12958 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12959 struct rte_eth_l2_tunnel_conf entry;
12963 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12965 if (!strcmp("enable", res->en_dis))
12970 RTE_ETH_FOREACH_DEV(pid) {
12971 rte_eth_dev_l2_tunnel_offload_set(pid,
12973 ETH_L2_TUNNEL_ENABLE_MASK,
12978 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12979 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12981 .help_str = "port config all l2-tunnel E-tag enable|disable",
12983 (void *)&cmd_config_l2_tunnel_en_dis_port,
12984 (void *)&cmd_config_l2_tunnel_en_dis_config,
12985 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12986 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12987 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12988 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12993 /* enable/disable l2 tunnel for a port */
12995 cmd_config_l2_tunnel_en_dis_specific_parsed(
12996 void *parsed_result,
12997 __rte_unused struct cmdline *cl,
12998 __rte_unused void *data)
13000 struct cmd_config_l2_tunnel_en_dis_result *res =
13002 struct rte_eth_l2_tunnel_conf entry;
13004 if (port_id_is_invalid(res->id, ENABLED_WARN))
13007 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13009 if (!strcmp("enable", res->en_dis))
13010 rte_eth_dev_l2_tunnel_offload_set(res->id,
13012 ETH_L2_TUNNEL_ENABLE_MASK,
13015 rte_eth_dev_l2_tunnel_offload_set(res->id,
13017 ETH_L2_TUNNEL_ENABLE_MASK,
13021 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13022 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13024 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13026 (void *)&cmd_config_l2_tunnel_en_dis_port,
13027 (void *)&cmd_config_l2_tunnel_en_dis_config,
13028 (void *)&cmd_config_l2_tunnel_en_dis_id,
13029 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13030 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13031 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13036 /* E-tag configuration */
13038 /* Common result structure for all E-tag configuration */
13039 struct cmd_config_e_tag_result {
13040 cmdline_fixed_string_t e_tag;
13041 cmdline_fixed_string_t set;
13042 cmdline_fixed_string_t insertion;
13043 cmdline_fixed_string_t stripping;
13044 cmdline_fixed_string_t forwarding;
13045 cmdline_fixed_string_t filter;
13046 cmdline_fixed_string_t add;
13047 cmdline_fixed_string_t del;
13048 cmdline_fixed_string_t on;
13049 cmdline_fixed_string_t off;
13050 cmdline_fixed_string_t on_off;
13051 cmdline_fixed_string_t port_tag_id;
13052 uint32_t port_tag_id_val;
13053 cmdline_fixed_string_t e_tag_id;
13054 uint16_t e_tag_id_val;
13055 cmdline_fixed_string_t dst_pool;
13056 uint8_t dst_pool_val;
13057 cmdline_fixed_string_t port;
13059 cmdline_fixed_string_t vf;
13063 /* Common CLI fields for all E-tag configuration */
13064 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13065 TOKEN_STRING_INITIALIZER
13066 (struct cmd_config_e_tag_result,
13068 cmdline_parse_token_string_t cmd_config_e_tag_set =
13069 TOKEN_STRING_INITIALIZER
13070 (struct cmd_config_e_tag_result,
13072 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13073 TOKEN_STRING_INITIALIZER
13074 (struct cmd_config_e_tag_result,
13075 insertion, "insertion");
13076 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13077 TOKEN_STRING_INITIALIZER
13078 (struct cmd_config_e_tag_result,
13079 stripping, "stripping");
13080 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13081 TOKEN_STRING_INITIALIZER
13082 (struct cmd_config_e_tag_result,
13083 forwarding, "forwarding");
13084 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13085 TOKEN_STRING_INITIALIZER
13086 (struct cmd_config_e_tag_result,
13088 cmdline_parse_token_string_t cmd_config_e_tag_add =
13089 TOKEN_STRING_INITIALIZER
13090 (struct cmd_config_e_tag_result,
13092 cmdline_parse_token_string_t cmd_config_e_tag_del =
13093 TOKEN_STRING_INITIALIZER
13094 (struct cmd_config_e_tag_result,
13096 cmdline_parse_token_string_t cmd_config_e_tag_on =
13097 TOKEN_STRING_INITIALIZER
13098 (struct cmd_config_e_tag_result,
13100 cmdline_parse_token_string_t cmd_config_e_tag_off =
13101 TOKEN_STRING_INITIALIZER
13102 (struct cmd_config_e_tag_result,
13104 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13105 TOKEN_STRING_INITIALIZER
13106 (struct cmd_config_e_tag_result,
13108 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13109 TOKEN_STRING_INITIALIZER
13110 (struct cmd_config_e_tag_result,
13111 port_tag_id, "port-tag-id");
13112 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13113 TOKEN_NUM_INITIALIZER
13114 (struct cmd_config_e_tag_result,
13115 port_tag_id_val, UINT32);
13116 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13117 TOKEN_STRING_INITIALIZER
13118 (struct cmd_config_e_tag_result,
13119 e_tag_id, "e-tag-id");
13120 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13121 TOKEN_NUM_INITIALIZER
13122 (struct cmd_config_e_tag_result,
13123 e_tag_id_val, UINT16);
13124 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13125 TOKEN_STRING_INITIALIZER
13126 (struct cmd_config_e_tag_result,
13127 dst_pool, "dst-pool");
13128 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13129 TOKEN_NUM_INITIALIZER
13130 (struct cmd_config_e_tag_result,
13131 dst_pool_val, UINT8);
13132 cmdline_parse_token_string_t cmd_config_e_tag_port =
13133 TOKEN_STRING_INITIALIZER
13134 (struct cmd_config_e_tag_result,
13136 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13137 TOKEN_NUM_INITIALIZER
13138 (struct cmd_config_e_tag_result,
13140 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13141 TOKEN_STRING_INITIALIZER
13142 (struct cmd_config_e_tag_result,
13144 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13145 TOKEN_NUM_INITIALIZER
13146 (struct cmd_config_e_tag_result,
13149 /* E-tag insertion configuration */
13151 cmd_config_e_tag_insertion_en_parsed(
13152 void *parsed_result,
13153 __rte_unused struct cmdline *cl,
13154 __rte_unused void *data)
13156 struct cmd_config_e_tag_result *res =
13158 struct rte_eth_l2_tunnel_conf entry;
13160 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13163 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13164 entry.tunnel_id = res->port_tag_id_val;
13165 entry.vf_id = res->vf_id;
13166 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13168 ETH_L2_TUNNEL_INSERTION_MASK,
13173 cmd_config_e_tag_insertion_dis_parsed(
13174 void *parsed_result,
13175 __rte_unused struct cmdline *cl,
13176 __rte_unused void *data)
13178 struct cmd_config_e_tag_result *res =
13180 struct rte_eth_l2_tunnel_conf entry;
13182 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13185 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13186 entry.vf_id = res->vf_id;
13188 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13190 ETH_L2_TUNNEL_INSERTION_MASK,
13194 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13195 .f = cmd_config_e_tag_insertion_en_parsed,
13197 .help_str = "E-tag ... : E-tag insertion enable",
13199 (void *)&cmd_config_e_tag_e_tag,
13200 (void *)&cmd_config_e_tag_set,
13201 (void *)&cmd_config_e_tag_insertion,
13202 (void *)&cmd_config_e_tag_on,
13203 (void *)&cmd_config_e_tag_port_tag_id,
13204 (void *)&cmd_config_e_tag_port_tag_id_val,
13205 (void *)&cmd_config_e_tag_port,
13206 (void *)&cmd_config_e_tag_port_id,
13207 (void *)&cmd_config_e_tag_vf,
13208 (void *)&cmd_config_e_tag_vf_id,
13213 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13214 .f = cmd_config_e_tag_insertion_dis_parsed,
13216 .help_str = "E-tag ... : E-tag insertion disable",
13218 (void *)&cmd_config_e_tag_e_tag,
13219 (void *)&cmd_config_e_tag_set,
13220 (void *)&cmd_config_e_tag_insertion,
13221 (void *)&cmd_config_e_tag_off,
13222 (void *)&cmd_config_e_tag_port,
13223 (void *)&cmd_config_e_tag_port_id,
13224 (void *)&cmd_config_e_tag_vf,
13225 (void *)&cmd_config_e_tag_vf_id,
13230 /* E-tag stripping configuration */
13232 cmd_config_e_tag_stripping_parsed(
13233 void *parsed_result,
13234 __rte_unused struct cmdline *cl,
13235 __rte_unused void *data)
13237 struct cmd_config_e_tag_result *res =
13239 struct rte_eth_l2_tunnel_conf entry;
13241 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13244 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13246 if (!strcmp(res->on_off, "on"))
13247 rte_eth_dev_l2_tunnel_offload_set
13250 ETH_L2_TUNNEL_STRIPPING_MASK,
13253 rte_eth_dev_l2_tunnel_offload_set
13256 ETH_L2_TUNNEL_STRIPPING_MASK,
13260 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13261 .f = cmd_config_e_tag_stripping_parsed,
13263 .help_str = "E-tag ... : E-tag stripping enable/disable",
13265 (void *)&cmd_config_e_tag_e_tag,
13266 (void *)&cmd_config_e_tag_set,
13267 (void *)&cmd_config_e_tag_stripping,
13268 (void *)&cmd_config_e_tag_on_off,
13269 (void *)&cmd_config_e_tag_port,
13270 (void *)&cmd_config_e_tag_port_id,
13275 /* E-tag forwarding configuration */
13277 cmd_config_e_tag_forwarding_parsed(
13278 void *parsed_result,
13279 __rte_unused struct cmdline *cl,
13280 __rte_unused void *data)
13282 struct cmd_config_e_tag_result *res = parsed_result;
13283 struct rte_eth_l2_tunnel_conf entry;
13285 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13288 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13290 if (!strcmp(res->on_off, "on"))
13291 rte_eth_dev_l2_tunnel_offload_set
13294 ETH_L2_TUNNEL_FORWARDING_MASK,
13297 rte_eth_dev_l2_tunnel_offload_set
13300 ETH_L2_TUNNEL_FORWARDING_MASK,
13304 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13305 .f = cmd_config_e_tag_forwarding_parsed,
13307 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13309 (void *)&cmd_config_e_tag_e_tag,
13310 (void *)&cmd_config_e_tag_set,
13311 (void *)&cmd_config_e_tag_forwarding,
13312 (void *)&cmd_config_e_tag_on_off,
13313 (void *)&cmd_config_e_tag_port,
13314 (void *)&cmd_config_e_tag_port_id,
13319 /* E-tag filter configuration */
13321 cmd_config_e_tag_filter_add_parsed(
13322 void *parsed_result,
13323 __rte_unused struct cmdline *cl,
13324 __rte_unused void *data)
13326 struct cmd_config_e_tag_result *res = parsed_result;
13327 struct rte_eth_l2_tunnel_conf entry;
13330 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13333 if (res->e_tag_id_val > 0x3fff) {
13334 printf("e-tag-id must be equal or less than 0x3fff.\n");
13338 ret = rte_eth_dev_filter_supported(res->port_id,
13339 RTE_ETH_FILTER_L2_TUNNEL);
13341 printf("E-tag filter is not supported on port %u.\n",
13346 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13347 entry.tunnel_id = res->e_tag_id_val;
13348 entry.pool = res->dst_pool_val;
13350 ret = rte_eth_dev_filter_ctrl(res->port_id,
13351 RTE_ETH_FILTER_L2_TUNNEL,
13352 RTE_ETH_FILTER_ADD,
13355 printf("E-tag filter programming error: (%s)\n",
13359 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13360 .f = cmd_config_e_tag_filter_add_parsed,
13362 .help_str = "E-tag ... : E-tag filter add",
13364 (void *)&cmd_config_e_tag_e_tag,
13365 (void *)&cmd_config_e_tag_set,
13366 (void *)&cmd_config_e_tag_filter,
13367 (void *)&cmd_config_e_tag_add,
13368 (void *)&cmd_config_e_tag_e_tag_id,
13369 (void *)&cmd_config_e_tag_e_tag_id_val,
13370 (void *)&cmd_config_e_tag_dst_pool,
13371 (void *)&cmd_config_e_tag_dst_pool_val,
13372 (void *)&cmd_config_e_tag_port,
13373 (void *)&cmd_config_e_tag_port_id,
13379 cmd_config_e_tag_filter_del_parsed(
13380 void *parsed_result,
13381 __rte_unused struct cmdline *cl,
13382 __rte_unused void *data)
13384 struct cmd_config_e_tag_result *res = parsed_result;
13385 struct rte_eth_l2_tunnel_conf entry;
13388 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13391 if (res->e_tag_id_val > 0x3fff) {
13392 printf("e-tag-id must be less than 0x3fff.\n");
13396 ret = rte_eth_dev_filter_supported(res->port_id,
13397 RTE_ETH_FILTER_L2_TUNNEL);
13399 printf("E-tag filter is not supported on port %u.\n",
13404 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13405 entry.tunnel_id = res->e_tag_id_val;
13407 ret = rte_eth_dev_filter_ctrl(res->port_id,
13408 RTE_ETH_FILTER_L2_TUNNEL,
13409 RTE_ETH_FILTER_DELETE,
13412 printf("E-tag filter programming error: (%s)\n",
13416 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13417 .f = cmd_config_e_tag_filter_del_parsed,
13419 .help_str = "E-tag ... : E-tag filter delete",
13421 (void *)&cmd_config_e_tag_e_tag,
13422 (void *)&cmd_config_e_tag_set,
13423 (void *)&cmd_config_e_tag_filter,
13424 (void *)&cmd_config_e_tag_del,
13425 (void *)&cmd_config_e_tag_e_tag_id,
13426 (void *)&cmd_config_e_tag_e_tag_id_val,
13427 (void *)&cmd_config_e_tag_port,
13428 (void *)&cmd_config_e_tag_port_id,
13433 /* vf vlan anti spoof configuration */
13435 /* Common result structure for vf vlan anti spoof */
13436 struct cmd_vf_vlan_anti_spoof_result {
13437 cmdline_fixed_string_t set;
13438 cmdline_fixed_string_t vf;
13439 cmdline_fixed_string_t vlan;
13440 cmdline_fixed_string_t antispoof;
13443 cmdline_fixed_string_t on_off;
13446 /* Common CLI fields for vf vlan anti spoof enable disable */
13447 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13448 TOKEN_STRING_INITIALIZER
13449 (struct cmd_vf_vlan_anti_spoof_result,
13451 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13452 TOKEN_STRING_INITIALIZER
13453 (struct cmd_vf_vlan_anti_spoof_result,
13455 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13456 TOKEN_STRING_INITIALIZER
13457 (struct cmd_vf_vlan_anti_spoof_result,
13459 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13460 TOKEN_STRING_INITIALIZER
13461 (struct cmd_vf_vlan_anti_spoof_result,
13462 antispoof, "antispoof");
13463 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13464 TOKEN_NUM_INITIALIZER
13465 (struct cmd_vf_vlan_anti_spoof_result,
13467 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13468 TOKEN_NUM_INITIALIZER
13469 (struct cmd_vf_vlan_anti_spoof_result,
13471 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13472 TOKEN_STRING_INITIALIZER
13473 (struct cmd_vf_vlan_anti_spoof_result,
13477 cmd_set_vf_vlan_anti_spoof_parsed(
13478 void *parsed_result,
13479 __rte_unused struct cmdline *cl,
13480 __rte_unused void *data)
13482 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13483 int ret = -ENOTSUP;
13485 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13487 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13490 #ifdef RTE_LIBRTE_IXGBE_PMD
13491 if (ret == -ENOTSUP)
13492 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13493 res->vf_id, is_on);
13495 #ifdef RTE_LIBRTE_I40E_PMD
13496 if (ret == -ENOTSUP)
13497 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13498 res->vf_id, is_on);
13500 #ifdef RTE_LIBRTE_BNXT_PMD
13501 if (ret == -ENOTSUP)
13502 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13503 res->vf_id, is_on);
13510 printf("invalid vf_id %d\n", res->vf_id);
13513 printf("invalid port_id %d\n", res->port_id);
13516 printf("function not implemented\n");
13519 printf("programming error: (%s)\n", strerror(-ret));
13523 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13524 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13526 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13528 (void *)&cmd_vf_vlan_anti_spoof_set,
13529 (void *)&cmd_vf_vlan_anti_spoof_vf,
13530 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13531 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13532 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13533 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13534 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13539 /* vf mac anti spoof configuration */
13541 /* Common result structure for vf mac anti spoof */
13542 struct cmd_vf_mac_anti_spoof_result {
13543 cmdline_fixed_string_t set;
13544 cmdline_fixed_string_t vf;
13545 cmdline_fixed_string_t mac;
13546 cmdline_fixed_string_t antispoof;
13549 cmdline_fixed_string_t on_off;
13552 /* Common CLI fields for vf mac anti spoof enable disable */
13553 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13554 TOKEN_STRING_INITIALIZER
13555 (struct cmd_vf_mac_anti_spoof_result,
13557 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13558 TOKEN_STRING_INITIALIZER
13559 (struct cmd_vf_mac_anti_spoof_result,
13561 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13562 TOKEN_STRING_INITIALIZER
13563 (struct cmd_vf_mac_anti_spoof_result,
13565 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13566 TOKEN_STRING_INITIALIZER
13567 (struct cmd_vf_mac_anti_spoof_result,
13568 antispoof, "antispoof");
13569 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13570 TOKEN_NUM_INITIALIZER
13571 (struct cmd_vf_mac_anti_spoof_result,
13573 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13574 TOKEN_NUM_INITIALIZER
13575 (struct cmd_vf_mac_anti_spoof_result,
13577 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13578 TOKEN_STRING_INITIALIZER
13579 (struct cmd_vf_mac_anti_spoof_result,
13583 cmd_set_vf_mac_anti_spoof_parsed(
13584 void *parsed_result,
13585 __rte_unused struct cmdline *cl,
13586 __rte_unused void *data)
13588 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13589 int ret = -ENOTSUP;
13591 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13596 #ifdef RTE_LIBRTE_IXGBE_PMD
13597 if (ret == -ENOTSUP)
13598 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13599 res->vf_id, is_on);
13601 #ifdef RTE_LIBRTE_I40E_PMD
13602 if (ret == -ENOTSUP)
13603 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13604 res->vf_id, is_on);
13606 #ifdef RTE_LIBRTE_BNXT_PMD
13607 if (ret == -ENOTSUP)
13608 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13609 res->vf_id, is_on);
13616 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13619 printf("invalid port_id %d\n", res->port_id);
13622 printf("function not implemented\n");
13625 printf("programming error: (%s)\n", strerror(-ret));
13629 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13630 .f = cmd_set_vf_mac_anti_spoof_parsed,
13632 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13634 (void *)&cmd_vf_mac_anti_spoof_set,
13635 (void *)&cmd_vf_mac_anti_spoof_vf,
13636 (void *)&cmd_vf_mac_anti_spoof_mac,
13637 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13638 (void *)&cmd_vf_mac_anti_spoof_port_id,
13639 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13640 (void *)&cmd_vf_mac_anti_spoof_on_off,
13645 /* vf vlan strip queue configuration */
13647 /* Common result structure for vf mac anti spoof */
13648 struct cmd_vf_vlan_stripq_result {
13649 cmdline_fixed_string_t set;
13650 cmdline_fixed_string_t vf;
13651 cmdline_fixed_string_t vlan;
13652 cmdline_fixed_string_t stripq;
13655 cmdline_fixed_string_t on_off;
13658 /* Common CLI fields for vf vlan strip enable disable */
13659 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13660 TOKEN_STRING_INITIALIZER
13661 (struct cmd_vf_vlan_stripq_result,
13663 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13664 TOKEN_STRING_INITIALIZER
13665 (struct cmd_vf_vlan_stripq_result,
13667 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13668 TOKEN_STRING_INITIALIZER
13669 (struct cmd_vf_vlan_stripq_result,
13671 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13672 TOKEN_STRING_INITIALIZER
13673 (struct cmd_vf_vlan_stripq_result,
13675 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13676 TOKEN_NUM_INITIALIZER
13677 (struct cmd_vf_vlan_stripq_result,
13679 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13680 TOKEN_NUM_INITIALIZER
13681 (struct cmd_vf_vlan_stripq_result,
13683 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13684 TOKEN_STRING_INITIALIZER
13685 (struct cmd_vf_vlan_stripq_result,
13689 cmd_set_vf_vlan_stripq_parsed(
13690 void *parsed_result,
13691 __rte_unused struct cmdline *cl,
13692 __rte_unused void *data)
13694 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13695 int ret = -ENOTSUP;
13697 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13702 #ifdef RTE_LIBRTE_IXGBE_PMD
13703 if (ret == -ENOTSUP)
13704 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13705 res->vf_id, is_on);
13707 #ifdef RTE_LIBRTE_I40E_PMD
13708 if (ret == -ENOTSUP)
13709 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13710 res->vf_id, is_on);
13712 #ifdef RTE_LIBRTE_BNXT_PMD
13713 if (ret == -ENOTSUP)
13714 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13715 res->vf_id, is_on);
13722 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13725 printf("invalid port_id %d\n", res->port_id);
13728 printf("function not implemented\n");
13731 printf("programming error: (%s)\n", strerror(-ret));
13735 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13736 .f = cmd_set_vf_vlan_stripq_parsed,
13738 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13740 (void *)&cmd_vf_vlan_stripq_set,
13741 (void *)&cmd_vf_vlan_stripq_vf,
13742 (void *)&cmd_vf_vlan_stripq_vlan,
13743 (void *)&cmd_vf_vlan_stripq_stripq,
13744 (void *)&cmd_vf_vlan_stripq_port_id,
13745 (void *)&cmd_vf_vlan_stripq_vf_id,
13746 (void *)&cmd_vf_vlan_stripq_on_off,
13751 /* vf vlan insert configuration */
13753 /* Common result structure for vf vlan insert */
13754 struct cmd_vf_vlan_insert_result {
13755 cmdline_fixed_string_t set;
13756 cmdline_fixed_string_t vf;
13757 cmdline_fixed_string_t vlan;
13758 cmdline_fixed_string_t insert;
13764 /* Common CLI fields for vf vlan insert enable disable */
13765 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13766 TOKEN_STRING_INITIALIZER
13767 (struct cmd_vf_vlan_insert_result,
13769 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13770 TOKEN_STRING_INITIALIZER
13771 (struct cmd_vf_vlan_insert_result,
13773 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13774 TOKEN_STRING_INITIALIZER
13775 (struct cmd_vf_vlan_insert_result,
13777 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13778 TOKEN_STRING_INITIALIZER
13779 (struct cmd_vf_vlan_insert_result,
13781 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13782 TOKEN_NUM_INITIALIZER
13783 (struct cmd_vf_vlan_insert_result,
13785 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13786 TOKEN_NUM_INITIALIZER
13787 (struct cmd_vf_vlan_insert_result,
13789 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13790 TOKEN_NUM_INITIALIZER
13791 (struct cmd_vf_vlan_insert_result,
13795 cmd_set_vf_vlan_insert_parsed(
13796 void *parsed_result,
13797 __rte_unused struct cmdline *cl,
13798 __rte_unused void *data)
13800 struct cmd_vf_vlan_insert_result *res = parsed_result;
13801 int ret = -ENOTSUP;
13803 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13806 #ifdef RTE_LIBRTE_IXGBE_PMD
13807 if (ret == -ENOTSUP)
13808 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13811 #ifdef RTE_LIBRTE_I40E_PMD
13812 if (ret == -ENOTSUP)
13813 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13816 #ifdef RTE_LIBRTE_BNXT_PMD
13817 if (ret == -ENOTSUP)
13818 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13826 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13829 printf("invalid port_id %d\n", res->port_id);
13832 printf("function not implemented\n");
13835 printf("programming error: (%s)\n", strerror(-ret));
13839 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13840 .f = cmd_set_vf_vlan_insert_parsed,
13842 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13844 (void *)&cmd_vf_vlan_insert_set,
13845 (void *)&cmd_vf_vlan_insert_vf,
13846 (void *)&cmd_vf_vlan_insert_vlan,
13847 (void *)&cmd_vf_vlan_insert_insert,
13848 (void *)&cmd_vf_vlan_insert_port_id,
13849 (void *)&cmd_vf_vlan_insert_vf_id,
13850 (void *)&cmd_vf_vlan_insert_vlan_id,
13855 /* tx loopback configuration */
13857 /* Common result structure for tx loopback */
13858 struct cmd_tx_loopback_result {
13859 cmdline_fixed_string_t set;
13860 cmdline_fixed_string_t tx;
13861 cmdline_fixed_string_t loopback;
13863 cmdline_fixed_string_t on_off;
13866 /* Common CLI fields for tx loopback enable disable */
13867 cmdline_parse_token_string_t cmd_tx_loopback_set =
13868 TOKEN_STRING_INITIALIZER
13869 (struct cmd_tx_loopback_result,
13871 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13872 TOKEN_STRING_INITIALIZER
13873 (struct cmd_tx_loopback_result,
13875 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13876 TOKEN_STRING_INITIALIZER
13877 (struct cmd_tx_loopback_result,
13878 loopback, "loopback");
13879 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13880 TOKEN_NUM_INITIALIZER
13881 (struct cmd_tx_loopback_result,
13883 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13884 TOKEN_STRING_INITIALIZER
13885 (struct cmd_tx_loopback_result,
13889 cmd_set_tx_loopback_parsed(
13890 void *parsed_result,
13891 __rte_unused struct cmdline *cl,
13892 __rte_unused void *data)
13894 struct cmd_tx_loopback_result *res = parsed_result;
13895 int ret = -ENOTSUP;
13897 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13899 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13902 #ifdef RTE_LIBRTE_IXGBE_PMD
13903 if (ret == -ENOTSUP)
13904 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13906 #ifdef RTE_LIBRTE_I40E_PMD
13907 if (ret == -ENOTSUP)
13908 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13910 #ifdef RTE_LIBRTE_BNXT_PMD
13911 if (ret == -ENOTSUP)
13912 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13914 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13915 if (ret == -ENOTSUP)
13916 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13923 printf("invalid is_on %d\n", is_on);
13926 printf("invalid port_id %d\n", res->port_id);
13929 printf("function not implemented\n");
13932 printf("programming error: (%s)\n", strerror(-ret));
13936 cmdline_parse_inst_t cmd_set_tx_loopback = {
13937 .f = cmd_set_tx_loopback_parsed,
13939 .help_str = "set tx loopback <port_id> on|off",
13941 (void *)&cmd_tx_loopback_set,
13942 (void *)&cmd_tx_loopback_tx,
13943 (void *)&cmd_tx_loopback_loopback,
13944 (void *)&cmd_tx_loopback_port_id,
13945 (void *)&cmd_tx_loopback_on_off,
13950 /* all queues drop enable configuration */
13952 /* Common result structure for all queues drop enable */
13953 struct cmd_all_queues_drop_en_result {
13954 cmdline_fixed_string_t set;
13955 cmdline_fixed_string_t all;
13956 cmdline_fixed_string_t queues;
13957 cmdline_fixed_string_t drop;
13959 cmdline_fixed_string_t on_off;
13962 /* Common CLI fields for tx loopback enable disable */
13963 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13964 TOKEN_STRING_INITIALIZER
13965 (struct cmd_all_queues_drop_en_result,
13967 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13968 TOKEN_STRING_INITIALIZER
13969 (struct cmd_all_queues_drop_en_result,
13971 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13972 TOKEN_STRING_INITIALIZER
13973 (struct cmd_all_queues_drop_en_result,
13975 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13976 TOKEN_STRING_INITIALIZER
13977 (struct cmd_all_queues_drop_en_result,
13979 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13980 TOKEN_NUM_INITIALIZER
13981 (struct cmd_all_queues_drop_en_result,
13983 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13984 TOKEN_STRING_INITIALIZER
13985 (struct cmd_all_queues_drop_en_result,
13989 cmd_set_all_queues_drop_en_parsed(
13990 void *parsed_result,
13991 __rte_unused struct cmdline *cl,
13992 __rte_unused void *data)
13994 struct cmd_all_queues_drop_en_result *res = parsed_result;
13995 int ret = -ENOTSUP;
13996 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13998 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14001 #ifdef RTE_LIBRTE_IXGBE_PMD
14002 if (ret == -ENOTSUP)
14003 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14005 #ifdef RTE_LIBRTE_BNXT_PMD
14006 if (ret == -ENOTSUP)
14007 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14013 printf("invalid is_on %d\n", is_on);
14016 printf("invalid port_id %d\n", res->port_id);
14019 printf("function not implemented\n");
14022 printf("programming error: (%s)\n", strerror(-ret));
14026 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14027 .f = cmd_set_all_queues_drop_en_parsed,
14029 .help_str = "set all queues drop <port_id> on|off",
14031 (void *)&cmd_all_queues_drop_en_set,
14032 (void *)&cmd_all_queues_drop_en_all,
14033 (void *)&cmd_all_queues_drop_en_queues,
14034 (void *)&cmd_all_queues_drop_en_drop,
14035 (void *)&cmd_all_queues_drop_en_port_id,
14036 (void *)&cmd_all_queues_drop_en_on_off,
14041 /* vf split drop enable configuration */
14043 /* Common result structure for vf split drop enable */
14044 struct cmd_vf_split_drop_en_result {
14045 cmdline_fixed_string_t set;
14046 cmdline_fixed_string_t vf;
14047 cmdline_fixed_string_t split;
14048 cmdline_fixed_string_t drop;
14051 cmdline_fixed_string_t on_off;
14054 /* Common CLI fields for vf split drop enable disable */
14055 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14056 TOKEN_STRING_INITIALIZER
14057 (struct cmd_vf_split_drop_en_result,
14059 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14060 TOKEN_STRING_INITIALIZER
14061 (struct cmd_vf_split_drop_en_result,
14063 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14064 TOKEN_STRING_INITIALIZER
14065 (struct cmd_vf_split_drop_en_result,
14067 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14068 TOKEN_STRING_INITIALIZER
14069 (struct cmd_vf_split_drop_en_result,
14071 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14072 TOKEN_NUM_INITIALIZER
14073 (struct cmd_vf_split_drop_en_result,
14075 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14076 TOKEN_NUM_INITIALIZER
14077 (struct cmd_vf_split_drop_en_result,
14079 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14080 TOKEN_STRING_INITIALIZER
14081 (struct cmd_vf_split_drop_en_result,
14085 cmd_set_vf_split_drop_en_parsed(
14086 void *parsed_result,
14087 __rte_unused struct cmdline *cl,
14088 __rte_unused void *data)
14090 struct cmd_vf_split_drop_en_result *res = parsed_result;
14091 int ret = -ENOTSUP;
14092 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14094 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14097 #ifdef RTE_LIBRTE_IXGBE_PMD
14098 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14105 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14108 printf("invalid port_id %d\n", res->port_id);
14111 printf("not supported on port %d\n", res->port_id);
14114 printf("programming error: (%s)\n", strerror(-ret));
14118 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14119 .f = cmd_set_vf_split_drop_en_parsed,
14121 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14123 (void *)&cmd_vf_split_drop_en_set,
14124 (void *)&cmd_vf_split_drop_en_vf,
14125 (void *)&cmd_vf_split_drop_en_split,
14126 (void *)&cmd_vf_split_drop_en_drop,
14127 (void *)&cmd_vf_split_drop_en_port_id,
14128 (void *)&cmd_vf_split_drop_en_vf_id,
14129 (void *)&cmd_vf_split_drop_en_on_off,
14134 /* vf mac address configuration */
14136 /* Common result structure for vf mac address */
14137 struct cmd_set_vf_mac_addr_result {
14138 cmdline_fixed_string_t set;
14139 cmdline_fixed_string_t vf;
14140 cmdline_fixed_string_t mac;
14141 cmdline_fixed_string_t addr;
14144 struct rte_ether_addr mac_addr;
14148 /* Common CLI fields for vf split drop enable disable */
14149 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14150 TOKEN_STRING_INITIALIZER
14151 (struct cmd_set_vf_mac_addr_result,
14153 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14154 TOKEN_STRING_INITIALIZER
14155 (struct cmd_set_vf_mac_addr_result,
14157 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14158 TOKEN_STRING_INITIALIZER
14159 (struct cmd_set_vf_mac_addr_result,
14161 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14162 TOKEN_STRING_INITIALIZER
14163 (struct cmd_set_vf_mac_addr_result,
14165 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14166 TOKEN_NUM_INITIALIZER
14167 (struct cmd_set_vf_mac_addr_result,
14169 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14170 TOKEN_NUM_INITIALIZER
14171 (struct cmd_set_vf_mac_addr_result,
14173 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14174 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14178 cmd_set_vf_mac_addr_parsed(
14179 void *parsed_result,
14180 __rte_unused struct cmdline *cl,
14181 __rte_unused void *data)
14183 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14184 int ret = -ENOTSUP;
14186 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14189 #ifdef RTE_LIBRTE_IXGBE_PMD
14190 if (ret == -ENOTSUP)
14191 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14194 #ifdef RTE_LIBRTE_I40E_PMD
14195 if (ret == -ENOTSUP)
14196 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14199 #ifdef RTE_LIBRTE_BNXT_PMD
14200 if (ret == -ENOTSUP)
14201 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14209 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14212 printf("invalid port_id %d\n", res->port_id);
14215 printf("function not implemented\n");
14218 printf("programming error: (%s)\n", strerror(-ret));
14222 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14223 .f = cmd_set_vf_mac_addr_parsed,
14225 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14227 (void *)&cmd_set_vf_mac_addr_set,
14228 (void *)&cmd_set_vf_mac_addr_vf,
14229 (void *)&cmd_set_vf_mac_addr_mac,
14230 (void *)&cmd_set_vf_mac_addr_addr,
14231 (void *)&cmd_set_vf_mac_addr_port_id,
14232 (void *)&cmd_set_vf_mac_addr_vf_id,
14233 (void *)&cmd_set_vf_mac_addr_mac_addr,
14238 /* MACsec configuration */
14240 /* Common result structure for MACsec offload enable */
14241 struct cmd_macsec_offload_on_result {
14242 cmdline_fixed_string_t set;
14243 cmdline_fixed_string_t macsec;
14244 cmdline_fixed_string_t offload;
14246 cmdline_fixed_string_t on;
14247 cmdline_fixed_string_t encrypt;
14248 cmdline_fixed_string_t en_on_off;
14249 cmdline_fixed_string_t replay_protect;
14250 cmdline_fixed_string_t rp_on_off;
14253 /* Common CLI fields for MACsec offload disable */
14254 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14255 TOKEN_STRING_INITIALIZER
14256 (struct cmd_macsec_offload_on_result,
14258 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14259 TOKEN_STRING_INITIALIZER
14260 (struct cmd_macsec_offload_on_result,
14262 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14263 TOKEN_STRING_INITIALIZER
14264 (struct cmd_macsec_offload_on_result,
14265 offload, "offload");
14266 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14267 TOKEN_NUM_INITIALIZER
14268 (struct cmd_macsec_offload_on_result,
14270 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14271 TOKEN_STRING_INITIALIZER
14272 (struct cmd_macsec_offload_on_result,
14274 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14275 TOKEN_STRING_INITIALIZER
14276 (struct cmd_macsec_offload_on_result,
14277 encrypt, "encrypt");
14278 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14279 TOKEN_STRING_INITIALIZER
14280 (struct cmd_macsec_offload_on_result,
14281 en_on_off, "on#off");
14282 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14283 TOKEN_STRING_INITIALIZER
14284 (struct cmd_macsec_offload_on_result,
14285 replay_protect, "replay-protect");
14286 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14287 TOKEN_STRING_INITIALIZER
14288 (struct cmd_macsec_offload_on_result,
14289 rp_on_off, "on#off");
14292 cmd_set_macsec_offload_on_parsed(
14293 void *parsed_result,
14294 __rte_unused struct cmdline *cl,
14295 __rte_unused void *data)
14297 struct cmd_macsec_offload_on_result *res = parsed_result;
14298 int ret = -ENOTSUP;
14299 portid_t port_id = res->port_id;
14300 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14301 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14302 struct rte_eth_dev_info dev_info;
14304 if (port_id_is_invalid(port_id, ENABLED_WARN))
14306 if (!port_is_stopped(port_id)) {
14307 printf("Please stop port %d first\n", port_id);
14311 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14315 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14316 #ifdef RTE_LIBRTE_IXGBE_PMD
14317 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14325 ports[port_id].dev_conf.txmode.offloads |=
14326 DEV_TX_OFFLOAD_MACSEC_INSERT;
14327 cmd_reconfig_device_queue(port_id, 1, 1);
14330 printf("invalid port_id %d\n", port_id);
14333 printf("not supported on port %d\n", port_id);
14336 printf("programming error: (%s)\n", strerror(-ret));
14340 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14341 .f = cmd_set_macsec_offload_on_parsed,
14343 .help_str = "set macsec offload <port_id> on "
14344 "encrypt on|off replay-protect on|off",
14346 (void *)&cmd_macsec_offload_on_set,
14347 (void *)&cmd_macsec_offload_on_macsec,
14348 (void *)&cmd_macsec_offload_on_offload,
14349 (void *)&cmd_macsec_offload_on_port_id,
14350 (void *)&cmd_macsec_offload_on_on,
14351 (void *)&cmd_macsec_offload_on_encrypt,
14352 (void *)&cmd_macsec_offload_on_en_on_off,
14353 (void *)&cmd_macsec_offload_on_replay_protect,
14354 (void *)&cmd_macsec_offload_on_rp_on_off,
14359 /* Common result structure for MACsec offload disable */
14360 struct cmd_macsec_offload_off_result {
14361 cmdline_fixed_string_t set;
14362 cmdline_fixed_string_t macsec;
14363 cmdline_fixed_string_t offload;
14365 cmdline_fixed_string_t off;
14368 /* Common CLI fields for MACsec offload disable */
14369 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14370 TOKEN_STRING_INITIALIZER
14371 (struct cmd_macsec_offload_off_result,
14373 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14374 TOKEN_STRING_INITIALIZER
14375 (struct cmd_macsec_offload_off_result,
14377 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14378 TOKEN_STRING_INITIALIZER
14379 (struct cmd_macsec_offload_off_result,
14380 offload, "offload");
14381 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14382 TOKEN_NUM_INITIALIZER
14383 (struct cmd_macsec_offload_off_result,
14385 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14386 TOKEN_STRING_INITIALIZER
14387 (struct cmd_macsec_offload_off_result,
14391 cmd_set_macsec_offload_off_parsed(
14392 void *parsed_result,
14393 __rte_unused struct cmdline *cl,
14394 __rte_unused void *data)
14396 struct cmd_macsec_offload_off_result *res = parsed_result;
14397 int ret = -ENOTSUP;
14398 struct rte_eth_dev_info dev_info;
14399 portid_t port_id = res->port_id;
14401 if (port_id_is_invalid(port_id, ENABLED_WARN))
14403 if (!port_is_stopped(port_id)) {
14404 printf("Please stop port %d first\n", port_id);
14408 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14412 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14413 #ifdef RTE_LIBRTE_IXGBE_PMD
14414 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14419 ports[port_id].dev_conf.txmode.offloads &=
14420 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14421 cmd_reconfig_device_queue(port_id, 1, 1);
14424 printf("invalid port_id %d\n", port_id);
14427 printf("not supported on port %d\n", port_id);
14430 printf("programming error: (%s)\n", strerror(-ret));
14434 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14435 .f = cmd_set_macsec_offload_off_parsed,
14437 .help_str = "set macsec offload <port_id> off",
14439 (void *)&cmd_macsec_offload_off_set,
14440 (void *)&cmd_macsec_offload_off_macsec,
14441 (void *)&cmd_macsec_offload_off_offload,
14442 (void *)&cmd_macsec_offload_off_port_id,
14443 (void *)&cmd_macsec_offload_off_off,
14448 /* Common result structure for MACsec secure connection configure */
14449 struct cmd_macsec_sc_result {
14450 cmdline_fixed_string_t set;
14451 cmdline_fixed_string_t macsec;
14452 cmdline_fixed_string_t sc;
14453 cmdline_fixed_string_t tx_rx;
14455 struct rte_ether_addr mac;
14459 /* Common CLI fields for MACsec secure connection configure */
14460 cmdline_parse_token_string_t cmd_macsec_sc_set =
14461 TOKEN_STRING_INITIALIZER
14462 (struct cmd_macsec_sc_result,
14464 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14465 TOKEN_STRING_INITIALIZER
14466 (struct cmd_macsec_sc_result,
14468 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14469 TOKEN_STRING_INITIALIZER
14470 (struct cmd_macsec_sc_result,
14472 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14473 TOKEN_STRING_INITIALIZER
14474 (struct cmd_macsec_sc_result,
14476 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14477 TOKEN_NUM_INITIALIZER
14478 (struct cmd_macsec_sc_result,
14480 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14481 TOKEN_ETHERADDR_INITIALIZER
14482 (struct cmd_macsec_sc_result,
14484 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14485 TOKEN_NUM_INITIALIZER
14486 (struct cmd_macsec_sc_result,
14490 cmd_set_macsec_sc_parsed(
14491 void *parsed_result,
14492 __rte_unused struct cmdline *cl,
14493 __rte_unused void *data)
14495 struct cmd_macsec_sc_result *res = parsed_result;
14496 int ret = -ENOTSUP;
14497 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14499 #ifdef RTE_LIBRTE_IXGBE_PMD
14501 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14502 res->mac.addr_bytes) :
14503 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14504 res->mac.addr_bytes, res->pi);
14506 RTE_SET_USED(is_tx);
14512 printf("invalid port_id %d\n", res->port_id);
14515 printf("not supported on port %d\n", res->port_id);
14518 printf("programming error: (%s)\n", strerror(-ret));
14522 cmdline_parse_inst_t cmd_set_macsec_sc = {
14523 .f = cmd_set_macsec_sc_parsed,
14525 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14527 (void *)&cmd_macsec_sc_set,
14528 (void *)&cmd_macsec_sc_macsec,
14529 (void *)&cmd_macsec_sc_sc,
14530 (void *)&cmd_macsec_sc_tx_rx,
14531 (void *)&cmd_macsec_sc_port_id,
14532 (void *)&cmd_macsec_sc_mac,
14533 (void *)&cmd_macsec_sc_pi,
14538 /* Common result structure for MACsec secure connection configure */
14539 struct cmd_macsec_sa_result {
14540 cmdline_fixed_string_t set;
14541 cmdline_fixed_string_t macsec;
14542 cmdline_fixed_string_t sa;
14543 cmdline_fixed_string_t tx_rx;
14548 cmdline_fixed_string_t key;
14551 /* Common CLI fields for MACsec secure connection configure */
14552 cmdline_parse_token_string_t cmd_macsec_sa_set =
14553 TOKEN_STRING_INITIALIZER
14554 (struct cmd_macsec_sa_result,
14556 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14557 TOKEN_STRING_INITIALIZER
14558 (struct cmd_macsec_sa_result,
14560 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14561 TOKEN_STRING_INITIALIZER
14562 (struct cmd_macsec_sa_result,
14564 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14565 TOKEN_STRING_INITIALIZER
14566 (struct cmd_macsec_sa_result,
14568 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14569 TOKEN_NUM_INITIALIZER
14570 (struct cmd_macsec_sa_result,
14572 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14573 TOKEN_NUM_INITIALIZER
14574 (struct cmd_macsec_sa_result,
14576 cmdline_parse_token_num_t cmd_macsec_sa_an =
14577 TOKEN_NUM_INITIALIZER
14578 (struct cmd_macsec_sa_result,
14580 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14581 TOKEN_NUM_INITIALIZER
14582 (struct cmd_macsec_sa_result,
14584 cmdline_parse_token_string_t cmd_macsec_sa_key =
14585 TOKEN_STRING_INITIALIZER
14586 (struct cmd_macsec_sa_result,
14590 cmd_set_macsec_sa_parsed(
14591 void *parsed_result,
14592 __rte_unused struct cmdline *cl,
14593 __rte_unused void *data)
14595 struct cmd_macsec_sa_result *res = parsed_result;
14596 int ret = -ENOTSUP;
14597 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14598 uint8_t key[16] = { 0 };
14604 key_len = strlen(res->key) / 2;
14608 for (i = 0; i < key_len; i++) {
14609 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14612 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14615 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14618 #ifdef RTE_LIBRTE_IXGBE_PMD
14620 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14621 res->idx, res->an, res->pn, key) :
14622 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14623 res->idx, res->an, res->pn, key);
14625 RTE_SET_USED(is_tx);
14632 printf("invalid idx %d or an %d\n", res->idx, res->an);
14635 printf("invalid port_id %d\n", res->port_id);
14638 printf("not supported on port %d\n", res->port_id);
14641 printf("programming error: (%s)\n", strerror(-ret));
14645 cmdline_parse_inst_t cmd_set_macsec_sa = {
14646 .f = cmd_set_macsec_sa_parsed,
14648 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14650 (void *)&cmd_macsec_sa_set,
14651 (void *)&cmd_macsec_sa_macsec,
14652 (void *)&cmd_macsec_sa_sa,
14653 (void *)&cmd_macsec_sa_tx_rx,
14654 (void *)&cmd_macsec_sa_port_id,
14655 (void *)&cmd_macsec_sa_idx,
14656 (void *)&cmd_macsec_sa_an,
14657 (void *)&cmd_macsec_sa_pn,
14658 (void *)&cmd_macsec_sa_key,
14663 /* VF unicast promiscuous mode configuration */
14665 /* Common result structure for VF unicast promiscuous mode */
14666 struct cmd_vf_promisc_result {
14667 cmdline_fixed_string_t set;
14668 cmdline_fixed_string_t vf;
14669 cmdline_fixed_string_t promisc;
14672 cmdline_fixed_string_t on_off;
14675 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14676 cmdline_parse_token_string_t cmd_vf_promisc_set =
14677 TOKEN_STRING_INITIALIZER
14678 (struct cmd_vf_promisc_result,
14680 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14681 TOKEN_STRING_INITIALIZER
14682 (struct cmd_vf_promisc_result,
14684 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14685 TOKEN_STRING_INITIALIZER
14686 (struct cmd_vf_promisc_result,
14687 promisc, "promisc");
14688 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14689 TOKEN_NUM_INITIALIZER
14690 (struct cmd_vf_promisc_result,
14692 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14693 TOKEN_NUM_INITIALIZER
14694 (struct cmd_vf_promisc_result,
14696 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14697 TOKEN_STRING_INITIALIZER
14698 (struct cmd_vf_promisc_result,
14702 cmd_set_vf_promisc_parsed(
14703 void *parsed_result,
14704 __rte_unused struct cmdline *cl,
14705 __rte_unused void *data)
14707 struct cmd_vf_promisc_result *res = parsed_result;
14708 int ret = -ENOTSUP;
14710 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14712 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14715 #ifdef RTE_LIBRTE_I40E_PMD
14716 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14717 res->vf_id, is_on);
14724 printf("invalid vf_id %d\n", res->vf_id);
14727 printf("invalid port_id %d\n", res->port_id);
14730 printf("function not implemented\n");
14733 printf("programming error: (%s)\n", strerror(-ret));
14737 cmdline_parse_inst_t cmd_set_vf_promisc = {
14738 .f = cmd_set_vf_promisc_parsed,
14740 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14741 "Set unicast promiscuous mode for a VF from the PF",
14743 (void *)&cmd_vf_promisc_set,
14744 (void *)&cmd_vf_promisc_vf,
14745 (void *)&cmd_vf_promisc_promisc,
14746 (void *)&cmd_vf_promisc_port_id,
14747 (void *)&cmd_vf_promisc_vf_id,
14748 (void *)&cmd_vf_promisc_on_off,
14753 /* VF multicast promiscuous mode configuration */
14755 /* Common result structure for VF multicast promiscuous mode */
14756 struct cmd_vf_allmulti_result {
14757 cmdline_fixed_string_t set;
14758 cmdline_fixed_string_t vf;
14759 cmdline_fixed_string_t allmulti;
14762 cmdline_fixed_string_t on_off;
14765 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14766 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14767 TOKEN_STRING_INITIALIZER
14768 (struct cmd_vf_allmulti_result,
14770 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14771 TOKEN_STRING_INITIALIZER
14772 (struct cmd_vf_allmulti_result,
14774 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14775 TOKEN_STRING_INITIALIZER
14776 (struct cmd_vf_allmulti_result,
14777 allmulti, "allmulti");
14778 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14779 TOKEN_NUM_INITIALIZER
14780 (struct cmd_vf_allmulti_result,
14782 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14783 TOKEN_NUM_INITIALIZER
14784 (struct cmd_vf_allmulti_result,
14786 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14787 TOKEN_STRING_INITIALIZER
14788 (struct cmd_vf_allmulti_result,
14792 cmd_set_vf_allmulti_parsed(
14793 void *parsed_result,
14794 __rte_unused struct cmdline *cl,
14795 __rte_unused void *data)
14797 struct cmd_vf_allmulti_result *res = parsed_result;
14798 int ret = -ENOTSUP;
14800 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14802 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14805 #ifdef RTE_LIBRTE_I40E_PMD
14806 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14807 res->vf_id, is_on);
14814 printf("invalid vf_id %d\n", res->vf_id);
14817 printf("invalid port_id %d\n", res->port_id);
14820 printf("function not implemented\n");
14823 printf("programming error: (%s)\n", strerror(-ret));
14827 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14828 .f = cmd_set_vf_allmulti_parsed,
14830 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14831 "Set multicast promiscuous mode for a VF from the PF",
14833 (void *)&cmd_vf_allmulti_set,
14834 (void *)&cmd_vf_allmulti_vf,
14835 (void *)&cmd_vf_allmulti_allmulti,
14836 (void *)&cmd_vf_allmulti_port_id,
14837 (void *)&cmd_vf_allmulti_vf_id,
14838 (void *)&cmd_vf_allmulti_on_off,
14843 /* vf broadcast mode configuration */
14845 /* Common result structure for vf broadcast */
14846 struct cmd_set_vf_broadcast_result {
14847 cmdline_fixed_string_t set;
14848 cmdline_fixed_string_t vf;
14849 cmdline_fixed_string_t broadcast;
14852 cmdline_fixed_string_t on_off;
14855 /* Common CLI fields for vf broadcast enable disable */
14856 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14857 TOKEN_STRING_INITIALIZER
14858 (struct cmd_set_vf_broadcast_result,
14860 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14861 TOKEN_STRING_INITIALIZER
14862 (struct cmd_set_vf_broadcast_result,
14864 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14865 TOKEN_STRING_INITIALIZER
14866 (struct cmd_set_vf_broadcast_result,
14867 broadcast, "broadcast");
14868 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14869 TOKEN_NUM_INITIALIZER
14870 (struct cmd_set_vf_broadcast_result,
14872 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14873 TOKEN_NUM_INITIALIZER
14874 (struct cmd_set_vf_broadcast_result,
14876 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14877 TOKEN_STRING_INITIALIZER
14878 (struct cmd_set_vf_broadcast_result,
14882 cmd_set_vf_broadcast_parsed(
14883 void *parsed_result,
14884 __rte_unused struct cmdline *cl,
14885 __rte_unused void *data)
14887 struct cmd_set_vf_broadcast_result *res = parsed_result;
14888 int ret = -ENOTSUP;
14890 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14892 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14895 #ifdef RTE_LIBRTE_I40E_PMD
14896 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14897 res->vf_id, is_on);
14904 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14907 printf("invalid port_id %d\n", res->port_id);
14910 printf("function not implemented\n");
14913 printf("programming error: (%s)\n", strerror(-ret));
14917 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14918 .f = cmd_set_vf_broadcast_parsed,
14920 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14922 (void *)&cmd_set_vf_broadcast_set,
14923 (void *)&cmd_set_vf_broadcast_vf,
14924 (void *)&cmd_set_vf_broadcast_broadcast,
14925 (void *)&cmd_set_vf_broadcast_port_id,
14926 (void *)&cmd_set_vf_broadcast_vf_id,
14927 (void *)&cmd_set_vf_broadcast_on_off,
14932 /* vf vlan tag configuration */
14934 /* Common result structure for vf vlan tag */
14935 struct cmd_set_vf_vlan_tag_result {
14936 cmdline_fixed_string_t set;
14937 cmdline_fixed_string_t vf;
14938 cmdline_fixed_string_t vlan;
14939 cmdline_fixed_string_t tag;
14942 cmdline_fixed_string_t on_off;
14945 /* Common CLI fields for vf vlan tag enable disable */
14946 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14947 TOKEN_STRING_INITIALIZER
14948 (struct cmd_set_vf_vlan_tag_result,
14950 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14951 TOKEN_STRING_INITIALIZER
14952 (struct cmd_set_vf_vlan_tag_result,
14954 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14955 TOKEN_STRING_INITIALIZER
14956 (struct cmd_set_vf_vlan_tag_result,
14958 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14959 TOKEN_STRING_INITIALIZER
14960 (struct cmd_set_vf_vlan_tag_result,
14962 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14963 TOKEN_NUM_INITIALIZER
14964 (struct cmd_set_vf_vlan_tag_result,
14966 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14967 TOKEN_NUM_INITIALIZER
14968 (struct cmd_set_vf_vlan_tag_result,
14970 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14971 TOKEN_STRING_INITIALIZER
14972 (struct cmd_set_vf_vlan_tag_result,
14976 cmd_set_vf_vlan_tag_parsed(
14977 void *parsed_result,
14978 __rte_unused struct cmdline *cl,
14979 __rte_unused void *data)
14981 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14982 int ret = -ENOTSUP;
14984 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14986 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14989 #ifdef RTE_LIBRTE_I40E_PMD
14990 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14991 res->vf_id, is_on);
14998 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15001 printf("invalid port_id %d\n", res->port_id);
15004 printf("function not implemented\n");
15007 printf("programming error: (%s)\n", strerror(-ret));
15011 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15012 .f = cmd_set_vf_vlan_tag_parsed,
15014 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15016 (void *)&cmd_set_vf_vlan_tag_set,
15017 (void *)&cmd_set_vf_vlan_tag_vf,
15018 (void *)&cmd_set_vf_vlan_tag_vlan,
15019 (void *)&cmd_set_vf_vlan_tag_tag,
15020 (void *)&cmd_set_vf_vlan_tag_port_id,
15021 (void *)&cmd_set_vf_vlan_tag_vf_id,
15022 (void *)&cmd_set_vf_vlan_tag_on_off,
15027 /* Common definition of VF and TC TX bandwidth configuration */
15028 struct cmd_vf_tc_bw_result {
15029 cmdline_fixed_string_t set;
15030 cmdline_fixed_string_t vf;
15031 cmdline_fixed_string_t tc;
15032 cmdline_fixed_string_t tx;
15033 cmdline_fixed_string_t min_bw;
15034 cmdline_fixed_string_t max_bw;
15035 cmdline_fixed_string_t strict_link_prio;
15040 cmdline_fixed_string_t bw_list;
15044 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15045 TOKEN_STRING_INITIALIZER
15046 (struct cmd_vf_tc_bw_result,
15048 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15049 TOKEN_STRING_INITIALIZER
15050 (struct cmd_vf_tc_bw_result,
15052 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15053 TOKEN_STRING_INITIALIZER
15054 (struct cmd_vf_tc_bw_result,
15056 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15057 TOKEN_STRING_INITIALIZER
15058 (struct cmd_vf_tc_bw_result,
15060 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15061 TOKEN_STRING_INITIALIZER
15062 (struct cmd_vf_tc_bw_result,
15063 strict_link_prio, "strict-link-priority");
15064 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15065 TOKEN_STRING_INITIALIZER
15066 (struct cmd_vf_tc_bw_result,
15067 min_bw, "min-bandwidth");
15068 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15069 TOKEN_STRING_INITIALIZER
15070 (struct cmd_vf_tc_bw_result,
15071 max_bw, "max-bandwidth");
15072 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15073 TOKEN_NUM_INITIALIZER
15074 (struct cmd_vf_tc_bw_result,
15076 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15077 TOKEN_NUM_INITIALIZER
15078 (struct cmd_vf_tc_bw_result,
15080 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15081 TOKEN_NUM_INITIALIZER
15082 (struct cmd_vf_tc_bw_result,
15084 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15085 TOKEN_NUM_INITIALIZER
15086 (struct cmd_vf_tc_bw_result,
15088 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15089 TOKEN_STRING_INITIALIZER
15090 (struct cmd_vf_tc_bw_result,
15092 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15093 TOKEN_NUM_INITIALIZER
15094 (struct cmd_vf_tc_bw_result,
15097 /* VF max bandwidth setting */
15099 cmd_vf_max_bw_parsed(
15100 void *parsed_result,
15101 __rte_unused struct cmdline *cl,
15102 __rte_unused void *data)
15104 struct cmd_vf_tc_bw_result *res = parsed_result;
15105 int ret = -ENOTSUP;
15107 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15110 #ifdef RTE_LIBRTE_I40E_PMD
15111 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15112 res->vf_id, res->bw);
15119 printf("invalid vf_id %d or bandwidth %d\n",
15120 res->vf_id, res->bw);
15123 printf("invalid port_id %d\n", res->port_id);
15126 printf("function not implemented\n");
15129 printf("programming error: (%s)\n", strerror(-ret));
15133 cmdline_parse_inst_t cmd_vf_max_bw = {
15134 .f = cmd_vf_max_bw_parsed,
15136 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15138 (void *)&cmd_vf_tc_bw_set,
15139 (void *)&cmd_vf_tc_bw_vf,
15140 (void *)&cmd_vf_tc_bw_tx,
15141 (void *)&cmd_vf_tc_bw_max_bw,
15142 (void *)&cmd_vf_tc_bw_port_id,
15143 (void *)&cmd_vf_tc_bw_vf_id,
15144 (void *)&cmd_vf_tc_bw_bw,
15150 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15155 const char *p, *p0 = str;
15162 p = strchr(p0, '(');
15164 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15168 p0 = strchr(p, ')');
15170 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15174 if (size >= sizeof(s)) {
15175 printf("The string size exceeds the internal buffer size\n");
15178 snprintf(s, sizeof(s), "%.*s", size, p);
15179 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15181 printf("Failed to get the bandwidth list. ");
15185 for (i = 0; i < ret; i++)
15186 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15191 /* TC min bandwidth setting */
15193 cmd_vf_tc_min_bw_parsed(
15194 void *parsed_result,
15195 __rte_unused struct cmdline *cl,
15196 __rte_unused void *data)
15198 struct cmd_vf_tc_bw_result *res = parsed_result;
15201 int ret = -ENOTSUP;
15203 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15206 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15210 #ifdef RTE_LIBRTE_I40E_PMD
15211 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15219 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15222 printf("invalid port_id %d\n", res->port_id);
15225 printf("function not implemented\n");
15228 printf("programming error: (%s)\n", strerror(-ret));
15232 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15233 .f = cmd_vf_tc_min_bw_parsed,
15235 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15236 " <bw1, bw2, ...>",
15238 (void *)&cmd_vf_tc_bw_set,
15239 (void *)&cmd_vf_tc_bw_vf,
15240 (void *)&cmd_vf_tc_bw_tc,
15241 (void *)&cmd_vf_tc_bw_tx,
15242 (void *)&cmd_vf_tc_bw_min_bw,
15243 (void *)&cmd_vf_tc_bw_port_id,
15244 (void *)&cmd_vf_tc_bw_vf_id,
15245 (void *)&cmd_vf_tc_bw_bw_list,
15251 cmd_tc_min_bw_parsed(
15252 void *parsed_result,
15253 __rte_unused struct cmdline *cl,
15254 __rte_unused void *data)
15256 struct cmd_vf_tc_bw_result *res = parsed_result;
15257 struct rte_port *port;
15260 int ret = -ENOTSUP;
15262 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15265 port = &ports[res->port_id];
15266 /** Check if the port is not started **/
15267 if (port->port_status != RTE_PORT_STOPPED) {
15268 printf("Please stop port %d first\n", res->port_id);
15272 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15276 #ifdef RTE_LIBRTE_IXGBE_PMD
15277 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15284 printf("invalid bandwidth\n");
15287 printf("invalid port_id %d\n", res->port_id);
15290 printf("function not implemented\n");
15293 printf("programming error: (%s)\n", strerror(-ret));
15297 cmdline_parse_inst_t cmd_tc_min_bw = {
15298 .f = cmd_tc_min_bw_parsed,
15300 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15302 (void *)&cmd_vf_tc_bw_set,
15303 (void *)&cmd_vf_tc_bw_tc,
15304 (void *)&cmd_vf_tc_bw_tx,
15305 (void *)&cmd_vf_tc_bw_min_bw,
15306 (void *)&cmd_vf_tc_bw_port_id,
15307 (void *)&cmd_vf_tc_bw_bw_list,
15312 /* TC max bandwidth setting */
15314 cmd_vf_tc_max_bw_parsed(
15315 void *parsed_result,
15316 __rte_unused struct cmdline *cl,
15317 __rte_unused void *data)
15319 struct cmd_vf_tc_bw_result *res = parsed_result;
15320 int ret = -ENOTSUP;
15322 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15325 #ifdef RTE_LIBRTE_I40E_PMD
15326 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15327 res->tc_no, res->bw);
15334 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15335 res->vf_id, res->tc_no, res->bw);
15338 printf("invalid port_id %d\n", res->port_id);
15341 printf("function not implemented\n");
15344 printf("programming error: (%s)\n", strerror(-ret));
15348 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15349 .f = cmd_vf_tc_max_bw_parsed,
15351 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15354 (void *)&cmd_vf_tc_bw_set,
15355 (void *)&cmd_vf_tc_bw_vf,
15356 (void *)&cmd_vf_tc_bw_tc,
15357 (void *)&cmd_vf_tc_bw_tx,
15358 (void *)&cmd_vf_tc_bw_max_bw,
15359 (void *)&cmd_vf_tc_bw_port_id,
15360 (void *)&cmd_vf_tc_bw_vf_id,
15361 (void *)&cmd_vf_tc_bw_tc_no,
15362 (void *)&cmd_vf_tc_bw_bw,
15367 /** Set VXLAN encapsulation details */
15368 struct cmd_set_vxlan_result {
15369 cmdline_fixed_string_t set;
15370 cmdline_fixed_string_t vxlan;
15371 cmdline_fixed_string_t pos_token;
15372 cmdline_fixed_string_t ip_version;
15373 uint32_t vlan_present:1;
15377 cmdline_ipaddr_t ip_src;
15378 cmdline_ipaddr_t ip_dst;
15382 struct rte_ether_addr eth_src;
15383 struct rte_ether_addr eth_dst;
15386 cmdline_parse_token_string_t cmd_set_vxlan_set =
15387 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15388 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15389 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15390 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15391 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15393 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15394 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15395 "vxlan-with-vlan");
15396 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15397 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15399 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15400 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15402 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15403 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15405 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15406 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15407 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15408 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15410 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15411 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15412 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15413 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15415 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15416 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15417 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15418 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15420 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15421 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15422 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15423 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15425 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15426 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15427 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15428 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15430 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15431 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15432 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15433 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15435 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15436 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15437 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15438 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15440 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15441 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15442 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15443 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15445 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15446 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15447 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15448 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15450 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15451 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15453 static void cmd_set_vxlan_parsed(void *parsed_result,
15454 __rte_unused struct cmdline *cl,
15455 __rte_unused void *data)
15457 struct cmd_set_vxlan_result *res = parsed_result;
15462 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15465 vxlan_encap_conf.select_tos_ttl = 0;
15466 if (strcmp(res->vxlan, "vxlan") == 0)
15467 vxlan_encap_conf.select_vlan = 0;
15468 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15469 vxlan_encap_conf.select_vlan = 1;
15470 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15471 vxlan_encap_conf.select_vlan = 0;
15472 vxlan_encap_conf.select_tos_ttl = 1;
15474 if (strcmp(res->ip_version, "ipv4") == 0)
15475 vxlan_encap_conf.select_ipv4 = 1;
15476 else if (strcmp(res->ip_version, "ipv6") == 0)
15477 vxlan_encap_conf.select_ipv4 = 0;
15480 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15481 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15482 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15483 vxlan_encap_conf.ip_tos = res->tos;
15484 vxlan_encap_conf.ip_ttl = res->ttl;
15485 if (vxlan_encap_conf.select_ipv4) {
15486 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15487 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15489 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15490 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15492 if (vxlan_encap_conf.select_vlan)
15493 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15494 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15495 RTE_ETHER_ADDR_LEN);
15496 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15497 RTE_ETHER_ADDR_LEN);
15500 cmdline_parse_inst_t cmd_set_vxlan = {
15501 .f = cmd_set_vxlan_parsed,
15503 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15504 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15505 " eth-src <eth-src> eth-dst <eth-dst>",
15507 (void *)&cmd_set_vxlan_set,
15508 (void *)&cmd_set_vxlan_vxlan,
15509 (void *)&cmd_set_vxlan_ip_version,
15510 (void *)&cmd_set_vxlan_ip_version_value,
15511 (void *)&cmd_set_vxlan_vni,
15512 (void *)&cmd_set_vxlan_vni_value,
15513 (void *)&cmd_set_vxlan_udp_src,
15514 (void *)&cmd_set_vxlan_udp_src_value,
15515 (void *)&cmd_set_vxlan_udp_dst,
15516 (void *)&cmd_set_vxlan_udp_dst_value,
15517 (void *)&cmd_set_vxlan_ip_src,
15518 (void *)&cmd_set_vxlan_ip_src_value,
15519 (void *)&cmd_set_vxlan_ip_dst,
15520 (void *)&cmd_set_vxlan_ip_dst_value,
15521 (void *)&cmd_set_vxlan_eth_src,
15522 (void *)&cmd_set_vxlan_eth_src_value,
15523 (void *)&cmd_set_vxlan_eth_dst,
15524 (void *)&cmd_set_vxlan_eth_dst_value,
15529 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15530 .f = cmd_set_vxlan_parsed,
15532 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15533 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15534 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15535 " eth-dst <eth-dst>",
15537 (void *)&cmd_set_vxlan_set,
15538 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15539 (void *)&cmd_set_vxlan_ip_version,
15540 (void *)&cmd_set_vxlan_ip_version_value,
15541 (void *)&cmd_set_vxlan_vni,
15542 (void *)&cmd_set_vxlan_vni_value,
15543 (void *)&cmd_set_vxlan_udp_src,
15544 (void *)&cmd_set_vxlan_udp_src_value,
15545 (void *)&cmd_set_vxlan_udp_dst,
15546 (void *)&cmd_set_vxlan_udp_dst_value,
15547 (void *)&cmd_set_vxlan_ip_tos,
15548 (void *)&cmd_set_vxlan_ip_tos_value,
15549 (void *)&cmd_set_vxlan_ip_ttl,
15550 (void *)&cmd_set_vxlan_ip_ttl_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_with_vlan = {
15564 .f = cmd_set_vxlan_parsed,
15566 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15567 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15568 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15571 (void *)&cmd_set_vxlan_set,
15572 (void *)&cmd_set_vxlan_vxlan_with_vlan,
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_src,
15582 (void *)&cmd_set_vxlan_ip_src_value,
15583 (void *)&cmd_set_vxlan_ip_dst,
15584 (void *)&cmd_set_vxlan_ip_dst_value,
15585 (void *)&cmd_set_vxlan_vlan,
15586 (void *)&cmd_set_vxlan_vlan_value,
15587 (void *)&cmd_set_vxlan_eth_src,
15588 (void *)&cmd_set_vxlan_eth_src_value,
15589 (void *)&cmd_set_vxlan_eth_dst,
15590 (void *)&cmd_set_vxlan_eth_dst_value,
15595 /** Set NVGRE encapsulation details */
15596 struct cmd_set_nvgre_result {
15597 cmdline_fixed_string_t set;
15598 cmdline_fixed_string_t nvgre;
15599 cmdline_fixed_string_t pos_token;
15600 cmdline_fixed_string_t ip_version;
15602 cmdline_ipaddr_t ip_src;
15603 cmdline_ipaddr_t ip_dst;
15605 struct rte_ether_addr eth_src;
15606 struct rte_ether_addr eth_dst;
15609 cmdline_parse_token_string_t cmd_set_nvgre_set =
15610 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15611 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15612 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15613 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15614 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15615 "nvgre-with-vlan");
15616 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15617 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15619 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15620 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15622 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15623 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15625 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15626 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15627 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15628 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15630 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15631 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15632 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15633 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15635 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15636 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15637 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15638 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15640 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15641 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15642 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15643 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15645 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15646 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15647 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15648 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15650 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15651 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15653 static void cmd_set_nvgre_parsed(void *parsed_result,
15654 __rte_unused struct cmdline *cl,
15655 __rte_unused void *data)
15657 struct cmd_set_nvgre_result *res = parsed_result;
15659 uint32_t nvgre_tni;
15662 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15665 if (strcmp(res->nvgre, "nvgre") == 0)
15666 nvgre_encap_conf.select_vlan = 0;
15667 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15668 nvgre_encap_conf.select_vlan = 1;
15669 if (strcmp(res->ip_version, "ipv4") == 0)
15670 nvgre_encap_conf.select_ipv4 = 1;
15671 else if (strcmp(res->ip_version, "ipv6") == 0)
15672 nvgre_encap_conf.select_ipv4 = 0;
15675 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15676 if (nvgre_encap_conf.select_ipv4) {
15677 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15678 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15680 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15681 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15683 if (nvgre_encap_conf.select_vlan)
15684 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15685 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15686 RTE_ETHER_ADDR_LEN);
15687 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15688 RTE_ETHER_ADDR_LEN);
15691 cmdline_parse_inst_t cmd_set_nvgre = {
15692 .f = cmd_set_nvgre_parsed,
15694 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15695 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15696 " eth-dst <eth-dst>",
15698 (void *)&cmd_set_nvgre_set,
15699 (void *)&cmd_set_nvgre_nvgre,
15700 (void *)&cmd_set_nvgre_ip_version,
15701 (void *)&cmd_set_nvgre_ip_version_value,
15702 (void *)&cmd_set_nvgre_tni,
15703 (void *)&cmd_set_nvgre_tni_value,
15704 (void *)&cmd_set_nvgre_ip_src,
15705 (void *)&cmd_set_nvgre_ip_src_value,
15706 (void *)&cmd_set_nvgre_ip_dst,
15707 (void *)&cmd_set_nvgre_ip_dst_value,
15708 (void *)&cmd_set_nvgre_eth_src,
15709 (void *)&cmd_set_nvgre_eth_src_value,
15710 (void *)&cmd_set_nvgre_eth_dst,
15711 (void *)&cmd_set_nvgre_eth_dst_value,
15716 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15717 .f = cmd_set_nvgre_parsed,
15719 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15720 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15721 " eth-src <eth-src> eth-dst <eth-dst>",
15723 (void *)&cmd_set_nvgre_set,
15724 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15725 (void *)&cmd_set_nvgre_ip_version,
15726 (void *)&cmd_set_nvgre_ip_version_value,
15727 (void *)&cmd_set_nvgre_tni,
15728 (void *)&cmd_set_nvgre_tni_value,
15729 (void *)&cmd_set_nvgre_ip_src,
15730 (void *)&cmd_set_nvgre_ip_src_value,
15731 (void *)&cmd_set_nvgre_ip_dst,
15732 (void *)&cmd_set_nvgre_ip_dst_value,
15733 (void *)&cmd_set_nvgre_vlan,
15734 (void *)&cmd_set_nvgre_vlan_value,
15735 (void *)&cmd_set_nvgre_eth_src,
15736 (void *)&cmd_set_nvgre_eth_src_value,
15737 (void *)&cmd_set_nvgre_eth_dst,
15738 (void *)&cmd_set_nvgre_eth_dst_value,
15743 /** Set L2 encapsulation details */
15744 struct cmd_set_l2_encap_result {
15745 cmdline_fixed_string_t set;
15746 cmdline_fixed_string_t l2_encap;
15747 cmdline_fixed_string_t pos_token;
15748 cmdline_fixed_string_t ip_version;
15749 uint32_t vlan_present:1;
15751 struct rte_ether_addr eth_src;
15752 struct rte_ether_addr eth_dst;
15755 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15756 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15757 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15758 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15759 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15760 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15761 "l2_encap-with-vlan");
15762 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15763 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15765 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15766 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15768 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15769 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15771 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15772 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15773 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15774 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15776 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15777 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15778 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15779 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15781 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15782 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15784 static void cmd_set_l2_encap_parsed(void *parsed_result,
15785 __rte_unused struct cmdline *cl,
15786 __rte_unused void *data)
15788 struct cmd_set_l2_encap_result *res = parsed_result;
15790 if (strcmp(res->l2_encap, "l2_encap") == 0)
15791 l2_encap_conf.select_vlan = 0;
15792 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15793 l2_encap_conf.select_vlan = 1;
15794 if (strcmp(res->ip_version, "ipv4") == 0)
15795 l2_encap_conf.select_ipv4 = 1;
15796 else if (strcmp(res->ip_version, "ipv6") == 0)
15797 l2_encap_conf.select_ipv4 = 0;
15800 if (l2_encap_conf.select_vlan)
15801 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15802 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15803 RTE_ETHER_ADDR_LEN);
15804 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15805 RTE_ETHER_ADDR_LEN);
15808 cmdline_parse_inst_t cmd_set_l2_encap = {
15809 .f = cmd_set_l2_encap_parsed,
15811 .help_str = "set l2_encap ip-version ipv4|ipv6"
15812 " eth-src <eth-src> eth-dst <eth-dst>",
15814 (void *)&cmd_set_l2_encap_set,
15815 (void *)&cmd_set_l2_encap_l2_encap,
15816 (void *)&cmd_set_l2_encap_ip_version,
15817 (void *)&cmd_set_l2_encap_ip_version_value,
15818 (void *)&cmd_set_l2_encap_eth_src,
15819 (void *)&cmd_set_l2_encap_eth_src_value,
15820 (void *)&cmd_set_l2_encap_eth_dst,
15821 (void *)&cmd_set_l2_encap_eth_dst_value,
15826 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15827 .f = cmd_set_l2_encap_parsed,
15829 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15830 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15832 (void *)&cmd_set_l2_encap_set,
15833 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15834 (void *)&cmd_set_l2_encap_ip_version,
15835 (void *)&cmd_set_l2_encap_ip_version_value,
15836 (void *)&cmd_set_l2_encap_vlan,
15837 (void *)&cmd_set_l2_encap_vlan_value,
15838 (void *)&cmd_set_l2_encap_eth_src,
15839 (void *)&cmd_set_l2_encap_eth_src_value,
15840 (void *)&cmd_set_l2_encap_eth_dst,
15841 (void *)&cmd_set_l2_encap_eth_dst_value,
15846 /** Set L2 decapsulation details */
15847 struct cmd_set_l2_decap_result {
15848 cmdline_fixed_string_t set;
15849 cmdline_fixed_string_t l2_decap;
15850 cmdline_fixed_string_t pos_token;
15851 uint32_t vlan_present:1;
15854 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15855 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15856 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15857 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15859 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15860 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15861 "l2_decap-with-vlan");
15863 static void cmd_set_l2_decap_parsed(void *parsed_result,
15864 __rte_unused struct cmdline *cl,
15865 __rte_unused void *data)
15867 struct cmd_set_l2_decap_result *res = parsed_result;
15869 if (strcmp(res->l2_decap, "l2_decap") == 0)
15870 l2_decap_conf.select_vlan = 0;
15871 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15872 l2_decap_conf.select_vlan = 1;
15875 cmdline_parse_inst_t cmd_set_l2_decap = {
15876 .f = cmd_set_l2_decap_parsed,
15878 .help_str = "set l2_decap",
15880 (void *)&cmd_set_l2_decap_set,
15881 (void *)&cmd_set_l2_decap_l2_decap,
15886 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15887 .f = cmd_set_l2_decap_parsed,
15889 .help_str = "set l2_decap-with-vlan",
15891 (void *)&cmd_set_l2_decap_set,
15892 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15897 /** Set MPLSoGRE encapsulation details */
15898 struct cmd_set_mplsogre_encap_result {
15899 cmdline_fixed_string_t set;
15900 cmdline_fixed_string_t mplsogre;
15901 cmdline_fixed_string_t pos_token;
15902 cmdline_fixed_string_t ip_version;
15903 uint32_t vlan_present:1;
15905 cmdline_ipaddr_t ip_src;
15906 cmdline_ipaddr_t ip_dst;
15908 struct rte_ether_addr eth_src;
15909 struct rte_ether_addr eth_dst;
15912 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15913 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15915 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15916 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15918 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15919 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15920 mplsogre, "mplsogre_encap-with-vlan");
15921 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15922 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15923 pos_token, "ip-version");
15924 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15925 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15926 ip_version, "ipv4#ipv6");
15927 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15928 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15929 pos_token, "label");
15930 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15931 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15933 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15934 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15935 pos_token, "ip-src");
15936 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15937 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15938 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15939 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15940 pos_token, "ip-dst");
15941 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15942 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15943 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15944 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15945 pos_token, "vlan-tci");
15946 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15947 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15949 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15950 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15951 pos_token, "eth-src");
15952 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15953 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15955 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15956 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15957 pos_token, "eth-dst");
15958 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15959 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15962 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15963 __rte_unused struct cmdline *cl,
15964 __rte_unused void *data)
15966 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15968 uint32_t mplsogre_label;
15971 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15974 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15975 mplsogre_encap_conf.select_vlan = 0;
15976 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15977 mplsogre_encap_conf.select_vlan = 1;
15978 if (strcmp(res->ip_version, "ipv4") == 0)
15979 mplsogre_encap_conf.select_ipv4 = 1;
15980 else if (strcmp(res->ip_version, "ipv6") == 0)
15981 mplsogre_encap_conf.select_ipv4 = 0;
15984 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15985 if (mplsogre_encap_conf.select_ipv4) {
15986 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15987 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15989 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15990 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15992 if (mplsogre_encap_conf.select_vlan)
15993 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15994 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15995 RTE_ETHER_ADDR_LEN);
15996 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15997 RTE_ETHER_ADDR_LEN);
16000 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16001 .f = cmd_set_mplsogre_encap_parsed,
16003 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16004 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16005 " eth-dst <eth-dst>",
16007 (void *)&cmd_set_mplsogre_encap_set,
16008 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16009 (void *)&cmd_set_mplsogre_encap_ip_version,
16010 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16011 (void *)&cmd_set_mplsogre_encap_label,
16012 (void *)&cmd_set_mplsogre_encap_label_value,
16013 (void *)&cmd_set_mplsogre_encap_ip_src,
16014 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16015 (void *)&cmd_set_mplsogre_encap_ip_dst,
16016 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16017 (void *)&cmd_set_mplsogre_encap_eth_src,
16018 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16019 (void *)&cmd_set_mplsogre_encap_eth_dst,
16020 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16025 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16026 .f = cmd_set_mplsogre_encap_parsed,
16028 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16029 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16030 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16032 (void *)&cmd_set_mplsogre_encap_set,
16033 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16034 (void *)&cmd_set_mplsogre_encap_ip_version,
16035 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16036 (void *)&cmd_set_mplsogre_encap_label,
16037 (void *)&cmd_set_mplsogre_encap_label_value,
16038 (void *)&cmd_set_mplsogre_encap_ip_src,
16039 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16040 (void *)&cmd_set_mplsogre_encap_ip_dst,
16041 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16042 (void *)&cmd_set_mplsogre_encap_vlan,
16043 (void *)&cmd_set_mplsogre_encap_vlan_value,
16044 (void *)&cmd_set_mplsogre_encap_eth_src,
16045 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16046 (void *)&cmd_set_mplsogre_encap_eth_dst,
16047 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16052 /** Set MPLSoGRE decapsulation details */
16053 struct cmd_set_mplsogre_decap_result {
16054 cmdline_fixed_string_t set;
16055 cmdline_fixed_string_t mplsogre;
16056 cmdline_fixed_string_t pos_token;
16057 cmdline_fixed_string_t ip_version;
16058 uint32_t vlan_present:1;
16061 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16062 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16064 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16065 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16067 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16068 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16069 mplsogre, "mplsogre_decap-with-vlan");
16070 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16071 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16072 pos_token, "ip-version");
16073 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16074 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16075 ip_version, "ipv4#ipv6");
16077 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16078 __rte_unused struct cmdline *cl,
16079 __rte_unused void *data)
16081 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16083 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16084 mplsogre_decap_conf.select_vlan = 0;
16085 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16086 mplsogre_decap_conf.select_vlan = 1;
16087 if (strcmp(res->ip_version, "ipv4") == 0)
16088 mplsogre_decap_conf.select_ipv4 = 1;
16089 else if (strcmp(res->ip_version, "ipv6") == 0)
16090 mplsogre_decap_conf.select_ipv4 = 0;
16093 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16094 .f = cmd_set_mplsogre_decap_parsed,
16096 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16098 (void *)&cmd_set_mplsogre_decap_set,
16099 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16100 (void *)&cmd_set_mplsogre_decap_ip_version,
16101 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16106 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16107 .f = cmd_set_mplsogre_decap_parsed,
16109 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16111 (void *)&cmd_set_mplsogre_decap_set,
16112 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16113 (void *)&cmd_set_mplsogre_decap_ip_version,
16114 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16119 /** Set MPLSoUDP encapsulation details */
16120 struct cmd_set_mplsoudp_encap_result {
16121 cmdline_fixed_string_t set;
16122 cmdline_fixed_string_t mplsoudp;
16123 cmdline_fixed_string_t pos_token;
16124 cmdline_fixed_string_t ip_version;
16125 uint32_t vlan_present:1;
16129 cmdline_ipaddr_t ip_src;
16130 cmdline_ipaddr_t ip_dst;
16132 struct rte_ether_addr eth_src;
16133 struct rte_ether_addr eth_dst;
16136 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16137 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16139 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16140 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16142 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16143 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16144 mplsoudp, "mplsoudp_encap-with-vlan");
16145 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16146 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16147 pos_token, "ip-version");
16148 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16149 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16150 ip_version, "ipv4#ipv6");
16151 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16152 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16153 pos_token, "label");
16154 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16155 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16157 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16158 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16159 pos_token, "udp-src");
16160 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16161 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16163 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16164 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16165 pos_token, "udp-dst");
16166 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16167 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16169 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16170 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16171 pos_token, "ip-src");
16172 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16173 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16174 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16175 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16176 pos_token, "ip-dst");
16177 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16178 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16179 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16180 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16181 pos_token, "vlan-tci");
16182 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16183 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16185 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16186 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16187 pos_token, "eth-src");
16188 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16189 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16191 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16192 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16193 pos_token, "eth-dst");
16194 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16195 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16198 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16199 __rte_unused struct cmdline *cl,
16200 __rte_unused void *data)
16202 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16204 uint32_t mplsoudp_label;
16207 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16210 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16211 mplsoudp_encap_conf.select_vlan = 0;
16212 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16213 mplsoudp_encap_conf.select_vlan = 1;
16214 if (strcmp(res->ip_version, "ipv4") == 0)
16215 mplsoudp_encap_conf.select_ipv4 = 1;
16216 else if (strcmp(res->ip_version, "ipv6") == 0)
16217 mplsoudp_encap_conf.select_ipv4 = 0;
16220 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16221 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16222 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16223 if (mplsoudp_encap_conf.select_ipv4) {
16224 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16225 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16227 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16228 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16230 if (mplsoudp_encap_conf.select_vlan)
16231 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16232 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16233 RTE_ETHER_ADDR_LEN);
16234 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16235 RTE_ETHER_ADDR_LEN);
16238 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16239 .f = cmd_set_mplsoudp_encap_parsed,
16241 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16242 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16243 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16245 (void *)&cmd_set_mplsoudp_encap_set,
16246 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16247 (void *)&cmd_set_mplsoudp_encap_ip_version,
16248 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16249 (void *)&cmd_set_mplsoudp_encap_label,
16250 (void *)&cmd_set_mplsoudp_encap_label_value,
16251 (void *)&cmd_set_mplsoudp_encap_udp_src,
16252 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16253 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16254 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16255 (void *)&cmd_set_mplsoudp_encap_ip_src,
16256 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16257 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16258 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16259 (void *)&cmd_set_mplsoudp_encap_eth_src,
16260 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16261 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16262 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16267 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16268 .f = cmd_set_mplsoudp_encap_parsed,
16270 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16271 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16272 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16273 " eth-src <eth-src> eth-dst <eth-dst>",
16275 (void *)&cmd_set_mplsoudp_encap_set,
16276 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16277 (void *)&cmd_set_mplsoudp_encap_ip_version,
16278 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16279 (void *)&cmd_set_mplsoudp_encap_label,
16280 (void *)&cmd_set_mplsoudp_encap_label_value,
16281 (void *)&cmd_set_mplsoudp_encap_udp_src,
16282 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16283 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16284 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16285 (void *)&cmd_set_mplsoudp_encap_ip_src,
16286 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16287 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16288 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16289 (void *)&cmd_set_mplsoudp_encap_vlan,
16290 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16291 (void *)&cmd_set_mplsoudp_encap_eth_src,
16292 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16293 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16294 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16299 /** Set MPLSoUDP decapsulation details */
16300 struct cmd_set_mplsoudp_decap_result {
16301 cmdline_fixed_string_t set;
16302 cmdline_fixed_string_t mplsoudp;
16303 cmdline_fixed_string_t pos_token;
16304 cmdline_fixed_string_t ip_version;
16305 uint32_t vlan_present:1;
16308 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16309 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16311 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16312 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16314 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16315 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16316 mplsoudp, "mplsoudp_decap-with-vlan");
16317 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16318 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16319 pos_token, "ip-version");
16320 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16321 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16322 ip_version, "ipv4#ipv6");
16324 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16325 __rte_unused struct cmdline *cl,
16326 __rte_unused void *data)
16328 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16330 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16331 mplsoudp_decap_conf.select_vlan = 0;
16332 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16333 mplsoudp_decap_conf.select_vlan = 1;
16334 if (strcmp(res->ip_version, "ipv4") == 0)
16335 mplsoudp_decap_conf.select_ipv4 = 1;
16336 else if (strcmp(res->ip_version, "ipv6") == 0)
16337 mplsoudp_decap_conf.select_ipv4 = 0;
16340 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16341 .f = cmd_set_mplsoudp_decap_parsed,
16343 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16345 (void *)&cmd_set_mplsoudp_decap_set,
16346 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16347 (void *)&cmd_set_mplsoudp_decap_ip_version,
16348 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16353 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16354 .f = cmd_set_mplsoudp_decap_parsed,
16356 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16358 (void *)&cmd_set_mplsoudp_decap_set,
16359 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16360 (void *)&cmd_set_mplsoudp_decap_ip_version,
16361 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16366 /* Strict link priority scheduling mode setting */
16368 cmd_strict_link_prio_parsed(
16369 void *parsed_result,
16370 __rte_unused struct cmdline *cl,
16371 __rte_unused void *data)
16373 struct cmd_vf_tc_bw_result *res = parsed_result;
16374 int ret = -ENOTSUP;
16376 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16379 #ifdef RTE_LIBRTE_I40E_PMD
16380 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16387 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16390 printf("invalid port_id %d\n", res->port_id);
16393 printf("function not implemented\n");
16396 printf("programming error: (%s)\n", strerror(-ret));
16400 cmdline_parse_inst_t cmd_strict_link_prio = {
16401 .f = cmd_strict_link_prio_parsed,
16403 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16405 (void *)&cmd_vf_tc_bw_set,
16406 (void *)&cmd_vf_tc_bw_tx,
16407 (void *)&cmd_vf_tc_bw_strict_link_prio,
16408 (void *)&cmd_vf_tc_bw_port_id,
16409 (void *)&cmd_vf_tc_bw_tc_map,
16414 /* Load dynamic device personalization*/
16415 struct cmd_ddp_add_result {
16416 cmdline_fixed_string_t ddp;
16417 cmdline_fixed_string_t add;
16422 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16423 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16424 cmdline_parse_token_string_t cmd_ddp_add_add =
16425 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16426 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16427 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16428 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16429 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16432 cmd_ddp_add_parsed(
16433 void *parsed_result,
16434 __rte_unused struct cmdline *cl,
16435 __rte_unused void *data)
16437 struct cmd_ddp_add_result *res = parsed_result;
16443 int ret = -ENOTSUP;
16445 if (!all_ports_stopped()) {
16446 printf("Please stop all ports first\n");
16450 filepath = strdup(res->filepath);
16451 if (filepath == NULL) {
16452 printf("Failed to allocate memory\n");
16455 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16457 buff = open_file(file_fld[0], &size);
16459 free((void *)filepath);
16463 #ifdef RTE_LIBRTE_I40E_PMD
16464 if (ret == -ENOTSUP)
16465 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16467 RTE_PMD_I40E_PKG_OP_WR_ADD);
16470 if (ret == -EEXIST)
16471 printf("Profile has already existed.\n");
16473 printf("Failed to load profile.\n");
16474 else if (file_num == 2)
16475 save_file(file_fld[1], buff, size);
16478 free((void *)filepath);
16481 cmdline_parse_inst_t cmd_ddp_add = {
16482 .f = cmd_ddp_add_parsed,
16484 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16486 (void *)&cmd_ddp_add_ddp,
16487 (void *)&cmd_ddp_add_add,
16488 (void *)&cmd_ddp_add_port_id,
16489 (void *)&cmd_ddp_add_filepath,
16494 /* Delete dynamic device personalization*/
16495 struct cmd_ddp_del_result {
16496 cmdline_fixed_string_t ddp;
16497 cmdline_fixed_string_t del;
16502 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16503 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16504 cmdline_parse_token_string_t cmd_ddp_del_del =
16505 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16506 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16507 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16508 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16509 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16512 cmd_ddp_del_parsed(
16513 void *parsed_result,
16514 __rte_unused struct cmdline *cl,
16515 __rte_unused void *data)
16517 struct cmd_ddp_del_result *res = parsed_result;
16520 int ret = -ENOTSUP;
16522 if (!all_ports_stopped()) {
16523 printf("Please stop all ports first\n");
16527 buff = open_file(res->filepath, &size);
16531 #ifdef RTE_LIBRTE_I40E_PMD
16532 if (ret == -ENOTSUP)
16533 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16535 RTE_PMD_I40E_PKG_OP_WR_DEL);
16538 if (ret == -EACCES)
16539 printf("Profile does not exist.\n");
16541 printf("Failed to delete profile.\n");
16546 cmdline_parse_inst_t cmd_ddp_del = {
16547 .f = cmd_ddp_del_parsed,
16549 .help_str = "ddp del <port_id> <backup_profile_path>",
16551 (void *)&cmd_ddp_del_ddp,
16552 (void *)&cmd_ddp_del_del,
16553 (void *)&cmd_ddp_del_port_id,
16554 (void *)&cmd_ddp_del_filepath,
16559 /* Get dynamic device personalization profile info */
16560 struct cmd_ddp_info_result {
16561 cmdline_fixed_string_t ddp;
16562 cmdline_fixed_string_t get;
16563 cmdline_fixed_string_t info;
16567 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16568 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16569 cmdline_parse_token_string_t cmd_ddp_info_get =
16570 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16571 cmdline_parse_token_string_t cmd_ddp_info_info =
16572 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16573 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16574 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16577 cmd_ddp_info_parsed(
16578 void *parsed_result,
16579 __rte_unused struct cmdline *cl,
16580 __rte_unused void *data)
16582 struct cmd_ddp_info_result *res = parsed_result;
16585 int ret = -ENOTSUP;
16586 #ifdef RTE_LIBRTE_I40E_PMD
16589 uint32_t buff_size = 0;
16590 struct rte_pmd_i40e_profile_info info;
16591 uint32_t dev_num = 0;
16592 struct rte_pmd_i40e_ddp_device_id *devs;
16593 uint32_t proto_num = 0;
16594 struct rte_pmd_i40e_proto_info *proto = NULL;
16595 uint32_t pctype_num = 0;
16596 struct rte_pmd_i40e_ptype_info *pctype;
16597 uint32_t ptype_num = 0;
16598 struct rte_pmd_i40e_ptype_info *ptype;
16603 pkg = open_file(res->filepath, &pkg_size);
16607 #ifdef RTE_LIBRTE_I40E_PMD
16608 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16609 (uint8_t *)&info, sizeof(info),
16610 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16612 printf("Global Track id: 0x%x\n", info.track_id);
16613 printf("Global Version: %d.%d.%d.%d\n",
16614 info.version.major,
16615 info.version.minor,
16616 info.version.update,
16617 info.version.draft);
16618 printf("Global Package name: %s\n\n", info.name);
16621 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16622 (uint8_t *)&info, sizeof(info),
16623 RTE_PMD_I40E_PKG_INFO_HEADER);
16625 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16626 printf("i40e Profile Version: %d.%d.%d.%d\n",
16627 info.version.major,
16628 info.version.minor,
16629 info.version.update,
16630 info.version.draft);
16631 printf("i40e Profile name: %s\n\n", info.name);
16634 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16635 (uint8_t *)&buff_size, sizeof(buff_size),
16636 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16637 if (!ret && buff_size) {
16638 buff = (uint8_t *)malloc(buff_size);
16640 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16642 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16644 printf("Package Notes:\n%s\n\n", buff);
16649 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16650 (uint8_t *)&dev_num, sizeof(dev_num),
16651 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16652 if (!ret && dev_num) {
16653 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16654 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16656 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16657 (uint8_t *)devs, buff_size,
16658 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16660 printf("List of supported devices:\n");
16661 for (i = 0; i < dev_num; i++) {
16662 printf(" %04X:%04X %04X:%04X\n",
16663 devs[i].vendor_dev_id >> 16,
16664 devs[i].vendor_dev_id & 0xFFFF,
16665 devs[i].sub_vendor_dev_id >> 16,
16666 devs[i].sub_vendor_dev_id & 0xFFFF);
16674 /* get information about protocols and packet types */
16675 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16676 (uint8_t *)&proto_num, sizeof(proto_num),
16677 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16678 if (ret || !proto_num)
16679 goto no_print_return;
16681 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16682 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16684 goto no_print_return;
16686 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16688 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16690 printf("List of used protocols:\n");
16691 for (i = 0; i < proto_num; i++)
16692 printf(" %2u: %s\n", proto[i].proto_id,
16696 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16697 (uint8_t *)&pctype_num, sizeof(pctype_num),
16698 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16699 if (ret || !pctype_num)
16700 goto no_print_pctypes;
16702 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16703 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16705 goto no_print_pctypes;
16707 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16709 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16712 goto no_print_pctypes;
16715 printf("List of defined packet classification types:\n");
16716 for (i = 0; i < pctype_num; i++) {
16717 printf(" %2u:", pctype[i].ptype_id);
16718 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16719 proto_id = pctype[i].protocols[j];
16720 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16721 for (n = 0; n < proto_num; n++) {
16722 if (proto[n].proto_id == proto_id) {
16723 printf(" %s", proto[n].name);
16736 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16738 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16739 if (ret || !ptype_num)
16740 goto no_print_return;
16742 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16743 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16745 goto no_print_return;
16747 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16749 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16752 goto no_print_return;
16754 printf("List of defined packet types:\n");
16755 for (i = 0; i < ptype_num; i++) {
16756 printf(" %2u:", ptype[i].ptype_id);
16757 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16758 proto_id = ptype[i].protocols[j];
16759 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16760 for (n = 0; n < proto_num; n++) {
16761 if (proto[n].proto_id == proto_id) {
16762 printf(" %s", proto[n].name);
16778 if (ret == -ENOTSUP)
16779 printf("Function not supported in PMD driver\n");
16783 cmdline_parse_inst_t cmd_ddp_get_info = {
16784 .f = cmd_ddp_info_parsed,
16786 .help_str = "ddp get info <profile_path>",
16788 (void *)&cmd_ddp_info_ddp,
16789 (void *)&cmd_ddp_info_get,
16790 (void *)&cmd_ddp_info_info,
16791 (void *)&cmd_ddp_info_filepath,
16796 /* Get dynamic device personalization profile info list*/
16797 #define PROFILE_INFO_SIZE 48
16798 #define MAX_PROFILE_NUM 16
16800 struct cmd_ddp_get_list_result {
16801 cmdline_fixed_string_t ddp;
16802 cmdline_fixed_string_t get;
16803 cmdline_fixed_string_t list;
16807 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16808 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16809 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16810 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16811 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16812 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16813 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16814 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16817 cmd_ddp_get_list_parsed(
16818 __rte_unused void *parsed_result,
16819 __rte_unused struct cmdline *cl,
16820 __rte_unused void *data)
16822 #ifdef RTE_LIBRTE_I40E_PMD
16823 struct cmd_ddp_get_list_result *res = parsed_result;
16824 struct rte_pmd_i40e_profile_list *p_list;
16825 struct rte_pmd_i40e_profile_info *p_info;
16830 int ret = -ENOTSUP;
16832 #ifdef RTE_LIBRTE_I40E_PMD
16833 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16834 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16836 printf("%s: Failed to malloc buffer\n", __func__);
16840 if (ret == -ENOTSUP)
16841 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16842 (uint8_t *)p_list, size);
16845 p_num = p_list->p_count;
16846 printf("Profile number is: %d\n\n", p_num);
16848 for (i = 0; i < p_num; i++) {
16849 p_info = &p_list->p_info[i];
16850 printf("Profile %d:\n", i);
16851 printf("Track id: 0x%x\n", p_info->track_id);
16852 printf("Version: %d.%d.%d.%d\n",
16853 p_info->version.major,
16854 p_info->version.minor,
16855 p_info->version.update,
16856 p_info->version.draft);
16857 printf("Profile name: %s\n\n", p_info->name);
16865 printf("Failed to get ddp list\n");
16868 cmdline_parse_inst_t cmd_ddp_get_list = {
16869 .f = cmd_ddp_get_list_parsed,
16871 .help_str = "ddp get list <port_id>",
16873 (void *)&cmd_ddp_get_list_ddp,
16874 (void *)&cmd_ddp_get_list_get,
16875 (void *)&cmd_ddp_get_list_list,
16876 (void *)&cmd_ddp_get_list_port_id,
16881 /* Configure input set */
16882 struct cmd_cfg_input_set_result {
16883 cmdline_fixed_string_t port;
16884 cmdline_fixed_string_t cfg;
16886 cmdline_fixed_string_t pctype;
16888 cmdline_fixed_string_t inset_type;
16889 cmdline_fixed_string_t opt;
16890 cmdline_fixed_string_t field;
16895 cmd_cfg_input_set_parsed(
16896 __rte_unused void *parsed_result,
16897 __rte_unused struct cmdline *cl,
16898 __rte_unused void *data)
16900 #ifdef RTE_LIBRTE_I40E_PMD
16901 struct cmd_cfg_input_set_result *res = parsed_result;
16902 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16903 struct rte_pmd_i40e_inset inset;
16905 int ret = -ENOTSUP;
16907 if (!all_ports_stopped()) {
16908 printf("Please stop all ports first\n");
16912 #ifdef RTE_LIBRTE_I40E_PMD
16913 if (!strcmp(res->inset_type, "hash_inset"))
16914 inset_type = INSET_HASH;
16915 else if (!strcmp(res->inset_type, "fdir_inset"))
16916 inset_type = INSET_FDIR;
16917 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16918 inset_type = INSET_FDIR_FLX;
16919 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16920 &inset, inset_type);
16922 printf("Failed to get input set.\n");
16926 if (!strcmp(res->opt, "get")) {
16927 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16930 printf("Field index %d is enabled.\n", res->field_idx);
16932 printf("Field index %d is disabled.\n", res->field_idx);
16934 } else if (!strcmp(res->opt, "set"))
16935 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16937 else if (!strcmp(res->opt, "clear"))
16938 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16941 printf("Failed to configure input set field.\n");
16945 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16946 &inset, inset_type);
16948 printf("Failed to set input set.\n");
16953 if (ret == -ENOTSUP)
16954 printf("Function not supported\n");
16957 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16958 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16960 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16961 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16963 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16964 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16966 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16967 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16969 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16970 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16972 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16973 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16975 "hash_inset#fdir_inset#fdir_flx_inset");
16976 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16977 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16978 opt, "get#set#clear");
16979 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16980 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16982 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16983 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16986 cmdline_parse_inst_t cmd_cfg_input_set = {
16987 .f = cmd_cfg_input_set_parsed,
16989 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16990 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16992 (void *)&cmd_cfg_input_set_port,
16993 (void *)&cmd_cfg_input_set_cfg,
16994 (void *)&cmd_cfg_input_set_port_id,
16995 (void *)&cmd_cfg_input_set_pctype,
16996 (void *)&cmd_cfg_input_set_pctype_id,
16997 (void *)&cmd_cfg_input_set_inset_type,
16998 (void *)&cmd_cfg_input_set_opt,
16999 (void *)&cmd_cfg_input_set_field,
17000 (void *)&cmd_cfg_input_set_field_idx,
17005 /* Clear input set */
17006 struct cmd_clear_input_set_result {
17007 cmdline_fixed_string_t port;
17008 cmdline_fixed_string_t cfg;
17010 cmdline_fixed_string_t pctype;
17012 cmdline_fixed_string_t inset_type;
17013 cmdline_fixed_string_t clear;
17014 cmdline_fixed_string_t all;
17018 cmd_clear_input_set_parsed(
17019 __rte_unused void *parsed_result,
17020 __rte_unused struct cmdline *cl,
17021 __rte_unused void *data)
17023 #ifdef RTE_LIBRTE_I40E_PMD
17024 struct cmd_clear_input_set_result *res = parsed_result;
17025 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17026 struct rte_pmd_i40e_inset inset;
17028 int ret = -ENOTSUP;
17030 if (!all_ports_stopped()) {
17031 printf("Please stop all ports first\n");
17035 #ifdef RTE_LIBRTE_I40E_PMD
17036 if (!strcmp(res->inset_type, "hash_inset"))
17037 inset_type = INSET_HASH;
17038 else if (!strcmp(res->inset_type, "fdir_inset"))
17039 inset_type = INSET_FDIR;
17040 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17041 inset_type = INSET_FDIR_FLX;
17043 memset(&inset, 0, sizeof(inset));
17045 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17046 &inset, inset_type);
17048 printf("Failed to clear input set.\n");
17054 if (ret == -ENOTSUP)
17055 printf("Function not supported\n");
17058 cmdline_parse_token_string_t cmd_clear_input_set_port =
17059 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17061 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17062 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17064 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17065 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17067 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17068 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17070 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17071 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17073 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17074 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17076 "hash_inset#fdir_inset#fdir_flx_inset");
17077 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17078 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17080 cmdline_parse_token_string_t cmd_clear_input_set_all =
17081 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17084 cmdline_parse_inst_t cmd_clear_input_set = {
17085 .f = cmd_clear_input_set_parsed,
17087 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17088 "fdir_inset|fdir_flx_inset clear all",
17090 (void *)&cmd_clear_input_set_port,
17091 (void *)&cmd_clear_input_set_cfg,
17092 (void *)&cmd_clear_input_set_port_id,
17093 (void *)&cmd_clear_input_set_pctype,
17094 (void *)&cmd_clear_input_set_pctype_id,
17095 (void *)&cmd_clear_input_set_inset_type,
17096 (void *)&cmd_clear_input_set_clear,
17097 (void *)&cmd_clear_input_set_all,
17102 /* show vf stats */
17104 /* Common result structure for show vf stats */
17105 struct cmd_show_vf_stats_result {
17106 cmdline_fixed_string_t show;
17107 cmdline_fixed_string_t vf;
17108 cmdline_fixed_string_t stats;
17113 /* Common CLI fields show vf stats*/
17114 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17115 TOKEN_STRING_INITIALIZER
17116 (struct cmd_show_vf_stats_result,
17118 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17119 TOKEN_STRING_INITIALIZER
17120 (struct cmd_show_vf_stats_result,
17122 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17123 TOKEN_STRING_INITIALIZER
17124 (struct cmd_show_vf_stats_result,
17126 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17127 TOKEN_NUM_INITIALIZER
17128 (struct cmd_show_vf_stats_result,
17130 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17131 TOKEN_NUM_INITIALIZER
17132 (struct cmd_show_vf_stats_result,
17136 cmd_show_vf_stats_parsed(
17137 void *parsed_result,
17138 __rte_unused struct cmdline *cl,
17139 __rte_unused void *data)
17141 struct cmd_show_vf_stats_result *res = parsed_result;
17142 struct rte_eth_stats stats;
17143 int ret = -ENOTSUP;
17144 static const char *nic_stats_border = "########################";
17146 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17149 memset(&stats, 0, sizeof(stats));
17151 #ifdef RTE_LIBRTE_I40E_PMD
17152 if (ret == -ENOTSUP)
17153 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17157 #ifdef RTE_LIBRTE_BNXT_PMD
17158 if (ret == -ENOTSUP)
17159 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17168 printf("invalid vf_id %d\n", res->vf_id);
17171 printf("invalid port_id %d\n", res->port_id);
17174 printf("function not implemented\n");
17177 printf("programming error: (%s)\n", strerror(-ret));
17180 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17181 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17183 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17185 stats.ipackets, stats.imissed, stats.ibytes);
17186 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17187 printf(" RX-nombuf: %-10"PRIu64"\n",
17189 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17191 stats.opackets, stats.oerrors, stats.obytes);
17193 printf(" %s############################%s\n",
17194 nic_stats_border, nic_stats_border);
17197 cmdline_parse_inst_t cmd_show_vf_stats = {
17198 .f = cmd_show_vf_stats_parsed,
17200 .help_str = "show vf stats <port_id> <vf_id>",
17202 (void *)&cmd_show_vf_stats_show,
17203 (void *)&cmd_show_vf_stats_vf,
17204 (void *)&cmd_show_vf_stats_stats,
17205 (void *)&cmd_show_vf_stats_port_id,
17206 (void *)&cmd_show_vf_stats_vf_id,
17211 /* clear vf stats */
17213 /* Common result structure for clear vf stats */
17214 struct cmd_clear_vf_stats_result {
17215 cmdline_fixed_string_t clear;
17216 cmdline_fixed_string_t vf;
17217 cmdline_fixed_string_t stats;
17222 /* Common CLI fields clear vf stats*/
17223 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17224 TOKEN_STRING_INITIALIZER
17225 (struct cmd_clear_vf_stats_result,
17227 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17228 TOKEN_STRING_INITIALIZER
17229 (struct cmd_clear_vf_stats_result,
17231 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17232 TOKEN_STRING_INITIALIZER
17233 (struct cmd_clear_vf_stats_result,
17235 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17236 TOKEN_NUM_INITIALIZER
17237 (struct cmd_clear_vf_stats_result,
17239 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17240 TOKEN_NUM_INITIALIZER
17241 (struct cmd_clear_vf_stats_result,
17245 cmd_clear_vf_stats_parsed(
17246 void *parsed_result,
17247 __rte_unused struct cmdline *cl,
17248 __rte_unused void *data)
17250 struct cmd_clear_vf_stats_result *res = parsed_result;
17251 int ret = -ENOTSUP;
17253 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17256 #ifdef RTE_LIBRTE_I40E_PMD
17257 if (ret == -ENOTSUP)
17258 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17261 #ifdef RTE_LIBRTE_BNXT_PMD
17262 if (ret == -ENOTSUP)
17263 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17271 printf("invalid vf_id %d\n", res->vf_id);
17274 printf("invalid port_id %d\n", res->port_id);
17277 printf("function not implemented\n");
17280 printf("programming error: (%s)\n", strerror(-ret));
17284 cmdline_parse_inst_t cmd_clear_vf_stats = {
17285 .f = cmd_clear_vf_stats_parsed,
17287 .help_str = "clear vf stats <port_id> <vf_id>",
17289 (void *)&cmd_clear_vf_stats_clear,
17290 (void *)&cmd_clear_vf_stats_vf,
17291 (void *)&cmd_clear_vf_stats_stats,
17292 (void *)&cmd_clear_vf_stats_port_id,
17293 (void *)&cmd_clear_vf_stats_vf_id,
17298 /* port config pctype mapping reset */
17300 /* Common result structure for port config pctype mapping reset */
17301 struct cmd_pctype_mapping_reset_result {
17302 cmdline_fixed_string_t port;
17303 cmdline_fixed_string_t config;
17305 cmdline_fixed_string_t pctype;
17306 cmdline_fixed_string_t mapping;
17307 cmdline_fixed_string_t reset;
17310 /* Common CLI fields for port config pctype mapping reset*/
17311 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17312 TOKEN_STRING_INITIALIZER
17313 (struct cmd_pctype_mapping_reset_result,
17315 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17316 TOKEN_STRING_INITIALIZER
17317 (struct cmd_pctype_mapping_reset_result,
17319 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17320 TOKEN_NUM_INITIALIZER
17321 (struct cmd_pctype_mapping_reset_result,
17323 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17324 TOKEN_STRING_INITIALIZER
17325 (struct cmd_pctype_mapping_reset_result,
17327 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17328 TOKEN_STRING_INITIALIZER
17329 (struct cmd_pctype_mapping_reset_result,
17330 mapping, "mapping");
17331 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17332 TOKEN_STRING_INITIALIZER
17333 (struct cmd_pctype_mapping_reset_result,
17337 cmd_pctype_mapping_reset_parsed(
17338 void *parsed_result,
17339 __rte_unused struct cmdline *cl,
17340 __rte_unused void *data)
17342 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17343 int ret = -ENOTSUP;
17345 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17348 #ifdef RTE_LIBRTE_I40E_PMD
17349 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17356 printf("invalid port_id %d\n", res->port_id);
17359 printf("function not implemented\n");
17362 printf("programming error: (%s)\n", strerror(-ret));
17366 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17367 .f = cmd_pctype_mapping_reset_parsed,
17369 .help_str = "port config <port_id> pctype mapping reset",
17371 (void *)&cmd_pctype_mapping_reset_port,
17372 (void *)&cmd_pctype_mapping_reset_config,
17373 (void *)&cmd_pctype_mapping_reset_port_id,
17374 (void *)&cmd_pctype_mapping_reset_pctype,
17375 (void *)&cmd_pctype_mapping_reset_mapping,
17376 (void *)&cmd_pctype_mapping_reset_reset,
17381 /* show port pctype mapping */
17383 /* Common result structure for show port pctype mapping */
17384 struct cmd_pctype_mapping_get_result {
17385 cmdline_fixed_string_t show;
17386 cmdline_fixed_string_t port;
17388 cmdline_fixed_string_t pctype;
17389 cmdline_fixed_string_t mapping;
17392 /* Common CLI fields for pctype mapping get */
17393 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17394 TOKEN_STRING_INITIALIZER
17395 (struct cmd_pctype_mapping_get_result,
17397 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17398 TOKEN_STRING_INITIALIZER
17399 (struct cmd_pctype_mapping_get_result,
17401 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17402 TOKEN_NUM_INITIALIZER
17403 (struct cmd_pctype_mapping_get_result,
17405 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17406 TOKEN_STRING_INITIALIZER
17407 (struct cmd_pctype_mapping_get_result,
17409 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17410 TOKEN_STRING_INITIALIZER
17411 (struct cmd_pctype_mapping_get_result,
17412 mapping, "mapping");
17415 cmd_pctype_mapping_get_parsed(
17416 void *parsed_result,
17417 __rte_unused struct cmdline *cl,
17418 __rte_unused void *data)
17420 struct cmd_pctype_mapping_get_result *res = parsed_result;
17421 int ret = -ENOTSUP;
17422 #ifdef RTE_LIBRTE_I40E_PMD
17423 struct rte_pmd_i40e_flow_type_mapping
17424 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17425 int i, j, first_pctype;
17428 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17431 #ifdef RTE_LIBRTE_I40E_PMD
17432 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17439 printf("invalid port_id %d\n", res->port_id);
17442 printf("function not implemented\n");
17445 printf("programming error: (%s)\n", strerror(-ret));
17449 #ifdef RTE_LIBRTE_I40E_PMD
17450 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17451 if (mapping[i].pctype != 0ULL) {
17454 printf("pctype: ");
17455 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17456 if (mapping[i].pctype & (1ULL << j)) {
17457 printf(first_pctype ?
17458 "%02d" : ",%02d", j);
17462 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17468 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17469 .f = cmd_pctype_mapping_get_parsed,
17471 .help_str = "show port <port_id> pctype mapping",
17473 (void *)&cmd_pctype_mapping_get_show,
17474 (void *)&cmd_pctype_mapping_get_port,
17475 (void *)&cmd_pctype_mapping_get_port_id,
17476 (void *)&cmd_pctype_mapping_get_pctype,
17477 (void *)&cmd_pctype_mapping_get_mapping,
17482 /* port config pctype mapping update */
17484 /* Common result structure for port config pctype mapping update */
17485 struct cmd_pctype_mapping_update_result {
17486 cmdline_fixed_string_t port;
17487 cmdline_fixed_string_t config;
17489 cmdline_fixed_string_t pctype;
17490 cmdline_fixed_string_t mapping;
17491 cmdline_fixed_string_t update;
17492 cmdline_fixed_string_t pctype_list;
17493 uint16_t flow_type;
17496 /* Common CLI fields for pctype mapping update*/
17497 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17498 TOKEN_STRING_INITIALIZER
17499 (struct cmd_pctype_mapping_update_result,
17501 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17502 TOKEN_STRING_INITIALIZER
17503 (struct cmd_pctype_mapping_update_result,
17505 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17506 TOKEN_NUM_INITIALIZER
17507 (struct cmd_pctype_mapping_update_result,
17509 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17510 TOKEN_STRING_INITIALIZER
17511 (struct cmd_pctype_mapping_update_result,
17513 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17514 TOKEN_STRING_INITIALIZER
17515 (struct cmd_pctype_mapping_update_result,
17516 mapping, "mapping");
17517 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17518 TOKEN_STRING_INITIALIZER
17519 (struct cmd_pctype_mapping_update_result,
17521 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17522 TOKEN_STRING_INITIALIZER
17523 (struct cmd_pctype_mapping_update_result,
17524 pctype_list, NULL);
17525 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17526 TOKEN_NUM_INITIALIZER
17527 (struct cmd_pctype_mapping_update_result,
17528 flow_type, UINT16);
17531 cmd_pctype_mapping_update_parsed(
17532 void *parsed_result,
17533 __rte_unused struct cmdline *cl,
17534 __rte_unused void *data)
17536 struct cmd_pctype_mapping_update_result *res = parsed_result;
17537 int ret = -ENOTSUP;
17538 #ifdef RTE_LIBRTE_I40E_PMD
17539 struct rte_pmd_i40e_flow_type_mapping mapping;
17541 unsigned int nb_item;
17542 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17545 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17548 #ifdef RTE_LIBRTE_I40E_PMD
17549 nb_item = parse_item_list(res->pctype_list, "pctypes",
17550 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17551 mapping.flow_type = res->flow_type;
17552 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17553 mapping.pctype |= (1ULL << pctype_list[i]);
17554 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17564 printf("invalid pctype or flow type\n");
17567 printf("invalid port_id %d\n", res->port_id);
17570 printf("function not implemented\n");
17573 printf("programming error: (%s)\n", strerror(-ret));
17577 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17578 .f = cmd_pctype_mapping_update_parsed,
17580 .help_str = "port config <port_id> pctype mapping update"
17581 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17583 (void *)&cmd_pctype_mapping_update_port,
17584 (void *)&cmd_pctype_mapping_update_config,
17585 (void *)&cmd_pctype_mapping_update_port_id,
17586 (void *)&cmd_pctype_mapping_update_pctype,
17587 (void *)&cmd_pctype_mapping_update_mapping,
17588 (void *)&cmd_pctype_mapping_update_update,
17589 (void *)&cmd_pctype_mapping_update_pc_type,
17590 (void *)&cmd_pctype_mapping_update_flow_type,
17595 /* ptype mapping get */
17597 /* Common result structure for ptype mapping get */
17598 struct cmd_ptype_mapping_get_result {
17599 cmdline_fixed_string_t ptype;
17600 cmdline_fixed_string_t mapping;
17601 cmdline_fixed_string_t get;
17603 uint8_t valid_only;
17606 /* Common CLI fields for ptype mapping get */
17607 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17608 TOKEN_STRING_INITIALIZER
17609 (struct cmd_ptype_mapping_get_result,
17611 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17612 TOKEN_STRING_INITIALIZER
17613 (struct cmd_ptype_mapping_get_result,
17614 mapping, "mapping");
17615 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17616 TOKEN_STRING_INITIALIZER
17617 (struct cmd_ptype_mapping_get_result,
17619 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17620 TOKEN_NUM_INITIALIZER
17621 (struct cmd_ptype_mapping_get_result,
17623 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17624 TOKEN_NUM_INITIALIZER
17625 (struct cmd_ptype_mapping_get_result,
17626 valid_only, UINT8);
17629 cmd_ptype_mapping_get_parsed(
17630 void *parsed_result,
17631 __rte_unused struct cmdline *cl,
17632 __rte_unused void *data)
17634 struct cmd_ptype_mapping_get_result *res = parsed_result;
17635 int ret = -ENOTSUP;
17636 #ifdef RTE_LIBRTE_I40E_PMD
17637 int max_ptype_num = 256;
17638 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17643 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17646 #ifdef RTE_LIBRTE_I40E_PMD
17647 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17658 printf("invalid port_id %d\n", res->port_id);
17661 printf("function not implemented\n");
17664 printf("programming error: (%s)\n", strerror(-ret));
17667 #ifdef RTE_LIBRTE_I40E_PMD
17669 for (i = 0; i < count; i++)
17670 printf("%3d\t0x%08x\n",
17671 mapping[i].hw_ptype, mapping[i].sw_ptype);
17676 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17677 .f = cmd_ptype_mapping_get_parsed,
17679 .help_str = "ptype mapping get <port_id> <valid_only>",
17681 (void *)&cmd_ptype_mapping_get_ptype,
17682 (void *)&cmd_ptype_mapping_get_mapping,
17683 (void *)&cmd_ptype_mapping_get_get,
17684 (void *)&cmd_ptype_mapping_get_port_id,
17685 (void *)&cmd_ptype_mapping_get_valid_only,
17690 /* ptype mapping replace */
17692 /* Common result structure for ptype mapping replace */
17693 struct cmd_ptype_mapping_replace_result {
17694 cmdline_fixed_string_t ptype;
17695 cmdline_fixed_string_t mapping;
17696 cmdline_fixed_string_t replace;
17703 /* Common CLI fields for ptype mapping replace */
17704 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17705 TOKEN_STRING_INITIALIZER
17706 (struct cmd_ptype_mapping_replace_result,
17708 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17709 TOKEN_STRING_INITIALIZER
17710 (struct cmd_ptype_mapping_replace_result,
17711 mapping, "mapping");
17712 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17713 TOKEN_STRING_INITIALIZER
17714 (struct cmd_ptype_mapping_replace_result,
17715 replace, "replace");
17716 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17717 TOKEN_NUM_INITIALIZER
17718 (struct cmd_ptype_mapping_replace_result,
17720 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17721 TOKEN_NUM_INITIALIZER
17722 (struct cmd_ptype_mapping_replace_result,
17724 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17725 TOKEN_NUM_INITIALIZER
17726 (struct cmd_ptype_mapping_replace_result,
17728 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17729 TOKEN_NUM_INITIALIZER
17730 (struct cmd_ptype_mapping_replace_result,
17734 cmd_ptype_mapping_replace_parsed(
17735 void *parsed_result,
17736 __rte_unused struct cmdline *cl,
17737 __rte_unused void *data)
17739 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17740 int ret = -ENOTSUP;
17742 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17745 #ifdef RTE_LIBRTE_I40E_PMD
17746 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17756 printf("invalid ptype 0x%8x or 0x%8x\n",
17757 res->target, res->pkt_type);
17760 printf("invalid port_id %d\n", res->port_id);
17763 printf("function not implemented\n");
17766 printf("programming error: (%s)\n", strerror(-ret));
17770 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17771 .f = cmd_ptype_mapping_replace_parsed,
17774 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17776 (void *)&cmd_ptype_mapping_replace_ptype,
17777 (void *)&cmd_ptype_mapping_replace_mapping,
17778 (void *)&cmd_ptype_mapping_replace_replace,
17779 (void *)&cmd_ptype_mapping_replace_port_id,
17780 (void *)&cmd_ptype_mapping_replace_target,
17781 (void *)&cmd_ptype_mapping_replace_mask,
17782 (void *)&cmd_ptype_mapping_replace_pkt_type,
17787 /* ptype mapping reset */
17789 /* Common result structure for ptype mapping reset */
17790 struct cmd_ptype_mapping_reset_result {
17791 cmdline_fixed_string_t ptype;
17792 cmdline_fixed_string_t mapping;
17793 cmdline_fixed_string_t reset;
17797 /* Common CLI fields for ptype mapping reset*/
17798 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17799 TOKEN_STRING_INITIALIZER
17800 (struct cmd_ptype_mapping_reset_result,
17802 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17803 TOKEN_STRING_INITIALIZER
17804 (struct cmd_ptype_mapping_reset_result,
17805 mapping, "mapping");
17806 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17807 TOKEN_STRING_INITIALIZER
17808 (struct cmd_ptype_mapping_reset_result,
17810 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17811 TOKEN_NUM_INITIALIZER
17812 (struct cmd_ptype_mapping_reset_result,
17816 cmd_ptype_mapping_reset_parsed(
17817 void *parsed_result,
17818 __rte_unused struct cmdline *cl,
17819 __rte_unused void *data)
17821 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17822 int ret = -ENOTSUP;
17824 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17827 #ifdef RTE_LIBRTE_I40E_PMD
17828 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17835 printf("invalid port_id %d\n", res->port_id);
17838 printf("function not implemented\n");
17841 printf("programming error: (%s)\n", strerror(-ret));
17845 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17846 .f = cmd_ptype_mapping_reset_parsed,
17848 .help_str = "ptype mapping reset <port_id>",
17850 (void *)&cmd_ptype_mapping_reset_ptype,
17851 (void *)&cmd_ptype_mapping_reset_mapping,
17852 (void *)&cmd_ptype_mapping_reset_reset,
17853 (void *)&cmd_ptype_mapping_reset_port_id,
17858 /* ptype mapping update */
17860 /* Common result structure for ptype mapping update */
17861 struct cmd_ptype_mapping_update_result {
17862 cmdline_fixed_string_t ptype;
17863 cmdline_fixed_string_t mapping;
17864 cmdline_fixed_string_t reset;
17870 /* Common CLI fields for ptype mapping update*/
17871 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17872 TOKEN_STRING_INITIALIZER
17873 (struct cmd_ptype_mapping_update_result,
17875 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17876 TOKEN_STRING_INITIALIZER
17877 (struct cmd_ptype_mapping_update_result,
17878 mapping, "mapping");
17879 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17880 TOKEN_STRING_INITIALIZER
17881 (struct cmd_ptype_mapping_update_result,
17883 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17884 TOKEN_NUM_INITIALIZER
17885 (struct cmd_ptype_mapping_update_result,
17887 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17888 TOKEN_NUM_INITIALIZER
17889 (struct cmd_ptype_mapping_update_result,
17891 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17892 TOKEN_NUM_INITIALIZER
17893 (struct cmd_ptype_mapping_update_result,
17897 cmd_ptype_mapping_update_parsed(
17898 void *parsed_result,
17899 __rte_unused struct cmdline *cl,
17900 __rte_unused void *data)
17902 struct cmd_ptype_mapping_update_result *res = parsed_result;
17903 int ret = -ENOTSUP;
17904 #ifdef RTE_LIBRTE_I40E_PMD
17905 struct rte_pmd_i40e_ptype_mapping mapping;
17907 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17910 #ifdef RTE_LIBRTE_I40E_PMD
17911 mapping.hw_ptype = res->hw_ptype;
17912 mapping.sw_ptype = res->sw_ptype;
17913 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17923 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17926 printf("invalid port_id %d\n", res->port_id);
17929 printf("function not implemented\n");
17932 printf("programming error: (%s)\n", strerror(-ret));
17936 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17937 .f = cmd_ptype_mapping_update_parsed,
17939 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17941 (void *)&cmd_ptype_mapping_update_ptype,
17942 (void *)&cmd_ptype_mapping_update_mapping,
17943 (void *)&cmd_ptype_mapping_update_update,
17944 (void *)&cmd_ptype_mapping_update_port_id,
17945 (void *)&cmd_ptype_mapping_update_hw_ptype,
17946 (void *)&cmd_ptype_mapping_update_sw_ptype,
17951 /* Common result structure for file commands */
17952 struct cmd_cmdfile_result {
17953 cmdline_fixed_string_t load;
17954 cmdline_fixed_string_t filename;
17957 /* Common CLI fields for file commands */
17958 cmdline_parse_token_string_t cmd_load_cmdfile =
17959 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17960 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17961 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17964 cmd_load_from_file_parsed(
17965 void *parsed_result,
17966 __rte_unused struct cmdline *cl,
17967 __rte_unused void *data)
17969 struct cmd_cmdfile_result *res = parsed_result;
17971 cmdline_read_from_file(res->filename);
17974 cmdline_parse_inst_t cmd_load_from_file = {
17975 .f = cmd_load_from_file_parsed,
17977 .help_str = "load <filename>",
17979 (void *)&cmd_load_cmdfile,
17980 (void *)&cmd_load_cmdfile_filename,
17985 /* Get Rx offloads capabilities */
17986 struct cmd_rx_offload_get_capa_result {
17987 cmdline_fixed_string_t show;
17988 cmdline_fixed_string_t port;
17990 cmdline_fixed_string_t rx_offload;
17991 cmdline_fixed_string_t capabilities;
17994 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17995 TOKEN_STRING_INITIALIZER
17996 (struct cmd_rx_offload_get_capa_result,
17998 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17999 TOKEN_STRING_INITIALIZER
18000 (struct cmd_rx_offload_get_capa_result,
18002 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18003 TOKEN_NUM_INITIALIZER
18004 (struct cmd_rx_offload_get_capa_result,
18006 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18007 TOKEN_STRING_INITIALIZER
18008 (struct cmd_rx_offload_get_capa_result,
18009 rx_offload, "rx_offload");
18010 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18011 TOKEN_STRING_INITIALIZER
18012 (struct cmd_rx_offload_get_capa_result,
18013 capabilities, "capabilities");
18016 print_rx_offloads(uint64_t offloads)
18018 uint64_t single_offload;
18026 begin = __builtin_ctzll(offloads);
18027 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18029 single_offload = 1ULL << begin;
18030 for (bit = begin; bit < end; bit++) {
18031 if (offloads & single_offload)
18033 rte_eth_dev_rx_offload_name(single_offload));
18034 single_offload <<= 1;
18039 cmd_rx_offload_get_capa_parsed(
18040 void *parsed_result,
18041 __rte_unused struct cmdline *cl,
18042 __rte_unused void *data)
18044 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18045 struct rte_eth_dev_info dev_info;
18046 portid_t port_id = res->port_id;
18047 uint64_t queue_offloads;
18048 uint64_t port_offloads;
18051 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18055 queue_offloads = dev_info.rx_queue_offload_capa;
18056 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18058 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18059 printf(" Per Queue :");
18060 print_rx_offloads(queue_offloads);
18063 printf(" Per Port :");
18064 print_rx_offloads(port_offloads);
18068 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18069 .f = cmd_rx_offload_get_capa_parsed,
18071 .help_str = "show port <port_id> rx_offload capabilities",
18073 (void *)&cmd_rx_offload_get_capa_show,
18074 (void *)&cmd_rx_offload_get_capa_port,
18075 (void *)&cmd_rx_offload_get_capa_port_id,
18076 (void *)&cmd_rx_offload_get_capa_rx_offload,
18077 (void *)&cmd_rx_offload_get_capa_capabilities,
18082 /* Get Rx offloads configuration */
18083 struct cmd_rx_offload_get_configuration_result {
18084 cmdline_fixed_string_t show;
18085 cmdline_fixed_string_t port;
18087 cmdline_fixed_string_t rx_offload;
18088 cmdline_fixed_string_t configuration;
18091 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18092 TOKEN_STRING_INITIALIZER
18093 (struct cmd_rx_offload_get_configuration_result,
18095 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18096 TOKEN_STRING_INITIALIZER
18097 (struct cmd_rx_offload_get_configuration_result,
18099 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18100 TOKEN_NUM_INITIALIZER
18101 (struct cmd_rx_offload_get_configuration_result,
18103 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18104 TOKEN_STRING_INITIALIZER
18105 (struct cmd_rx_offload_get_configuration_result,
18106 rx_offload, "rx_offload");
18107 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18108 TOKEN_STRING_INITIALIZER
18109 (struct cmd_rx_offload_get_configuration_result,
18110 configuration, "configuration");
18113 cmd_rx_offload_get_configuration_parsed(
18114 void *parsed_result,
18115 __rte_unused struct cmdline *cl,
18116 __rte_unused void *data)
18118 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18119 struct rte_eth_dev_info dev_info;
18120 portid_t port_id = res->port_id;
18121 struct rte_port *port = &ports[port_id];
18122 uint64_t port_offloads;
18123 uint64_t queue_offloads;
18124 uint16_t nb_rx_queues;
18128 printf("Rx Offloading Configuration of port %d :\n", port_id);
18130 port_offloads = port->dev_conf.rxmode.offloads;
18132 print_rx_offloads(port_offloads);
18135 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18139 nb_rx_queues = dev_info.nb_rx_queues;
18140 for (q = 0; q < nb_rx_queues; q++) {
18141 queue_offloads = port->rx_conf[q].offloads;
18142 printf(" Queue[%2d] :", q);
18143 print_rx_offloads(queue_offloads);
18149 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18150 .f = cmd_rx_offload_get_configuration_parsed,
18152 .help_str = "show port <port_id> rx_offload configuration",
18154 (void *)&cmd_rx_offload_get_configuration_show,
18155 (void *)&cmd_rx_offload_get_configuration_port,
18156 (void *)&cmd_rx_offload_get_configuration_port_id,
18157 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18158 (void *)&cmd_rx_offload_get_configuration_configuration,
18163 /* Enable/Disable a per port offloading */
18164 struct cmd_config_per_port_rx_offload_result {
18165 cmdline_fixed_string_t port;
18166 cmdline_fixed_string_t config;
18168 cmdline_fixed_string_t rx_offload;
18169 cmdline_fixed_string_t offload;
18170 cmdline_fixed_string_t on_off;
18173 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18174 TOKEN_STRING_INITIALIZER
18175 (struct cmd_config_per_port_rx_offload_result,
18177 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18178 TOKEN_STRING_INITIALIZER
18179 (struct cmd_config_per_port_rx_offload_result,
18181 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18182 TOKEN_NUM_INITIALIZER
18183 (struct cmd_config_per_port_rx_offload_result,
18185 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18186 TOKEN_STRING_INITIALIZER
18187 (struct cmd_config_per_port_rx_offload_result,
18188 rx_offload, "rx_offload");
18189 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18190 TOKEN_STRING_INITIALIZER
18191 (struct cmd_config_per_port_rx_offload_result,
18192 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18193 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18194 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18195 "scatter#timestamp#security#keep_crc#rss_hash");
18196 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18197 TOKEN_STRING_INITIALIZER
18198 (struct cmd_config_per_port_rx_offload_result,
18202 search_rx_offload(const char *name)
18204 uint64_t single_offload;
18205 const char *single_name;
18209 single_offload = 1;
18210 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18211 single_name = rte_eth_dev_rx_offload_name(single_offload);
18212 if (!strcasecmp(single_name, name)) {
18216 single_offload <<= 1;
18220 return single_offload;
18226 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18227 __rte_unused struct cmdline *cl,
18228 __rte_unused void *data)
18230 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18231 portid_t port_id = res->port_id;
18232 struct rte_eth_dev_info dev_info;
18233 struct rte_port *port = &ports[port_id];
18234 uint64_t single_offload;
18235 uint16_t nb_rx_queues;
18239 if (port->port_status != RTE_PORT_STOPPED) {
18240 printf("Error: Can't config offload when Port %d "
18241 "is not stopped\n", port_id);
18245 single_offload = search_rx_offload(res->offload);
18246 if (single_offload == 0) {
18247 printf("Unknown offload name: %s\n", res->offload);
18251 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18255 nb_rx_queues = dev_info.nb_rx_queues;
18256 if (!strcmp(res->on_off, "on")) {
18257 port->dev_conf.rxmode.offloads |= single_offload;
18258 for (q = 0; q < nb_rx_queues; q++)
18259 port->rx_conf[q].offloads |= single_offload;
18261 port->dev_conf.rxmode.offloads &= ~single_offload;
18262 for (q = 0; q < nb_rx_queues; q++)
18263 port->rx_conf[q].offloads &= ~single_offload;
18266 cmd_reconfig_device_queue(port_id, 1, 1);
18269 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18270 .f = cmd_config_per_port_rx_offload_parsed,
18272 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18273 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18274 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18275 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18278 (void *)&cmd_config_per_port_rx_offload_result_port,
18279 (void *)&cmd_config_per_port_rx_offload_result_config,
18280 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18281 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18282 (void *)&cmd_config_per_port_rx_offload_result_offload,
18283 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18288 /* Enable/Disable a per queue offloading */
18289 struct cmd_config_per_queue_rx_offload_result {
18290 cmdline_fixed_string_t port;
18292 cmdline_fixed_string_t rxq;
18294 cmdline_fixed_string_t rx_offload;
18295 cmdline_fixed_string_t offload;
18296 cmdline_fixed_string_t on_off;
18299 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18300 TOKEN_STRING_INITIALIZER
18301 (struct cmd_config_per_queue_rx_offload_result,
18303 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18304 TOKEN_NUM_INITIALIZER
18305 (struct cmd_config_per_queue_rx_offload_result,
18307 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18308 TOKEN_STRING_INITIALIZER
18309 (struct cmd_config_per_queue_rx_offload_result,
18311 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18312 TOKEN_NUM_INITIALIZER
18313 (struct cmd_config_per_queue_rx_offload_result,
18315 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18316 TOKEN_STRING_INITIALIZER
18317 (struct cmd_config_per_queue_rx_offload_result,
18318 rx_offload, "rx_offload");
18319 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18320 TOKEN_STRING_INITIALIZER
18321 (struct cmd_config_per_queue_rx_offload_result,
18322 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18323 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18324 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18325 "scatter#timestamp#security#keep_crc");
18326 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18327 TOKEN_STRING_INITIALIZER
18328 (struct cmd_config_per_queue_rx_offload_result,
18332 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18333 __rte_unused struct cmdline *cl,
18334 __rte_unused void *data)
18336 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18337 struct rte_eth_dev_info dev_info;
18338 portid_t port_id = res->port_id;
18339 uint16_t queue_id = res->queue_id;
18340 struct rte_port *port = &ports[port_id];
18341 uint64_t single_offload;
18344 if (port->port_status != RTE_PORT_STOPPED) {
18345 printf("Error: Can't config offload when Port %d "
18346 "is not stopped\n", port_id);
18350 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18354 if (queue_id >= dev_info.nb_rx_queues) {
18355 printf("Error: input queue_id should be 0 ... "
18356 "%d\n", dev_info.nb_rx_queues - 1);
18360 single_offload = search_rx_offload(res->offload);
18361 if (single_offload == 0) {
18362 printf("Unknown offload name: %s\n", res->offload);
18366 if (!strcmp(res->on_off, "on"))
18367 port->rx_conf[queue_id].offloads |= single_offload;
18369 port->rx_conf[queue_id].offloads &= ~single_offload;
18371 cmd_reconfig_device_queue(port_id, 1, 1);
18374 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18375 .f = cmd_config_per_queue_rx_offload_parsed,
18377 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18378 "vlan_strip|ipv4_cksum|"
18379 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18380 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18381 "jumbo_frame|scatter|timestamp|security|keep_crc "
18384 (void *)&cmd_config_per_queue_rx_offload_result_port,
18385 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18386 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18387 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18388 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18389 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18390 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18395 /* Get Tx offloads capabilities */
18396 struct cmd_tx_offload_get_capa_result {
18397 cmdline_fixed_string_t show;
18398 cmdline_fixed_string_t port;
18400 cmdline_fixed_string_t tx_offload;
18401 cmdline_fixed_string_t capabilities;
18404 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18405 TOKEN_STRING_INITIALIZER
18406 (struct cmd_tx_offload_get_capa_result,
18408 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18409 TOKEN_STRING_INITIALIZER
18410 (struct cmd_tx_offload_get_capa_result,
18412 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18413 TOKEN_NUM_INITIALIZER
18414 (struct cmd_tx_offload_get_capa_result,
18416 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18417 TOKEN_STRING_INITIALIZER
18418 (struct cmd_tx_offload_get_capa_result,
18419 tx_offload, "tx_offload");
18420 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18421 TOKEN_STRING_INITIALIZER
18422 (struct cmd_tx_offload_get_capa_result,
18423 capabilities, "capabilities");
18426 print_tx_offloads(uint64_t offloads)
18428 uint64_t single_offload;
18436 begin = __builtin_ctzll(offloads);
18437 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18439 single_offload = 1ULL << begin;
18440 for (bit = begin; bit < end; bit++) {
18441 if (offloads & single_offload)
18443 rte_eth_dev_tx_offload_name(single_offload));
18444 single_offload <<= 1;
18449 cmd_tx_offload_get_capa_parsed(
18450 void *parsed_result,
18451 __rte_unused struct cmdline *cl,
18452 __rte_unused void *data)
18454 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18455 struct rte_eth_dev_info dev_info;
18456 portid_t port_id = res->port_id;
18457 uint64_t queue_offloads;
18458 uint64_t port_offloads;
18461 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18465 queue_offloads = dev_info.tx_queue_offload_capa;
18466 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18468 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18469 printf(" Per Queue :");
18470 print_tx_offloads(queue_offloads);
18473 printf(" Per Port :");
18474 print_tx_offloads(port_offloads);
18478 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18479 .f = cmd_tx_offload_get_capa_parsed,
18481 .help_str = "show port <port_id> tx_offload capabilities",
18483 (void *)&cmd_tx_offload_get_capa_show,
18484 (void *)&cmd_tx_offload_get_capa_port,
18485 (void *)&cmd_tx_offload_get_capa_port_id,
18486 (void *)&cmd_tx_offload_get_capa_tx_offload,
18487 (void *)&cmd_tx_offload_get_capa_capabilities,
18492 /* Get Tx offloads configuration */
18493 struct cmd_tx_offload_get_configuration_result {
18494 cmdline_fixed_string_t show;
18495 cmdline_fixed_string_t port;
18497 cmdline_fixed_string_t tx_offload;
18498 cmdline_fixed_string_t configuration;
18501 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18502 TOKEN_STRING_INITIALIZER
18503 (struct cmd_tx_offload_get_configuration_result,
18505 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18506 TOKEN_STRING_INITIALIZER
18507 (struct cmd_tx_offload_get_configuration_result,
18509 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18510 TOKEN_NUM_INITIALIZER
18511 (struct cmd_tx_offload_get_configuration_result,
18513 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18514 TOKEN_STRING_INITIALIZER
18515 (struct cmd_tx_offload_get_configuration_result,
18516 tx_offload, "tx_offload");
18517 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18518 TOKEN_STRING_INITIALIZER
18519 (struct cmd_tx_offload_get_configuration_result,
18520 configuration, "configuration");
18523 cmd_tx_offload_get_configuration_parsed(
18524 void *parsed_result,
18525 __rte_unused struct cmdline *cl,
18526 __rte_unused void *data)
18528 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18529 struct rte_eth_dev_info dev_info;
18530 portid_t port_id = res->port_id;
18531 struct rte_port *port = &ports[port_id];
18532 uint64_t port_offloads;
18533 uint64_t queue_offloads;
18534 uint16_t nb_tx_queues;
18538 printf("Tx Offloading Configuration of port %d :\n", port_id);
18540 port_offloads = port->dev_conf.txmode.offloads;
18542 print_tx_offloads(port_offloads);
18545 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18549 nb_tx_queues = dev_info.nb_tx_queues;
18550 for (q = 0; q < nb_tx_queues; q++) {
18551 queue_offloads = port->tx_conf[q].offloads;
18552 printf(" Queue[%2d] :", q);
18553 print_tx_offloads(queue_offloads);
18559 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18560 .f = cmd_tx_offload_get_configuration_parsed,
18562 .help_str = "show port <port_id> tx_offload configuration",
18564 (void *)&cmd_tx_offload_get_configuration_show,
18565 (void *)&cmd_tx_offload_get_configuration_port,
18566 (void *)&cmd_tx_offload_get_configuration_port_id,
18567 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18568 (void *)&cmd_tx_offload_get_configuration_configuration,
18573 /* Enable/Disable a per port offloading */
18574 struct cmd_config_per_port_tx_offload_result {
18575 cmdline_fixed_string_t port;
18576 cmdline_fixed_string_t config;
18578 cmdline_fixed_string_t tx_offload;
18579 cmdline_fixed_string_t offload;
18580 cmdline_fixed_string_t on_off;
18583 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18584 TOKEN_STRING_INITIALIZER
18585 (struct cmd_config_per_port_tx_offload_result,
18587 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18588 TOKEN_STRING_INITIALIZER
18589 (struct cmd_config_per_port_tx_offload_result,
18591 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18592 TOKEN_NUM_INITIALIZER
18593 (struct cmd_config_per_port_tx_offload_result,
18595 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18596 TOKEN_STRING_INITIALIZER
18597 (struct cmd_config_per_port_tx_offload_result,
18598 tx_offload, "tx_offload");
18599 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18600 TOKEN_STRING_INITIALIZER
18601 (struct cmd_config_per_port_tx_offload_result,
18602 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18603 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18604 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18605 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18606 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18607 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18608 TOKEN_STRING_INITIALIZER
18609 (struct cmd_config_per_port_tx_offload_result,
18613 search_tx_offload(const char *name)
18615 uint64_t single_offload;
18616 const char *single_name;
18620 single_offload = 1;
18621 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18622 single_name = rte_eth_dev_tx_offload_name(single_offload);
18623 if (single_name == NULL)
18625 if (!strcasecmp(single_name, name)) {
18628 } else if (!strcasecmp(single_name, "UNKNOWN"))
18630 single_offload <<= 1;
18634 return single_offload;
18640 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18641 __rte_unused struct cmdline *cl,
18642 __rte_unused void *data)
18644 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18645 portid_t port_id = res->port_id;
18646 struct rte_eth_dev_info dev_info;
18647 struct rte_port *port = &ports[port_id];
18648 uint64_t single_offload;
18649 uint16_t nb_tx_queues;
18653 if (port->port_status != RTE_PORT_STOPPED) {
18654 printf("Error: Can't config offload when Port %d "
18655 "is not stopped\n", port_id);
18659 single_offload = search_tx_offload(res->offload);
18660 if (single_offload == 0) {
18661 printf("Unknown offload name: %s\n", res->offload);
18665 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18669 nb_tx_queues = dev_info.nb_tx_queues;
18670 if (!strcmp(res->on_off, "on")) {
18671 port->dev_conf.txmode.offloads |= single_offload;
18672 for (q = 0; q < nb_tx_queues; q++)
18673 port->tx_conf[q].offloads |= single_offload;
18675 port->dev_conf.txmode.offloads &= ~single_offload;
18676 for (q = 0; q < nb_tx_queues; q++)
18677 port->tx_conf[q].offloads &= ~single_offload;
18680 cmd_reconfig_device_queue(port_id, 1, 1);
18683 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18684 .f = cmd_config_per_port_tx_offload_parsed,
18686 .help_str = "port config <port_id> tx_offload "
18687 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18688 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18689 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18690 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18691 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18693 (void *)&cmd_config_per_port_tx_offload_result_port,
18694 (void *)&cmd_config_per_port_tx_offload_result_config,
18695 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18696 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18697 (void *)&cmd_config_per_port_tx_offload_result_offload,
18698 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18703 /* Enable/Disable a per queue offloading */
18704 struct cmd_config_per_queue_tx_offload_result {
18705 cmdline_fixed_string_t port;
18707 cmdline_fixed_string_t txq;
18709 cmdline_fixed_string_t tx_offload;
18710 cmdline_fixed_string_t offload;
18711 cmdline_fixed_string_t on_off;
18714 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18715 TOKEN_STRING_INITIALIZER
18716 (struct cmd_config_per_queue_tx_offload_result,
18718 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18719 TOKEN_NUM_INITIALIZER
18720 (struct cmd_config_per_queue_tx_offload_result,
18722 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18723 TOKEN_STRING_INITIALIZER
18724 (struct cmd_config_per_queue_tx_offload_result,
18726 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18727 TOKEN_NUM_INITIALIZER
18728 (struct cmd_config_per_queue_tx_offload_result,
18730 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18731 TOKEN_STRING_INITIALIZER
18732 (struct cmd_config_per_queue_tx_offload_result,
18733 tx_offload, "tx_offload");
18734 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18735 TOKEN_STRING_INITIALIZER
18736 (struct cmd_config_per_queue_tx_offload_result,
18737 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18738 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18739 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18740 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18741 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18742 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18743 TOKEN_STRING_INITIALIZER
18744 (struct cmd_config_per_queue_tx_offload_result,
18748 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18749 __rte_unused struct cmdline *cl,
18750 __rte_unused void *data)
18752 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18753 struct rte_eth_dev_info dev_info;
18754 portid_t port_id = res->port_id;
18755 uint16_t queue_id = res->queue_id;
18756 struct rte_port *port = &ports[port_id];
18757 uint64_t single_offload;
18760 if (port->port_status != RTE_PORT_STOPPED) {
18761 printf("Error: Can't config offload when Port %d "
18762 "is not stopped\n", port_id);
18766 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18770 if (queue_id >= dev_info.nb_tx_queues) {
18771 printf("Error: input queue_id should be 0 ... "
18772 "%d\n", dev_info.nb_tx_queues - 1);
18776 single_offload = search_tx_offload(res->offload);
18777 if (single_offload == 0) {
18778 printf("Unknown offload name: %s\n", res->offload);
18782 if (!strcmp(res->on_off, "on"))
18783 port->tx_conf[queue_id].offloads |= single_offload;
18785 port->tx_conf[queue_id].offloads &= ~single_offload;
18787 cmd_reconfig_device_queue(port_id, 1, 1);
18790 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18791 .f = cmd_config_per_queue_tx_offload_parsed,
18793 .help_str = "port <port_id> txq <queue_id> tx_offload "
18794 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18795 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18796 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18797 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18798 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18801 (void *)&cmd_config_per_queue_tx_offload_result_port,
18802 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18803 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18804 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18805 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18806 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18807 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18812 /* *** configure tx_metadata for specific port *** */
18813 struct cmd_config_tx_metadata_specific_result {
18814 cmdline_fixed_string_t port;
18815 cmdline_fixed_string_t keyword;
18817 cmdline_fixed_string_t item;
18822 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18823 __rte_unused struct cmdline *cl,
18824 __rte_unused void *data)
18826 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18828 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18830 ports[res->port_id].tx_metadata = res->value;
18831 /* Add/remove callback to insert valid metadata in every Tx packet. */
18832 if (ports[res->port_id].tx_metadata)
18833 add_tx_md_callback(res->port_id);
18835 remove_tx_md_callback(res->port_id);
18836 rte_flow_dynf_metadata_register();
18839 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18840 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18842 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18843 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18844 keyword, "config");
18845 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18846 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18848 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18849 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18850 item, "tx_metadata");
18851 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18852 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18855 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18856 .f = cmd_config_tx_metadata_specific_parsed,
18858 .help_str = "port config <port_id> tx_metadata <value>",
18860 (void *)&cmd_config_tx_metadata_specific_port,
18861 (void *)&cmd_config_tx_metadata_specific_keyword,
18862 (void *)&cmd_config_tx_metadata_specific_id,
18863 (void *)&cmd_config_tx_metadata_specific_item,
18864 (void *)&cmd_config_tx_metadata_specific_value,
18869 /* *** set dynf *** */
18870 struct cmd_config_tx_dynf_specific_result {
18871 cmdline_fixed_string_t port;
18872 cmdline_fixed_string_t keyword;
18874 cmdline_fixed_string_t item;
18875 cmdline_fixed_string_t name;
18876 cmdline_fixed_string_t value;
18880 cmd_config_dynf_specific_parsed(void *parsed_result,
18881 __rte_unused struct cmdline *cl,
18882 __rte_unused void *data)
18884 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18885 struct rte_mbuf_dynflag desc_flag;
18887 uint64_t old_port_flags;
18889 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18891 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18893 if (strlcpy(desc_flag.name, res->name,
18894 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18895 printf("Flag name too long\n");
18898 desc_flag.flags = 0;
18899 flag = rte_mbuf_dynflag_register(&desc_flag);
18901 printf("Can't register flag\n");
18904 strcpy(dynf_names[flag], desc_flag.name);
18906 old_port_flags = ports[res->port_id].mbuf_dynf;
18907 if (!strcmp(res->value, "set")) {
18908 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18909 if (old_port_flags == 0)
18910 add_tx_dynf_callback(res->port_id);
18912 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18913 if (ports[res->port_id].mbuf_dynf == 0)
18914 remove_tx_dynf_callback(res->port_id);
18918 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18919 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18921 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18922 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18923 keyword, "config");
18924 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18925 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18927 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18928 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18930 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18931 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18933 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18934 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18935 value, "set#clear");
18937 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18938 .f = cmd_config_dynf_specific_parsed,
18940 .help_str = "port config <port id> dynf <name> set|clear",
18942 (void *)&cmd_config_tx_dynf_specific_port,
18943 (void *)&cmd_config_tx_dynf_specific_keyword,
18944 (void *)&cmd_config_tx_dynf_specific_port_id,
18945 (void *)&cmd_config_tx_dynf_specific_item,
18946 (void *)&cmd_config_tx_dynf_specific_name,
18947 (void *)&cmd_config_tx_dynf_specific_value,
18952 /* *** display tx_metadata per port configuration *** */
18953 struct cmd_show_tx_metadata_result {
18954 cmdline_fixed_string_t cmd_show;
18955 cmdline_fixed_string_t cmd_port;
18956 cmdline_fixed_string_t cmd_keyword;
18961 cmd_show_tx_metadata_parsed(void *parsed_result,
18962 __rte_unused struct cmdline *cl,
18963 __rte_unused void *data)
18965 struct cmd_show_tx_metadata_result *res = parsed_result;
18967 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18968 printf("invalid port id %u\n", res->cmd_pid);
18971 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18972 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18973 ports[res->cmd_pid].tx_metadata);
18977 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18978 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18980 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18981 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18983 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18984 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18986 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18987 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18988 cmd_keyword, "tx_metadata");
18990 cmdline_parse_inst_t cmd_show_tx_metadata = {
18991 .f = cmd_show_tx_metadata_parsed,
18993 .help_str = "show port <port_id> tx_metadata",
18995 (void *)&cmd_show_tx_metadata_show,
18996 (void *)&cmd_show_tx_metadata_port,
18997 (void *)&cmd_show_tx_metadata_pid,
18998 (void *)&cmd_show_tx_metadata_keyword,
19003 /* show port supported ptypes */
19005 /* Common result structure for show port ptypes */
19006 struct cmd_show_port_supported_ptypes_result {
19007 cmdline_fixed_string_t show;
19008 cmdline_fixed_string_t port;
19010 cmdline_fixed_string_t ptypes;
19013 /* Common CLI fields for show port ptypes */
19014 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19015 TOKEN_STRING_INITIALIZER
19016 (struct cmd_show_port_supported_ptypes_result,
19018 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19019 TOKEN_STRING_INITIALIZER
19020 (struct cmd_show_port_supported_ptypes_result,
19022 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19023 TOKEN_NUM_INITIALIZER
19024 (struct cmd_show_port_supported_ptypes_result,
19026 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19027 TOKEN_STRING_INITIALIZER
19028 (struct cmd_show_port_supported_ptypes_result,
19032 cmd_show_port_supported_ptypes_parsed(
19033 void *parsed_result,
19034 __rte_unused struct cmdline *cl,
19035 __rte_unused void *data)
19037 #define RSVD_PTYPE_MASK 0xf0000000
19038 #define MAX_PTYPES_PER_LAYER 16
19039 #define LTYPE_NAMESIZE 32
19040 #define PTYPE_NAMESIZE 256
19041 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19042 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19043 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19044 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19045 uint16_t port_id = res->port_id;
19048 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19052 while (ptype_mask != RSVD_PTYPE_MASK) {
19054 switch (ptype_mask) {
19055 case RTE_PTYPE_L2_MASK:
19056 strlcpy(ltype, "L2", sizeof(ltype));
19058 case RTE_PTYPE_L3_MASK:
19059 strlcpy(ltype, "L3", sizeof(ltype));
19061 case RTE_PTYPE_L4_MASK:
19062 strlcpy(ltype, "L4", sizeof(ltype));
19064 case RTE_PTYPE_TUNNEL_MASK:
19065 strlcpy(ltype, "Tunnel", sizeof(ltype));
19067 case RTE_PTYPE_INNER_L2_MASK:
19068 strlcpy(ltype, "Inner L2", sizeof(ltype));
19070 case RTE_PTYPE_INNER_L3_MASK:
19071 strlcpy(ltype, "Inner L3", sizeof(ltype));
19073 case RTE_PTYPE_INNER_L4_MASK:
19074 strlcpy(ltype, "Inner L4", sizeof(ltype));
19080 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19081 ptype_mask, ptypes,
19082 MAX_PTYPES_PER_LAYER);
19085 printf("Supported %s ptypes:\n", ltype);
19087 printf("%s ptypes unsupported\n", ltype);
19089 for (i = 0; i < ret; ++i) {
19090 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19091 printf("%s\n", buf);
19098 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19099 .f = cmd_show_port_supported_ptypes_parsed,
19101 .help_str = "show port <port_id> ptypes",
19103 (void *)&cmd_show_port_supported_ptypes_show,
19104 (void *)&cmd_show_port_supported_ptypes_port,
19105 (void *)&cmd_show_port_supported_ptypes_port_id,
19106 (void *)&cmd_show_port_supported_ptypes_ptypes,
19111 /* *** display rx/tx descriptor status *** */
19112 struct cmd_show_rx_tx_desc_status_result {
19113 cmdline_fixed_string_t cmd_show;
19114 cmdline_fixed_string_t cmd_port;
19115 cmdline_fixed_string_t cmd_keyword;
19116 cmdline_fixed_string_t cmd_desc;
19117 cmdline_fixed_string_t cmd_status;
19124 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19125 __rte_unused struct cmdline *cl,
19126 __rte_unused void *data)
19128 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19131 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19132 printf("invalid port id %u\n", res->cmd_pid);
19136 if (!strcmp(res->cmd_keyword, "rxq")) {
19137 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19140 printf("Invalid queueid = %d\n", res->cmd_qid);
19143 if (rc == RTE_ETH_RX_DESC_AVAIL)
19144 printf("Desc status = AVAILABLE\n");
19145 else if (rc == RTE_ETH_RX_DESC_DONE)
19146 printf("Desc status = DONE\n");
19148 printf("Desc status = UNAVAILABLE\n");
19149 } else if (!strcmp(res->cmd_keyword, "txq")) {
19150 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19153 printf("Invalid queueid = %d\n", res->cmd_qid);
19156 if (rc == RTE_ETH_TX_DESC_FULL)
19157 printf("Desc status = FULL\n");
19158 else if (rc == RTE_ETH_TX_DESC_DONE)
19159 printf("Desc status = DONE\n");
19161 printf("Desc status = UNAVAILABLE\n");
19165 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19166 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19168 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19169 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19171 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19172 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19174 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19175 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19176 cmd_keyword, "rxq#txq");
19177 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19178 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19180 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19181 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19183 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19184 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19186 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19187 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19188 cmd_status, "status");
19189 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19190 .f = cmd_show_rx_tx_desc_status_parsed,
19192 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19195 (void *)&cmd_show_rx_tx_desc_status_show,
19196 (void *)&cmd_show_rx_tx_desc_status_port,
19197 (void *)&cmd_show_rx_tx_desc_status_pid,
19198 (void *)&cmd_show_rx_tx_desc_status_keyword,
19199 (void *)&cmd_show_rx_tx_desc_status_qid,
19200 (void *)&cmd_show_rx_tx_desc_status_desc,
19201 (void *)&cmd_show_rx_tx_desc_status_did,
19202 (void *)&cmd_show_rx_tx_desc_status_status,
19207 /* Common result structure for set port ptypes */
19208 struct cmd_set_port_ptypes_result {
19209 cmdline_fixed_string_t set;
19210 cmdline_fixed_string_t port;
19212 cmdline_fixed_string_t ptype_mask;
19216 /* Common CLI fields for set port ptypes */
19217 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19218 TOKEN_STRING_INITIALIZER
19219 (struct cmd_set_port_ptypes_result,
19221 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19222 TOKEN_STRING_INITIALIZER
19223 (struct cmd_set_port_ptypes_result,
19225 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19226 TOKEN_NUM_INITIALIZER
19227 (struct cmd_set_port_ptypes_result,
19229 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19230 TOKEN_STRING_INITIALIZER
19231 (struct cmd_set_port_ptypes_result,
19232 ptype_mask, "ptype_mask");
19233 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19234 TOKEN_NUM_INITIALIZER
19235 (struct cmd_set_port_ptypes_result,
19239 cmd_set_port_ptypes_parsed(
19240 void *parsed_result,
19241 __rte_unused struct cmdline *cl,
19242 __rte_unused void *data)
19244 struct cmd_set_port_ptypes_result *res = parsed_result;
19245 #define PTYPE_NAMESIZE 256
19246 char ptype_name[PTYPE_NAMESIZE];
19247 uint16_t port_id = res->port_id;
19248 uint32_t ptype_mask = res->mask;
19251 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19254 printf("Port %d doesn't support any ptypes.\n", port_id);
19258 uint32_t ptypes[ret];
19260 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19262 printf("Unable to set requested ptypes for Port %d\n", port_id);
19266 printf("Successfully set following ptypes for Port %d\n", port_id);
19267 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19268 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19269 printf("%s\n", ptype_name);
19272 clear_ptypes = false;
19275 cmdline_parse_inst_t cmd_set_port_ptypes = {
19276 .f = cmd_set_port_ptypes_parsed,
19278 .help_str = "set port <port_id> ptype_mask <mask>",
19280 (void *)&cmd_set_port_ptypes_set,
19281 (void *)&cmd_set_port_ptypes_port,
19282 (void *)&cmd_set_port_ptypes_port_id,
19283 (void *)&cmd_set_port_ptypes_mask_str,
19284 (void *)&cmd_set_port_ptypes_mask_u32,
19289 /* *** display mac addresses added to a port *** */
19290 struct cmd_showport_macs_result {
19291 cmdline_fixed_string_t cmd_show;
19292 cmdline_fixed_string_t cmd_port;
19293 cmdline_fixed_string_t cmd_keyword;
19298 cmd_showport_macs_parsed(void *parsed_result,
19299 __rte_unused struct cmdline *cl,
19300 __rte_unused void *data)
19302 struct cmd_showport_macs_result *res = parsed_result;
19304 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19307 if (!strcmp(res->cmd_keyword, "macs"))
19308 show_macs(res->cmd_pid);
19309 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19310 show_mcast_macs(res->cmd_pid);
19313 cmdline_parse_token_string_t cmd_showport_macs_show =
19314 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19316 cmdline_parse_token_string_t cmd_showport_macs_port =
19317 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19319 cmdline_parse_token_num_t cmd_showport_macs_pid =
19320 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19322 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19323 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19324 cmd_keyword, "macs#mcast_macs");
19326 cmdline_parse_inst_t cmd_showport_macs = {
19327 .f = cmd_showport_macs_parsed,
19329 .help_str = "show port <port_id> macs|mcast_macs",
19331 (void *)&cmd_showport_macs_show,
19332 (void *)&cmd_showport_macs_port,
19333 (void *)&cmd_showport_macs_pid,
19334 (void *)&cmd_showport_macs_keyword,
19339 /* ******************************************************************************** */
19341 /* list of instructions */
19342 cmdline_parse_ctx_t main_ctx[] = {
19343 (cmdline_parse_inst_t *)&cmd_help_brief,
19344 (cmdline_parse_inst_t *)&cmd_help_long,
19345 (cmdline_parse_inst_t *)&cmd_quit,
19346 (cmdline_parse_inst_t *)&cmd_load_from_file,
19347 (cmdline_parse_inst_t *)&cmd_showport,
19348 (cmdline_parse_inst_t *)&cmd_showqueue,
19349 (cmdline_parse_inst_t *)&cmd_showportall,
19350 (cmdline_parse_inst_t *)&cmd_showdevice,
19351 (cmdline_parse_inst_t *)&cmd_showcfg,
19352 (cmdline_parse_inst_t *)&cmd_showfwdall,
19353 (cmdline_parse_inst_t *)&cmd_start,
19354 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19355 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19356 (cmdline_parse_inst_t *)&cmd_set_link_up,
19357 (cmdline_parse_inst_t *)&cmd_set_link_down,
19358 (cmdline_parse_inst_t *)&cmd_reset,
19359 (cmdline_parse_inst_t *)&cmd_set_numbers,
19360 (cmdline_parse_inst_t *)&cmd_set_log,
19361 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19362 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19363 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19364 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19365 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19366 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19367 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19368 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19369 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19370 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19371 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19372 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19373 (cmdline_parse_inst_t *)&cmd_set_link_check,
19374 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19375 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19376 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19377 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19378 #ifdef RTE_LIBRTE_PMD_BOND
19379 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19380 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19381 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19382 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19383 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19384 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19385 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19386 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19387 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19388 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19389 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19391 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19392 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19393 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19394 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19395 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19396 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19397 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19398 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19399 (cmdline_parse_inst_t *)&cmd_csum_set,
19400 (cmdline_parse_inst_t *)&cmd_csum_show,
19401 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19402 (cmdline_parse_inst_t *)&cmd_tso_set,
19403 (cmdline_parse_inst_t *)&cmd_tso_show,
19404 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19405 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19406 (cmdline_parse_inst_t *)&cmd_gro_enable,
19407 (cmdline_parse_inst_t *)&cmd_gro_flush,
19408 (cmdline_parse_inst_t *)&cmd_gro_show,
19409 (cmdline_parse_inst_t *)&cmd_gso_enable,
19410 (cmdline_parse_inst_t *)&cmd_gso_size,
19411 (cmdline_parse_inst_t *)&cmd_gso_show,
19412 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19413 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19414 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19415 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19416 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19417 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19418 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19419 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19420 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19421 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19422 (cmdline_parse_inst_t *)&cmd_config_dcb,
19423 (cmdline_parse_inst_t *)&cmd_read_reg,
19424 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19425 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19426 (cmdline_parse_inst_t *)&cmd_write_reg,
19427 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19428 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19429 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19430 (cmdline_parse_inst_t *)&cmd_stop,
19431 (cmdline_parse_inst_t *)&cmd_mac_addr,
19432 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19433 (cmdline_parse_inst_t *)&cmd_set_qmap,
19434 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19435 (cmdline_parse_inst_t *)&cmd_operate_port,
19436 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19437 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19438 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19439 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19440 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19441 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19442 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19443 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19444 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19445 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19446 (cmdline_parse_inst_t *)&cmd_config_mtu,
19447 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19448 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19449 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19450 (cmdline_parse_inst_t *)&cmd_config_rss,
19451 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19452 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19453 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19454 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19455 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19456 (cmdline_parse_inst_t *)&cmd_showport_reta,
19457 (cmdline_parse_inst_t *)&cmd_showport_macs,
19458 (cmdline_parse_inst_t *)&cmd_config_burst,
19459 (cmdline_parse_inst_t *)&cmd_config_thresh,
19460 (cmdline_parse_inst_t *)&cmd_config_threshold,
19461 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19462 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19463 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19464 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19465 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19466 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19467 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19468 (cmdline_parse_inst_t *)&cmd_global_config,
19469 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19470 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19471 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19472 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19473 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19474 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19475 (cmdline_parse_inst_t *)&cmd_dump,
19476 (cmdline_parse_inst_t *)&cmd_dump_one,
19477 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19478 (cmdline_parse_inst_t *)&cmd_syn_filter,
19479 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19480 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19481 (cmdline_parse_inst_t *)&cmd_flex_filter,
19482 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19483 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19484 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19485 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19486 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19487 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19488 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19489 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19490 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19491 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19492 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19493 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19494 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19495 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19496 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19497 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19498 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19499 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19500 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19501 (cmdline_parse_inst_t *)&cmd_flow,
19502 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19503 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19504 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19505 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19506 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19507 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19508 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19509 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19510 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19511 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19512 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19513 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19514 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19515 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19516 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19517 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19518 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19519 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19520 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19521 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19522 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19523 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19524 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19525 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19526 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19527 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19528 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19529 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19530 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19531 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19532 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19533 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19534 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19535 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19536 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19537 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19538 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19539 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19540 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19541 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19542 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19543 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19544 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19545 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19546 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19547 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19548 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19549 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19550 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19551 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19552 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19553 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19554 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19555 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19556 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19557 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19558 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19559 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19560 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19561 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19562 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19563 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19564 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19565 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19566 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19567 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19568 (cmdline_parse_inst_t *)&cmd_ddp_add,
19569 (cmdline_parse_inst_t *)&cmd_ddp_del,
19570 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19571 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19572 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19573 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19574 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19575 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19576 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19577 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19578 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19579 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19580 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19581 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19583 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19584 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19585 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19586 (cmdline_parse_inst_t *)&cmd_queue_region,
19587 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19588 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19589 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19590 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19591 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19592 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19593 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19594 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19595 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19596 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19597 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19598 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19599 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19600 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19601 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19602 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19603 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19604 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19605 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19606 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19607 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19608 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19609 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19610 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19611 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19612 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19613 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19614 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19615 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19616 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19617 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19618 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19619 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19620 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19621 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19622 #ifdef RTE_LIBRTE_BPF
19623 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19624 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19626 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19627 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19628 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19629 (cmdline_parse_inst_t *)&cmd_set_raw,
19630 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19631 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19632 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19636 /* read cmdline commands from file */
19638 cmdline_read_from_file(const char *filename)
19640 struct cmdline *cl;
19642 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19644 printf("Failed to create file based cmdline context: %s\n",
19649 cmdline_interact(cl);
19654 printf("Read CLI commands from %s\n", filename);
19657 /* prompt function, called from main on MASTER lcore */
19661 /* initialize non-constant commands */
19662 cmd_set_fwd_mode_init();
19663 cmd_set_fwd_retry_mode_init();
19665 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19666 if (testpmd_cl == NULL)
19668 cmdline_interact(testpmd_cl);
19669 cmdline_stdin_exit(testpmd_cl);
19675 if (testpmd_cl != NULL)
19676 cmdline_quit(testpmd_cl);
19680 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19682 if (id == (portid_t)RTE_PORT_ALL) {
19685 RTE_ETH_FOREACH_DEV(pid) {
19686 /* check if need_reconfig has been set to 1 */
19687 if (ports[pid].need_reconfig == 0)
19688 ports[pid].need_reconfig = dev;
19689 /* check if need_reconfig_queues has been set to 1 */
19690 if (ports[pid].need_reconfig_queues == 0)
19691 ports[pid].need_reconfig_queues = queue;
19693 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19694 /* check if need_reconfig has been set to 1 */
19695 if (ports[id].need_reconfig == 0)
19696 ports[id].need_reconfig = dev;
19697 /* check if need_reconfig_queues has been set to 1 */
19698 if (ports[id].need_reconfig_queues == 0)
19699 ports[id].need_reconfig_queues = queue;