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 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1190 "set port tm hierarchy default (port_id)\n"
1191 " Set default traffic Management hierarchy on a port\n\n"
1194 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1195 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1196 " (packet_length_adjust)\n"
1197 " Add port tm node private shaper profile.\n\n"
1199 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1200 " Delete port tm node private shaper profile.\n\n"
1202 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1203 " (shaper_profile_id)\n"
1204 " Add/update port tm node shared shaper.\n\n"
1206 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1207 " Delete port tm node shared shaper.\n\n"
1209 "set port tm node shaper profile (port_id) (node_id)"
1210 " (shaper_profile_id)\n"
1211 " Set port tm node shaper profile.\n\n"
1213 "add port tm node wred profile (port_id) (wred_profile_id)"
1214 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1215 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1216 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1217 " Add port tm node wred profile.\n\n"
1219 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1220 " Delete port tm node wred profile.\n\n"
1222 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1223 " (priority) (weight) (level_id) (shaper_profile_id)"
1224 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1225 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1226 " Add port tm nonleaf node.\n\n"
1228 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1229 " (priority) (weight) (level_id) (shaper_profile_id)"
1230 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1231 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1232 " Add port tm leaf node.\n\n"
1234 "del port tm node (port_id) (node_id)\n"
1235 " Delete port tm node.\n\n"
1237 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1238 " (priority) (weight)\n"
1239 " Set port tm node parent.\n\n"
1241 "suspend port tm node (port_id) (node_id)"
1242 " Suspend tm node.\n\n"
1244 "resume port tm node (port_id) (node_id)"
1245 " Resume tm node.\n\n"
1247 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1248 " Commit tm hierarchy.\n\n"
1250 "set port tm mark ip_ecn (port) (green) (yellow)"
1252 " Enables/Disables the traffic management marking"
1253 " for IP ECN (Explicit Congestion Notification)"
1254 " packets on a given port\n\n"
1256 "set port tm mark ip_dscp (port) (green) (yellow)"
1258 " Enables/Disables the traffic management marking"
1259 " on the port for IP dscp packets\n\n"
1261 "set port tm mark vlan_dei (port) (green) (yellow)"
1263 " Enables/Disables the traffic management marking"
1264 " on the port for VLAN packets with DEI enabled\n\n"
1268 if (show_all || !strcmp(res->section, "devices")) {
1272 "Device Operations:\n"
1274 "device detach (identifier)\n"
1275 " Detach device by identifier.\n\n"
1281 cmdline_parse_token_string_t cmd_help_long_help =
1282 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1284 cmdline_parse_token_string_t cmd_help_long_section =
1285 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1286 "all#control#display#config#"
1287 "ports#registers#filters#traffic_management#devices");
1289 cmdline_parse_inst_t cmd_help_long = {
1290 .f = cmd_help_long_parsed,
1292 .help_str = "help all|control|display|config|ports|register|"
1293 "filters|traffic_management|devices: "
1296 (void *)&cmd_help_long_help,
1297 (void *)&cmd_help_long_section,
1303 /* *** start/stop/close all ports *** */
1304 struct cmd_operate_port_result {
1305 cmdline_fixed_string_t keyword;
1306 cmdline_fixed_string_t name;
1307 cmdline_fixed_string_t value;
1310 static void cmd_operate_port_parsed(void *parsed_result,
1311 __rte_unused struct cmdline *cl,
1312 __rte_unused void *data)
1314 struct cmd_operate_port_result *res = parsed_result;
1316 if (!strcmp(res->name, "start"))
1317 start_port(RTE_PORT_ALL);
1318 else if (!strcmp(res->name, "stop"))
1319 stop_port(RTE_PORT_ALL);
1320 else if (!strcmp(res->name, "close"))
1321 close_port(RTE_PORT_ALL);
1322 else if (!strcmp(res->name, "reset"))
1323 reset_port(RTE_PORT_ALL);
1325 printf("Unknown parameter\n");
1328 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1329 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1331 cmdline_parse_token_string_t cmd_operate_port_all_port =
1332 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1333 "start#stop#close#reset");
1334 cmdline_parse_token_string_t cmd_operate_port_all_all =
1335 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1337 cmdline_parse_inst_t cmd_operate_port = {
1338 .f = cmd_operate_port_parsed,
1340 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1342 (void *)&cmd_operate_port_all_cmd,
1343 (void *)&cmd_operate_port_all_port,
1344 (void *)&cmd_operate_port_all_all,
1349 /* *** start/stop/close specific port *** */
1350 struct cmd_operate_specific_port_result {
1351 cmdline_fixed_string_t keyword;
1352 cmdline_fixed_string_t name;
1356 static void cmd_operate_specific_port_parsed(void *parsed_result,
1357 __rte_unused struct cmdline *cl,
1358 __rte_unused void *data)
1360 struct cmd_operate_specific_port_result *res = parsed_result;
1362 if (!strcmp(res->name, "start"))
1363 start_port(res->value);
1364 else if (!strcmp(res->name, "stop"))
1365 stop_port(res->value);
1366 else if (!strcmp(res->name, "close"))
1367 close_port(res->value);
1368 else if (!strcmp(res->name, "reset"))
1369 reset_port(res->value);
1371 printf("Unknown parameter\n");
1374 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1375 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1377 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1378 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1379 name, "start#stop#close#reset");
1380 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1381 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1384 cmdline_parse_inst_t cmd_operate_specific_port = {
1385 .f = cmd_operate_specific_port_parsed,
1387 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1389 (void *)&cmd_operate_specific_port_cmd,
1390 (void *)&cmd_operate_specific_port_port,
1391 (void *)&cmd_operate_specific_port_id,
1396 /* *** enable port setup (after attach) via iterator or event *** */
1397 struct cmd_set_port_setup_on_result {
1398 cmdline_fixed_string_t set;
1399 cmdline_fixed_string_t port;
1400 cmdline_fixed_string_t setup;
1401 cmdline_fixed_string_t on;
1402 cmdline_fixed_string_t mode;
1405 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1406 __rte_unused struct cmdline *cl,
1407 __rte_unused void *data)
1409 struct cmd_set_port_setup_on_result *res = parsed_result;
1411 if (strcmp(res->mode, "event") == 0)
1412 setup_on_probe_event = true;
1413 else if (strcmp(res->mode, "iterator") == 0)
1414 setup_on_probe_event = false;
1416 printf("Unknown mode\n");
1419 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1420 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1422 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1423 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1425 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1426 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1428 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1429 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1431 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1432 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1433 mode, "iterator#event");
1435 cmdline_parse_inst_t cmd_set_port_setup_on = {
1436 .f = cmd_set_port_setup_on_parsed,
1438 .help_str = "set port setup on iterator|event",
1440 (void *)&cmd_set_port_setup_on_set,
1441 (void *)&cmd_set_port_setup_on_port,
1442 (void *)&cmd_set_port_setup_on_setup,
1443 (void *)&cmd_set_port_setup_on_on,
1444 (void *)&cmd_set_port_setup_on_mode,
1449 /* *** attach a specified port *** */
1450 struct cmd_operate_attach_port_result {
1451 cmdline_fixed_string_t port;
1452 cmdline_fixed_string_t keyword;
1453 cmdline_multi_string_t identifier;
1456 static void cmd_operate_attach_port_parsed(void *parsed_result,
1457 __rte_unused struct cmdline *cl,
1458 __rte_unused void *data)
1460 struct cmd_operate_attach_port_result *res = parsed_result;
1462 if (!strcmp(res->keyword, "attach"))
1463 attach_port(res->identifier);
1465 printf("Unknown parameter\n");
1468 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1469 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1471 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1472 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1474 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1475 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1476 identifier, TOKEN_STRING_MULTI);
1478 cmdline_parse_inst_t cmd_operate_attach_port = {
1479 .f = cmd_operate_attach_port_parsed,
1481 .help_str = "port attach <identifier>: "
1482 "(identifier: pci address or virtual dev name)",
1484 (void *)&cmd_operate_attach_port_port,
1485 (void *)&cmd_operate_attach_port_keyword,
1486 (void *)&cmd_operate_attach_port_identifier,
1491 /* *** detach a specified port *** */
1492 struct cmd_operate_detach_port_result {
1493 cmdline_fixed_string_t port;
1494 cmdline_fixed_string_t keyword;
1498 static void cmd_operate_detach_port_parsed(void *parsed_result,
1499 __rte_unused struct cmdline *cl,
1500 __rte_unused void *data)
1502 struct cmd_operate_detach_port_result *res = parsed_result;
1504 if (!strcmp(res->keyword, "detach")) {
1505 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1506 detach_port_device(res->port_id);
1508 printf("Unknown parameter\n");
1512 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1513 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1515 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1516 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1518 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1519 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1522 cmdline_parse_inst_t cmd_operate_detach_port = {
1523 .f = cmd_operate_detach_port_parsed,
1525 .help_str = "port detach <port_id>",
1527 (void *)&cmd_operate_detach_port_port,
1528 (void *)&cmd_operate_detach_port_keyword,
1529 (void *)&cmd_operate_detach_port_port_id,
1534 /* *** detach device by identifier *** */
1535 struct cmd_operate_detach_device_result {
1536 cmdline_fixed_string_t device;
1537 cmdline_fixed_string_t keyword;
1538 cmdline_fixed_string_t identifier;
1541 static void cmd_operate_detach_device_parsed(void *parsed_result,
1542 __rte_unused struct cmdline *cl,
1543 __rte_unused void *data)
1545 struct cmd_operate_detach_device_result *res = parsed_result;
1547 if (!strcmp(res->keyword, "detach"))
1548 detach_devargs(res->identifier);
1550 printf("Unknown parameter\n");
1553 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1554 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1556 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1557 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1559 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1560 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1563 cmdline_parse_inst_t cmd_operate_detach_device = {
1564 .f = cmd_operate_detach_device_parsed,
1566 .help_str = "device detach <identifier>:"
1567 "(identifier: pci address or virtual dev name)",
1569 (void *)&cmd_operate_detach_device_device,
1570 (void *)&cmd_operate_detach_device_keyword,
1571 (void *)&cmd_operate_detach_device_identifier,
1575 /* *** configure speed for all ports *** */
1576 struct cmd_config_speed_all {
1577 cmdline_fixed_string_t port;
1578 cmdline_fixed_string_t keyword;
1579 cmdline_fixed_string_t all;
1580 cmdline_fixed_string_t item1;
1581 cmdline_fixed_string_t item2;
1582 cmdline_fixed_string_t value1;
1583 cmdline_fixed_string_t value2;
1587 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1592 if (!strcmp(duplexstr, "half")) {
1593 duplex = ETH_LINK_HALF_DUPLEX;
1594 } else if (!strcmp(duplexstr, "full")) {
1595 duplex = ETH_LINK_FULL_DUPLEX;
1596 } else if (!strcmp(duplexstr, "auto")) {
1597 duplex = ETH_LINK_FULL_DUPLEX;
1599 printf("Unknown duplex parameter\n");
1603 if (!strcmp(speedstr, "10")) {
1604 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1605 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1606 } else if (!strcmp(speedstr, "100")) {
1607 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1608 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1610 if (duplex != ETH_LINK_FULL_DUPLEX) {
1611 printf("Invalid speed/duplex parameters\n");
1614 if (!strcmp(speedstr, "1000")) {
1615 *speed = ETH_LINK_SPEED_1G;
1616 } else if (!strcmp(speedstr, "10000")) {
1617 *speed = ETH_LINK_SPEED_10G;
1618 } else if (!strcmp(speedstr, "25000")) {
1619 *speed = ETH_LINK_SPEED_25G;
1620 } else if (!strcmp(speedstr, "40000")) {
1621 *speed = ETH_LINK_SPEED_40G;
1622 } else if (!strcmp(speedstr, "50000")) {
1623 *speed = ETH_LINK_SPEED_50G;
1624 } else if (!strcmp(speedstr, "100000")) {
1625 *speed = ETH_LINK_SPEED_100G;
1626 } else if (!strcmp(speedstr, "200000")) {
1627 *speed = ETH_LINK_SPEED_200G;
1628 } else if (!strcmp(speedstr, "auto")) {
1629 *speed = ETH_LINK_SPEED_AUTONEG;
1631 printf("Unknown speed parameter\n");
1640 cmd_config_speed_all_parsed(void *parsed_result,
1641 __rte_unused struct cmdline *cl,
1642 __rte_unused void *data)
1644 struct cmd_config_speed_all *res = parsed_result;
1645 uint32_t link_speed;
1648 if (!all_ports_stopped()) {
1649 printf("Please stop all ports first\n");
1653 if (parse_and_check_speed_duplex(res->value1, res->value2,
1657 RTE_ETH_FOREACH_DEV(pid) {
1658 ports[pid].dev_conf.link_speeds = link_speed;
1661 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1664 cmdline_parse_token_string_t cmd_config_speed_all_port =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1666 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1667 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1669 cmdline_parse_token_string_t cmd_config_speed_all_all =
1670 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1671 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1673 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1675 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1676 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1678 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1682 cmdline_parse_inst_t cmd_config_speed_all = {
1683 .f = cmd_config_speed_all_parsed,
1685 .help_str = "port config all speed "
1686 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1689 (void *)&cmd_config_speed_all_port,
1690 (void *)&cmd_config_speed_all_keyword,
1691 (void *)&cmd_config_speed_all_all,
1692 (void *)&cmd_config_speed_all_item1,
1693 (void *)&cmd_config_speed_all_value1,
1694 (void *)&cmd_config_speed_all_item2,
1695 (void *)&cmd_config_speed_all_value2,
1700 /* *** configure speed for specific port *** */
1701 struct cmd_config_speed_specific {
1702 cmdline_fixed_string_t port;
1703 cmdline_fixed_string_t keyword;
1705 cmdline_fixed_string_t item1;
1706 cmdline_fixed_string_t item2;
1707 cmdline_fixed_string_t value1;
1708 cmdline_fixed_string_t value2;
1712 cmd_config_speed_specific_parsed(void *parsed_result,
1713 __rte_unused struct cmdline *cl,
1714 __rte_unused void *data)
1716 struct cmd_config_speed_specific *res = parsed_result;
1717 uint32_t link_speed;
1719 if (!all_ports_stopped()) {
1720 printf("Please stop all ports first\n");
1724 if (port_id_is_invalid(res->id, ENABLED_WARN))
1727 if (parse_and_check_speed_duplex(res->value1, res->value2,
1731 ports[res->id].dev_conf.link_speeds = link_speed;
1733 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1737 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1738 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1740 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1741 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1743 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1744 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1745 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1746 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1748 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1749 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1750 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1751 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1752 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1754 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1755 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1758 cmdline_parse_inst_t cmd_config_speed_specific = {
1759 .f = cmd_config_speed_specific_parsed,
1761 .help_str = "port config <port_id> speed "
1762 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1765 (void *)&cmd_config_speed_specific_port,
1766 (void *)&cmd_config_speed_specific_keyword,
1767 (void *)&cmd_config_speed_specific_id,
1768 (void *)&cmd_config_speed_specific_item1,
1769 (void *)&cmd_config_speed_specific_value1,
1770 (void *)&cmd_config_speed_specific_item2,
1771 (void *)&cmd_config_speed_specific_value2,
1776 /* *** configure loopback for all ports *** */
1777 struct cmd_config_loopback_all {
1778 cmdline_fixed_string_t port;
1779 cmdline_fixed_string_t keyword;
1780 cmdline_fixed_string_t all;
1781 cmdline_fixed_string_t item;
1786 cmd_config_loopback_all_parsed(void *parsed_result,
1787 __rte_unused struct cmdline *cl,
1788 __rte_unused void *data)
1790 struct cmd_config_loopback_all *res = parsed_result;
1793 if (!all_ports_stopped()) {
1794 printf("Please stop all ports first\n");
1798 RTE_ETH_FOREACH_DEV(pid) {
1799 ports[pid].dev_conf.lpbk_mode = res->mode;
1802 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1805 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1806 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1807 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1808 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1810 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1811 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1812 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1813 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1815 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1816 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1818 cmdline_parse_inst_t cmd_config_loopback_all = {
1819 .f = cmd_config_loopback_all_parsed,
1821 .help_str = "port config all loopback <mode>",
1823 (void *)&cmd_config_loopback_all_port,
1824 (void *)&cmd_config_loopback_all_keyword,
1825 (void *)&cmd_config_loopback_all_all,
1826 (void *)&cmd_config_loopback_all_item,
1827 (void *)&cmd_config_loopback_all_mode,
1832 /* *** configure loopback for specific port *** */
1833 struct cmd_config_loopback_specific {
1834 cmdline_fixed_string_t port;
1835 cmdline_fixed_string_t keyword;
1837 cmdline_fixed_string_t item;
1842 cmd_config_loopback_specific_parsed(void *parsed_result,
1843 __rte_unused struct cmdline *cl,
1844 __rte_unused void *data)
1846 struct cmd_config_loopback_specific *res = parsed_result;
1848 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1851 if (!port_is_stopped(res->port_id)) {
1852 printf("Please stop port %u first\n", res->port_id);
1856 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1858 cmd_reconfig_device_queue(res->port_id, 1, 1);
1862 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1863 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1865 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1868 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1869 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1871 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1872 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1874 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1875 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1878 cmdline_parse_inst_t cmd_config_loopback_specific = {
1879 .f = cmd_config_loopback_specific_parsed,
1881 .help_str = "port config <port_id> loopback <mode>",
1883 (void *)&cmd_config_loopback_specific_port,
1884 (void *)&cmd_config_loopback_specific_keyword,
1885 (void *)&cmd_config_loopback_specific_id,
1886 (void *)&cmd_config_loopback_specific_item,
1887 (void *)&cmd_config_loopback_specific_mode,
1892 /* *** configure txq/rxq, txd/rxd *** */
1893 struct cmd_config_rx_tx {
1894 cmdline_fixed_string_t port;
1895 cmdline_fixed_string_t keyword;
1896 cmdline_fixed_string_t all;
1897 cmdline_fixed_string_t name;
1902 cmd_config_rx_tx_parsed(void *parsed_result,
1903 __rte_unused struct cmdline *cl,
1904 __rte_unused void *data)
1906 struct cmd_config_rx_tx *res = parsed_result;
1908 if (!all_ports_stopped()) {
1909 printf("Please stop all ports first\n");
1912 if (!strcmp(res->name, "rxq")) {
1913 if (!res->value && !nb_txq) {
1914 printf("Warning: Either rx or tx queues should be non zero\n");
1917 if (check_nb_rxq(res->value) != 0)
1919 nb_rxq = res->value;
1921 else if (!strcmp(res->name, "txq")) {
1922 if (!res->value && !nb_rxq) {
1923 printf("Warning: Either rx or tx queues should be non zero\n");
1926 if (check_nb_txq(res->value) != 0)
1928 nb_txq = res->value;
1930 else if (!strcmp(res->name, "rxd")) {
1931 if (check_nb_rxd(res->value) != 0)
1933 nb_rxd = res->value;
1934 } else if (!strcmp(res->name, "txd")) {
1935 if (check_nb_txd(res->value) != 0)
1938 nb_txd = res->value;
1940 printf("Unknown parameter\n");
1948 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1951 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1952 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1953 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1954 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1955 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1956 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1957 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1960 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1961 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1963 cmdline_parse_inst_t cmd_config_rx_tx = {
1964 .f = cmd_config_rx_tx_parsed,
1966 .help_str = "port config all rxq|txq|rxd|txd <value>",
1968 (void *)&cmd_config_rx_tx_port,
1969 (void *)&cmd_config_rx_tx_keyword,
1970 (void *)&cmd_config_rx_tx_all,
1971 (void *)&cmd_config_rx_tx_name,
1972 (void *)&cmd_config_rx_tx_value,
1977 /* *** config max packet length *** */
1978 struct cmd_config_max_pkt_len_result {
1979 cmdline_fixed_string_t port;
1980 cmdline_fixed_string_t keyword;
1981 cmdline_fixed_string_t all;
1982 cmdline_fixed_string_t name;
1987 cmd_config_max_pkt_len_parsed(void *parsed_result,
1988 __rte_unused struct cmdline *cl,
1989 __rte_unused void *data)
1991 struct cmd_config_max_pkt_len_result *res = parsed_result;
1994 if (!all_ports_stopped()) {
1995 printf("Please stop all ports first\n");
1999 RTE_ETH_FOREACH_DEV(pid) {
2000 struct rte_port *port = &ports[pid];
2001 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2003 if (!strcmp(res->name, "max-pkt-len")) {
2004 if (res->value < RTE_ETHER_MIN_LEN) {
2005 printf("max-pkt-len can not be less than %d\n",
2009 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2012 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2013 if (res->value > RTE_ETHER_MAX_LEN)
2014 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2016 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2017 port->dev_conf.rxmode.offloads = rx_offloads;
2019 printf("Unknown parameter\n");
2026 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2029 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2030 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2032 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2035 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2036 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2038 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2039 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2041 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2042 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2045 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2046 .f = cmd_config_max_pkt_len_parsed,
2048 .help_str = "port config all max-pkt-len <value>",
2050 (void *)&cmd_config_max_pkt_len_port,
2051 (void *)&cmd_config_max_pkt_len_keyword,
2052 (void *)&cmd_config_max_pkt_len_all,
2053 (void *)&cmd_config_max_pkt_len_name,
2054 (void *)&cmd_config_max_pkt_len_value,
2059 /* *** config max LRO aggregated packet size *** */
2060 struct cmd_config_max_lro_pkt_size_result {
2061 cmdline_fixed_string_t port;
2062 cmdline_fixed_string_t keyword;
2063 cmdline_fixed_string_t all;
2064 cmdline_fixed_string_t name;
2069 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2070 __rte_unused struct cmdline *cl,
2071 __rte_unused void *data)
2073 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2076 if (!all_ports_stopped()) {
2077 printf("Please stop all ports first\n");
2081 RTE_ETH_FOREACH_DEV(pid) {
2082 struct rte_port *port = &ports[pid];
2084 if (!strcmp(res->name, "max-lro-pkt-size")) {
2086 port->dev_conf.rxmode.max_lro_pkt_size)
2089 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2091 printf("Unknown parameter\n");
2098 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2101 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2102 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2104 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2105 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2107 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2108 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2110 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2111 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2112 name, "max-lro-pkt-size");
2113 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2114 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2117 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2118 .f = cmd_config_max_lro_pkt_size_parsed,
2120 .help_str = "port config all max-lro-pkt-size <value>",
2122 (void *)&cmd_config_max_lro_pkt_size_port,
2123 (void *)&cmd_config_max_lro_pkt_size_keyword,
2124 (void *)&cmd_config_max_lro_pkt_size_all,
2125 (void *)&cmd_config_max_lro_pkt_size_name,
2126 (void *)&cmd_config_max_lro_pkt_size_value,
2131 /* *** configure port MTU *** */
2132 struct cmd_config_mtu_result {
2133 cmdline_fixed_string_t port;
2134 cmdline_fixed_string_t keyword;
2135 cmdline_fixed_string_t mtu;
2141 cmd_config_mtu_parsed(void *parsed_result,
2142 __rte_unused struct cmdline *cl,
2143 __rte_unused void *data)
2145 struct cmd_config_mtu_result *res = parsed_result;
2147 if (res->value < RTE_ETHER_MIN_LEN) {
2148 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2151 port_mtu_set(res->port_id, res->value);
2154 cmdline_parse_token_string_t cmd_config_mtu_port =
2155 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2157 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2158 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2160 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2161 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2163 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2164 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2165 cmdline_parse_token_num_t cmd_config_mtu_value =
2166 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2168 cmdline_parse_inst_t cmd_config_mtu = {
2169 .f = cmd_config_mtu_parsed,
2171 .help_str = "port config mtu <port_id> <value>",
2173 (void *)&cmd_config_mtu_port,
2174 (void *)&cmd_config_mtu_keyword,
2175 (void *)&cmd_config_mtu_mtu,
2176 (void *)&cmd_config_mtu_port_id,
2177 (void *)&cmd_config_mtu_value,
2182 /* *** configure rx mode *** */
2183 struct cmd_config_rx_mode_flag {
2184 cmdline_fixed_string_t port;
2185 cmdline_fixed_string_t keyword;
2186 cmdline_fixed_string_t all;
2187 cmdline_fixed_string_t name;
2188 cmdline_fixed_string_t value;
2192 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2193 __rte_unused struct cmdline *cl,
2194 __rte_unused void *data)
2196 struct cmd_config_rx_mode_flag *res = parsed_result;
2198 if (!all_ports_stopped()) {
2199 printf("Please stop all ports first\n");
2203 if (!strcmp(res->name, "drop-en")) {
2204 if (!strcmp(res->value, "on"))
2206 else if (!strcmp(res->value, "off"))
2209 printf("Unknown parameter\n");
2213 printf("Unknown parameter\n");
2219 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2222 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2223 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2224 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2225 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2227 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2228 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2229 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2230 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2232 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2233 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2236 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2237 .f = cmd_config_rx_mode_flag_parsed,
2239 .help_str = "port config all drop-en on|off",
2241 (void *)&cmd_config_rx_mode_flag_port,
2242 (void *)&cmd_config_rx_mode_flag_keyword,
2243 (void *)&cmd_config_rx_mode_flag_all,
2244 (void *)&cmd_config_rx_mode_flag_name,
2245 (void *)&cmd_config_rx_mode_flag_value,
2250 /* *** configure rss *** */
2251 struct cmd_config_rss {
2252 cmdline_fixed_string_t port;
2253 cmdline_fixed_string_t keyword;
2254 cmdline_fixed_string_t all;
2255 cmdline_fixed_string_t name;
2256 cmdline_fixed_string_t value;
2260 cmd_config_rss_parsed(void *parsed_result,
2261 __rte_unused struct cmdline *cl,
2262 __rte_unused void *data)
2264 struct cmd_config_rss *res = parsed_result;
2265 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2266 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2267 int use_default = 0;
2268 int all_updated = 1;
2273 if (!strcmp(res->value, "all"))
2274 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2275 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2276 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2277 ETH_RSS_AH | ETH_RSS_PFCP;
2278 else if (!strcmp(res->value, "eth"))
2279 rss_conf.rss_hf = ETH_RSS_ETH;
2280 else if (!strcmp(res->value, "vlan"))
2281 rss_conf.rss_hf = ETH_RSS_VLAN;
2282 else if (!strcmp(res->value, "ip"))
2283 rss_conf.rss_hf = ETH_RSS_IP;
2284 else if (!strcmp(res->value, "udp"))
2285 rss_conf.rss_hf = ETH_RSS_UDP;
2286 else if (!strcmp(res->value, "tcp"))
2287 rss_conf.rss_hf = ETH_RSS_TCP;
2288 else if (!strcmp(res->value, "sctp"))
2289 rss_conf.rss_hf = ETH_RSS_SCTP;
2290 else if (!strcmp(res->value, "ether"))
2291 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2292 else if (!strcmp(res->value, "port"))
2293 rss_conf.rss_hf = ETH_RSS_PORT;
2294 else if (!strcmp(res->value, "vxlan"))
2295 rss_conf.rss_hf = ETH_RSS_VXLAN;
2296 else if (!strcmp(res->value, "geneve"))
2297 rss_conf.rss_hf = ETH_RSS_GENEVE;
2298 else if (!strcmp(res->value, "nvgre"))
2299 rss_conf.rss_hf = ETH_RSS_NVGRE;
2300 else if (!strcmp(res->value, "l3-src-only"))
2301 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2302 else if (!strcmp(res->value, "l3-dst-only"))
2303 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2304 else if (!strcmp(res->value, "l4-src-only"))
2305 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2306 else if (!strcmp(res->value, "l4-dst-only"))
2307 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2308 else if (!strcmp(res->value, "l2-src-only"))
2309 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2310 else if (!strcmp(res->value, "l2-dst-only"))
2311 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2312 else if (!strcmp(res->value, "l2tpv3"))
2313 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2314 else if (!strcmp(res->value, "esp"))
2315 rss_conf.rss_hf = ETH_RSS_ESP;
2316 else if (!strcmp(res->value, "ah"))
2317 rss_conf.rss_hf = ETH_RSS_AH;
2318 else if (!strcmp(res->value, "pfcp"))
2319 rss_conf.rss_hf = ETH_RSS_PFCP;
2320 else if (!strcmp(res->value, "none"))
2321 rss_conf.rss_hf = 0;
2322 else if (!strcmp(res->value, "default"))
2324 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2325 atoi(res->value) < 64)
2326 rss_conf.rss_hf = 1ULL << atoi(res->value);
2328 printf("Unknown parameter\n");
2331 rss_conf.rss_key = NULL;
2332 /* Update global configuration for RSS types. */
2333 RTE_ETH_FOREACH_DEV(i) {
2334 struct rte_eth_rss_conf local_rss_conf;
2336 ret = eth_dev_info_get_print_err(i, &dev_info);
2341 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2343 local_rss_conf = rss_conf;
2344 local_rss_conf.rss_hf = rss_conf.rss_hf &
2345 dev_info.flow_type_rss_offloads;
2346 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2347 printf("Port %u modified RSS hash function based on hardware support,"
2348 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2349 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2351 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2354 printf("Configuration of RSS hash at ethernet port %d "
2355 "failed with error (%d): %s.\n",
2356 i, -diag, strerror(-diag));
2359 if (all_updated && !use_default) {
2360 rss_hf = rss_conf.rss_hf;
2361 printf("rss_hf %#"PRIx64"\n", rss_hf);
2365 cmdline_parse_token_string_t cmd_config_rss_port =
2366 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2367 cmdline_parse_token_string_t cmd_config_rss_keyword =
2368 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2369 cmdline_parse_token_string_t cmd_config_rss_all =
2370 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2371 cmdline_parse_token_string_t cmd_config_rss_name =
2372 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2373 cmdline_parse_token_string_t cmd_config_rss_value =
2374 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2376 cmdline_parse_inst_t cmd_config_rss = {
2377 .f = cmd_config_rss_parsed,
2379 .help_str = "port config all rss "
2380 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2381 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|<flowtype_id>",
2383 (void *)&cmd_config_rss_port,
2384 (void *)&cmd_config_rss_keyword,
2385 (void *)&cmd_config_rss_all,
2386 (void *)&cmd_config_rss_name,
2387 (void *)&cmd_config_rss_value,
2392 /* *** configure rss hash key *** */
2393 struct cmd_config_rss_hash_key {
2394 cmdline_fixed_string_t port;
2395 cmdline_fixed_string_t config;
2397 cmdline_fixed_string_t rss_hash_key;
2398 cmdline_fixed_string_t rss_type;
2399 cmdline_fixed_string_t key;
2403 hexa_digit_to_value(char hexa_digit)
2405 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2406 return (uint8_t) (hexa_digit - '0');
2407 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2408 return (uint8_t) ((hexa_digit - 'a') + 10);
2409 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2410 return (uint8_t) ((hexa_digit - 'A') + 10);
2411 /* Invalid hexa digit */
2416 parse_and_check_key_hexa_digit(char *key, int idx)
2420 hexa_v = hexa_digit_to_value(key[idx]);
2422 printf("invalid key: character %c at position %d is not a "
2423 "valid hexa digit\n", key[idx], idx);
2428 cmd_config_rss_hash_key_parsed(void *parsed_result,
2429 __rte_unused struct cmdline *cl,
2430 __rte_unused void *data)
2432 struct cmd_config_rss_hash_key *res = parsed_result;
2433 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2437 struct rte_eth_dev_info dev_info;
2438 uint8_t hash_key_size;
2442 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2446 if (dev_info.hash_key_size > 0 &&
2447 dev_info.hash_key_size <= sizeof(hash_key))
2448 hash_key_size = dev_info.hash_key_size;
2450 printf("dev_info did not provide a valid hash key size\n");
2453 /* Check the length of the RSS hash key */
2454 key_len = strlen(res->key);
2455 if (key_len != (hash_key_size * 2)) {
2456 printf("key length: %d invalid - key must be a string of %d"
2457 " hexa-decimal numbers\n",
2458 (int) key_len, hash_key_size * 2);
2461 /* Translate RSS hash key into binary representation */
2462 for (i = 0; i < hash_key_size; i++) {
2463 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2466 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2469 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2471 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2475 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2476 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2477 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2478 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2480 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2481 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2482 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2483 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2484 rss_hash_key, "rss-hash-key");
2485 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2486 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2487 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2488 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2489 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2490 "ipv6-tcp-ex#ipv6-udp-ex#"
2491 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2492 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2493 "l2tpv3#esp#ah#pfcp");
2494 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2495 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2497 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2498 .f = cmd_config_rss_hash_key_parsed,
2500 .help_str = "port config <port_id> rss-hash-key "
2501 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2502 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2503 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2504 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2505 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2506 "l2tpv3|esp|ah|pfcp "
2507 "<string of hex digits (variable length, NIC dependent)>",
2509 (void *)&cmd_config_rss_hash_key_port,
2510 (void *)&cmd_config_rss_hash_key_config,
2511 (void *)&cmd_config_rss_hash_key_port_id,
2512 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2513 (void *)&cmd_config_rss_hash_key_rss_type,
2514 (void *)&cmd_config_rss_hash_key_value,
2519 /* *** configure port rxq/txq ring size *** */
2520 struct cmd_config_rxtx_ring_size {
2521 cmdline_fixed_string_t port;
2522 cmdline_fixed_string_t config;
2524 cmdline_fixed_string_t rxtxq;
2526 cmdline_fixed_string_t rsize;
2531 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2532 __rte_unused struct cmdline *cl,
2533 __rte_unused void *data)
2535 struct cmd_config_rxtx_ring_size *res = parsed_result;
2536 struct rte_port *port;
2539 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2542 if (res->portid == (portid_t)RTE_PORT_ALL) {
2543 printf("Invalid port id\n");
2547 port = &ports[res->portid];
2549 if (!strcmp(res->rxtxq, "rxq"))
2551 else if (!strcmp(res->rxtxq, "txq"))
2554 printf("Unknown parameter\n");
2558 if (isrx && rx_queue_id_is_invalid(res->qid))
2560 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2563 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2564 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2570 port->nb_rx_desc[res->qid] = res->size;
2572 port->nb_tx_desc[res->qid] = res->size;
2574 cmd_reconfig_device_queue(res->portid, 0, 1);
2577 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2578 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2580 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2581 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2583 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2584 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2586 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2587 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2589 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2590 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2592 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2593 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2594 rsize, "ring_size");
2595 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2596 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2599 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2600 .f = cmd_config_rxtx_ring_size_parsed,
2602 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2604 (void *)&cmd_config_rxtx_ring_size_port,
2605 (void *)&cmd_config_rxtx_ring_size_config,
2606 (void *)&cmd_config_rxtx_ring_size_portid,
2607 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2608 (void *)&cmd_config_rxtx_ring_size_qid,
2609 (void *)&cmd_config_rxtx_ring_size_rsize,
2610 (void *)&cmd_config_rxtx_ring_size_size,
2615 /* *** configure port rxq/txq start/stop *** */
2616 struct cmd_config_rxtx_queue {
2617 cmdline_fixed_string_t port;
2619 cmdline_fixed_string_t rxtxq;
2621 cmdline_fixed_string_t opname;
2625 cmd_config_rxtx_queue_parsed(void *parsed_result,
2626 __rte_unused struct cmdline *cl,
2627 __rte_unused void *data)
2629 struct cmd_config_rxtx_queue *res = parsed_result;
2634 if (test_done == 0) {
2635 printf("Please stop forwarding first\n");
2639 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2642 if (port_is_started(res->portid) != 1) {
2643 printf("Please start port %u first\n", res->portid);
2647 if (!strcmp(res->rxtxq, "rxq"))
2649 else if (!strcmp(res->rxtxq, "txq"))
2652 printf("Unknown parameter\n");
2656 if (isrx && rx_queue_id_is_invalid(res->qid))
2658 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2661 if (!strcmp(res->opname, "start"))
2663 else if (!strcmp(res->opname, "stop"))
2666 printf("Unknown parameter\n");
2670 if (isstart && isrx)
2671 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2672 else if (!isstart && isrx)
2673 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2674 else if (isstart && !isrx)
2675 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2677 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2679 if (ret == -ENOTSUP)
2680 printf("Function not supported in PMD driver\n");
2683 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2684 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2685 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2686 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2687 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2688 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2689 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2690 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2691 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2692 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2695 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2696 .f = cmd_config_rxtx_queue_parsed,
2698 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2700 (void *)&cmd_config_rxtx_queue_port,
2701 (void *)&cmd_config_rxtx_queue_portid,
2702 (void *)&cmd_config_rxtx_queue_rxtxq,
2703 (void *)&cmd_config_rxtx_queue_qid,
2704 (void *)&cmd_config_rxtx_queue_opname,
2709 /* *** configure port rxq/txq deferred start on/off *** */
2710 struct cmd_config_deferred_start_rxtx_queue {
2711 cmdline_fixed_string_t port;
2713 cmdline_fixed_string_t rxtxq;
2715 cmdline_fixed_string_t opname;
2716 cmdline_fixed_string_t state;
2720 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2721 __rte_unused struct cmdline *cl,
2722 __rte_unused void *data)
2724 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2725 struct rte_port *port;
2728 uint8_t needreconfig = 0;
2730 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2733 if (port_is_started(res->port_id) != 0) {
2734 printf("Please stop port %u first\n", res->port_id);
2738 port = &ports[res->port_id];
2740 isrx = !strcmp(res->rxtxq, "rxq");
2742 if (isrx && rx_queue_id_is_invalid(res->qid))
2744 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2747 ison = !strcmp(res->state, "on");
2749 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2750 port->rx_conf[res->qid].rx_deferred_start = ison;
2752 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2753 port->tx_conf[res->qid].tx_deferred_start = ison;
2758 cmd_reconfig_device_queue(res->port_id, 0, 1);
2761 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2762 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2764 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2765 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2767 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2768 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2770 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2771 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2773 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2774 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2775 opname, "deferred_start");
2776 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2777 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2780 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2781 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2783 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2785 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2786 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2787 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2788 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2789 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2790 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2795 /* *** configure port rxq/txq setup *** */
2796 struct cmd_setup_rxtx_queue {
2797 cmdline_fixed_string_t port;
2799 cmdline_fixed_string_t rxtxq;
2801 cmdline_fixed_string_t setup;
2804 /* Common CLI fields for queue setup */
2805 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2806 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2807 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2808 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2809 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2810 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2811 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2812 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2813 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2814 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2817 cmd_setup_rxtx_queue_parsed(
2818 void *parsed_result,
2819 __rte_unused struct cmdline *cl,
2820 __rte_unused void *data)
2822 struct cmd_setup_rxtx_queue *res = parsed_result;
2823 struct rte_port *port;
2824 struct rte_mempool *mp;
2825 unsigned int socket_id;
2829 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2832 if (res->portid == (portid_t)RTE_PORT_ALL) {
2833 printf("Invalid port id\n");
2837 if (!strcmp(res->rxtxq, "rxq"))
2839 else if (!strcmp(res->rxtxq, "txq"))
2842 printf("Unknown parameter\n");
2846 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2847 printf("Invalid rx queue\n");
2849 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2850 printf("Invalid tx queue\n");
2854 port = &ports[res->portid];
2856 socket_id = rxring_numa[res->portid];
2857 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2858 socket_id = port->socket_id;
2860 mp = mbuf_pool_find(socket_id);
2862 printf("Failed to setup RX queue: "
2863 "No mempool allocation"
2864 " on the socket %d\n",
2865 rxring_numa[res->portid]);
2868 ret = rte_eth_rx_queue_setup(res->portid,
2870 port->nb_rx_desc[res->qid],
2872 &port->rx_conf[res->qid],
2875 printf("Failed to setup RX queue\n");
2877 socket_id = txring_numa[res->portid];
2878 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2879 socket_id = port->socket_id;
2881 ret = rte_eth_tx_queue_setup(res->portid,
2883 port->nb_tx_desc[res->qid],
2885 &port->tx_conf[res->qid]);
2887 printf("Failed to setup TX queue\n");
2891 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2892 .f = cmd_setup_rxtx_queue_parsed,
2894 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2896 (void *)&cmd_setup_rxtx_queue_port,
2897 (void *)&cmd_setup_rxtx_queue_portid,
2898 (void *)&cmd_setup_rxtx_queue_rxtxq,
2899 (void *)&cmd_setup_rxtx_queue_qid,
2900 (void *)&cmd_setup_rxtx_queue_setup,
2906 /* *** Configure RSS RETA *** */
2907 struct cmd_config_rss_reta {
2908 cmdline_fixed_string_t port;
2909 cmdline_fixed_string_t keyword;
2911 cmdline_fixed_string_t name;
2912 cmdline_fixed_string_t list_name;
2913 cmdline_fixed_string_t list_of_items;
2917 parse_reta_config(const char *str,
2918 struct rte_eth_rss_reta_entry64 *reta_conf,
2919 uint16_t nb_entries)
2923 uint16_t hash_index, idx, shift;
2926 const char *p, *p0 = str;
2933 unsigned long int_fld[_NUM_FLD];
2934 char *str_fld[_NUM_FLD];
2936 while ((p = strchr(p0,'(')) != NULL) {
2938 if((p0 = strchr(p,')')) == NULL)
2942 if(size >= sizeof(s))
2945 snprintf(s, sizeof(s), "%.*s", size, p);
2946 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2948 for (i = 0; i < _NUM_FLD; i++) {
2950 int_fld[i] = strtoul(str_fld[i], &end, 0);
2951 if (errno != 0 || end == str_fld[i] ||
2956 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2957 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2959 if (hash_index >= nb_entries) {
2960 printf("Invalid RETA hash index=%d\n", hash_index);
2964 idx = hash_index / RTE_RETA_GROUP_SIZE;
2965 shift = hash_index % RTE_RETA_GROUP_SIZE;
2966 reta_conf[idx].mask |= (1ULL << shift);
2967 reta_conf[idx].reta[shift] = nb_queue;
2974 cmd_set_rss_reta_parsed(void *parsed_result,
2975 __rte_unused struct cmdline *cl,
2976 __rte_unused void *data)
2979 struct rte_eth_dev_info dev_info;
2980 struct rte_eth_rss_reta_entry64 reta_conf[8];
2981 struct cmd_config_rss_reta *res = parsed_result;
2983 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2987 if (dev_info.reta_size == 0) {
2988 printf("Redirection table size is 0 which is "
2989 "invalid for RSS\n");
2992 printf("The reta size of port %d is %u\n",
2993 res->port_id, dev_info.reta_size);
2994 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2995 printf("Currently do not support more than %u entries of "
2996 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3000 memset(reta_conf, 0, sizeof(reta_conf));
3001 if (!strcmp(res->list_name, "reta")) {
3002 if (parse_reta_config(res->list_of_items, reta_conf,
3003 dev_info.reta_size)) {
3004 printf("Invalid RSS Redirection Table "
3005 "config entered\n");
3008 ret = rte_eth_dev_rss_reta_update(res->port_id,
3009 reta_conf, dev_info.reta_size);
3011 printf("Bad redirection table parameter, "
3012 "return code = %d \n", ret);
3016 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3017 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3018 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3019 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3020 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3021 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3022 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3023 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3024 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3025 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3026 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3027 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3029 cmdline_parse_inst_t cmd_config_rss_reta = {
3030 .f = cmd_set_rss_reta_parsed,
3032 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3034 (void *)&cmd_config_rss_reta_port,
3035 (void *)&cmd_config_rss_reta_keyword,
3036 (void *)&cmd_config_rss_reta_port_id,
3037 (void *)&cmd_config_rss_reta_name,
3038 (void *)&cmd_config_rss_reta_list_name,
3039 (void *)&cmd_config_rss_reta_list_of_items,
3044 /* *** SHOW PORT RETA INFO *** */
3045 struct cmd_showport_reta {
3046 cmdline_fixed_string_t show;
3047 cmdline_fixed_string_t port;
3049 cmdline_fixed_string_t rss;
3050 cmdline_fixed_string_t reta;
3052 cmdline_fixed_string_t list_of_items;
3056 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3057 uint16_t nb_entries,
3061 const char *p, *p0 = str;
3066 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3067 RTE_RETA_GROUP_SIZE;
3070 p = strchr(p0, '(');
3074 p0 = strchr(p, ')');
3078 if (size >= sizeof(s)) {
3079 printf("The string size exceeds the internal buffer size\n");
3082 snprintf(s, sizeof(s), "%.*s", size, p);
3083 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3084 if (ret <= 0 || ret != num) {
3085 printf("The bits of masks do not match the number of "
3086 "reta entries: %u\n", num);
3089 for (i = 0; i < ret; i++)
3090 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3096 cmd_showport_reta_parsed(void *parsed_result,
3097 __rte_unused struct cmdline *cl,
3098 __rte_unused void *data)
3100 struct cmd_showport_reta *res = parsed_result;
3101 struct rte_eth_rss_reta_entry64 reta_conf[8];
3102 struct rte_eth_dev_info dev_info;
3103 uint16_t max_reta_size;
3106 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3110 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3111 if (res->size == 0 || res->size > max_reta_size) {
3112 printf("Invalid redirection table size: %u (1-%u)\n",
3113 res->size, max_reta_size);
3117 memset(reta_conf, 0, sizeof(reta_conf));
3118 if (showport_parse_reta_config(reta_conf, res->size,
3119 res->list_of_items) < 0) {
3120 printf("Invalid string: %s for reta masks\n",
3121 res->list_of_items);
3124 port_rss_reta_info(res->port_id, reta_conf, res->size);
3127 cmdline_parse_token_string_t cmd_showport_reta_show =
3128 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3129 cmdline_parse_token_string_t cmd_showport_reta_port =
3130 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3131 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3132 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3133 cmdline_parse_token_string_t cmd_showport_reta_rss =
3134 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3135 cmdline_parse_token_string_t cmd_showport_reta_reta =
3136 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3137 cmdline_parse_token_num_t cmd_showport_reta_size =
3138 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3139 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3140 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3141 list_of_items, NULL);
3143 cmdline_parse_inst_t cmd_showport_reta = {
3144 .f = cmd_showport_reta_parsed,
3146 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3148 (void *)&cmd_showport_reta_show,
3149 (void *)&cmd_showport_reta_port,
3150 (void *)&cmd_showport_reta_port_id,
3151 (void *)&cmd_showport_reta_rss,
3152 (void *)&cmd_showport_reta_reta,
3153 (void *)&cmd_showport_reta_size,
3154 (void *)&cmd_showport_reta_list_of_items,
3159 /* *** Show RSS hash configuration *** */
3160 struct cmd_showport_rss_hash {
3161 cmdline_fixed_string_t show;
3162 cmdline_fixed_string_t port;
3164 cmdline_fixed_string_t rss_hash;
3165 cmdline_fixed_string_t rss_type;
3166 cmdline_fixed_string_t key; /* optional argument */
3169 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3170 __rte_unused struct cmdline *cl,
3173 struct cmd_showport_rss_hash *res = parsed_result;
3175 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3178 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3179 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3180 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3181 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3182 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3183 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3184 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3185 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3187 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3188 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3190 cmdline_parse_inst_t cmd_showport_rss_hash = {
3191 .f = cmd_showport_rss_hash_parsed,
3193 .help_str = "show port <port_id> rss-hash",
3195 (void *)&cmd_showport_rss_hash_show,
3196 (void *)&cmd_showport_rss_hash_port,
3197 (void *)&cmd_showport_rss_hash_port_id,
3198 (void *)&cmd_showport_rss_hash_rss_hash,
3203 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3204 .f = cmd_showport_rss_hash_parsed,
3206 .help_str = "show port <port_id> rss-hash key",
3208 (void *)&cmd_showport_rss_hash_show,
3209 (void *)&cmd_showport_rss_hash_port,
3210 (void *)&cmd_showport_rss_hash_port_id,
3211 (void *)&cmd_showport_rss_hash_rss_hash,
3212 (void *)&cmd_showport_rss_hash_rss_key,
3217 /* *** Configure DCB *** */
3218 struct cmd_config_dcb {
3219 cmdline_fixed_string_t port;
3220 cmdline_fixed_string_t config;
3222 cmdline_fixed_string_t dcb;
3223 cmdline_fixed_string_t vt;
3224 cmdline_fixed_string_t vt_en;
3226 cmdline_fixed_string_t pfc;
3227 cmdline_fixed_string_t pfc_en;
3231 cmd_config_dcb_parsed(void *parsed_result,
3232 __rte_unused struct cmdline *cl,
3233 __rte_unused void *data)
3235 struct cmd_config_dcb *res = parsed_result;
3236 portid_t port_id = res->port_id;
3237 struct rte_port *port;
3241 port = &ports[port_id];
3242 /** Check if the port is not started **/
3243 if (port->port_status != RTE_PORT_STOPPED) {
3244 printf("Please stop port %d first\n", port_id);
3248 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3249 printf("The invalid number of traffic class,"
3250 " only 4 or 8 allowed.\n");
3254 if (nb_fwd_lcores < res->num_tcs) {
3255 printf("nb_cores shouldn't be less than number of TCs.\n");
3258 if (!strncmp(res->pfc_en, "on", 2))
3263 /* DCB in VT mode */
3264 if (!strncmp(res->vt_en, "on", 2))
3265 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3266 (enum rte_eth_nb_tcs)res->num_tcs,
3269 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3270 (enum rte_eth_nb_tcs)res->num_tcs,
3275 printf("Cannot initialize network ports.\n");
3279 cmd_reconfig_device_queue(port_id, 1, 1);
3282 cmdline_parse_token_string_t cmd_config_dcb_port =
3283 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3284 cmdline_parse_token_string_t cmd_config_dcb_config =
3285 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3286 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3287 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3288 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3289 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3290 cmdline_parse_token_string_t cmd_config_dcb_vt =
3291 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3292 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3293 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3294 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3295 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3296 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3297 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3298 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3299 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3301 cmdline_parse_inst_t cmd_config_dcb = {
3302 .f = cmd_config_dcb_parsed,
3304 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3306 (void *)&cmd_config_dcb_port,
3307 (void *)&cmd_config_dcb_config,
3308 (void *)&cmd_config_dcb_port_id,
3309 (void *)&cmd_config_dcb_dcb,
3310 (void *)&cmd_config_dcb_vt,
3311 (void *)&cmd_config_dcb_vt_en,
3312 (void *)&cmd_config_dcb_num_tcs,
3313 (void *)&cmd_config_dcb_pfc,
3314 (void *)&cmd_config_dcb_pfc_en,
3319 /* *** configure number of packets per burst *** */
3320 struct cmd_config_burst {
3321 cmdline_fixed_string_t port;
3322 cmdline_fixed_string_t keyword;
3323 cmdline_fixed_string_t all;
3324 cmdline_fixed_string_t name;
3329 cmd_config_burst_parsed(void *parsed_result,
3330 __rte_unused struct cmdline *cl,
3331 __rte_unused void *data)
3333 struct cmd_config_burst *res = parsed_result;
3334 struct rte_eth_dev_info dev_info;
3335 uint16_t rec_nb_pkts;
3338 if (!all_ports_stopped()) {
3339 printf("Please stop all ports first\n");
3343 if (!strcmp(res->name, "burst")) {
3344 if (res->value == 0) {
3345 /* If user gives a value of zero, query the PMD for
3346 * its recommended Rx burst size. Testpmd uses a single
3347 * size for all ports, so assume all ports are the same
3348 * NIC model and use the values from Port 0.
3350 ret = eth_dev_info_get_print_err(0, &dev_info);
3354 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3356 if (rec_nb_pkts == 0) {
3357 printf("PMD does not recommend a burst size.\n"
3358 "User provided value must be between"
3359 " 1 and %d\n", MAX_PKT_BURST);
3361 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3362 printf("PMD recommended burst size of %d"
3363 " exceeds maximum value of %d\n",
3364 rec_nb_pkts, MAX_PKT_BURST);
3367 printf("Using PMD-provided burst value of %d\n",
3369 nb_pkt_per_burst = rec_nb_pkts;
3370 } else if (res->value > MAX_PKT_BURST) {
3371 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3374 nb_pkt_per_burst = res->value;
3376 printf("Unknown parameter\n");
3382 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3385 cmdline_parse_token_string_t cmd_config_burst_port =
3386 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3387 cmdline_parse_token_string_t cmd_config_burst_keyword =
3388 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3389 cmdline_parse_token_string_t cmd_config_burst_all =
3390 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3391 cmdline_parse_token_string_t cmd_config_burst_name =
3392 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3393 cmdline_parse_token_num_t cmd_config_burst_value =
3394 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3396 cmdline_parse_inst_t cmd_config_burst = {
3397 .f = cmd_config_burst_parsed,
3399 .help_str = "port config all burst <value>",
3401 (void *)&cmd_config_burst_port,
3402 (void *)&cmd_config_burst_keyword,
3403 (void *)&cmd_config_burst_all,
3404 (void *)&cmd_config_burst_name,
3405 (void *)&cmd_config_burst_value,
3410 /* *** configure rx/tx queues *** */
3411 struct cmd_config_thresh {
3412 cmdline_fixed_string_t port;
3413 cmdline_fixed_string_t keyword;
3414 cmdline_fixed_string_t all;
3415 cmdline_fixed_string_t name;
3420 cmd_config_thresh_parsed(void *parsed_result,
3421 __rte_unused struct cmdline *cl,
3422 __rte_unused void *data)
3424 struct cmd_config_thresh *res = parsed_result;
3426 if (!all_ports_stopped()) {
3427 printf("Please stop all ports first\n");
3431 if (!strcmp(res->name, "txpt"))
3432 tx_pthresh = res->value;
3433 else if(!strcmp(res->name, "txht"))
3434 tx_hthresh = res->value;
3435 else if(!strcmp(res->name, "txwt"))
3436 tx_wthresh = res->value;
3437 else if(!strcmp(res->name, "rxpt"))
3438 rx_pthresh = res->value;
3439 else if(!strcmp(res->name, "rxht"))
3440 rx_hthresh = res->value;
3441 else if(!strcmp(res->name, "rxwt"))
3442 rx_wthresh = res->value;
3444 printf("Unknown parameter\n");
3450 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3453 cmdline_parse_token_string_t cmd_config_thresh_port =
3454 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3455 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3456 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3457 cmdline_parse_token_string_t cmd_config_thresh_all =
3458 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3459 cmdline_parse_token_string_t cmd_config_thresh_name =
3460 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3461 "txpt#txht#txwt#rxpt#rxht#rxwt");
3462 cmdline_parse_token_num_t cmd_config_thresh_value =
3463 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3465 cmdline_parse_inst_t cmd_config_thresh = {
3466 .f = cmd_config_thresh_parsed,
3468 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3470 (void *)&cmd_config_thresh_port,
3471 (void *)&cmd_config_thresh_keyword,
3472 (void *)&cmd_config_thresh_all,
3473 (void *)&cmd_config_thresh_name,
3474 (void *)&cmd_config_thresh_value,
3479 /* *** configure free/rs threshold *** */
3480 struct cmd_config_threshold {
3481 cmdline_fixed_string_t port;
3482 cmdline_fixed_string_t keyword;
3483 cmdline_fixed_string_t all;
3484 cmdline_fixed_string_t name;
3489 cmd_config_threshold_parsed(void *parsed_result,
3490 __rte_unused struct cmdline *cl,
3491 __rte_unused void *data)
3493 struct cmd_config_threshold *res = parsed_result;
3495 if (!all_ports_stopped()) {
3496 printf("Please stop all ports first\n");
3500 if (!strcmp(res->name, "txfreet"))
3501 tx_free_thresh = res->value;
3502 else if (!strcmp(res->name, "txrst"))
3503 tx_rs_thresh = res->value;
3504 else if (!strcmp(res->name, "rxfreet"))
3505 rx_free_thresh = res->value;
3507 printf("Unknown parameter\n");
3513 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3516 cmdline_parse_token_string_t cmd_config_threshold_port =
3517 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3518 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3519 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3521 cmdline_parse_token_string_t cmd_config_threshold_all =
3522 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3523 cmdline_parse_token_string_t cmd_config_threshold_name =
3524 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3525 "txfreet#txrst#rxfreet");
3526 cmdline_parse_token_num_t cmd_config_threshold_value =
3527 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3529 cmdline_parse_inst_t cmd_config_threshold = {
3530 .f = cmd_config_threshold_parsed,
3532 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3534 (void *)&cmd_config_threshold_port,
3535 (void *)&cmd_config_threshold_keyword,
3536 (void *)&cmd_config_threshold_all,
3537 (void *)&cmd_config_threshold_name,
3538 (void *)&cmd_config_threshold_value,
3544 struct cmd_stop_result {
3545 cmdline_fixed_string_t stop;
3548 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3549 __rte_unused struct cmdline *cl,
3550 __rte_unused void *data)
3552 stop_packet_forwarding();
3555 cmdline_parse_token_string_t cmd_stop_stop =
3556 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3558 cmdline_parse_inst_t cmd_stop = {
3559 .f = cmd_stop_parsed,
3561 .help_str = "stop: Stop packet forwarding",
3563 (void *)&cmd_stop_stop,
3568 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3571 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3572 unsigned int *parsed_items, int check_unique_values)
3574 unsigned int nb_item;
3582 * First parse all items in the list and store their value.
3587 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3589 if ((c >= '0') && (c <= '9')) {
3590 value = (unsigned int) (value * 10 + (c - '0'));
3595 printf("character %c is not a decimal digit\n", c);
3599 printf("No valid value before comma\n");
3602 if (nb_item < max_items) {
3603 parsed_items[nb_item] = value;
3609 if (nb_item >= max_items) {
3610 printf("Number of %s = %u > %u (maximum items)\n",
3611 item_name, nb_item + 1, max_items);
3614 parsed_items[nb_item++] = value;
3615 if (! check_unique_values)
3619 * Then, check that all values in the list are differents.
3620 * No optimization here...
3622 for (i = 0; i < nb_item; i++) {
3623 for (j = i + 1; j < nb_item; j++) {
3624 if (parsed_items[j] == parsed_items[i]) {
3625 printf("duplicated %s %u at index %u and %u\n",
3626 item_name, parsed_items[i], i, j);
3634 struct cmd_set_list_result {
3635 cmdline_fixed_string_t cmd_keyword;
3636 cmdline_fixed_string_t list_name;
3637 cmdline_fixed_string_t list_of_items;
3640 static void cmd_set_list_parsed(void *parsed_result,
3641 __rte_unused struct cmdline *cl,
3642 __rte_unused void *data)
3644 struct cmd_set_list_result *res;
3646 unsigned int lcorelist[RTE_MAX_LCORE];
3647 unsigned int portlist[RTE_MAX_ETHPORTS];
3649 unsigned int nb_item;
3651 if (test_done == 0) {
3652 printf("Please stop forwarding first\n");
3656 res = parsed_result;
3657 if (!strcmp(res->list_name, "corelist")) {
3658 nb_item = parse_item_list(res->list_of_items, "core",
3660 parsed_items.lcorelist, 1);
3662 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3667 if (!strcmp(res->list_name, "portlist")) {
3668 nb_item = parse_item_list(res->list_of_items, "port",
3670 parsed_items.portlist, 1);
3672 set_fwd_ports_list(parsed_items.portlist, nb_item);
3678 cmdline_parse_token_string_t cmd_set_list_keyword =
3679 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3681 cmdline_parse_token_string_t cmd_set_list_name =
3682 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3683 "corelist#portlist");
3684 cmdline_parse_token_string_t cmd_set_list_of_items =
3685 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3688 cmdline_parse_inst_t cmd_set_fwd_list = {
3689 .f = cmd_set_list_parsed,
3691 .help_str = "set corelist|portlist <list0[,list1]*>",
3693 (void *)&cmd_set_list_keyword,
3694 (void *)&cmd_set_list_name,
3695 (void *)&cmd_set_list_of_items,
3700 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3702 struct cmd_setmask_result {
3703 cmdline_fixed_string_t set;
3704 cmdline_fixed_string_t mask;
3708 static void cmd_set_mask_parsed(void *parsed_result,
3709 __rte_unused struct cmdline *cl,
3710 __rte_unused void *data)
3712 struct cmd_setmask_result *res = parsed_result;
3714 if (test_done == 0) {
3715 printf("Please stop forwarding first\n");
3718 if (!strcmp(res->mask, "coremask")) {
3719 set_fwd_lcores_mask(res->hexavalue);
3721 } else if (!strcmp(res->mask, "portmask")) {
3722 set_fwd_ports_mask(res->hexavalue);
3727 cmdline_parse_token_string_t cmd_setmask_set =
3728 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3729 cmdline_parse_token_string_t cmd_setmask_mask =
3730 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3731 "coremask#portmask");
3732 cmdline_parse_token_num_t cmd_setmask_value =
3733 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3735 cmdline_parse_inst_t cmd_set_fwd_mask = {
3736 .f = cmd_set_mask_parsed,
3738 .help_str = "set coremask|portmask <hexadecimal value>",
3740 (void *)&cmd_setmask_set,
3741 (void *)&cmd_setmask_mask,
3742 (void *)&cmd_setmask_value,
3748 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3750 struct cmd_set_result {
3751 cmdline_fixed_string_t set;
3752 cmdline_fixed_string_t what;
3756 static void cmd_set_parsed(void *parsed_result,
3757 __rte_unused struct cmdline *cl,
3758 __rte_unused void *data)
3760 struct cmd_set_result *res = parsed_result;
3761 if (!strcmp(res->what, "nbport")) {
3762 set_fwd_ports_number(res->value);
3764 } else if (!strcmp(res->what, "nbcore")) {
3765 set_fwd_lcores_number(res->value);
3767 } else if (!strcmp(res->what, "burst"))
3768 set_nb_pkt_per_burst(res->value);
3769 else if (!strcmp(res->what, "verbose"))
3770 set_verbose_level(res->value);
3773 cmdline_parse_token_string_t cmd_set_set =
3774 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3775 cmdline_parse_token_string_t cmd_set_what =
3776 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3777 "nbport#nbcore#burst#verbose");
3778 cmdline_parse_token_num_t cmd_set_value =
3779 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3781 cmdline_parse_inst_t cmd_set_numbers = {
3782 .f = cmd_set_parsed,
3784 .help_str = "set nbport|nbcore|burst|verbose <value>",
3786 (void *)&cmd_set_set,
3787 (void *)&cmd_set_what,
3788 (void *)&cmd_set_value,
3793 /* *** SET LOG LEVEL CONFIGURATION *** */
3795 struct cmd_set_log_result {
3796 cmdline_fixed_string_t set;
3797 cmdline_fixed_string_t log;
3798 cmdline_fixed_string_t type;
3803 cmd_set_log_parsed(void *parsed_result,
3804 __rte_unused struct cmdline *cl,
3805 __rte_unused void *data)
3807 struct cmd_set_log_result *res;
3810 res = parsed_result;
3811 if (!strcmp(res->type, "global"))
3812 rte_log_set_global_level(res->level);
3814 ret = rte_log_set_level_regexp(res->type, res->level);
3816 printf("Unable to set log level\n");
3820 cmdline_parse_token_string_t cmd_set_log_set =
3821 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3822 cmdline_parse_token_string_t cmd_set_log_log =
3823 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3824 cmdline_parse_token_string_t cmd_set_log_type =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3826 cmdline_parse_token_num_t cmd_set_log_level =
3827 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3829 cmdline_parse_inst_t cmd_set_log = {
3830 .f = cmd_set_log_parsed,
3832 .help_str = "set log global|<type> <level>",
3834 (void *)&cmd_set_log_set,
3835 (void *)&cmd_set_log_log,
3836 (void *)&cmd_set_log_type,
3837 (void *)&cmd_set_log_level,
3842 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3844 struct cmd_set_txpkts_result {
3845 cmdline_fixed_string_t cmd_keyword;
3846 cmdline_fixed_string_t txpkts;
3847 cmdline_fixed_string_t seg_lengths;
3851 cmd_set_txpkts_parsed(void *parsed_result,
3852 __rte_unused struct cmdline *cl,
3853 __rte_unused void *data)
3855 struct cmd_set_txpkts_result *res;
3856 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3857 unsigned int nb_segs;
3859 res = parsed_result;
3860 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3861 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3863 set_tx_pkt_segments(seg_lengths, nb_segs);
3866 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3867 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3868 cmd_keyword, "set");
3869 cmdline_parse_token_string_t cmd_set_txpkts_name =
3870 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3872 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3873 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3876 cmdline_parse_inst_t cmd_set_txpkts = {
3877 .f = cmd_set_txpkts_parsed,
3879 .help_str = "set txpkts <len0[,len1]*>",
3881 (void *)&cmd_set_txpkts_keyword,
3882 (void *)&cmd_set_txpkts_name,
3883 (void *)&cmd_set_txpkts_lengths,
3888 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3890 struct cmd_set_txsplit_result {
3891 cmdline_fixed_string_t cmd_keyword;
3892 cmdline_fixed_string_t txsplit;
3893 cmdline_fixed_string_t mode;
3897 cmd_set_txsplit_parsed(void *parsed_result,
3898 __rte_unused struct cmdline *cl,
3899 __rte_unused void *data)
3901 struct cmd_set_txsplit_result *res;
3903 res = parsed_result;
3904 set_tx_pkt_split(res->mode);
3907 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3908 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3909 cmd_keyword, "set");
3910 cmdline_parse_token_string_t cmd_set_txsplit_name =
3911 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3912 txsplit, "txsplit");
3913 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3914 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3917 cmdline_parse_inst_t cmd_set_txsplit = {
3918 .f = cmd_set_txsplit_parsed,
3920 .help_str = "set txsplit on|off|rand",
3922 (void *)&cmd_set_txsplit_keyword,
3923 (void *)&cmd_set_txsplit_name,
3924 (void *)&cmd_set_txsplit_mode,
3929 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3930 struct cmd_rx_vlan_filter_all_result {
3931 cmdline_fixed_string_t rx_vlan;
3932 cmdline_fixed_string_t what;
3933 cmdline_fixed_string_t all;
3938 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3939 __rte_unused struct cmdline *cl,
3940 __rte_unused void *data)
3942 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3944 if (!strcmp(res->what, "add"))
3945 rx_vlan_all_filter_set(res->port_id, 1);
3947 rx_vlan_all_filter_set(res->port_id, 0);
3950 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3951 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3952 rx_vlan, "rx_vlan");
3953 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3954 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3956 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3957 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3959 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3960 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3963 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3964 .f = cmd_rx_vlan_filter_all_parsed,
3966 .help_str = "rx_vlan add|rm all <port_id>: "
3967 "Add/Remove all identifiers to/from the set of VLAN "
3968 "identifiers filtered by a port",
3970 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3971 (void *)&cmd_rx_vlan_filter_all_what,
3972 (void *)&cmd_rx_vlan_filter_all_all,
3973 (void *)&cmd_rx_vlan_filter_all_portid,
3978 /* *** VLAN OFFLOAD SET ON A PORT *** */
3979 struct cmd_vlan_offload_result {
3980 cmdline_fixed_string_t vlan;
3981 cmdline_fixed_string_t set;
3982 cmdline_fixed_string_t vlan_type;
3983 cmdline_fixed_string_t what;
3984 cmdline_fixed_string_t on;
3985 cmdline_fixed_string_t port_id;
3989 cmd_vlan_offload_parsed(void *parsed_result,
3990 __rte_unused struct cmdline *cl,
3991 __rte_unused void *data)
3994 struct cmd_vlan_offload_result *res = parsed_result;
3997 portid_t port_id = 0;
4001 len = strnlen(str, STR_TOKEN_SIZE);
4003 /* Get port_id first */
4011 tmp = strtoul(str, NULL, 0);
4012 /* If port_id greater that what portid_t can represent, return */
4013 if(tmp >= RTE_MAX_ETHPORTS)
4015 port_id = (portid_t)tmp;
4017 if (!strcmp(res->on, "on"))
4022 if (!strcmp(res->what, "strip"))
4023 rx_vlan_strip_set(port_id, on);
4024 else if(!strcmp(res->what, "stripq")){
4025 uint16_t queue_id = 0;
4027 /* No queue_id, return */
4029 printf("must specify (port,queue_id)\n");
4032 tmp = strtoul(str + i + 1, NULL, 0);
4033 /* If queue_id greater that what 16-bits can represent, return */
4037 queue_id = (uint16_t)tmp;
4038 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4040 else if (!strcmp(res->what, "filter"))
4041 rx_vlan_filter_set(port_id, on);
4042 else if (!strcmp(res->what, "qinq_strip"))
4043 rx_vlan_qinq_strip_set(port_id, on);
4045 vlan_extend_set(port_id, on);
4050 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4051 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4053 cmdline_parse_token_string_t cmd_vlan_offload_set =
4054 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4056 cmdline_parse_token_string_t cmd_vlan_offload_what =
4057 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4058 what, "strip#filter#qinq_strip#extend#stripq");
4059 cmdline_parse_token_string_t cmd_vlan_offload_on =
4060 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4062 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4063 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4066 cmdline_parse_inst_t cmd_vlan_offload = {
4067 .f = cmd_vlan_offload_parsed,
4069 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4070 "<port_id[,queue_id]>: "
4071 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4073 (void *)&cmd_vlan_offload_vlan,
4074 (void *)&cmd_vlan_offload_set,
4075 (void *)&cmd_vlan_offload_what,
4076 (void *)&cmd_vlan_offload_on,
4077 (void *)&cmd_vlan_offload_portid,
4082 /* *** VLAN TPID SET ON A PORT *** */
4083 struct cmd_vlan_tpid_result {
4084 cmdline_fixed_string_t vlan;
4085 cmdline_fixed_string_t set;
4086 cmdline_fixed_string_t vlan_type;
4087 cmdline_fixed_string_t what;
4093 cmd_vlan_tpid_parsed(void *parsed_result,
4094 __rte_unused struct cmdline *cl,
4095 __rte_unused void *data)
4097 struct cmd_vlan_tpid_result *res = parsed_result;
4098 enum rte_vlan_type vlan_type;
4100 if (!strcmp(res->vlan_type, "inner"))
4101 vlan_type = ETH_VLAN_TYPE_INNER;
4102 else if (!strcmp(res->vlan_type, "outer"))
4103 vlan_type = ETH_VLAN_TYPE_OUTER;
4105 printf("Unknown vlan type\n");
4108 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4111 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4112 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4114 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4115 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4117 cmdline_parse_token_string_t cmd_vlan_type =
4118 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4119 vlan_type, "inner#outer");
4120 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4121 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4123 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4124 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4126 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4127 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4130 cmdline_parse_inst_t cmd_vlan_tpid = {
4131 .f = cmd_vlan_tpid_parsed,
4133 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4134 "Set the VLAN Ether type",
4136 (void *)&cmd_vlan_tpid_vlan,
4137 (void *)&cmd_vlan_tpid_set,
4138 (void *)&cmd_vlan_type,
4139 (void *)&cmd_vlan_tpid_what,
4140 (void *)&cmd_vlan_tpid_tpid,
4141 (void *)&cmd_vlan_tpid_portid,
4146 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4147 struct cmd_rx_vlan_filter_result {
4148 cmdline_fixed_string_t rx_vlan;
4149 cmdline_fixed_string_t what;
4155 cmd_rx_vlan_filter_parsed(void *parsed_result,
4156 __rte_unused struct cmdline *cl,
4157 __rte_unused void *data)
4159 struct cmd_rx_vlan_filter_result *res = parsed_result;
4161 if (!strcmp(res->what, "add"))
4162 rx_vft_set(res->port_id, res->vlan_id, 1);
4164 rx_vft_set(res->port_id, res->vlan_id, 0);
4167 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4168 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4169 rx_vlan, "rx_vlan");
4170 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4171 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4173 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4174 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4176 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4177 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4180 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4181 .f = cmd_rx_vlan_filter_parsed,
4183 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4184 "Add/Remove a VLAN identifier to/from the set of VLAN "
4185 "identifiers filtered by a port",
4187 (void *)&cmd_rx_vlan_filter_rx_vlan,
4188 (void *)&cmd_rx_vlan_filter_what,
4189 (void *)&cmd_rx_vlan_filter_vlanid,
4190 (void *)&cmd_rx_vlan_filter_portid,
4195 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4196 struct cmd_tx_vlan_set_result {
4197 cmdline_fixed_string_t tx_vlan;
4198 cmdline_fixed_string_t set;
4204 cmd_tx_vlan_set_parsed(void *parsed_result,
4205 __rte_unused struct cmdline *cl,
4206 __rte_unused void *data)
4208 struct cmd_tx_vlan_set_result *res = parsed_result;
4210 if (!port_is_stopped(res->port_id)) {
4211 printf("Please stop port %d first\n", res->port_id);
4215 tx_vlan_set(res->port_id, res->vlan_id);
4217 cmd_reconfig_device_queue(res->port_id, 1, 1);
4220 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4221 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4222 tx_vlan, "tx_vlan");
4223 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4224 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4226 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4227 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4229 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4230 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4233 cmdline_parse_inst_t cmd_tx_vlan_set = {
4234 .f = cmd_tx_vlan_set_parsed,
4236 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4237 "Enable hardware insertion of a single VLAN header "
4238 "with a given TAG Identifier in packets sent on a port",
4240 (void *)&cmd_tx_vlan_set_tx_vlan,
4241 (void *)&cmd_tx_vlan_set_set,
4242 (void *)&cmd_tx_vlan_set_portid,
4243 (void *)&cmd_tx_vlan_set_vlanid,
4248 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4249 struct cmd_tx_vlan_set_qinq_result {
4250 cmdline_fixed_string_t tx_vlan;
4251 cmdline_fixed_string_t set;
4254 uint16_t vlan_id_outer;
4258 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4259 __rte_unused struct cmdline *cl,
4260 __rte_unused void *data)
4262 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4264 if (!port_is_stopped(res->port_id)) {
4265 printf("Please stop port %d first\n", res->port_id);
4269 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4271 cmd_reconfig_device_queue(res->port_id, 1, 1);
4274 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4275 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4276 tx_vlan, "tx_vlan");
4277 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4278 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4280 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4281 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4283 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4284 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4286 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4287 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4288 vlan_id_outer, UINT16);
4290 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4291 .f = cmd_tx_vlan_set_qinq_parsed,
4293 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4294 "Enable hardware insertion of double VLAN header "
4295 "with given TAG Identifiers in packets sent on a port",
4297 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4298 (void *)&cmd_tx_vlan_set_qinq_set,
4299 (void *)&cmd_tx_vlan_set_qinq_portid,
4300 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4301 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4306 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4307 struct cmd_tx_vlan_set_pvid_result {
4308 cmdline_fixed_string_t tx_vlan;
4309 cmdline_fixed_string_t set;
4310 cmdline_fixed_string_t pvid;
4313 cmdline_fixed_string_t mode;
4317 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4318 __rte_unused struct cmdline *cl,
4319 __rte_unused void *data)
4321 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4323 if (strcmp(res->mode, "on") == 0)
4324 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4326 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4329 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4330 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4331 tx_vlan, "tx_vlan");
4332 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4333 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4335 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4336 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4338 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4339 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4341 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4342 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4344 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4345 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4348 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4349 .f = cmd_tx_vlan_set_pvid_parsed,
4351 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4353 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4354 (void *)&cmd_tx_vlan_set_pvid_set,
4355 (void *)&cmd_tx_vlan_set_pvid_pvid,
4356 (void *)&cmd_tx_vlan_set_pvid_port_id,
4357 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4358 (void *)&cmd_tx_vlan_set_pvid_mode,
4363 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4364 struct cmd_tx_vlan_reset_result {
4365 cmdline_fixed_string_t tx_vlan;
4366 cmdline_fixed_string_t reset;
4371 cmd_tx_vlan_reset_parsed(void *parsed_result,
4372 __rte_unused struct cmdline *cl,
4373 __rte_unused void *data)
4375 struct cmd_tx_vlan_reset_result *res = parsed_result;
4377 if (!port_is_stopped(res->port_id)) {
4378 printf("Please stop port %d first\n", res->port_id);
4382 tx_vlan_reset(res->port_id);
4384 cmd_reconfig_device_queue(res->port_id, 1, 1);
4387 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4388 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4389 tx_vlan, "tx_vlan");
4390 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4391 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4393 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4394 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4397 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4398 .f = cmd_tx_vlan_reset_parsed,
4400 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4401 "VLAN header in packets sent on a port",
4403 (void *)&cmd_tx_vlan_reset_tx_vlan,
4404 (void *)&cmd_tx_vlan_reset_reset,
4405 (void *)&cmd_tx_vlan_reset_portid,
4411 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4412 struct cmd_csum_result {
4413 cmdline_fixed_string_t csum;
4414 cmdline_fixed_string_t mode;
4415 cmdline_fixed_string_t proto;
4416 cmdline_fixed_string_t hwsw;
4421 csum_show(int port_id)
4423 struct rte_eth_dev_info dev_info;
4424 uint64_t tx_offloads;
4427 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4428 printf("Parse tunnel is %s\n",
4429 (ports[port_id].parse_tunnel) ? "on" : "off");
4430 printf("IP checksum offload is %s\n",
4431 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4432 printf("UDP checksum offload is %s\n",
4433 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4434 printf("TCP checksum offload is %s\n",
4435 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4436 printf("SCTP checksum offload is %s\n",
4437 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4438 printf("Outer-Ip checksum offload is %s\n",
4439 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4440 printf("Outer-Udp checksum offload is %s\n",
4441 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4443 /* display warnings if configuration is not supported by the NIC */
4444 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4448 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4449 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4450 printf("Warning: hardware IP checksum enabled but not "
4451 "supported by port %d\n", port_id);
4453 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4454 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4455 printf("Warning: hardware UDP checksum enabled but not "
4456 "supported by port %d\n", port_id);
4458 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4459 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4460 printf("Warning: hardware TCP checksum enabled but not "
4461 "supported by port %d\n", port_id);
4463 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4464 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4465 printf("Warning: hardware SCTP checksum enabled but not "
4466 "supported by port %d\n", port_id);
4468 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4469 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4470 printf("Warning: hardware outer IP checksum enabled but not "
4471 "supported by port %d\n", port_id);
4473 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4474 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4476 printf("Warning: hardware outer UDP checksum enabled but not "
4477 "supported by port %d\n", port_id);
4482 cmd_config_queue_tx_offloads(struct rte_port *port)
4486 /* Apply queue tx offloads configuration */
4487 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4488 port->tx_conf[k].offloads =
4489 port->dev_conf.txmode.offloads;
4493 cmd_csum_parsed(void *parsed_result,
4494 __rte_unused struct cmdline *cl,
4495 __rte_unused void *data)
4497 struct cmd_csum_result *res = parsed_result;
4499 uint64_t csum_offloads = 0;
4500 struct rte_eth_dev_info dev_info;
4503 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4504 printf("invalid port %d\n", res->port_id);
4507 if (!port_is_stopped(res->port_id)) {
4508 printf("Please stop port %d first\n", res->port_id);
4512 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4516 if (!strcmp(res->mode, "set")) {
4518 if (!strcmp(res->hwsw, "hw"))
4521 if (!strcmp(res->proto, "ip")) {
4522 if (hw == 0 || (dev_info.tx_offload_capa &
4523 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4524 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4526 printf("IP checksum offload is not supported "
4527 "by port %u\n", res->port_id);
4529 } else if (!strcmp(res->proto, "udp")) {
4530 if (hw == 0 || (dev_info.tx_offload_capa &
4531 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4532 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4534 printf("UDP checksum offload is not supported "
4535 "by port %u\n", res->port_id);
4537 } else if (!strcmp(res->proto, "tcp")) {
4538 if (hw == 0 || (dev_info.tx_offload_capa &
4539 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4540 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4542 printf("TCP checksum offload is not supported "
4543 "by port %u\n", res->port_id);
4545 } else if (!strcmp(res->proto, "sctp")) {
4546 if (hw == 0 || (dev_info.tx_offload_capa &
4547 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4548 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4550 printf("SCTP checksum offload is not supported "
4551 "by port %u\n", res->port_id);
4553 } else if (!strcmp(res->proto, "outer-ip")) {
4554 if (hw == 0 || (dev_info.tx_offload_capa &
4555 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4557 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4559 printf("Outer IP checksum offload is not "
4560 "supported by port %u\n", res->port_id);
4562 } else if (!strcmp(res->proto, "outer-udp")) {
4563 if (hw == 0 || (dev_info.tx_offload_capa &
4564 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4566 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4568 printf("Outer UDP checksum offload is not "
4569 "supported by port %u\n", res->port_id);
4574 ports[res->port_id].dev_conf.txmode.offloads |=
4577 ports[res->port_id].dev_conf.txmode.offloads &=
4580 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4582 csum_show(res->port_id);
4584 cmd_reconfig_device_queue(res->port_id, 1, 1);
4587 cmdline_parse_token_string_t cmd_csum_csum =
4588 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4590 cmdline_parse_token_string_t cmd_csum_mode =
4591 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4593 cmdline_parse_token_string_t cmd_csum_proto =
4594 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4595 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4596 cmdline_parse_token_string_t cmd_csum_hwsw =
4597 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4599 cmdline_parse_token_num_t cmd_csum_portid =
4600 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4603 cmdline_parse_inst_t cmd_csum_set = {
4604 .f = cmd_csum_parsed,
4606 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4607 "Enable/Disable hardware calculation of L3/L4 checksum when "
4608 "using csum forward engine",
4610 (void *)&cmd_csum_csum,
4611 (void *)&cmd_csum_mode,
4612 (void *)&cmd_csum_proto,
4613 (void *)&cmd_csum_hwsw,
4614 (void *)&cmd_csum_portid,
4619 cmdline_parse_token_string_t cmd_csum_mode_show =
4620 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4623 cmdline_parse_inst_t cmd_csum_show = {
4624 .f = cmd_csum_parsed,
4626 .help_str = "csum show <port_id>: Show checksum offload configuration",
4628 (void *)&cmd_csum_csum,
4629 (void *)&cmd_csum_mode_show,
4630 (void *)&cmd_csum_portid,
4635 /* Enable/disable tunnel parsing */
4636 struct cmd_csum_tunnel_result {
4637 cmdline_fixed_string_t csum;
4638 cmdline_fixed_string_t parse;
4639 cmdline_fixed_string_t onoff;
4644 cmd_csum_tunnel_parsed(void *parsed_result,
4645 __rte_unused struct cmdline *cl,
4646 __rte_unused void *data)
4648 struct cmd_csum_tunnel_result *res = parsed_result;
4650 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4653 if (!strcmp(res->onoff, "on"))
4654 ports[res->port_id].parse_tunnel = 1;
4656 ports[res->port_id].parse_tunnel = 0;
4658 csum_show(res->port_id);
4661 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4662 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4664 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4665 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4666 parse, "parse-tunnel");
4667 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4668 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4670 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4671 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4674 cmdline_parse_inst_t cmd_csum_tunnel = {
4675 .f = cmd_csum_tunnel_parsed,
4677 .help_str = "csum parse-tunnel on|off <port_id>: "
4678 "Enable/Disable parsing of tunnels for csum engine",
4680 (void *)&cmd_csum_tunnel_csum,
4681 (void *)&cmd_csum_tunnel_parse,
4682 (void *)&cmd_csum_tunnel_onoff,
4683 (void *)&cmd_csum_tunnel_portid,
4688 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4689 struct cmd_tso_set_result {
4690 cmdline_fixed_string_t tso;
4691 cmdline_fixed_string_t mode;
4697 cmd_tso_set_parsed(void *parsed_result,
4698 __rte_unused struct cmdline *cl,
4699 __rte_unused void *data)
4701 struct cmd_tso_set_result *res = parsed_result;
4702 struct rte_eth_dev_info dev_info;
4705 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4707 if (!port_is_stopped(res->port_id)) {
4708 printf("Please stop port %d first\n", res->port_id);
4712 if (!strcmp(res->mode, "set"))
4713 ports[res->port_id].tso_segsz = res->tso_segsz;
4715 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4719 if ((ports[res->port_id].tso_segsz != 0) &&
4720 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4721 printf("Error: TSO is not supported by port %d\n",
4726 if (ports[res->port_id].tso_segsz == 0) {
4727 ports[res->port_id].dev_conf.txmode.offloads &=
4728 ~DEV_TX_OFFLOAD_TCP_TSO;
4729 printf("TSO for non-tunneled packets is disabled\n");
4731 ports[res->port_id].dev_conf.txmode.offloads |=
4732 DEV_TX_OFFLOAD_TCP_TSO;
4733 printf("TSO segment size for non-tunneled packets is %d\n",
4734 ports[res->port_id].tso_segsz);
4736 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4738 /* display warnings if configuration is not supported by the NIC */
4739 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4743 if ((ports[res->port_id].tso_segsz != 0) &&
4744 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4745 printf("Warning: TSO enabled but not "
4746 "supported by port %d\n", res->port_id);
4749 cmd_reconfig_device_queue(res->port_id, 1, 1);
4752 cmdline_parse_token_string_t cmd_tso_set_tso =
4753 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4755 cmdline_parse_token_string_t cmd_tso_set_mode =
4756 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4758 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4759 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4761 cmdline_parse_token_num_t cmd_tso_set_portid =
4762 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4765 cmdline_parse_inst_t cmd_tso_set = {
4766 .f = cmd_tso_set_parsed,
4768 .help_str = "tso set <tso_segsz> <port_id>: "
4769 "Set TSO segment size of non-tunneled packets for csum engine "
4772 (void *)&cmd_tso_set_tso,
4773 (void *)&cmd_tso_set_mode,
4774 (void *)&cmd_tso_set_tso_segsz,
4775 (void *)&cmd_tso_set_portid,
4780 cmdline_parse_token_string_t cmd_tso_show_mode =
4781 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4785 cmdline_parse_inst_t cmd_tso_show = {
4786 .f = cmd_tso_set_parsed,
4788 .help_str = "tso show <port_id>: "
4789 "Show TSO segment size of non-tunneled packets for csum engine",
4791 (void *)&cmd_tso_set_tso,
4792 (void *)&cmd_tso_show_mode,
4793 (void *)&cmd_tso_set_portid,
4798 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4799 struct cmd_tunnel_tso_set_result {
4800 cmdline_fixed_string_t tso;
4801 cmdline_fixed_string_t mode;
4806 static struct rte_eth_dev_info
4807 check_tunnel_tso_nic_support(portid_t port_id)
4809 struct rte_eth_dev_info dev_info;
4811 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4814 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4815 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4816 "not enabled for port %d\n", port_id);
4817 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4818 printf("Warning: GRE TUNNEL TSO not supported therefore "
4819 "not enabled for port %d\n", port_id);
4820 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4821 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4822 "not enabled for port %d\n", port_id);
4823 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4824 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4825 "not enabled for port %d\n", port_id);
4826 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4827 printf("Warning: IP TUNNEL TSO not supported therefore "
4828 "not enabled for port %d\n", port_id);
4829 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4830 printf("Warning: UDP TUNNEL TSO not supported therefore "
4831 "not enabled for port %d\n", port_id);
4836 cmd_tunnel_tso_set_parsed(void *parsed_result,
4837 __rte_unused struct cmdline *cl,
4838 __rte_unused void *data)
4840 struct cmd_tunnel_tso_set_result *res = parsed_result;
4841 struct rte_eth_dev_info dev_info;
4843 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4845 if (!port_is_stopped(res->port_id)) {
4846 printf("Please stop port %d first\n", res->port_id);
4850 if (!strcmp(res->mode, "set"))
4851 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4853 dev_info = check_tunnel_tso_nic_support(res->port_id);
4854 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4855 ports[res->port_id].dev_conf.txmode.offloads &=
4856 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4857 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4858 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4859 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4860 DEV_TX_OFFLOAD_IP_TNL_TSO |
4861 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4862 printf("TSO for tunneled packets is disabled\n");
4864 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4865 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4866 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4867 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4868 DEV_TX_OFFLOAD_IP_TNL_TSO |
4869 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4871 ports[res->port_id].dev_conf.txmode.offloads |=
4872 (tso_offloads & dev_info.tx_offload_capa);
4873 printf("TSO segment size for tunneled packets is %d\n",
4874 ports[res->port_id].tunnel_tso_segsz);
4876 /* Below conditions are needed to make it work:
4877 * (1) tunnel TSO is supported by the NIC;
4878 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4880 * (3) for tunneled pkts with outer L3 of IPv4,
4881 * "csum set outer-ip" must be set to hw, because after tso,
4882 * total_len of outer IP header is changed, and the checksum
4883 * of outer IP header calculated by sw should be wrong; that
4884 * is not necessary for IPv6 tunneled pkts because there's no
4885 * checksum in IP header anymore.
4888 if (!ports[res->port_id].parse_tunnel)
4889 printf("Warning: csum parse_tunnel must be set "
4890 "so that tunneled packets are recognized\n");
4891 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4892 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4893 printf("Warning: csum set outer-ip must be set to hw "
4894 "if outer L3 is IPv4; not necessary for IPv6\n");
4897 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4898 cmd_reconfig_device_queue(res->port_id, 1, 1);
4901 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4902 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4904 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4905 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4907 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4908 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4910 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4911 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4914 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4915 .f = cmd_tunnel_tso_set_parsed,
4917 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4918 "Set TSO segment size of tunneled packets for csum engine "
4921 (void *)&cmd_tunnel_tso_set_tso,
4922 (void *)&cmd_tunnel_tso_set_mode,
4923 (void *)&cmd_tunnel_tso_set_tso_segsz,
4924 (void *)&cmd_tunnel_tso_set_portid,
4929 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4930 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4934 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4935 .f = cmd_tunnel_tso_set_parsed,
4937 .help_str = "tunnel_tso show <port_id> "
4938 "Show TSO segment size of tunneled packets for csum engine",
4940 (void *)&cmd_tunnel_tso_set_tso,
4941 (void *)&cmd_tunnel_tso_show_mode,
4942 (void *)&cmd_tunnel_tso_set_portid,
4947 /* *** SET GRO FOR A PORT *** */
4948 struct cmd_gro_enable_result {
4949 cmdline_fixed_string_t cmd_set;
4950 cmdline_fixed_string_t cmd_port;
4951 cmdline_fixed_string_t cmd_keyword;
4952 cmdline_fixed_string_t cmd_onoff;
4957 cmd_gro_enable_parsed(void *parsed_result,
4958 __rte_unused struct cmdline *cl,
4959 __rte_unused void *data)
4961 struct cmd_gro_enable_result *res;
4963 res = parsed_result;
4964 if (!strcmp(res->cmd_keyword, "gro"))
4965 setup_gro(res->cmd_onoff, res->cmd_pid);
4968 cmdline_parse_token_string_t cmd_gro_enable_set =
4969 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4971 cmdline_parse_token_string_t cmd_gro_enable_port =
4972 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4973 cmd_keyword, "port");
4974 cmdline_parse_token_num_t cmd_gro_enable_pid =
4975 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4977 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4978 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4979 cmd_keyword, "gro");
4980 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4981 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4982 cmd_onoff, "on#off");
4984 cmdline_parse_inst_t cmd_gro_enable = {
4985 .f = cmd_gro_enable_parsed,
4987 .help_str = "set port <port_id> gro on|off",
4989 (void *)&cmd_gro_enable_set,
4990 (void *)&cmd_gro_enable_port,
4991 (void *)&cmd_gro_enable_pid,
4992 (void *)&cmd_gro_enable_keyword,
4993 (void *)&cmd_gro_enable_onoff,
4998 /* *** DISPLAY GRO CONFIGURATION *** */
4999 struct cmd_gro_show_result {
5000 cmdline_fixed_string_t cmd_show;
5001 cmdline_fixed_string_t cmd_port;
5002 cmdline_fixed_string_t cmd_keyword;
5007 cmd_gro_show_parsed(void *parsed_result,
5008 __rte_unused struct cmdline *cl,
5009 __rte_unused void *data)
5011 struct cmd_gro_show_result *res;
5013 res = parsed_result;
5014 if (!strcmp(res->cmd_keyword, "gro"))
5015 show_gro(res->cmd_pid);
5018 cmdline_parse_token_string_t cmd_gro_show_show =
5019 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5021 cmdline_parse_token_string_t cmd_gro_show_port =
5022 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5024 cmdline_parse_token_num_t cmd_gro_show_pid =
5025 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5027 cmdline_parse_token_string_t cmd_gro_show_keyword =
5028 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5029 cmd_keyword, "gro");
5031 cmdline_parse_inst_t cmd_gro_show = {
5032 .f = cmd_gro_show_parsed,
5034 .help_str = "show port <port_id> gro",
5036 (void *)&cmd_gro_show_show,
5037 (void *)&cmd_gro_show_port,
5038 (void *)&cmd_gro_show_pid,
5039 (void *)&cmd_gro_show_keyword,
5044 /* *** SET FLUSH CYCLES FOR GRO *** */
5045 struct cmd_gro_flush_result {
5046 cmdline_fixed_string_t cmd_set;
5047 cmdline_fixed_string_t cmd_keyword;
5048 cmdline_fixed_string_t cmd_flush;
5053 cmd_gro_flush_parsed(void *parsed_result,
5054 __rte_unused struct cmdline *cl,
5055 __rte_unused void *data)
5057 struct cmd_gro_flush_result *res;
5059 res = parsed_result;
5060 if ((!strcmp(res->cmd_keyword, "gro")) &&
5061 (!strcmp(res->cmd_flush, "flush")))
5062 setup_gro_flush_cycles(res->cmd_cycles);
5065 cmdline_parse_token_string_t cmd_gro_flush_set =
5066 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5068 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5069 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5070 cmd_keyword, "gro");
5071 cmdline_parse_token_string_t cmd_gro_flush_flush =
5072 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5073 cmd_flush, "flush");
5074 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5075 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5078 cmdline_parse_inst_t cmd_gro_flush = {
5079 .f = cmd_gro_flush_parsed,
5081 .help_str = "set gro flush <cycles>",
5083 (void *)&cmd_gro_flush_set,
5084 (void *)&cmd_gro_flush_keyword,
5085 (void *)&cmd_gro_flush_flush,
5086 (void *)&cmd_gro_flush_cycles,
5091 /* *** ENABLE/DISABLE GSO *** */
5092 struct cmd_gso_enable_result {
5093 cmdline_fixed_string_t cmd_set;
5094 cmdline_fixed_string_t cmd_port;
5095 cmdline_fixed_string_t cmd_keyword;
5096 cmdline_fixed_string_t cmd_mode;
5101 cmd_gso_enable_parsed(void *parsed_result,
5102 __rte_unused struct cmdline *cl,
5103 __rte_unused void *data)
5105 struct cmd_gso_enable_result *res;
5107 res = parsed_result;
5108 if (!strcmp(res->cmd_keyword, "gso"))
5109 setup_gso(res->cmd_mode, res->cmd_pid);
5112 cmdline_parse_token_string_t cmd_gso_enable_set =
5113 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5115 cmdline_parse_token_string_t cmd_gso_enable_port =
5116 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5118 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5119 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5120 cmd_keyword, "gso");
5121 cmdline_parse_token_string_t cmd_gso_enable_mode =
5122 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5123 cmd_mode, "on#off");
5124 cmdline_parse_token_num_t cmd_gso_enable_pid =
5125 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5128 cmdline_parse_inst_t cmd_gso_enable = {
5129 .f = cmd_gso_enable_parsed,
5131 .help_str = "set port <port_id> gso on|off",
5133 (void *)&cmd_gso_enable_set,
5134 (void *)&cmd_gso_enable_port,
5135 (void *)&cmd_gso_enable_pid,
5136 (void *)&cmd_gso_enable_keyword,
5137 (void *)&cmd_gso_enable_mode,
5142 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5143 struct cmd_gso_size_result {
5144 cmdline_fixed_string_t cmd_set;
5145 cmdline_fixed_string_t cmd_keyword;
5146 cmdline_fixed_string_t cmd_segsz;
5151 cmd_gso_size_parsed(void *parsed_result,
5152 __rte_unused struct cmdline *cl,
5153 __rte_unused void *data)
5155 struct cmd_gso_size_result *res = parsed_result;
5157 if (test_done == 0) {
5158 printf("Before setting GSO segsz, please first"
5159 " stop forwarding\n");
5163 if (!strcmp(res->cmd_keyword, "gso") &&
5164 !strcmp(res->cmd_segsz, "segsz")) {
5165 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5166 printf("gso_size should be larger than %zu."
5167 " Please input a legal value\n",
5168 RTE_GSO_SEG_SIZE_MIN);
5170 gso_max_segment_size = res->cmd_size;
5174 cmdline_parse_token_string_t cmd_gso_size_set =
5175 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5177 cmdline_parse_token_string_t cmd_gso_size_keyword =
5178 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5179 cmd_keyword, "gso");
5180 cmdline_parse_token_string_t cmd_gso_size_segsz =
5181 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5182 cmd_segsz, "segsz");
5183 cmdline_parse_token_num_t cmd_gso_size_size =
5184 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5187 cmdline_parse_inst_t cmd_gso_size = {
5188 .f = cmd_gso_size_parsed,
5190 .help_str = "set gso segsz <length>",
5192 (void *)&cmd_gso_size_set,
5193 (void *)&cmd_gso_size_keyword,
5194 (void *)&cmd_gso_size_segsz,
5195 (void *)&cmd_gso_size_size,
5200 /* *** SHOW GSO CONFIGURATION *** */
5201 struct cmd_gso_show_result {
5202 cmdline_fixed_string_t cmd_show;
5203 cmdline_fixed_string_t cmd_port;
5204 cmdline_fixed_string_t cmd_keyword;
5209 cmd_gso_show_parsed(void *parsed_result,
5210 __rte_unused struct cmdline *cl,
5211 __rte_unused void *data)
5213 struct cmd_gso_show_result *res = parsed_result;
5215 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5216 printf("invalid port id %u\n", res->cmd_pid);
5219 if (!strcmp(res->cmd_keyword, "gso")) {
5220 if (gso_ports[res->cmd_pid].enable) {
5221 printf("Max GSO'd packet size: %uB\n"
5222 "Supported GSO types: TCP/IPv4, "
5223 "UDP/IPv4, VxLAN with inner "
5224 "TCP/IPv4 packet, GRE with inner "
5225 "TCP/IPv4 packet\n",
5226 gso_max_segment_size);
5228 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5232 cmdline_parse_token_string_t cmd_gso_show_show =
5233 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5235 cmdline_parse_token_string_t cmd_gso_show_port =
5236 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5238 cmdline_parse_token_string_t cmd_gso_show_keyword =
5239 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5240 cmd_keyword, "gso");
5241 cmdline_parse_token_num_t cmd_gso_show_pid =
5242 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5245 cmdline_parse_inst_t cmd_gso_show = {
5246 .f = cmd_gso_show_parsed,
5248 .help_str = "show port <port_id> gso",
5250 (void *)&cmd_gso_show_show,
5251 (void *)&cmd_gso_show_port,
5252 (void *)&cmd_gso_show_pid,
5253 (void *)&cmd_gso_show_keyword,
5258 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5259 struct cmd_set_flush_rx {
5260 cmdline_fixed_string_t set;
5261 cmdline_fixed_string_t flush_rx;
5262 cmdline_fixed_string_t mode;
5266 cmd_set_flush_rx_parsed(void *parsed_result,
5267 __rte_unused struct cmdline *cl,
5268 __rte_unused void *data)
5270 struct cmd_set_flush_rx *res = parsed_result;
5271 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5274 cmdline_parse_token_string_t cmd_setflushrx_set =
5275 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5277 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5278 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5279 flush_rx, "flush_rx");
5280 cmdline_parse_token_string_t cmd_setflushrx_mode =
5281 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5285 cmdline_parse_inst_t cmd_set_flush_rx = {
5286 .f = cmd_set_flush_rx_parsed,
5287 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5290 (void *)&cmd_setflushrx_set,
5291 (void *)&cmd_setflushrx_flush_rx,
5292 (void *)&cmd_setflushrx_mode,
5297 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5298 struct cmd_set_link_check {
5299 cmdline_fixed_string_t set;
5300 cmdline_fixed_string_t link_check;
5301 cmdline_fixed_string_t mode;
5305 cmd_set_link_check_parsed(void *parsed_result,
5306 __rte_unused struct cmdline *cl,
5307 __rte_unused void *data)
5309 struct cmd_set_link_check *res = parsed_result;
5310 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5313 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5314 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5316 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5317 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5318 link_check, "link_check");
5319 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5320 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5324 cmdline_parse_inst_t cmd_set_link_check = {
5325 .f = cmd_set_link_check_parsed,
5326 .help_str = "set link_check on|off: Enable/Disable link status check "
5327 "when starting/stopping a port",
5330 (void *)&cmd_setlinkcheck_set,
5331 (void *)&cmd_setlinkcheck_link_check,
5332 (void *)&cmd_setlinkcheck_mode,
5337 /* *** SET NIC BYPASS MODE *** */
5338 struct cmd_set_bypass_mode_result {
5339 cmdline_fixed_string_t set;
5340 cmdline_fixed_string_t bypass;
5341 cmdline_fixed_string_t mode;
5342 cmdline_fixed_string_t value;
5347 cmd_set_bypass_mode_parsed(void *parsed_result,
5348 __rte_unused struct cmdline *cl,
5349 __rte_unused void *data)
5351 struct cmd_set_bypass_mode_result *res = parsed_result;
5352 portid_t port_id = res->port_id;
5353 int32_t rc = -EINVAL;
5355 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5356 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5358 if (!strcmp(res->value, "bypass"))
5359 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5360 else if (!strcmp(res->value, "isolate"))
5361 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5363 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5365 /* Set the bypass mode for the relevant port. */
5366 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5369 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5372 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5373 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5375 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5376 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5378 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5379 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5381 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5382 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5383 value, "normal#bypass#isolate");
5384 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5385 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5388 cmdline_parse_inst_t cmd_set_bypass_mode = {
5389 .f = cmd_set_bypass_mode_parsed,
5390 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5391 "Set the NIC bypass mode for port_id",
5394 (void *)&cmd_setbypass_mode_set,
5395 (void *)&cmd_setbypass_mode_bypass,
5396 (void *)&cmd_setbypass_mode_mode,
5397 (void *)&cmd_setbypass_mode_value,
5398 (void *)&cmd_setbypass_mode_port,
5403 /* *** SET NIC BYPASS EVENT *** */
5404 struct cmd_set_bypass_event_result {
5405 cmdline_fixed_string_t set;
5406 cmdline_fixed_string_t bypass;
5407 cmdline_fixed_string_t event;
5408 cmdline_fixed_string_t event_value;
5409 cmdline_fixed_string_t mode;
5410 cmdline_fixed_string_t mode_value;
5415 cmd_set_bypass_event_parsed(void *parsed_result,
5416 __rte_unused struct cmdline *cl,
5417 __rte_unused void *data)
5419 int32_t rc = -EINVAL;
5420 struct cmd_set_bypass_event_result *res = parsed_result;
5421 portid_t port_id = res->port_id;
5423 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5424 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5425 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5427 if (!strcmp(res->event_value, "timeout"))
5428 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5429 else if (!strcmp(res->event_value, "os_on"))
5430 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5431 else if (!strcmp(res->event_value, "os_off"))
5432 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5433 else if (!strcmp(res->event_value, "power_on"))
5434 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5435 else if (!strcmp(res->event_value, "power_off"))
5436 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5438 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5440 if (!strcmp(res->mode_value, "bypass"))
5441 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5442 else if (!strcmp(res->mode_value, "isolate"))
5443 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5445 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5447 /* Set the watchdog timeout. */
5448 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5451 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5452 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5456 printf("Failed to set timeout value %u "
5457 "for port %d, errto code: %d.\n",
5458 bypass_timeout, port_id, rc);
5462 /* Set the bypass event to transition to bypass mode. */
5463 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5468 printf("\t Failed to set bypass event for port = %d.\n",
5472 cmdline_parse_token_string_t cmd_setbypass_event_set =
5473 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5475 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5476 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5478 cmdline_parse_token_string_t cmd_setbypass_event_event =
5479 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5481 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5482 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5483 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5484 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5485 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5487 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5488 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5489 mode_value, "normal#bypass#isolate");
5490 cmdline_parse_token_num_t cmd_setbypass_event_port =
5491 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5494 cmdline_parse_inst_t cmd_set_bypass_event = {
5495 .f = cmd_set_bypass_event_parsed,
5496 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5497 "power_off mode normal|bypass|isolate <port_id>: "
5498 "Set the NIC bypass event mode for port_id",
5501 (void *)&cmd_setbypass_event_set,
5502 (void *)&cmd_setbypass_event_bypass,
5503 (void *)&cmd_setbypass_event_event,
5504 (void *)&cmd_setbypass_event_event_value,
5505 (void *)&cmd_setbypass_event_mode,
5506 (void *)&cmd_setbypass_event_mode_value,
5507 (void *)&cmd_setbypass_event_port,
5513 /* *** SET NIC BYPASS TIMEOUT *** */
5514 struct cmd_set_bypass_timeout_result {
5515 cmdline_fixed_string_t set;
5516 cmdline_fixed_string_t bypass;
5517 cmdline_fixed_string_t timeout;
5518 cmdline_fixed_string_t value;
5522 cmd_set_bypass_timeout_parsed(void *parsed_result,
5523 __rte_unused struct cmdline *cl,
5524 __rte_unused void *data)
5526 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5528 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5529 if (!strcmp(res->value, "1.5"))
5530 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5531 else if (!strcmp(res->value, "2"))
5532 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5533 else if (!strcmp(res->value, "3"))
5534 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5535 else if (!strcmp(res->value, "4"))
5536 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5537 else if (!strcmp(res->value, "8"))
5538 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5539 else if (!strcmp(res->value, "16"))
5540 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5541 else if (!strcmp(res->value, "32"))
5542 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5544 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5548 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5551 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5554 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5555 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5556 timeout, "timeout");
5557 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5558 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5559 value, "0#1.5#2#3#4#8#16#32");
5561 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5562 .f = cmd_set_bypass_timeout_parsed,
5563 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5564 "Set the NIC bypass watchdog timeout in seconds",
5567 (void *)&cmd_setbypass_timeout_set,
5568 (void *)&cmd_setbypass_timeout_bypass,
5569 (void *)&cmd_setbypass_timeout_timeout,
5570 (void *)&cmd_setbypass_timeout_value,
5575 /* *** SHOW NIC BYPASS MODE *** */
5576 struct cmd_show_bypass_config_result {
5577 cmdline_fixed_string_t show;
5578 cmdline_fixed_string_t bypass;
5579 cmdline_fixed_string_t config;
5584 cmd_show_bypass_config_parsed(void *parsed_result,
5585 __rte_unused struct cmdline *cl,
5586 __rte_unused void *data)
5588 struct cmd_show_bypass_config_result *res = parsed_result;
5589 portid_t port_id = res->port_id;
5591 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5592 uint32_t event_mode;
5593 uint32_t bypass_mode;
5594 uint32_t timeout = bypass_timeout;
5597 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5598 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5599 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5600 {"UNKNOWN", "normal", "bypass", "isolate"};
5601 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5609 /* Display the bypass mode.*/
5610 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5611 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5615 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5616 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5618 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5621 /* Display the bypass timeout.*/
5622 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5623 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5625 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5627 /* Display the bypass events and associated modes. */
5628 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5630 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5631 printf("\tFailed to get bypass mode for event = %s\n",
5634 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5635 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5637 printf("\tbypass event: %-16s = %s\n", events[i],
5643 printf("\tFailed to get bypass configuration for port = %d\n",
5647 cmdline_parse_token_string_t cmd_showbypass_config_show =
5648 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5650 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5651 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5653 cmdline_parse_token_string_t cmd_showbypass_config_config =
5654 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5656 cmdline_parse_token_num_t cmd_showbypass_config_port =
5657 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5660 cmdline_parse_inst_t cmd_show_bypass_config = {
5661 .f = cmd_show_bypass_config_parsed,
5662 .help_str = "show bypass config <port_id>: "
5663 "Show the NIC bypass config for port_id",
5666 (void *)&cmd_showbypass_config_show,
5667 (void *)&cmd_showbypass_config_bypass,
5668 (void *)&cmd_showbypass_config_config,
5669 (void *)&cmd_showbypass_config_port,
5674 #ifdef RTE_LIBRTE_PMD_BOND
5675 /* *** SET BONDING MODE *** */
5676 struct cmd_set_bonding_mode_result {
5677 cmdline_fixed_string_t set;
5678 cmdline_fixed_string_t bonding;
5679 cmdline_fixed_string_t mode;
5684 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5685 __rte_unused struct cmdline *cl,
5686 __rte_unused void *data)
5688 struct cmd_set_bonding_mode_result *res = parsed_result;
5689 portid_t port_id = res->port_id;
5691 /* Set the bonding mode for the relevant port. */
5692 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5693 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5696 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5697 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5699 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5700 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5701 bonding, "bonding");
5702 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5703 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5705 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5706 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5708 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5709 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5712 cmdline_parse_inst_t cmd_set_bonding_mode = {
5713 .f = cmd_set_bonding_mode_parsed,
5714 .help_str = "set bonding mode <mode_value> <port_id>: "
5715 "Set the bonding mode for port_id",
5718 (void *) &cmd_setbonding_mode_set,
5719 (void *) &cmd_setbonding_mode_bonding,
5720 (void *) &cmd_setbonding_mode_mode,
5721 (void *) &cmd_setbonding_mode_value,
5722 (void *) &cmd_setbonding_mode_port,
5727 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5728 struct cmd_set_bonding_lacp_dedicated_queues_result {
5729 cmdline_fixed_string_t set;
5730 cmdline_fixed_string_t bonding;
5731 cmdline_fixed_string_t lacp;
5732 cmdline_fixed_string_t dedicated_queues;
5734 cmdline_fixed_string_t mode;
5737 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5738 __rte_unused struct cmdline *cl,
5739 __rte_unused void *data)
5741 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5742 portid_t port_id = res->port_id;
5743 struct rte_port *port;
5745 port = &ports[port_id];
5747 /** Check if the port is not started **/
5748 if (port->port_status != RTE_PORT_STOPPED) {
5749 printf("Please stop port %d first\n", port_id);
5753 if (!strcmp(res->mode, "enable")) {
5754 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5755 printf("Dedicate queues for LACP control packets"
5758 printf("Enabling dedicate queues for LACP control "
5759 "packets on port %d failed\n", port_id);
5760 } else if (!strcmp(res->mode, "disable")) {
5761 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5762 printf("Dedicated queues for LACP control packets "
5765 printf("Disabling dedicated queues for LACP control "
5766 "traffic on port %d failed\n", port_id);
5770 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5771 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5773 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5774 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5775 bonding, "bonding");
5776 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5777 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5779 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5780 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5781 dedicated_queues, "dedicated_queues");
5782 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5783 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5785 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5786 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5787 mode, "enable#disable");
5789 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5790 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5791 .help_str = "set bonding lacp dedicated_queues <port_id> "
5793 "Enable/disable dedicated queues for LACP control traffic for port_id",
5796 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5797 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5798 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5799 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5800 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5801 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5806 /* *** SET BALANCE XMIT POLICY *** */
5807 struct cmd_set_bonding_balance_xmit_policy_result {
5808 cmdline_fixed_string_t set;
5809 cmdline_fixed_string_t bonding;
5810 cmdline_fixed_string_t balance_xmit_policy;
5812 cmdline_fixed_string_t policy;
5815 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5816 __rte_unused struct cmdline *cl,
5817 __rte_unused void *data)
5819 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5820 portid_t port_id = res->port_id;
5823 if (!strcmp(res->policy, "l2")) {
5824 policy = BALANCE_XMIT_POLICY_LAYER2;
5825 } else if (!strcmp(res->policy, "l23")) {
5826 policy = BALANCE_XMIT_POLICY_LAYER23;
5827 } else if (!strcmp(res->policy, "l34")) {
5828 policy = BALANCE_XMIT_POLICY_LAYER34;
5830 printf("\t Invalid xmit policy selection");
5834 /* Set the bonding mode for the relevant port. */
5835 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5836 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5841 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5842 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5844 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5845 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5846 bonding, "bonding");
5847 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5848 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5849 balance_xmit_policy, "balance_xmit_policy");
5850 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5851 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5853 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5854 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5855 policy, "l2#l23#l34");
5857 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5858 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5859 .help_str = "set bonding balance_xmit_policy <port_id> "
5861 "Set the bonding balance_xmit_policy for port_id",
5864 (void *)&cmd_setbonding_balance_xmit_policy_set,
5865 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5866 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5867 (void *)&cmd_setbonding_balance_xmit_policy_port,
5868 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5873 /* *** SHOW NIC BONDING CONFIGURATION *** */
5874 struct cmd_show_bonding_config_result {
5875 cmdline_fixed_string_t show;
5876 cmdline_fixed_string_t bonding;
5877 cmdline_fixed_string_t config;
5881 static void cmd_show_bonding_config_parsed(void *parsed_result,
5882 __rte_unused struct cmdline *cl,
5883 __rte_unused void *data)
5885 struct cmd_show_bonding_config_result *res = parsed_result;
5886 int bonding_mode, agg_mode;
5887 portid_t slaves[RTE_MAX_ETHPORTS];
5888 int num_slaves, num_active_slaves;
5891 portid_t port_id = res->port_id;
5893 /* Display the bonding mode.*/
5894 bonding_mode = rte_eth_bond_mode_get(port_id);
5895 if (bonding_mode < 0) {
5896 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5899 printf("\tBonding mode: %d\n", bonding_mode);
5901 if (bonding_mode == BONDING_MODE_BALANCE) {
5902 int balance_xmit_policy;
5904 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5905 if (balance_xmit_policy < 0) {
5906 printf("\tFailed to get balance xmit policy for port = %d\n",
5910 printf("\tBalance Xmit Policy: ");
5912 switch (balance_xmit_policy) {
5913 case BALANCE_XMIT_POLICY_LAYER2:
5914 printf("BALANCE_XMIT_POLICY_LAYER2");
5916 case BALANCE_XMIT_POLICY_LAYER23:
5917 printf("BALANCE_XMIT_POLICY_LAYER23");
5919 case BALANCE_XMIT_POLICY_LAYER34:
5920 printf("BALANCE_XMIT_POLICY_LAYER34");
5927 if (bonding_mode == BONDING_MODE_8023AD) {
5928 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5929 printf("\tIEEE802.3AD Aggregator Mode: ");
5932 printf("bandwidth");
5944 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5946 if (num_slaves < 0) {
5947 printf("\tFailed to get slave list for port = %d\n", port_id);
5950 if (num_slaves > 0) {
5951 printf("\tSlaves (%d): [", num_slaves);
5952 for (i = 0; i < num_slaves - 1; i++)
5953 printf("%d ", slaves[i]);
5955 printf("%d]\n", slaves[num_slaves - 1]);
5957 printf("\tSlaves: []\n");
5961 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5964 if (num_active_slaves < 0) {
5965 printf("\tFailed to get active slave list for port = %d\n", port_id);
5968 if (num_active_slaves > 0) {
5969 printf("\tActive Slaves (%d): [", num_active_slaves);
5970 for (i = 0; i < num_active_slaves - 1; i++)
5971 printf("%d ", slaves[i]);
5973 printf("%d]\n", slaves[num_active_slaves - 1]);
5976 printf("\tActive Slaves: []\n");
5980 primary_id = rte_eth_bond_primary_get(port_id);
5981 if (primary_id < 0) {
5982 printf("\tFailed to get primary slave for port = %d\n", port_id);
5985 printf("\tPrimary: [%d]\n", primary_id);
5989 cmdline_parse_token_string_t cmd_showbonding_config_show =
5990 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5992 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5993 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5994 bonding, "bonding");
5995 cmdline_parse_token_string_t cmd_showbonding_config_config =
5996 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5998 cmdline_parse_token_num_t cmd_showbonding_config_port =
5999 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6002 cmdline_parse_inst_t cmd_show_bonding_config = {
6003 .f = cmd_show_bonding_config_parsed,
6004 .help_str = "show bonding config <port_id>: "
6005 "Show the bonding config for port_id",
6008 (void *)&cmd_showbonding_config_show,
6009 (void *)&cmd_showbonding_config_bonding,
6010 (void *)&cmd_showbonding_config_config,
6011 (void *)&cmd_showbonding_config_port,
6016 /* *** SET BONDING PRIMARY *** */
6017 struct cmd_set_bonding_primary_result {
6018 cmdline_fixed_string_t set;
6019 cmdline_fixed_string_t bonding;
6020 cmdline_fixed_string_t primary;
6025 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6026 __rte_unused struct cmdline *cl,
6027 __rte_unused void *data)
6029 struct cmd_set_bonding_primary_result *res = parsed_result;
6030 portid_t master_port_id = res->port_id;
6031 portid_t slave_port_id = res->slave_id;
6033 /* Set the primary slave for a bonded device. */
6034 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6035 printf("\t Failed to set primary slave for port = %d.\n",
6042 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6043 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6045 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6046 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6047 bonding, "bonding");
6048 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6049 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6050 primary, "primary");
6051 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6052 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6054 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6055 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6058 cmdline_parse_inst_t cmd_set_bonding_primary = {
6059 .f = cmd_set_bonding_primary_parsed,
6060 .help_str = "set bonding primary <slave_id> <port_id>: "
6061 "Set the primary slave for port_id",
6064 (void *)&cmd_setbonding_primary_set,
6065 (void *)&cmd_setbonding_primary_bonding,
6066 (void *)&cmd_setbonding_primary_primary,
6067 (void *)&cmd_setbonding_primary_slave,
6068 (void *)&cmd_setbonding_primary_port,
6073 /* *** ADD SLAVE *** */
6074 struct cmd_add_bonding_slave_result {
6075 cmdline_fixed_string_t add;
6076 cmdline_fixed_string_t bonding;
6077 cmdline_fixed_string_t slave;
6082 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6083 __rte_unused struct cmdline *cl,
6084 __rte_unused void *data)
6086 struct cmd_add_bonding_slave_result *res = parsed_result;
6087 portid_t master_port_id = res->port_id;
6088 portid_t slave_port_id = res->slave_id;
6090 /* add the slave for a bonded device. */
6091 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6092 printf("\t Failed to add slave %d to master port = %d.\n",
6093 slave_port_id, master_port_id);
6097 set_port_slave_flag(slave_port_id);
6100 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6101 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6103 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6104 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6105 bonding, "bonding");
6106 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6107 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6109 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6110 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6112 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6113 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6116 cmdline_parse_inst_t cmd_add_bonding_slave = {
6117 .f = cmd_add_bonding_slave_parsed,
6118 .help_str = "add bonding slave <slave_id> <port_id>: "
6119 "Add a slave device to a bonded device",
6122 (void *)&cmd_addbonding_slave_add,
6123 (void *)&cmd_addbonding_slave_bonding,
6124 (void *)&cmd_addbonding_slave_slave,
6125 (void *)&cmd_addbonding_slave_slaveid,
6126 (void *)&cmd_addbonding_slave_port,
6131 /* *** REMOVE SLAVE *** */
6132 struct cmd_remove_bonding_slave_result {
6133 cmdline_fixed_string_t remove;
6134 cmdline_fixed_string_t bonding;
6135 cmdline_fixed_string_t slave;
6140 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6141 __rte_unused struct cmdline *cl,
6142 __rte_unused void *data)
6144 struct cmd_remove_bonding_slave_result *res = parsed_result;
6145 portid_t master_port_id = res->port_id;
6146 portid_t slave_port_id = res->slave_id;
6148 /* remove the slave from a bonded device. */
6149 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6150 printf("\t Failed to remove slave %d from master port = %d.\n",
6151 slave_port_id, master_port_id);
6155 clear_port_slave_flag(slave_port_id);
6158 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6159 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6161 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6162 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6163 bonding, "bonding");
6164 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6165 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6167 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6168 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6170 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6171 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6174 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6175 .f = cmd_remove_bonding_slave_parsed,
6176 .help_str = "remove bonding slave <slave_id> <port_id>: "
6177 "Remove a slave device from a bonded device",
6180 (void *)&cmd_removebonding_slave_remove,
6181 (void *)&cmd_removebonding_slave_bonding,
6182 (void *)&cmd_removebonding_slave_slave,
6183 (void *)&cmd_removebonding_slave_slaveid,
6184 (void *)&cmd_removebonding_slave_port,
6189 /* *** CREATE BONDED DEVICE *** */
6190 struct cmd_create_bonded_device_result {
6191 cmdline_fixed_string_t create;
6192 cmdline_fixed_string_t bonded;
6193 cmdline_fixed_string_t device;
6198 static int bond_dev_num = 0;
6200 static void cmd_create_bonded_device_parsed(void *parsed_result,
6201 __rte_unused struct cmdline *cl,
6202 __rte_unused void *data)
6204 struct cmd_create_bonded_device_result *res = parsed_result;
6205 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6209 if (test_done == 0) {
6210 printf("Please stop forwarding first\n");
6214 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6217 /* Create a new bonded device. */
6218 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6220 printf("\t Failed to create bonded device.\n");
6223 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6226 /* Update number of ports */
6227 nb_ports = rte_eth_dev_count_avail();
6228 reconfig(port_id, res->socket);
6229 ret = rte_eth_promiscuous_enable(port_id);
6231 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6232 port_id, rte_strerror(-ret));
6234 ports[port_id].need_setup = 0;
6235 ports[port_id].port_status = RTE_PORT_STOPPED;
6240 cmdline_parse_token_string_t cmd_createbonded_device_create =
6241 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6243 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6244 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6246 cmdline_parse_token_string_t cmd_createbonded_device_device =
6247 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6249 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6250 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6252 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6253 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6256 cmdline_parse_inst_t cmd_create_bonded_device = {
6257 .f = cmd_create_bonded_device_parsed,
6258 .help_str = "create bonded device <mode> <socket>: "
6259 "Create a new bonded device with specific bonding mode and socket",
6262 (void *)&cmd_createbonded_device_create,
6263 (void *)&cmd_createbonded_device_bonded,
6264 (void *)&cmd_createbonded_device_device,
6265 (void *)&cmd_createbonded_device_mode,
6266 (void *)&cmd_createbonded_device_socket,
6271 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6272 struct cmd_set_bond_mac_addr_result {
6273 cmdline_fixed_string_t set;
6274 cmdline_fixed_string_t bonding;
6275 cmdline_fixed_string_t mac_addr;
6277 struct rte_ether_addr address;
6280 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6281 __rte_unused struct cmdline *cl,
6282 __rte_unused void *data)
6284 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6287 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6290 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6292 /* check the return value and print it if is < 0 */
6294 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6297 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6298 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6299 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6300 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6302 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6303 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6305 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6306 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6308 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6309 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6311 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6312 .f = cmd_set_bond_mac_addr_parsed,
6314 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6316 (void *)&cmd_set_bond_mac_addr_set,
6317 (void *)&cmd_set_bond_mac_addr_bonding,
6318 (void *)&cmd_set_bond_mac_addr_mac,
6319 (void *)&cmd_set_bond_mac_addr_portnum,
6320 (void *)&cmd_set_bond_mac_addr_addr,
6326 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6327 struct cmd_set_bond_mon_period_result {
6328 cmdline_fixed_string_t set;
6329 cmdline_fixed_string_t bonding;
6330 cmdline_fixed_string_t mon_period;
6335 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6336 __rte_unused struct cmdline *cl,
6337 __rte_unused void *data)
6339 struct cmd_set_bond_mon_period_result *res = parsed_result;
6342 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6344 /* check the return value and print it if is < 0 */
6346 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6349 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6350 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6352 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6353 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6354 bonding, "bonding");
6355 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6356 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6357 mon_period, "mon_period");
6358 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6359 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6361 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6362 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6365 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6366 .f = cmd_set_bond_mon_period_parsed,
6368 .help_str = "set bonding mon_period <port_id> <period_ms>",
6370 (void *)&cmd_set_bond_mon_period_set,
6371 (void *)&cmd_set_bond_mon_period_bonding,
6372 (void *)&cmd_set_bond_mon_period_mon_period,
6373 (void *)&cmd_set_bond_mon_period_portnum,
6374 (void *)&cmd_set_bond_mon_period_period_ms,
6381 struct cmd_set_bonding_agg_mode_policy_result {
6382 cmdline_fixed_string_t set;
6383 cmdline_fixed_string_t bonding;
6384 cmdline_fixed_string_t agg_mode;
6386 cmdline_fixed_string_t policy;
6391 cmd_set_bonding_agg_mode(void *parsed_result,
6392 __rte_unused struct cmdline *cl,
6393 __rte_unused void *data)
6395 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6396 uint8_t policy = AGG_BANDWIDTH;
6398 if (!strcmp(res->policy, "bandwidth"))
6399 policy = AGG_BANDWIDTH;
6400 else if (!strcmp(res->policy, "stable"))
6401 policy = AGG_STABLE;
6402 else if (!strcmp(res->policy, "count"))
6405 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6409 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6410 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6412 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6413 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6414 bonding, "bonding");
6416 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6417 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6418 agg_mode, "agg_mode");
6420 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6421 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6424 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6425 TOKEN_STRING_INITIALIZER(
6426 struct cmd_set_bonding_balance_xmit_policy_result,
6427 policy, "stable#bandwidth#count");
6429 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6430 .f = cmd_set_bonding_agg_mode,
6432 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6434 (void *)&cmd_set_bonding_agg_mode_set,
6435 (void *)&cmd_set_bonding_agg_mode_bonding,
6436 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6437 (void *)&cmd_set_bonding_agg_mode_portnum,
6438 (void *)&cmd_set_bonding_agg_mode_policy_string,
6444 #endif /* RTE_LIBRTE_PMD_BOND */
6446 /* *** SET FORWARDING MODE *** */
6447 struct cmd_set_fwd_mode_result {
6448 cmdline_fixed_string_t set;
6449 cmdline_fixed_string_t fwd;
6450 cmdline_fixed_string_t mode;
6453 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6454 __rte_unused struct cmdline *cl,
6455 __rte_unused void *data)
6457 struct cmd_set_fwd_mode_result *res = parsed_result;
6460 set_pkt_forwarding_mode(res->mode);
6463 cmdline_parse_token_string_t cmd_setfwd_set =
6464 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6465 cmdline_parse_token_string_t cmd_setfwd_fwd =
6466 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6467 cmdline_parse_token_string_t cmd_setfwd_mode =
6468 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6469 "" /* defined at init */);
6471 cmdline_parse_inst_t cmd_set_fwd_mode = {
6472 .f = cmd_set_fwd_mode_parsed,
6474 .help_str = NULL, /* defined at init */
6476 (void *)&cmd_setfwd_set,
6477 (void *)&cmd_setfwd_fwd,
6478 (void *)&cmd_setfwd_mode,
6483 static void cmd_set_fwd_mode_init(void)
6486 static char token[128];
6487 static char help[256];
6488 cmdline_parse_token_string_t *token_struct;
6490 modes = list_pkt_forwarding_modes();
6491 snprintf(help, sizeof(help), "set fwd %s: "
6492 "Set packet forwarding mode", modes);
6493 cmd_set_fwd_mode.help_str = help;
6495 /* string token separator is # */
6496 for (c = token; *modes != '\0'; modes++)
6501 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6502 token_struct->string_data.str = token;
6505 /* *** SET RETRY FORWARDING MODE *** */
6506 struct cmd_set_fwd_retry_mode_result {
6507 cmdline_fixed_string_t set;
6508 cmdline_fixed_string_t fwd;
6509 cmdline_fixed_string_t mode;
6510 cmdline_fixed_string_t retry;
6513 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6514 __rte_unused struct cmdline *cl,
6515 __rte_unused void *data)
6517 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6520 set_pkt_forwarding_mode(res->mode);
6523 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6524 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6526 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6527 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6529 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6530 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6532 "" /* defined at init */);
6533 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6534 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6537 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6538 .f = cmd_set_fwd_retry_mode_parsed,
6540 .help_str = NULL, /* defined at init */
6542 (void *)&cmd_setfwd_retry_set,
6543 (void *)&cmd_setfwd_retry_fwd,
6544 (void *)&cmd_setfwd_retry_mode,
6545 (void *)&cmd_setfwd_retry_retry,
6550 static void cmd_set_fwd_retry_mode_init(void)
6553 static char token[128];
6554 static char help[256];
6555 cmdline_parse_token_string_t *token_struct;
6557 modes = list_pkt_forwarding_retry_modes();
6558 snprintf(help, sizeof(help), "set fwd %s retry: "
6559 "Set packet forwarding mode with retry", modes);
6560 cmd_set_fwd_retry_mode.help_str = help;
6562 /* string token separator is # */
6563 for (c = token; *modes != '\0'; modes++)
6568 token_struct = (cmdline_parse_token_string_t *)
6569 cmd_set_fwd_retry_mode.tokens[2];
6570 token_struct->string_data.str = token;
6573 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6574 struct cmd_set_burst_tx_retry_result {
6575 cmdline_fixed_string_t set;
6576 cmdline_fixed_string_t burst;
6577 cmdline_fixed_string_t tx;
6578 cmdline_fixed_string_t delay;
6580 cmdline_fixed_string_t retry;
6584 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6585 __rte_unused struct cmdline *cl,
6586 __rte_unused void *data)
6588 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6590 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6591 && !strcmp(res->tx, "tx")) {
6592 if (!strcmp(res->delay, "delay"))
6593 burst_tx_delay_time = res->time;
6594 if (!strcmp(res->retry, "retry"))
6595 burst_tx_retry_num = res->retry_num;
6600 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6601 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6602 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6603 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6605 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6606 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6607 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6608 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6609 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6610 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6611 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6612 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6613 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6614 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6616 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6617 .f = cmd_set_burst_tx_retry_parsed,
6618 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6620 (void *)&cmd_set_burst_tx_retry_set,
6621 (void *)&cmd_set_burst_tx_retry_burst,
6622 (void *)&cmd_set_burst_tx_retry_tx,
6623 (void *)&cmd_set_burst_tx_retry_delay,
6624 (void *)&cmd_set_burst_tx_retry_time,
6625 (void *)&cmd_set_burst_tx_retry_retry,
6626 (void *)&cmd_set_burst_tx_retry_retry_num,
6631 /* *** SET PROMISC MODE *** */
6632 struct cmd_set_promisc_mode_result {
6633 cmdline_fixed_string_t set;
6634 cmdline_fixed_string_t promisc;
6635 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6636 uint16_t port_num; /* valid if "allports" argument == 0 */
6637 cmdline_fixed_string_t mode;
6640 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6641 __rte_unused struct cmdline *cl,
6644 struct cmd_set_promisc_mode_result *res = parsed_result;
6648 if (!strcmp(res->mode, "on"))
6655 RTE_ETH_FOREACH_DEV(i)
6656 eth_set_promisc_mode(i, enable);
6658 eth_set_promisc_mode(res->port_num, enable);
6662 cmdline_parse_token_string_t cmd_setpromisc_set =
6663 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6664 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6665 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6667 cmdline_parse_token_string_t cmd_setpromisc_portall =
6668 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6670 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6671 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6673 cmdline_parse_token_string_t cmd_setpromisc_mode =
6674 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6677 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6678 .f = cmd_set_promisc_mode_parsed,
6680 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6682 (void *)&cmd_setpromisc_set,
6683 (void *)&cmd_setpromisc_promisc,
6684 (void *)&cmd_setpromisc_portall,
6685 (void *)&cmd_setpromisc_mode,
6690 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6691 .f = cmd_set_promisc_mode_parsed,
6693 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6695 (void *)&cmd_setpromisc_set,
6696 (void *)&cmd_setpromisc_promisc,
6697 (void *)&cmd_setpromisc_portnum,
6698 (void *)&cmd_setpromisc_mode,
6703 /* *** SET ALLMULTI MODE *** */
6704 struct cmd_set_allmulti_mode_result {
6705 cmdline_fixed_string_t set;
6706 cmdline_fixed_string_t allmulti;
6707 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6708 uint16_t port_num; /* valid if "allports" argument == 0 */
6709 cmdline_fixed_string_t mode;
6712 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6713 __rte_unused struct cmdline *cl,
6716 struct cmd_set_allmulti_mode_result *res = parsed_result;
6720 if (!strcmp(res->mode, "on"))
6727 RTE_ETH_FOREACH_DEV(i) {
6728 eth_set_allmulticast_mode(i, enable);
6732 eth_set_allmulticast_mode(res->port_num, enable);
6736 cmdline_parse_token_string_t cmd_setallmulti_set =
6737 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6738 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6739 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6741 cmdline_parse_token_string_t cmd_setallmulti_portall =
6742 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6744 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6745 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6747 cmdline_parse_token_string_t cmd_setallmulti_mode =
6748 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6751 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6752 .f = cmd_set_allmulti_mode_parsed,
6754 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6756 (void *)&cmd_setallmulti_set,
6757 (void *)&cmd_setallmulti_allmulti,
6758 (void *)&cmd_setallmulti_portall,
6759 (void *)&cmd_setallmulti_mode,
6764 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6765 .f = cmd_set_allmulti_mode_parsed,
6767 .help_str = "set allmulti <port_id> on|off: "
6768 "Set allmulti mode on port_id",
6770 (void *)&cmd_setallmulti_set,
6771 (void *)&cmd_setallmulti_allmulti,
6772 (void *)&cmd_setallmulti_portnum,
6773 (void *)&cmd_setallmulti_mode,
6778 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6779 struct cmd_link_flow_ctrl_set_result {
6780 cmdline_fixed_string_t set;
6781 cmdline_fixed_string_t flow_ctrl;
6782 cmdline_fixed_string_t rx;
6783 cmdline_fixed_string_t rx_lfc_mode;
6784 cmdline_fixed_string_t tx;
6785 cmdline_fixed_string_t tx_lfc_mode;
6786 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6787 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6788 cmdline_fixed_string_t autoneg_str;
6789 cmdline_fixed_string_t autoneg;
6790 cmdline_fixed_string_t hw_str;
6791 uint32_t high_water;
6792 cmdline_fixed_string_t lw_str;
6794 cmdline_fixed_string_t pt_str;
6795 uint16_t pause_time;
6796 cmdline_fixed_string_t xon_str;
6801 cmdline_parse_token_string_t cmd_lfc_set_set =
6802 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6804 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6805 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6806 flow_ctrl, "flow_ctrl");
6807 cmdline_parse_token_string_t cmd_lfc_set_rx =
6808 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6810 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6811 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6812 rx_lfc_mode, "on#off");
6813 cmdline_parse_token_string_t cmd_lfc_set_tx =
6814 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6816 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6817 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6818 tx_lfc_mode, "on#off");
6819 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6820 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6821 hw_str, "high_water");
6822 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6823 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6824 high_water, UINT32);
6825 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6826 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6827 lw_str, "low_water");
6828 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6829 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6831 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6832 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6833 pt_str, "pause_time");
6834 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6835 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6836 pause_time, UINT16);
6837 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6838 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6839 xon_str, "send_xon");
6840 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6841 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6843 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6844 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6845 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6846 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6847 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6848 mac_ctrl_frame_fwd_mode, "on#off");
6849 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6850 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6851 autoneg_str, "autoneg");
6852 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6853 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6855 cmdline_parse_token_num_t cmd_lfc_set_portid =
6856 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6859 /* forward declaration */
6861 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6864 cmdline_parse_inst_t cmd_link_flow_control_set = {
6865 .f = cmd_link_flow_ctrl_set_parsed,
6867 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6868 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6869 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6871 (void *)&cmd_lfc_set_set,
6872 (void *)&cmd_lfc_set_flow_ctrl,
6873 (void *)&cmd_lfc_set_rx,
6874 (void *)&cmd_lfc_set_rx_mode,
6875 (void *)&cmd_lfc_set_tx,
6876 (void *)&cmd_lfc_set_tx_mode,
6877 (void *)&cmd_lfc_set_high_water,
6878 (void *)&cmd_lfc_set_low_water,
6879 (void *)&cmd_lfc_set_pause_time,
6880 (void *)&cmd_lfc_set_send_xon,
6881 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6882 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6883 (void *)&cmd_lfc_set_autoneg_str,
6884 (void *)&cmd_lfc_set_autoneg,
6885 (void *)&cmd_lfc_set_portid,
6890 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6891 .f = cmd_link_flow_ctrl_set_parsed,
6892 .data = (void *)&cmd_link_flow_control_set_rx,
6893 .help_str = "set flow_ctrl rx on|off <port_id>: "
6894 "Change rx flow control parameter",
6896 (void *)&cmd_lfc_set_set,
6897 (void *)&cmd_lfc_set_flow_ctrl,
6898 (void *)&cmd_lfc_set_rx,
6899 (void *)&cmd_lfc_set_rx_mode,
6900 (void *)&cmd_lfc_set_portid,
6905 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6906 .f = cmd_link_flow_ctrl_set_parsed,
6907 .data = (void *)&cmd_link_flow_control_set_tx,
6908 .help_str = "set flow_ctrl tx on|off <port_id>: "
6909 "Change tx flow control parameter",
6911 (void *)&cmd_lfc_set_set,
6912 (void *)&cmd_lfc_set_flow_ctrl,
6913 (void *)&cmd_lfc_set_tx,
6914 (void *)&cmd_lfc_set_tx_mode,
6915 (void *)&cmd_lfc_set_portid,
6920 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6921 .f = cmd_link_flow_ctrl_set_parsed,
6922 .data = (void *)&cmd_link_flow_control_set_hw,
6923 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6924 "Change high water flow control parameter",
6926 (void *)&cmd_lfc_set_set,
6927 (void *)&cmd_lfc_set_flow_ctrl,
6928 (void *)&cmd_lfc_set_high_water_str,
6929 (void *)&cmd_lfc_set_high_water,
6930 (void *)&cmd_lfc_set_portid,
6935 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6936 .f = cmd_link_flow_ctrl_set_parsed,
6937 .data = (void *)&cmd_link_flow_control_set_lw,
6938 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6939 "Change low water flow control parameter",
6941 (void *)&cmd_lfc_set_set,
6942 (void *)&cmd_lfc_set_flow_ctrl,
6943 (void *)&cmd_lfc_set_low_water_str,
6944 (void *)&cmd_lfc_set_low_water,
6945 (void *)&cmd_lfc_set_portid,
6950 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6951 .f = cmd_link_flow_ctrl_set_parsed,
6952 .data = (void *)&cmd_link_flow_control_set_pt,
6953 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6954 "Change pause time flow control parameter",
6956 (void *)&cmd_lfc_set_set,
6957 (void *)&cmd_lfc_set_flow_ctrl,
6958 (void *)&cmd_lfc_set_pause_time_str,
6959 (void *)&cmd_lfc_set_pause_time,
6960 (void *)&cmd_lfc_set_portid,
6965 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6966 .f = cmd_link_flow_ctrl_set_parsed,
6967 .data = (void *)&cmd_link_flow_control_set_xon,
6968 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6969 "Change send_xon flow control parameter",
6971 (void *)&cmd_lfc_set_set,
6972 (void *)&cmd_lfc_set_flow_ctrl,
6973 (void *)&cmd_lfc_set_send_xon_str,
6974 (void *)&cmd_lfc_set_send_xon,
6975 (void *)&cmd_lfc_set_portid,
6980 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6981 .f = cmd_link_flow_ctrl_set_parsed,
6982 .data = (void *)&cmd_link_flow_control_set_macfwd,
6983 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6984 "Change mac ctrl fwd flow control parameter",
6986 (void *)&cmd_lfc_set_set,
6987 (void *)&cmd_lfc_set_flow_ctrl,
6988 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6989 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6990 (void *)&cmd_lfc_set_portid,
6995 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6996 .f = cmd_link_flow_ctrl_set_parsed,
6997 .data = (void *)&cmd_link_flow_control_set_autoneg,
6998 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6999 "Change autoneg flow control parameter",
7001 (void *)&cmd_lfc_set_set,
7002 (void *)&cmd_lfc_set_flow_ctrl,
7003 (void *)&cmd_lfc_set_autoneg_str,
7004 (void *)&cmd_lfc_set_autoneg,
7005 (void *)&cmd_lfc_set_portid,
7011 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7012 __rte_unused struct cmdline *cl,
7015 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7016 cmdline_parse_inst_t *cmd = data;
7017 struct rte_eth_fc_conf fc_conf;
7023 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7024 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7025 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7026 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7028 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7029 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7032 /* Partial command line, retrieve current configuration */
7034 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7036 printf("cannot get current flow ctrl parameters, return"
7037 "code = %d\n", ret);
7041 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7042 (fc_conf.mode == RTE_FC_FULL))
7044 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7045 (fc_conf.mode == RTE_FC_FULL))
7049 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7050 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7052 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7053 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7055 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7057 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7058 fc_conf.high_water = res->high_water;
7060 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7061 fc_conf.low_water = res->low_water;
7063 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7064 fc_conf.pause_time = res->pause_time;
7066 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7067 fc_conf.send_xon = res->send_xon;
7069 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7070 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7071 fc_conf.mac_ctrl_frame_fwd = 1;
7073 fc_conf.mac_ctrl_frame_fwd = 0;
7076 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7077 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7079 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7081 printf("bad flow contrl parameter, return code = %d \n", ret);
7084 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7085 struct cmd_priority_flow_ctrl_set_result {
7086 cmdline_fixed_string_t set;
7087 cmdline_fixed_string_t pfc_ctrl;
7088 cmdline_fixed_string_t rx;
7089 cmdline_fixed_string_t rx_pfc_mode;
7090 cmdline_fixed_string_t tx;
7091 cmdline_fixed_string_t tx_pfc_mode;
7092 uint32_t high_water;
7094 uint16_t pause_time;
7100 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7101 __rte_unused struct cmdline *cl,
7102 __rte_unused void *data)
7104 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7105 struct rte_eth_pfc_conf pfc_conf;
7106 int rx_fc_enable, tx_fc_enable;
7110 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7111 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7112 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7113 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7115 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7116 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7119 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7120 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7121 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7122 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7123 pfc_conf.fc.high_water = res->high_water;
7124 pfc_conf.fc.low_water = res->low_water;
7125 pfc_conf.fc.pause_time = res->pause_time;
7126 pfc_conf.priority = res->priority;
7128 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7130 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7133 cmdline_parse_token_string_t cmd_pfc_set_set =
7134 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7136 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7137 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7138 pfc_ctrl, "pfc_ctrl");
7139 cmdline_parse_token_string_t cmd_pfc_set_rx =
7140 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7142 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7143 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7144 rx_pfc_mode, "on#off");
7145 cmdline_parse_token_string_t cmd_pfc_set_tx =
7146 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7148 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7149 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7150 tx_pfc_mode, "on#off");
7151 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7152 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7153 high_water, UINT32);
7154 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7155 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7157 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7158 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7159 pause_time, UINT16);
7160 cmdline_parse_token_num_t cmd_pfc_set_priority =
7161 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7163 cmdline_parse_token_num_t cmd_pfc_set_portid =
7164 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7167 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7168 .f = cmd_priority_flow_ctrl_set_parsed,
7170 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7171 "<pause_time> <priority> <port_id>: "
7172 "Configure the Ethernet priority flow control",
7174 (void *)&cmd_pfc_set_set,
7175 (void *)&cmd_pfc_set_flow_ctrl,
7176 (void *)&cmd_pfc_set_rx,
7177 (void *)&cmd_pfc_set_rx_mode,
7178 (void *)&cmd_pfc_set_tx,
7179 (void *)&cmd_pfc_set_tx_mode,
7180 (void *)&cmd_pfc_set_high_water,
7181 (void *)&cmd_pfc_set_low_water,
7182 (void *)&cmd_pfc_set_pause_time,
7183 (void *)&cmd_pfc_set_priority,
7184 (void *)&cmd_pfc_set_portid,
7189 /* *** RESET CONFIGURATION *** */
7190 struct cmd_reset_result {
7191 cmdline_fixed_string_t reset;
7192 cmdline_fixed_string_t def;
7195 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7197 __rte_unused void *data)
7199 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7200 set_def_fwd_config();
7203 cmdline_parse_token_string_t cmd_reset_set =
7204 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7205 cmdline_parse_token_string_t cmd_reset_def =
7206 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7209 cmdline_parse_inst_t cmd_reset = {
7210 .f = cmd_reset_parsed,
7212 .help_str = "set default: Reset default forwarding configuration",
7214 (void *)&cmd_reset_set,
7215 (void *)&cmd_reset_def,
7220 /* *** START FORWARDING *** */
7221 struct cmd_start_result {
7222 cmdline_fixed_string_t start;
7225 cmdline_parse_token_string_t cmd_start_start =
7226 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7228 static void cmd_start_parsed(__rte_unused void *parsed_result,
7229 __rte_unused struct cmdline *cl,
7230 __rte_unused void *data)
7232 start_packet_forwarding(0);
7235 cmdline_parse_inst_t cmd_start = {
7236 .f = cmd_start_parsed,
7238 .help_str = "start: Start packet forwarding",
7240 (void *)&cmd_start_start,
7245 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7246 struct cmd_start_tx_first_result {
7247 cmdline_fixed_string_t start;
7248 cmdline_fixed_string_t tx_first;
7252 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7253 __rte_unused struct cmdline *cl,
7254 __rte_unused void *data)
7256 start_packet_forwarding(1);
7259 cmdline_parse_token_string_t cmd_start_tx_first_start =
7260 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7262 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7263 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7264 tx_first, "tx_first");
7266 cmdline_parse_inst_t cmd_start_tx_first = {
7267 .f = cmd_start_tx_first_parsed,
7269 .help_str = "start tx_first: Start packet forwarding, "
7270 "after sending 1 burst of packets",
7272 (void *)&cmd_start_tx_first_start,
7273 (void *)&cmd_start_tx_first_tx_first,
7278 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7279 struct cmd_start_tx_first_n_result {
7280 cmdline_fixed_string_t start;
7281 cmdline_fixed_string_t tx_first;
7286 cmd_start_tx_first_n_parsed(void *parsed_result,
7287 __rte_unused struct cmdline *cl,
7288 __rte_unused void *data)
7290 struct cmd_start_tx_first_n_result *res = parsed_result;
7292 start_packet_forwarding(res->tx_num);
7295 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7296 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7298 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7299 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7300 tx_first, "tx_first");
7301 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7302 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7305 cmdline_parse_inst_t cmd_start_tx_first_n = {
7306 .f = cmd_start_tx_first_n_parsed,
7308 .help_str = "start tx_first <num>: "
7309 "packet forwarding, after sending <num> bursts of packets",
7311 (void *)&cmd_start_tx_first_n_start,
7312 (void *)&cmd_start_tx_first_n_tx_first,
7313 (void *)&cmd_start_tx_first_n_tx_num,
7318 /* *** SET LINK UP *** */
7319 struct cmd_set_link_up_result {
7320 cmdline_fixed_string_t set;
7321 cmdline_fixed_string_t link_up;
7322 cmdline_fixed_string_t port;
7326 cmdline_parse_token_string_t cmd_set_link_up_set =
7327 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7328 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7329 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7331 cmdline_parse_token_string_t cmd_set_link_up_port =
7332 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7333 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7334 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7336 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7337 __rte_unused struct cmdline *cl,
7338 __rte_unused void *data)
7340 struct cmd_set_link_up_result *res = parsed_result;
7341 dev_set_link_up(res->port_id);
7344 cmdline_parse_inst_t cmd_set_link_up = {
7345 .f = cmd_set_link_up_parsed,
7347 .help_str = "set link-up port <port id>",
7349 (void *)&cmd_set_link_up_set,
7350 (void *)&cmd_set_link_up_link_up,
7351 (void *)&cmd_set_link_up_port,
7352 (void *)&cmd_set_link_up_port_id,
7357 /* *** SET LINK DOWN *** */
7358 struct cmd_set_link_down_result {
7359 cmdline_fixed_string_t set;
7360 cmdline_fixed_string_t link_down;
7361 cmdline_fixed_string_t port;
7365 cmdline_parse_token_string_t cmd_set_link_down_set =
7366 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7367 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7368 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7370 cmdline_parse_token_string_t cmd_set_link_down_port =
7371 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7372 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7373 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7375 static void cmd_set_link_down_parsed(
7376 __rte_unused void *parsed_result,
7377 __rte_unused struct cmdline *cl,
7378 __rte_unused void *data)
7380 struct cmd_set_link_down_result *res = parsed_result;
7381 dev_set_link_down(res->port_id);
7384 cmdline_parse_inst_t cmd_set_link_down = {
7385 .f = cmd_set_link_down_parsed,
7387 .help_str = "set link-down port <port id>",
7389 (void *)&cmd_set_link_down_set,
7390 (void *)&cmd_set_link_down_link_down,
7391 (void *)&cmd_set_link_down_port,
7392 (void *)&cmd_set_link_down_port_id,
7397 /* *** SHOW CFG *** */
7398 struct cmd_showcfg_result {
7399 cmdline_fixed_string_t show;
7400 cmdline_fixed_string_t cfg;
7401 cmdline_fixed_string_t what;
7404 static void cmd_showcfg_parsed(void *parsed_result,
7405 __rte_unused struct cmdline *cl,
7406 __rte_unused void *data)
7408 struct cmd_showcfg_result *res = parsed_result;
7409 if (!strcmp(res->what, "rxtx"))
7410 rxtx_config_display();
7411 else if (!strcmp(res->what, "cores"))
7412 fwd_lcores_config_display();
7413 else if (!strcmp(res->what, "fwd"))
7414 pkt_fwd_config_display(&cur_fwd_config);
7415 else if (!strcmp(res->what, "txpkts"))
7416 show_tx_pkt_segments();
7419 cmdline_parse_token_string_t cmd_showcfg_show =
7420 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7421 cmdline_parse_token_string_t cmd_showcfg_port =
7422 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7423 cmdline_parse_token_string_t cmd_showcfg_what =
7424 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7425 "rxtx#cores#fwd#txpkts");
7427 cmdline_parse_inst_t cmd_showcfg = {
7428 .f = cmd_showcfg_parsed,
7430 .help_str = "show config rxtx|cores|fwd|txpkts",
7432 (void *)&cmd_showcfg_show,
7433 (void *)&cmd_showcfg_port,
7434 (void *)&cmd_showcfg_what,
7439 /* *** SHOW ALL PORT INFO *** */
7440 struct cmd_showportall_result {
7441 cmdline_fixed_string_t show;
7442 cmdline_fixed_string_t port;
7443 cmdline_fixed_string_t what;
7444 cmdline_fixed_string_t all;
7447 static void cmd_showportall_parsed(void *parsed_result,
7448 __rte_unused struct cmdline *cl,
7449 __rte_unused void *data)
7453 struct cmd_showportall_result *res = parsed_result;
7454 if (!strcmp(res->show, "clear")) {
7455 if (!strcmp(res->what, "stats"))
7456 RTE_ETH_FOREACH_DEV(i)
7458 else if (!strcmp(res->what, "xstats"))
7459 RTE_ETH_FOREACH_DEV(i)
7460 nic_xstats_clear(i);
7461 } else if (!strcmp(res->what, "info"))
7462 RTE_ETH_FOREACH_DEV(i)
7463 port_infos_display(i);
7464 else if (!strcmp(res->what, "summary")) {
7465 port_summary_header_display();
7466 RTE_ETH_FOREACH_DEV(i)
7467 port_summary_display(i);
7469 else if (!strcmp(res->what, "stats"))
7470 RTE_ETH_FOREACH_DEV(i)
7471 nic_stats_display(i);
7472 else if (!strcmp(res->what, "xstats"))
7473 RTE_ETH_FOREACH_DEV(i)
7474 nic_xstats_display(i);
7475 else if (!strcmp(res->what, "fdir"))
7476 RTE_ETH_FOREACH_DEV(i)
7478 else if (!strcmp(res->what, "stat_qmap"))
7479 RTE_ETH_FOREACH_DEV(i)
7480 nic_stats_mapping_display(i);
7481 else if (!strcmp(res->what, "dcb_tc"))
7482 RTE_ETH_FOREACH_DEV(i)
7483 port_dcb_info_display(i);
7484 else if (!strcmp(res->what, "cap"))
7485 RTE_ETH_FOREACH_DEV(i)
7486 port_offload_cap_display(i);
7489 cmdline_parse_token_string_t cmd_showportall_show =
7490 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7492 cmdline_parse_token_string_t cmd_showportall_port =
7493 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7494 cmdline_parse_token_string_t cmd_showportall_what =
7495 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7496 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7497 cmdline_parse_token_string_t cmd_showportall_all =
7498 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7499 cmdline_parse_inst_t cmd_showportall = {
7500 .f = cmd_showportall_parsed,
7502 .help_str = "show|clear port "
7503 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7505 (void *)&cmd_showportall_show,
7506 (void *)&cmd_showportall_port,
7507 (void *)&cmd_showportall_what,
7508 (void *)&cmd_showportall_all,
7513 /* *** SHOW PORT INFO *** */
7514 struct cmd_showport_result {
7515 cmdline_fixed_string_t show;
7516 cmdline_fixed_string_t port;
7517 cmdline_fixed_string_t what;
7521 static void cmd_showport_parsed(void *parsed_result,
7522 __rte_unused struct cmdline *cl,
7523 __rte_unused void *data)
7525 struct cmd_showport_result *res = parsed_result;
7526 if (!strcmp(res->show, "clear")) {
7527 if (!strcmp(res->what, "stats"))
7528 nic_stats_clear(res->portnum);
7529 else if (!strcmp(res->what, "xstats"))
7530 nic_xstats_clear(res->portnum);
7531 } else if (!strcmp(res->what, "info"))
7532 port_infos_display(res->portnum);
7533 else if (!strcmp(res->what, "summary")) {
7534 port_summary_header_display();
7535 port_summary_display(res->portnum);
7537 else if (!strcmp(res->what, "stats"))
7538 nic_stats_display(res->portnum);
7539 else if (!strcmp(res->what, "xstats"))
7540 nic_xstats_display(res->portnum);
7541 else if (!strcmp(res->what, "fdir"))
7542 fdir_get_infos(res->portnum);
7543 else if (!strcmp(res->what, "stat_qmap"))
7544 nic_stats_mapping_display(res->portnum);
7545 else if (!strcmp(res->what, "dcb_tc"))
7546 port_dcb_info_display(res->portnum);
7547 else if (!strcmp(res->what, "cap"))
7548 port_offload_cap_display(res->portnum);
7551 cmdline_parse_token_string_t cmd_showport_show =
7552 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7554 cmdline_parse_token_string_t cmd_showport_port =
7555 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7556 cmdline_parse_token_string_t cmd_showport_what =
7557 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7558 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7559 cmdline_parse_token_num_t cmd_showport_portnum =
7560 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7562 cmdline_parse_inst_t cmd_showport = {
7563 .f = cmd_showport_parsed,
7565 .help_str = "show|clear port "
7566 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7569 (void *)&cmd_showport_show,
7570 (void *)&cmd_showport_port,
7571 (void *)&cmd_showport_what,
7572 (void *)&cmd_showport_portnum,
7577 /* *** SHOW DEVICE INFO *** */
7578 struct cmd_showdevice_result {
7579 cmdline_fixed_string_t show;
7580 cmdline_fixed_string_t device;
7581 cmdline_fixed_string_t what;
7582 cmdline_fixed_string_t identifier;
7585 static void cmd_showdevice_parsed(void *parsed_result,
7586 __rte_unused struct cmdline *cl,
7587 __rte_unused void *data)
7589 struct cmd_showdevice_result *res = parsed_result;
7590 if (!strcmp(res->what, "info")) {
7591 if (!strcmp(res->identifier, "all"))
7592 device_infos_display(NULL);
7594 device_infos_display(res->identifier);
7598 cmdline_parse_token_string_t cmd_showdevice_show =
7599 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7601 cmdline_parse_token_string_t cmd_showdevice_device =
7602 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7603 cmdline_parse_token_string_t cmd_showdevice_what =
7604 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7606 cmdline_parse_token_string_t cmd_showdevice_identifier =
7607 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7610 cmdline_parse_inst_t cmd_showdevice = {
7611 .f = cmd_showdevice_parsed,
7613 .help_str = "show device info <identifier>|all",
7615 (void *)&cmd_showdevice_show,
7616 (void *)&cmd_showdevice_device,
7617 (void *)&cmd_showdevice_what,
7618 (void *)&cmd_showdevice_identifier,
7622 /* *** SHOW QUEUE INFO *** */
7623 struct cmd_showqueue_result {
7624 cmdline_fixed_string_t show;
7625 cmdline_fixed_string_t type;
7626 cmdline_fixed_string_t what;
7632 cmd_showqueue_parsed(void *parsed_result,
7633 __rte_unused struct cmdline *cl,
7634 __rte_unused void *data)
7636 struct cmd_showqueue_result *res = parsed_result;
7638 if (!strcmp(res->type, "rxq"))
7639 rx_queue_infos_display(res->portnum, res->queuenum);
7640 else if (!strcmp(res->type, "txq"))
7641 tx_queue_infos_display(res->portnum, res->queuenum);
7644 cmdline_parse_token_string_t cmd_showqueue_show =
7645 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7646 cmdline_parse_token_string_t cmd_showqueue_type =
7647 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7648 cmdline_parse_token_string_t cmd_showqueue_what =
7649 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7650 cmdline_parse_token_num_t cmd_showqueue_portnum =
7651 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7652 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7653 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7655 cmdline_parse_inst_t cmd_showqueue = {
7656 .f = cmd_showqueue_parsed,
7658 .help_str = "show rxq|txq info <port_id> <queue_id>",
7660 (void *)&cmd_showqueue_show,
7661 (void *)&cmd_showqueue_type,
7662 (void *)&cmd_showqueue_what,
7663 (void *)&cmd_showqueue_portnum,
7664 (void *)&cmd_showqueue_queuenum,
7669 /* show/clear fwd engine statistics */
7671 cmdline_fixed_string_t action;
7672 cmdline_fixed_string_t fwd;
7673 cmdline_fixed_string_t stats;
7674 cmdline_fixed_string_t all;
7677 cmdline_parse_token_string_t cmd_fwd_action =
7678 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7679 cmdline_parse_token_string_t cmd_fwd_fwd =
7680 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7681 cmdline_parse_token_string_t cmd_fwd_stats =
7682 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7683 cmdline_parse_token_string_t cmd_fwd_all =
7684 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7687 cmd_showfwdall_parsed(void *parsed_result,
7688 __rte_unused struct cmdline *cl,
7689 __rte_unused void *data)
7691 struct fwd_result *res = parsed_result;
7693 if (!strcmp(res->action, "show"))
7694 fwd_stats_display();
7699 static cmdline_parse_inst_t cmd_showfwdall = {
7700 .f = cmd_showfwdall_parsed,
7702 .help_str = "show|clear fwd stats all",
7704 (void *)&cmd_fwd_action,
7705 (void *)&cmd_fwd_fwd,
7706 (void *)&cmd_fwd_stats,
7707 (void *)&cmd_fwd_all,
7712 /* *** READ PORT REGISTER *** */
7713 struct cmd_read_reg_result {
7714 cmdline_fixed_string_t read;
7715 cmdline_fixed_string_t reg;
7721 cmd_read_reg_parsed(void *parsed_result,
7722 __rte_unused struct cmdline *cl,
7723 __rte_unused void *data)
7725 struct cmd_read_reg_result *res = parsed_result;
7726 port_reg_display(res->port_id, res->reg_off);
7729 cmdline_parse_token_string_t cmd_read_reg_read =
7730 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7731 cmdline_parse_token_string_t cmd_read_reg_reg =
7732 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7733 cmdline_parse_token_num_t cmd_read_reg_port_id =
7734 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7735 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7736 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7738 cmdline_parse_inst_t cmd_read_reg = {
7739 .f = cmd_read_reg_parsed,
7741 .help_str = "read reg <port_id> <reg_off>",
7743 (void *)&cmd_read_reg_read,
7744 (void *)&cmd_read_reg_reg,
7745 (void *)&cmd_read_reg_port_id,
7746 (void *)&cmd_read_reg_reg_off,
7751 /* *** READ PORT REGISTER BIT FIELD *** */
7752 struct cmd_read_reg_bit_field_result {
7753 cmdline_fixed_string_t read;
7754 cmdline_fixed_string_t regfield;
7762 cmd_read_reg_bit_field_parsed(void *parsed_result,
7763 __rte_unused struct cmdline *cl,
7764 __rte_unused void *data)
7766 struct cmd_read_reg_bit_field_result *res = parsed_result;
7767 port_reg_bit_field_display(res->port_id, res->reg_off,
7768 res->bit1_pos, res->bit2_pos);
7771 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7772 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7774 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7775 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7776 regfield, "regfield");
7777 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7778 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7780 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7781 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7783 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7784 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7786 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7787 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7790 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7791 .f = cmd_read_reg_bit_field_parsed,
7793 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7794 "Read register bit field between bit_x and bit_y included",
7796 (void *)&cmd_read_reg_bit_field_read,
7797 (void *)&cmd_read_reg_bit_field_regfield,
7798 (void *)&cmd_read_reg_bit_field_port_id,
7799 (void *)&cmd_read_reg_bit_field_reg_off,
7800 (void *)&cmd_read_reg_bit_field_bit1_pos,
7801 (void *)&cmd_read_reg_bit_field_bit2_pos,
7806 /* *** READ PORT REGISTER BIT *** */
7807 struct cmd_read_reg_bit_result {
7808 cmdline_fixed_string_t read;
7809 cmdline_fixed_string_t regbit;
7816 cmd_read_reg_bit_parsed(void *parsed_result,
7817 __rte_unused struct cmdline *cl,
7818 __rte_unused void *data)
7820 struct cmd_read_reg_bit_result *res = parsed_result;
7821 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7824 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7825 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7826 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7827 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7829 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7830 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7831 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7832 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7833 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7834 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7836 cmdline_parse_inst_t cmd_read_reg_bit = {
7837 .f = cmd_read_reg_bit_parsed,
7839 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7841 (void *)&cmd_read_reg_bit_read,
7842 (void *)&cmd_read_reg_bit_regbit,
7843 (void *)&cmd_read_reg_bit_port_id,
7844 (void *)&cmd_read_reg_bit_reg_off,
7845 (void *)&cmd_read_reg_bit_bit_pos,
7850 /* *** WRITE PORT REGISTER *** */
7851 struct cmd_write_reg_result {
7852 cmdline_fixed_string_t write;
7853 cmdline_fixed_string_t reg;
7860 cmd_write_reg_parsed(void *parsed_result,
7861 __rte_unused struct cmdline *cl,
7862 __rte_unused void *data)
7864 struct cmd_write_reg_result *res = parsed_result;
7865 port_reg_set(res->port_id, res->reg_off, res->value);
7868 cmdline_parse_token_string_t cmd_write_reg_write =
7869 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7870 cmdline_parse_token_string_t cmd_write_reg_reg =
7871 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7872 cmdline_parse_token_num_t cmd_write_reg_port_id =
7873 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7874 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7875 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7876 cmdline_parse_token_num_t cmd_write_reg_value =
7877 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7879 cmdline_parse_inst_t cmd_write_reg = {
7880 .f = cmd_write_reg_parsed,
7882 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7884 (void *)&cmd_write_reg_write,
7885 (void *)&cmd_write_reg_reg,
7886 (void *)&cmd_write_reg_port_id,
7887 (void *)&cmd_write_reg_reg_off,
7888 (void *)&cmd_write_reg_value,
7893 /* *** WRITE PORT REGISTER BIT FIELD *** */
7894 struct cmd_write_reg_bit_field_result {
7895 cmdline_fixed_string_t write;
7896 cmdline_fixed_string_t regfield;
7905 cmd_write_reg_bit_field_parsed(void *parsed_result,
7906 __rte_unused struct cmdline *cl,
7907 __rte_unused void *data)
7909 struct cmd_write_reg_bit_field_result *res = parsed_result;
7910 port_reg_bit_field_set(res->port_id, res->reg_off,
7911 res->bit1_pos, res->bit2_pos, res->value);
7914 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7915 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7917 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7918 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7919 regfield, "regfield");
7920 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7921 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7923 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7924 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7926 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7927 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7929 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7930 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7932 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7933 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7936 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7937 .f = cmd_write_reg_bit_field_parsed,
7939 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7941 "Set register bit field between bit_x and bit_y included",
7943 (void *)&cmd_write_reg_bit_field_write,
7944 (void *)&cmd_write_reg_bit_field_regfield,
7945 (void *)&cmd_write_reg_bit_field_port_id,
7946 (void *)&cmd_write_reg_bit_field_reg_off,
7947 (void *)&cmd_write_reg_bit_field_bit1_pos,
7948 (void *)&cmd_write_reg_bit_field_bit2_pos,
7949 (void *)&cmd_write_reg_bit_field_value,
7954 /* *** WRITE PORT REGISTER BIT *** */
7955 struct cmd_write_reg_bit_result {
7956 cmdline_fixed_string_t write;
7957 cmdline_fixed_string_t regbit;
7965 cmd_write_reg_bit_parsed(void *parsed_result,
7966 __rte_unused struct cmdline *cl,
7967 __rte_unused void *data)
7969 struct cmd_write_reg_bit_result *res = parsed_result;
7970 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7973 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7974 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7976 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7977 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7979 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7980 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7981 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7982 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7983 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7984 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7985 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7986 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7988 cmdline_parse_inst_t cmd_write_reg_bit = {
7989 .f = cmd_write_reg_bit_parsed,
7991 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7994 (void *)&cmd_write_reg_bit_write,
7995 (void *)&cmd_write_reg_bit_regbit,
7996 (void *)&cmd_write_reg_bit_port_id,
7997 (void *)&cmd_write_reg_bit_reg_off,
7998 (void *)&cmd_write_reg_bit_bit_pos,
7999 (void *)&cmd_write_reg_bit_value,
8004 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8005 struct cmd_read_rxd_txd_result {
8006 cmdline_fixed_string_t read;
8007 cmdline_fixed_string_t rxd_txd;
8014 cmd_read_rxd_txd_parsed(void *parsed_result,
8015 __rte_unused struct cmdline *cl,
8016 __rte_unused void *data)
8018 struct cmd_read_rxd_txd_result *res = parsed_result;
8020 if (!strcmp(res->rxd_txd, "rxd"))
8021 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8022 else if (!strcmp(res->rxd_txd, "txd"))
8023 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8026 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8027 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8028 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8029 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8031 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8032 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8033 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8034 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8035 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8036 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8038 cmdline_parse_inst_t cmd_read_rxd_txd = {
8039 .f = cmd_read_rxd_txd_parsed,
8041 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8043 (void *)&cmd_read_rxd_txd_read,
8044 (void *)&cmd_read_rxd_txd_rxd_txd,
8045 (void *)&cmd_read_rxd_txd_port_id,
8046 (void *)&cmd_read_rxd_txd_queue_id,
8047 (void *)&cmd_read_rxd_txd_desc_id,
8053 struct cmd_quit_result {
8054 cmdline_fixed_string_t quit;
8057 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8059 __rte_unused void *data)
8064 cmdline_parse_token_string_t cmd_quit_quit =
8065 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8067 cmdline_parse_inst_t cmd_quit = {
8068 .f = cmd_quit_parsed,
8070 .help_str = "quit: Exit application",
8072 (void *)&cmd_quit_quit,
8077 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8078 struct cmd_mac_addr_result {
8079 cmdline_fixed_string_t mac_addr_cmd;
8080 cmdline_fixed_string_t what;
8082 struct rte_ether_addr address;
8085 static void cmd_mac_addr_parsed(void *parsed_result,
8086 __rte_unused struct cmdline *cl,
8087 __rte_unused void *data)
8089 struct cmd_mac_addr_result *res = parsed_result;
8092 if (strcmp(res->what, "add") == 0)
8093 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8094 else if (strcmp(res->what, "set") == 0)
8095 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8098 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8100 /* check the return value and print it if is < 0 */
8102 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8106 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8107 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8109 cmdline_parse_token_string_t cmd_mac_addr_what =
8110 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8112 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8113 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8115 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8116 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8118 cmdline_parse_inst_t cmd_mac_addr = {
8119 .f = cmd_mac_addr_parsed,
8121 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8122 "Add/Remove/Set MAC address on port_id",
8124 (void *)&cmd_mac_addr_cmd,
8125 (void *)&cmd_mac_addr_what,
8126 (void *)&cmd_mac_addr_portnum,
8127 (void *)&cmd_mac_addr_addr,
8132 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8133 struct cmd_eth_peer_result {
8134 cmdline_fixed_string_t set;
8135 cmdline_fixed_string_t eth_peer;
8137 cmdline_fixed_string_t peer_addr;
8140 static void cmd_set_eth_peer_parsed(void *parsed_result,
8141 __rte_unused struct cmdline *cl,
8142 __rte_unused void *data)
8144 struct cmd_eth_peer_result *res = parsed_result;
8146 if (test_done == 0) {
8147 printf("Please stop forwarding first\n");
8150 if (!strcmp(res->eth_peer, "eth-peer")) {
8151 set_fwd_eth_peer(res->port_id, res->peer_addr);
8155 cmdline_parse_token_string_t cmd_eth_peer_set =
8156 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8157 cmdline_parse_token_string_t cmd_eth_peer =
8158 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8159 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8160 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8161 cmdline_parse_token_string_t cmd_eth_peer_addr =
8162 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8164 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8165 .f = cmd_set_eth_peer_parsed,
8167 .help_str = "set eth-peer <port_id> <peer_mac>",
8169 (void *)&cmd_eth_peer_set,
8170 (void *)&cmd_eth_peer,
8171 (void *)&cmd_eth_peer_port_id,
8172 (void *)&cmd_eth_peer_addr,
8177 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8178 struct cmd_set_qmap_result {
8179 cmdline_fixed_string_t set;
8180 cmdline_fixed_string_t qmap;
8181 cmdline_fixed_string_t what;
8188 cmd_set_qmap_parsed(void *parsed_result,
8189 __rte_unused struct cmdline *cl,
8190 __rte_unused void *data)
8192 struct cmd_set_qmap_result *res = parsed_result;
8193 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8195 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8198 cmdline_parse_token_string_t cmd_setqmap_set =
8199 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8201 cmdline_parse_token_string_t cmd_setqmap_qmap =
8202 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8204 cmdline_parse_token_string_t cmd_setqmap_what =
8205 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8207 cmdline_parse_token_num_t cmd_setqmap_portid =
8208 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8210 cmdline_parse_token_num_t cmd_setqmap_queueid =
8211 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8213 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8214 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8217 cmdline_parse_inst_t cmd_set_qmap = {
8218 .f = cmd_set_qmap_parsed,
8220 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8221 "Set statistics mapping value on tx|rx queue_id of port_id",
8223 (void *)&cmd_setqmap_set,
8224 (void *)&cmd_setqmap_qmap,
8225 (void *)&cmd_setqmap_what,
8226 (void *)&cmd_setqmap_portid,
8227 (void *)&cmd_setqmap_queueid,
8228 (void *)&cmd_setqmap_mapvalue,
8233 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8234 struct cmd_set_xstats_hide_zero_result {
8235 cmdline_fixed_string_t keyword;
8236 cmdline_fixed_string_t name;
8237 cmdline_fixed_string_t on_off;
8241 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8242 __rte_unused struct cmdline *cl,
8243 __rte_unused void *data)
8245 struct cmd_set_xstats_hide_zero_result *res;
8246 uint16_t on_off = 0;
8248 res = parsed_result;
8249 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8250 set_xstats_hide_zero(on_off);
8253 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8254 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8256 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8257 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8258 name, "xstats-hide-zero");
8259 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8260 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8263 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8264 .f = cmd_set_xstats_hide_zero_parsed,
8266 .help_str = "set xstats-hide-zero on|off",
8268 (void *)&cmd_set_xstats_hide_zero_keyword,
8269 (void *)&cmd_set_xstats_hide_zero_name,
8270 (void *)&cmd_set_xstats_hide_zero_on_off,
8275 /* *** CONFIGURE UNICAST HASH TABLE *** */
8276 struct cmd_set_uc_hash_table {
8277 cmdline_fixed_string_t set;
8278 cmdline_fixed_string_t port;
8280 cmdline_fixed_string_t what;
8281 struct rte_ether_addr address;
8282 cmdline_fixed_string_t mode;
8286 cmd_set_uc_hash_parsed(void *parsed_result,
8287 __rte_unused struct cmdline *cl,
8288 __rte_unused void *data)
8291 struct cmd_set_uc_hash_table *res = parsed_result;
8293 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8295 if (strcmp(res->what, "uta") == 0)
8296 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8297 &res->address,(uint8_t)is_on);
8299 printf("bad unicast hash table parameter, return code = %d \n", ret);
8303 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8304 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8306 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8307 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8309 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8310 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8312 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8313 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8315 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8316 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8318 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8319 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8322 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8323 .f = cmd_set_uc_hash_parsed,
8325 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8327 (void *)&cmd_set_uc_hash_set,
8328 (void *)&cmd_set_uc_hash_port,
8329 (void *)&cmd_set_uc_hash_portid,
8330 (void *)&cmd_set_uc_hash_what,
8331 (void *)&cmd_set_uc_hash_mac,
8332 (void *)&cmd_set_uc_hash_mode,
8337 struct cmd_set_uc_all_hash_table {
8338 cmdline_fixed_string_t set;
8339 cmdline_fixed_string_t port;
8341 cmdline_fixed_string_t what;
8342 cmdline_fixed_string_t value;
8343 cmdline_fixed_string_t mode;
8347 cmd_set_uc_all_hash_parsed(void *parsed_result,
8348 __rte_unused struct cmdline *cl,
8349 __rte_unused void *data)
8352 struct cmd_set_uc_all_hash_table *res = parsed_result;
8354 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8356 if ((strcmp(res->what, "uta") == 0) &&
8357 (strcmp(res->value, "all") == 0))
8358 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8360 printf("bad unicast hash table parameter,"
8361 "return code = %d \n", ret);
8364 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8365 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8367 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8368 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8370 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8371 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8373 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8374 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8376 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8377 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8379 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8380 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8383 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8384 .f = cmd_set_uc_all_hash_parsed,
8386 .help_str = "set port <port_id> uta all on|off",
8388 (void *)&cmd_set_uc_all_hash_set,
8389 (void *)&cmd_set_uc_all_hash_port,
8390 (void *)&cmd_set_uc_all_hash_portid,
8391 (void *)&cmd_set_uc_all_hash_what,
8392 (void *)&cmd_set_uc_all_hash_value,
8393 (void *)&cmd_set_uc_all_hash_mode,
8398 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8399 struct cmd_set_vf_macvlan_filter {
8400 cmdline_fixed_string_t set;
8401 cmdline_fixed_string_t port;
8403 cmdline_fixed_string_t vf;
8405 struct rte_ether_addr address;
8406 cmdline_fixed_string_t filter_type;
8407 cmdline_fixed_string_t mode;
8411 cmd_set_vf_macvlan_parsed(void *parsed_result,
8412 __rte_unused struct cmdline *cl,
8413 __rte_unused void *data)
8416 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8417 struct rte_eth_mac_filter filter;
8419 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8421 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8423 /* set VF MAC filter */
8427 filter.dst_id = res->vf_id;
8429 if (!strcmp(res->filter_type, "exact-mac"))
8430 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8431 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8432 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8433 else if (!strcmp(res->filter_type, "hashmac"))
8434 filter.filter_type = RTE_MAC_HASH_MATCH;
8435 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8436 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8438 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8441 ret = rte_eth_dev_filter_ctrl(res->port_id,
8442 RTE_ETH_FILTER_MACVLAN,
8446 ret = rte_eth_dev_filter_ctrl(res->port_id,
8447 RTE_ETH_FILTER_MACVLAN,
8448 RTE_ETH_FILTER_DELETE,
8452 printf("bad set MAC hash parameter, return code = %d\n", ret);
8456 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8457 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8459 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8460 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8462 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8463 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8465 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8466 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8468 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8469 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8471 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8472 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8474 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8475 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8476 filter_type, "exact-mac#exact-mac-vlan"
8477 "#hashmac#hashmac-vlan");
8478 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8479 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8482 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8483 .f = cmd_set_vf_macvlan_parsed,
8485 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8486 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8487 "Exact match rule: exact match of MAC or MAC and VLAN; "
8488 "hash match rule: hash match of MAC and exact match of VLAN",
8490 (void *)&cmd_set_vf_macvlan_set,
8491 (void *)&cmd_set_vf_macvlan_port,
8492 (void *)&cmd_set_vf_macvlan_portid,
8493 (void *)&cmd_set_vf_macvlan_vf,
8494 (void *)&cmd_set_vf_macvlan_vf_id,
8495 (void *)&cmd_set_vf_macvlan_mac,
8496 (void *)&cmd_set_vf_macvlan_filter_type,
8497 (void *)&cmd_set_vf_macvlan_mode,
8502 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8503 struct cmd_set_vf_traffic {
8504 cmdline_fixed_string_t set;
8505 cmdline_fixed_string_t port;
8507 cmdline_fixed_string_t vf;
8509 cmdline_fixed_string_t what;
8510 cmdline_fixed_string_t mode;
8514 cmd_set_vf_traffic_parsed(void *parsed_result,
8515 __rte_unused struct cmdline *cl,
8516 __rte_unused void *data)
8518 struct cmd_set_vf_traffic *res = parsed_result;
8519 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8520 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8522 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8525 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8526 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8528 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8529 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8531 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8532 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8534 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8535 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8537 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8538 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8540 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8541 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8543 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8544 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8547 cmdline_parse_inst_t cmd_set_vf_traffic = {
8548 .f = cmd_set_vf_traffic_parsed,
8550 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8552 (void *)&cmd_setvf_traffic_set,
8553 (void *)&cmd_setvf_traffic_port,
8554 (void *)&cmd_setvf_traffic_portid,
8555 (void *)&cmd_setvf_traffic_vf,
8556 (void *)&cmd_setvf_traffic_vfid,
8557 (void *)&cmd_setvf_traffic_what,
8558 (void *)&cmd_setvf_traffic_mode,
8563 /* *** CONFIGURE VF RECEIVE MODE *** */
8564 struct cmd_set_vf_rxmode {
8565 cmdline_fixed_string_t set;
8566 cmdline_fixed_string_t port;
8568 cmdline_fixed_string_t vf;
8570 cmdline_fixed_string_t what;
8571 cmdline_fixed_string_t mode;
8572 cmdline_fixed_string_t on;
8576 cmd_set_vf_rxmode_parsed(void *parsed_result,
8577 __rte_unused struct cmdline *cl,
8578 __rte_unused void *data)
8581 uint16_t vf_rxmode = 0;
8582 struct cmd_set_vf_rxmode *res = parsed_result;
8584 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8585 if (!strcmp(res->what,"rxmode")) {
8586 if (!strcmp(res->mode, "AUPE"))
8587 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8588 else if (!strcmp(res->mode, "ROPE"))
8589 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8590 else if (!strcmp(res->mode, "BAM"))
8591 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8592 else if (!strncmp(res->mode, "MPE",3))
8593 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8596 RTE_SET_USED(is_on);
8598 #ifdef RTE_LIBRTE_IXGBE_PMD
8599 if (ret == -ENOTSUP)
8600 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8601 vf_rxmode, (uint8_t)is_on);
8603 #ifdef RTE_LIBRTE_BNXT_PMD
8604 if (ret == -ENOTSUP)
8605 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8606 vf_rxmode, (uint8_t)is_on);
8609 printf("bad VF receive mode parameter, return code = %d \n",
8613 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8614 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8616 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8617 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8619 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8620 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8622 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8623 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8625 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8626 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8628 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8629 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8631 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8632 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8633 mode, "AUPE#ROPE#BAM#MPE");
8634 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8635 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8638 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8639 .f = cmd_set_vf_rxmode_parsed,
8641 .help_str = "set port <port_id> vf <vf_id> rxmode "
8642 "AUPE|ROPE|BAM|MPE on|off",
8644 (void *)&cmd_set_vf_rxmode_set,
8645 (void *)&cmd_set_vf_rxmode_port,
8646 (void *)&cmd_set_vf_rxmode_portid,
8647 (void *)&cmd_set_vf_rxmode_vf,
8648 (void *)&cmd_set_vf_rxmode_vfid,
8649 (void *)&cmd_set_vf_rxmode_what,
8650 (void *)&cmd_set_vf_rxmode_mode,
8651 (void *)&cmd_set_vf_rxmode_on,
8656 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8657 struct cmd_vf_mac_addr_result {
8658 cmdline_fixed_string_t mac_addr_cmd;
8659 cmdline_fixed_string_t what;
8660 cmdline_fixed_string_t port;
8662 cmdline_fixed_string_t vf;
8664 struct rte_ether_addr address;
8667 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8668 __rte_unused struct cmdline *cl,
8669 __rte_unused void *data)
8671 struct cmd_vf_mac_addr_result *res = parsed_result;
8674 if (strcmp(res->what, "add") != 0)
8677 #ifdef RTE_LIBRTE_I40E_PMD
8678 if (ret == -ENOTSUP)
8679 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8682 #ifdef RTE_LIBRTE_BNXT_PMD
8683 if (ret == -ENOTSUP)
8684 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8689 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8693 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8694 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8695 mac_addr_cmd,"mac_addr");
8696 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8697 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8699 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8700 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8702 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8703 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8705 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8706 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8708 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8709 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8711 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8712 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8715 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8716 .f = cmd_vf_mac_addr_parsed,
8718 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8719 "Add MAC address filtering for a VF on port_id",
8721 (void *)&cmd_vf_mac_addr_cmd,
8722 (void *)&cmd_vf_mac_addr_what,
8723 (void *)&cmd_vf_mac_addr_port,
8724 (void *)&cmd_vf_mac_addr_portnum,
8725 (void *)&cmd_vf_mac_addr_vf,
8726 (void *)&cmd_vf_mac_addr_vfnum,
8727 (void *)&cmd_vf_mac_addr_addr,
8732 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8733 struct cmd_vf_rx_vlan_filter {
8734 cmdline_fixed_string_t rx_vlan;
8735 cmdline_fixed_string_t what;
8737 cmdline_fixed_string_t port;
8739 cmdline_fixed_string_t vf;
8744 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8745 __rte_unused struct cmdline *cl,
8746 __rte_unused void *data)
8748 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8751 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8753 #ifdef RTE_LIBRTE_IXGBE_PMD
8754 if (ret == -ENOTSUP)
8755 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8756 res->vlan_id, res->vf_mask, is_add);
8758 #ifdef RTE_LIBRTE_I40E_PMD
8759 if (ret == -ENOTSUP)
8760 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8761 res->vlan_id, res->vf_mask, is_add);
8763 #ifdef RTE_LIBRTE_BNXT_PMD
8764 if (ret == -ENOTSUP)
8765 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8766 res->vlan_id, res->vf_mask, is_add);
8773 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8774 res->vlan_id, res->vf_mask);
8777 printf("invalid port_id %d\n", res->port_id);
8780 printf("function not implemented or supported\n");
8783 printf("programming error: (%s)\n", strerror(-ret));
8787 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8788 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8789 rx_vlan, "rx_vlan");
8790 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8791 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8793 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8794 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8796 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8797 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8799 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8800 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8802 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8803 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8805 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8806 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8809 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8810 .f = cmd_vf_rx_vlan_filter_parsed,
8812 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8813 "(vf_mask = hexadecimal VF mask)",
8815 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8816 (void *)&cmd_vf_rx_vlan_filter_what,
8817 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8818 (void *)&cmd_vf_rx_vlan_filter_port,
8819 (void *)&cmd_vf_rx_vlan_filter_portid,
8820 (void *)&cmd_vf_rx_vlan_filter_vf,
8821 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8826 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8827 struct cmd_queue_rate_limit_result {
8828 cmdline_fixed_string_t set;
8829 cmdline_fixed_string_t port;
8831 cmdline_fixed_string_t queue;
8833 cmdline_fixed_string_t rate;
8837 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8838 __rte_unused struct cmdline *cl,
8839 __rte_unused void *data)
8841 struct cmd_queue_rate_limit_result *res = parsed_result;
8844 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8845 && (strcmp(res->queue, "queue") == 0)
8846 && (strcmp(res->rate, "rate") == 0))
8847 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8850 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8854 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8855 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8857 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8858 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8860 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8861 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8863 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8864 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8866 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8867 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8869 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8870 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8872 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8873 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8876 cmdline_parse_inst_t cmd_queue_rate_limit = {
8877 .f = cmd_queue_rate_limit_parsed,
8879 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8880 "Set rate limit for a queue on port_id",
8882 (void *)&cmd_queue_rate_limit_set,
8883 (void *)&cmd_queue_rate_limit_port,
8884 (void *)&cmd_queue_rate_limit_portnum,
8885 (void *)&cmd_queue_rate_limit_queue,
8886 (void *)&cmd_queue_rate_limit_queuenum,
8887 (void *)&cmd_queue_rate_limit_rate,
8888 (void *)&cmd_queue_rate_limit_ratenum,
8893 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8894 struct cmd_vf_rate_limit_result {
8895 cmdline_fixed_string_t set;
8896 cmdline_fixed_string_t port;
8898 cmdline_fixed_string_t vf;
8900 cmdline_fixed_string_t rate;
8902 cmdline_fixed_string_t q_msk;
8906 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8907 __rte_unused struct cmdline *cl,
8908 __rte_unused void *data)
8910 struct cmd_vf_rate_limit_result *res = parsed_result;
8913 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8914 && (strcmp(res->vf, "vf") == 0)
8915 && (strcmp(res->rate, "rate") == 0)
8916 && (strcmp(res->q_msk, "queue_mask") == 0))
8917 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8918 res->rate_num, res->q_msk_val);
8920 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8924 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8925 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8927 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8928 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8930 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8931 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8933 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8934 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8936 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8937 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8939 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8940 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8942 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8943 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8945 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8946 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8947 q_msk, "queue_mask");
8948 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8949 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8952 cmdline_parse_inst_t cmd_vf_rate_limit = {
8953 .f = cmd_vf_rate_limit_parsed,
8955 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8956 "queue_mask <queue_mask_value>: "
8957 "Set rate limit for queues of VF on port_id",
8959 (void *)&cmd_vf_rate_limit_set,
8960 (void *)&cmd_vf_rate_limit_port,
8961 (void *)&cmd_vf_rate_limit_portnum,
8962 (void *)&cmd_vf_rate_limit_vf,
8963 (void *)&cmd_vf_rate_limit_vfnum,
8964 (void *)&cmd_vf_rate_limit_rate,
8965 (void *)&cmd_vf_rate_limit_ratenum,
8966 (void *)&cmd_vf_rate_limit_q_msk,
8967 (void *)&cmd_vf_rate_limit_q_msk_val,
8972 /* *** ADD TUNNEL FILTER OF A PORT *** */
8973 struct cmd_tunnel_filter_result {
8974 cmdline_fixed_string_t cmd;
8975 cmdline_fixed_string_t what;
8977 struct rte_ether_addr outer_mac;
8978 struct rte_ether_addr inner_mac;
8979 cmdline_ipaddr_t ip_value;
8980 uint16_t inner_vlan;
8981 cmdline_fixed_string_t tunnel_type;
8982 cmdline_fixed_string_t filter_type;
8988 cmd_tunnel_filter_parsed(void *parsed_result,
8989 __rte_unused struct cmdline *cl,
8990 __rte_unused void *data)
8992 struct cmd_tunnel_filter_result *res = parsed_result;
8993 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8996 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8998 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8999 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9000 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9002 if (res->ip_value.family == AF_INET) {
9003 tunnel_filter_conf.ip_addr.ipv4_addr =
9004 res->ip_value.addr.ipv4.s_addr;
9005 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9007 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9008 &(res->ip_value.addr.ipv6),
9009 sizeof(struct in6_addr));
9010 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9013 if (!strcmp(res->filter_type, "imac-ivlan"))
9014 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9015 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9016 tunnel_filter_conf.filter_type =
9017 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9018 else if (!strcmp(res->filter_type, "imac-tenid"))
9019 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9020 else if (!strcmp(res->filter_type, "imac"))
9021 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9022 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9023 tunnel_filter_conf.filter_type =
9024 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9025 else if (!strcmp(res->filter_type, "oip"))
9026 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9027 else if (!strcmp(res->filter_type, "iip"))
9028 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9030 printf("The filter type is not supported");
9034 if (!strcmp(res->tunnel_type, "vxlan"))
9035 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9036 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9037 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9038 else if (!strcmp(res->tunnel_type, "nvgre"))
9039 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9040 else if (!strcmp(res->tunnel_type, "ipingre"))
9041 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9043 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9047 tunnel_filter_conf.tenant_id = res->tenant_id;
9048 tunnel_filter_conf.queue_id = res->queue_num;
9049 if (!strcmp(res->what, "add"))
9050 ret = rte_eth_dev_filter_ctrl(res->port_id,
9051 RTE_ETH_FILTER_TUNNEL,
9053 &tunnel_filter_conf);
9055 ret = rte_eth_dev_filter_ctrl(res->port_id,
9056 RTE_ETH_FILTER_TUNNEL,
9057 RTE_ETH_FILTER_DELETE,
9058 &tunnel_filter_conf);
9060 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9064 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9065 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9066 cmd, "tunnel_filter");
9067 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9068 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9070 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9071 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9073 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9074 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9076 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9077 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9079 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9080 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9081 inner_vlan, UINT16);
9082 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9083 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9085 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9086 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9087 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9089 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9090 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9091 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9092 "imac#omac-imac-tenid");
9093 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9094 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9096 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9097 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9100 cmdline_parse_inst_t cmd_tunnel_filter = {
9101 .f = cmd_tunnel_filter_parsed,
9103 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9104 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9105 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9106 "<queue_id>: Add/Rm tunnel filter of a port",
9108 (void *)&cmd_tunnel_filter_cmd,
9109 (void *)&cmd_tunnel_filter_what,
9110 (void *)&cmd_tunnel_filter_port_id,
9111 (void *)&cmd_tunnel_filter_outer_mac,
9112 (void *)&cmd_tunnel_filter_inner_mac,
9113 (void *)&cmd_tunnel_filter_ip_value,
9114 (void *)&cmd_tunnel_filter_innner_vlan,
9115 (void *)&cmd_tunnel_filter_tunnel_type,
9116 (void *)&cmd_tunnel_filter_filter_type,
9117 (void *)&cmd_tunnel_filter_tenant_id,
9118 (void *)&cmd_tunnel_filter_queue_num,
9123 /* *** CONFIGURE TUNNEL UDP PORT *** */
9124 struct cmd_tunnel_udp_config {
9125 cmdline_fixed_string_t cmd;
9126 cmdline_fixed_string_t what;
9132 cmd_tunnel_udp_config_parsed(void *parsed_result,
9133 __rte_unused struct cmdline *cl,
9134 __rte_unused void *data)
9136 struct cmd_tunnel_udp_config *res = parsed_result;
9137 struct rte_eth_udp_tunnel tunnel_udp;
9140 tunnel_udp.udp_port = res->udp_port;
9142 if (!strcmp(res->cmd, "rx_vxlan_port"))
9143 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9145 if (!strcmp(res->what, "add"))
9146 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9149 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9153 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9156 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9157 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9158 cmd, "rx_vxlan_port");
9159 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9160 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9162 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9163 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9165 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9166 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9169 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9170 .f = cmd_tunnel_udp_config_parsed,
9172 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9173 "Add/Remove a tunneling UDP port filter",
9175 (void *)&cmd_tunnel_udp_config_cmd,
9176 (void *)&cmd_tunnel_udp_config_what,
9177 (void *)&cmd_tunnel_udp_config_udp_port,
9178 (void *)&cmd_tunnel_udp_config_port_id,
9183 struct cmd_config_tunnel_udp_port {
9184 cmdline_fixed_string_t port;
9185 cmdline_fixed_string_t config;
9187 cmdline_fixed_string_t udp_tunnel_port;
9188 cmdline_fixed_string_t action;
9189 cmdline_fixed_string_t tunnel_type;
9194 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9195 __rte_unused struct cmdline *cl,
9196 __rte_unused void *data)
9198 struct cmd_config_tunnel_udp_port *res = parsed_result;
9199 struct rte_eth_udp_tunnel tunnel_udp;
9202 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9205 tunnel_udp.udp_port = res->udp_port;
9207 if (!strcmp(res->tunnel_type, "vxlan")) {
9208 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9209 } else if (!strcmp(res->tunnel_type, "geneve")) {
9210 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9211 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9212 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9214 printf("Invalid tunnel type\n");
9218 if (!strcmp(res->action, "add"))
9219 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9222 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9226 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9229 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9230 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9232 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9233 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9235 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9236 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9238 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9239 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9242 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9243 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9245 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9246 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9247 "vxlan#geneve#vxlan-gpe");
9248 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9249 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9252 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9253 .f = cmd_cfg_tunnel_udp_port_parsed,
9255 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9257 (void *)&cmd_config_tunnel_udp_port_port,
9258 (void *)&cmd_config_tunnel_udp_port_config,
9259 (void *)&cmd_config_tunnel_udp_port_port_id,
9260 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9261 (void *)&cmd_config_tunnel_udp_port_action,
9262 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9263 (void *)&cmd_config_tunnel_udp_port_value,
9268 /* *** GLOBAL CONFIG *** */
9269 struct cmd_global_config_result {
9270 cmdline_fixed_string_t cmd;
9272 cmdline_fixed_string_t cfg_type;
9277 cmd_global_config_parsed(void *parsed_result,
9278 __rte_unused struct cmdline *cl,
9279 __rte_unused void *data)
9281 struct cmd_global_config_result *res = parsed_result;
9282 struct rte_eth_global_cfg conf;
9285 memset(&conf, 0, sizeof(conf));
9286 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9287 conf.cfg.gre_key_len = res->len;
9288 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9289 RTE_ETH_FILTER_SET, &conf);
9291 printf("Global config error\n");
9294 cmdline_parse_token_string_t cmd_global_config_cmd =
9295 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9297 cmdline_parse_token_num_t cmd_global_config_port_id =
9298 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9300 cmdline_parse_token_string_t cmd_global_config_type =
9301 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9302 cfg_type, "gre-key-len");
9303 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9304 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9307 cmdline_parse_inst_t cmd_global_config = {
9308 .f = cmd_global_config_parsed,
9309 .data = (void *)NULL,
9310 .help_str = "global_config <port_id> gre-key-len <key_len>",
9312 (void *)&cmd_global_config_cmd,
9313 (void *)&cmd_global_config_port_id,
9314 (void *)&cmd_global_config_type,
9315 (void *)&cmd_global_config_gre_key_len,
9320 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9321 struct cmd_set_mirror_mask_result {
9322 cmdline_fixed_string_t set;
9323 cmdline_fixed_string_t port;
9325 cmdline_fixed_string_t mirror;
9327 cmdline_fixed_string_t what;
9328 cmdline_fixed_string_t value;
9329 cmdline_fixed_string_t dstpool;
9331 cmdline_fixed_string_t on;
9334 cmdline_parse_token_string_t cmd_mirror_mask_set =
9335 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9337 cmdline_parse_token_string_t cmd_mirror_mask_port =
9338 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9340 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9341 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9343 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9344 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9345 mirror, "mirror-rule");
9346 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9347 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9349 cmdline_parse_token_string_t cmd_mirror_mask_what =
9350 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9351 what, "pool-mirror-up#pool-mirror-down"
9353 cmdline_parse_token_string_t cmd_mirror_mask_value =
9354 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9356 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9357 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9358 dstpool, "dst-pool");
9359 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9360 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9362 cmdline_parse_token_string_t cmd_mirror_mask_on =
9363 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9367 cmd_set_mirror_mask_parsed(void *parsed_result,
9368 __rte_unused struct cmdline *cl,
9369 __rte_unused void *data)
9372 struct cmd_set_mirror_mask_result *res = parsed_result;
9373 struct rte_eth_mirror_conf mr_conf;
9375 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9377 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9379 mr_conf.dst_pool = res->dstpool_id;
9381 if (!strcmp(res->what, "pool-mirror-up")) {
9382 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9383 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9384 } else if (!strcmp(res->what, "pool-mirror-down")) {
9385 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9386 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9387 } else if (!strcmp(res->what, "vlan-mirror")) {
9388 mr_conf.rule_type = ETH_MIRROR_VLAN;
9389 nb_item = parse_item_list(res->value, "vlan",
9390 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9394 for (i = 0; i < nb_item; i++) {
9395 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9396 printf("Invalid vlan_id: must be < 4096\n");
9400 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9401 mr_conf.vlan.vlan_mask |= 1ULL << i;
9405 if (!strcmp(res->on, "on"))
9406 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9409 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9412 printf("mirror rule add error: (%s)\n", strerror(-ret));
9415 cmdline_parse_inst_t cmd_set_mirror_mask = {
9416 .f = cmd_set_mirror_mask_parsed,
9418 .help_str = "set port <port_id> mirror-rule <rule_id> "
9419 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9420 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9422 (void *)&cmd_mirror_mask_set,
9423 (void *)&cmd_mirror_mask_port,
9424 (void *)&cmd_mirror_mask_portid,
9425 (void *)&cmd_mirror_mask_mirror,
9426 (void *)&cmd_mirror_mask_ruleid,
9427 (void *)&cmd_mirror_mask_what,
9428 (void *)&cmd_mirror_mask_value,
9429 (void *)&cmd_mirror_mask_dstpool,
9430 (void *)&cmd_mirror_mask_poolid,
9431 (void *)&cmd_mirror_mask_on,
9436 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9437 struct cmd_set_mirror_link_result {
9438 cmdline_fixed_string_t set;
9439 cmdline_fixed_string_t port;
9441 cmdline_fixed_string_t mirror;
9443 cmdline_fixed_string_t what;
9444 cmdline_fixed_string_t dstpool;
9446 cmdline_fixed_string_t on;
9449 cmdline_parse_token_string_t cmd_mirror_link_set =
9450 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9452 cmdline_parse_token_string_t cmd_mirror_link_port =
9453 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9455 cmdline_parse_token_num_t cmd_mirror_link_portid =
9456 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9458 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9459 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9460 mirror, "mirror-rule");
9461 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9462 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9464 cmdline_parse_token_string_t cmd_mirror_link_what =
9465 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9466 what, "uplink-mirror#downlink-mirror");
9467 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9468 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9469 dstpool, "dst-pool");
9470 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9471 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9473 cmdline_parse_token_string_t cmd_mirror_link_on =
9474 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9478 cmd_set_mirror_link_parsed(void *parsed_result,
9479 __rte_unused struct cmdline *cl,
9480 __rte_unused void *data)
9483 struct cmd_set_mirror_link_result *res = parsed_result;
9484 struct rte_eth_mirror_conf mr_conf;
9486 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9487 if (!strcmp(res->what, "uplink-mirror"))
9488 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9490 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9492 mr_conf.dst_pool = res->dstpool_id;
9494 if (!strcmp(res->on, "on"))
9495 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9498 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9501 /* check the return value and print it if is < 0 */
9503 printf("mirror rule add error: (%s)\n", strerror(-ret));
9507 cmdline_parse_inst_t cmd_set_mirror_link = {
9508 .f = cmd_set_mirror_link_parsed,
9510 .help_str = "set port <port_id> mirror-rule <rule_id> "
9511 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9513 (void *)&cmd_mirror_link_set,
9514 (void *)&cmd_mirror_link_port,
9515 (void *)&cmd_mirror_link_portid,
9516 (void *)&cmd_mirror_link_mirror,
9517 (void *)&cmd_mirror_link_ruleid,
9518 (void *)&cmd_mirror_link_what,
9519 (void *)&cmd_mirror_link_dstpool,
9520 (void *)&cmd_mirror_link_poolid,
9521 (void *)&cmd_mirror_link_on,
9526 /* *** RESET VM MIRROR RULE *** */
9527 struct cmd_rm_mirror_rule_result {
9528 cmdline_fixed_string_t reset;
9529 cmdline_fixed_string_t port;
9531 cmdline_fixed_string_t mirror;
9535 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9536 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9538 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9539 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9541 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9542 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9544 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9545 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9546 mirror, "mirror-rule");
9547 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9548 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9552 cmd_reset_mirror_rule_parsed(void *parsed_result,
9553 __rte_unused struct cmdline *cl,
9554 __rte_unused void *data)
9557 struct cmd_set_mirror_link_result *res = parsed_result;
9559 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9561 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9564 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9565 .f = cmd_reset_mirror_rule_parsed,
9567 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9569 (void *)&cmd_rm_mirror_rule_reset,
9570 (void *)&cmd_rm_mirror_rule_port,
9571 (void *)&cmd_rm_mirror_rule_portid,
9572 (void *)&cmd_rm_mirror_rule_mirror,
9573 (void *)&cmd_rm_mirror_rule_ruleid,
9578 /* ******************************************************************************** */
9580 struct cmd_dump_result {
9581 cmdline_fixed_string_t dump;
9585 dump_struct_sizes(void)
9587 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9588 DUMP_SIZE(struct rte_mbuf);
9589 DUMP_SIZE(struct rte_mempool);
9590 DUMP_SIZE(struct rte_ring);
9595 /* Dump the socket memory statistics on console */
9597 dump_socket_mem(FILE *f)
9599 struct rte_malloc_socket_stats socket_stats;
9604 unsigned int n_alloc = 0;
9605 unsigned int n_free = 0;
9606 static size_t last_allocs;
9607 static size_t last_total;
9610 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9611 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9612 !socket_stats.heap_totalsz_bytes)
9614 total += socket_stats.heap_totalsz_bytes;
9615 alloc += socket_stats.heap_allocsz_bytes;
9616 free += socket_stats.heap_freesz_bytes;
9617 n_alloc += socket_stats.alloc_count;
9618 n_free += socket_stats.free_count;
9620 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9622 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9623 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9624 (double)socket_stats.heap_allocsz_bytes * 100 /
9625 (double)socket_stats.heap_totalsz_bytes,
9626 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9627 socket_stats.alloc_count,
9628 socket_stats.free_count);
9631 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9632 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9633 (double)alloc * 100 / (double)total,
9634 (double)free / (1024 * 1024),
9637 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9638 ((double)total - (double)last_total) / (1024 * 1024),
9639 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9640 last_allocs = alloc;
9644 static void cmd_dump_parsed(void *parsed_result,
9645 __rte_unused struct cmdline *cl,
9646 __rte_unused void *data)
9648 struct cmd_dump_result *res = parsed_result;
9650 if (!strcmp(res->dump, "dump_physmem"))
9651 rte_dump_physmem_layout(stdout);
9652 else if (!strcmp(res->dump, "dump_socket_mem"))
9653 dump_socket_mem(stdout);
9654 else if (!strcmp(res->dump, "dump_memzone"))
9655 rte_memzone_dump(stdout);
9656 else if (!strcmp(res->dump, "dump_struct_sizes"))
9657 dump_struct_sizes();
9658 else if (!strcmp(res->dump, "dump_ring"))
9659 rte_ring_list_dump(stdout);
9660 else if (!strcmp(res->dump, "dump_mempool"))
9661 rte_mempool_list_dump(stdout);
9662 else if (!strcmp(res->dump, "dump_devargs"))
9663 rte_devargs_dump(stdout);
9664 else if (!strcmp(res->dump, "dump_log_types"))
9665 rte_log_dump(stdout);
9668 cmdline_parse_token_string_t cmd_dump_dump =
9669 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9673 "dump_struct_sizes#"
9679 cmdline_parse_inst_t cmd_dump = {
9680 .f = cmd_dump_parsed, /* function to call */
9681 .data = NULL, /* 2nd arg of func */
9682 .help_str = "Dump status",
9683 .tokens = { /* token list, NULL terminated */
9684 (void *)&cmd_dump_dump,
9689 /* ******************************************************************************** */
9691 struct cmd_dump_one_result {
9692 cmdline_fixed_string_t dump;
9693 cmdline_fixed_string_t name;
9696 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9697 __rte_unused void *data)
9699 struct cmd_dump_one_result *res = parsed_result;
9701 if (!strcmp(res->dump, "dump_ring")) {
9703 r = rte_ring_lookup(res->name);
9705 cmdline_printf(cl, "Cannot find ring\n");
9708 rte_ring_dump(stdout, r);
9709 } else if (!strcmp(res->dump, "dump_mempool")) {
9710 struct rte_mempool *mp;
9711 mp = rte_mempool_lookup(res->name);
9713 cmdline_printf(cl, "Cannot find mempool\n");
9716 rte_mempool_dump(stdout, mp);
9720 cmdline_parse_token_string_t cmd_dump_one_dump =
9721 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9722 "dump_ring#dump_mempool");
9724 cmdline_parse_token_string_t cmd_dump_one_name =
9725 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9727 cmdline_parse_inst_t cmd_dump_one = {
9728 .f = cmd_dump_one_parsed, /* function to call */
9729 .data = NULL, /* 2nd arg of func */
9730 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9731 .tokens = { /* token list, NULL terminated */
9732 (void *)&cmd_dump_one_dump,
9733 (void *)&cmd_dump_one_name,
9738 /* *** Add/Del syn filter *** */
9739 struct cmd_syn_filter_result {
9740 cmdline_fixed_string_t filter;
9742 cmdline_fixed_string_t ops;
9743 cmdline_fixed_string_t priority;
9744 cmdline_fixed_string_t high;
9745 cmdline_fixed_string_t queue;
9750 cmd_syn_filter_parsed(void *parsed_result,
9751 __rte_unused struct cmdline *cl,
9752 __rte_unused void *data)
9754 struct cmd_syn_filter_result *res = parsed_result;
9755 struct rte_eth_syn_filter syn_filter;
9758 ret = rte_eth_dev_filter_supported(res->port_id,
9759 RTE_ETH_FILTER_SYN);
9761 printf("syn filter is not supported on port %u.\n",
9766 memset(&syn_filter, 0, sizeof(syn_filter));
9768 if (!strcmp(res->ops, "add")) {
9769 if (!strcmp(res->high, "high"))
9770 syn_filter.hig_pri = 1;
9772 syn_filter.hig_pri = 0;
9774 syn_filter.queue = res->queue_id;
9775 ret = rte_eth_dev_filter_ctrl(res->port_id,
9780 ret = rte_eth_dev_filter_ctrl(res->port_id,
9782 RTE_ETH_FILTER_DELETE,
9786 printf("syn filter programming error: (%s)\n",
9790 cmdline_parse_token_string_t cmd_syn_filter_filter =
9791 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9792 filter, "syn_filter");
9793 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9794 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9796 cmdline_parse_token_string_t cmd_syn_filter_ops =
9797 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9799 cmdline_parse_token_string_t cmd_syn_filter_priority =
9800 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9801 priority, "priority");
9802 cmdline_parse_token_string_t cmd_syn_filter_high =
9803 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9805 cmdline_parse_token_string_t cmd_syn_filter_queue =
9806 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9808 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9809 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9812 cmdline_parse_inst_t cmd_syn_filter = {
9813 .f = cmd_syn_filter_parsed,
9815 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9816 "<queue_id>: Add/Delete syn filter",
9818 (void *)&cmd_syn_filter_filter,
9819 (void *)&cmd_syn_filter_port_id,
9820 (void *)&cmd_syn_filter_ops,
9821 (void *)&cmd_syn_filter_priority,
9822 (void *)&cmd_syn_filter_high,
9823 (void *)&cmd_syn_filter_queue,
9824 (void *)&cmd_syn_filter_queue_id,
9829 /* *** queue region set *** */
9830 struct cmd_queue_region_result {
9831 cmdline_fixed_string_t set;
9832 cmdline_fixed_string_t port;
9834 cmdline_fixed_string_t cmd;
9835 cmdline_fixed_string_t region;
9837 cmdline_fixed_string_t queue_start_index;
9839 cmdline_fixed_string_t queue_num;
9840 uint8_t queue_num_value;
9844 cmd_queue_region_parsed(void *parsed_result,
9845 __rte_unused struct cmdline *cl,
9846 __rte_unused void *data)
9848 struct cmd_queue_region_result *res = parsed_result;
9850 #ifdef RTE_LIBRTE_I40E_PMD
9851 struct rte_pmd_i40e_queue_region_conf region_conf;
9852 enum rte_pmd_i40e_queue_region_op op_type;
9855 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9858 #ifdef RTE_LIBRTE_I40E_PMD
9859 memset(®ion_conf, 0, sizeof(region_conf));
9860 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9861 region_conf.region_id = res->region_id;
9862 region_conf.queue_num = res->queue_num_value;
9863 region_conf.queue_start_index = res->queue_id;
9865 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9866 op_type, ®ion_conf);
9873 printf("function not implemented or supported\n");
9876 printf("queue region config error: (%s)\n", strerror(-ret));
9880 cmdline_parse_token_string_t cmd_queue_region_set =
9881 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9883 cmdline_parse_token_string_t cmd_queue_region_port =
9884 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9885 cmdline_parse_token_num_t cmd_queue_region_port_id =
9886 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9888 cmdline_parse_token_string_t cmd_queue_region_cmd =
9889 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9890 cmd, "queue-region");
9891 cmdline_parse_token_string_t cmd_queue_region_id =
9892 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9893 region, "region_id");
9894 cmdline_parse_token_num_t cmd_queue_region_index =
9895 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9897 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9898 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9899 queue_start_index, "queue_start_index");
9900 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9901 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9903 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9904 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9905 queue_num, "queue_num");
9906 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9907 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9908 queue_num_value, UINT8);
9910 cmdline_parse_inst_t cmd_queue_region = {
9911 .f = cmd_queue_region_parsed,
9913 .help_str = "set port <port_id> queue-region region_id <value> "
9914 "queue_start_index <value> queue_num <value>: Set a queue region",
9916 (void *)&cmd_queue_region_set,
9917 (void *)&cmd_queue_region_port,
9918 (void *)&cmd_queue_region_port_id,
9919 (void *)&cmd_queue_region_cmd,
9920 (void *)&cmd_queue_region_id,
9921 (void *)&cmd_queue_region_index,
9922 (void *)&cmd_queue_region_queue_start_index,
9923 (void *)&cmd_queue_region_queue_id,
9924 (void *)&cmd_queue_region_queue_num,
9925 (void *)&cmd_queue_region_queue_num_value,
9930 /* *** queue region and flowtype set *** */
9931 struct cmd_region_flowtype_result {
9932 cmdline_fixed_string_t set;
9933 cmdline_fixed_string_t port;
9935 cmdline_fixed_string_t cmd;
9936 cmdline_fixed_string_t region;
9938 cmdline_fixed_string_t flowtype;
9939 uint8_t flowtype_id;
9943 cmd_region_flowtype_parsed(void *parsed_result,
9944 __rte_unused struct cmdline *cl,
9945 __rte_unused void *data)
9947 struct cmd_region_flowtype_result *res = parsed_result;
9949 #ifdef RTE_LIBRTE_I40E_PMD
9950 struct rte_pmd_i40e_queue_region_conf region_conf;
9951 enum rte_pmd_i40e_queue_region_op op_type;
9954 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9957 #ifdef RTE_LIBRTE_I40E_PMD
9958 memset(®ion_conf, 0, sizeof(region_conf));
9960 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9961 region_conf.region_id = res->region_id;
9962 region_conf.hw_flowtype = res->flowtype_id;
9964 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9965 op_type, ®ion_conf);
9972 printf("function not implemented or supported\n");
9975 printf("region flowtype config error: (%s)\n", strerror(-ret));
9979 cmdline_parse_token_string_t cmd_region_flowtype_set =
9980 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9982 cmdline_parse_token_string_t cmd_region_flowtype_port =
9983 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9985 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9986 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9988 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9989 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9990 cmd, "queue-region");
9991 cmdline_parse_token_string_t cmd_region_flowtype_index =
9992 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9993 region, "region_id");
9994 cmdline_parse_token_num_t cmd_region_flowtype_id =
9995 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9997 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9998 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9999 flowtype, "flowtype");
10000 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10001 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10002 flowtype_id, UINT8);
10003 cmdline_parse_inst_t cmd_region_flowtype = {
10004 .f = cmd_region_flowtype_parsed,
10006 .help_str = "set port <port_id> queue-region region_id <value> "
10007 "flowtype <value>: Set a flowtype region index",
10009 (void *)&cmd_region_flowtype_set,
10010 (void *)&cmd_region_flowtype_port,
10011 (void *)&cmd_region_flowtype_port_index,
10012 (void *)&cmd_region_flowtype_cmd,
10013 (void *)&cmd_region_flowtype_index,
10014 (void *)&cmd_region_flowtype_id,
10015 (void *)&cmd_region_flowtype_flow_index,
10016 (void *)&cmd_region_flowtype_flow_id,
10021 /* *** User Priority (UP) to queue region (region_id) set *** */
10022 struct cmd_user_priority_region_result {
10023 cmdline_fixed_string_t set;
10024 cmdline_fixed_string_t port;
10026 cmdline_fixed_string_t cmd;
10027 cmdline_fixed_string_t user_priority;
10028 uint8_t user_priority_id;
10029 cmdline_fixed_string_t region;
10034 cmd_user_priority_region_parsed(void *parsed_result,
10035 __rte_unused struct cmdline *cl,
10036 __rte_unused void *data)
10038 struct cmd_user_priority_region_result *res = parsed_result;
10039 int ret = -ENOTSUP;
10040 #ifdef RTE_LIBRTE_I40E_PMD
10041 struct rte_pmd_i40e_queue_region_conf region_conf;
10042 enum rte_pmd_i40e_queue_region_op op_type;
10045 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10048 #ifdef RTE_LIBRTE_I40E_PMD
10049 memset(®ion_conf, 0, sizeof(region_conf));
10050 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10051 region_conf.user_priority = res->user_priority_id;
10052 region_conf.region_id = res->region_id;
10054 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10055 op_type, ®ion_conf);
10062 printf("function not implemented or supported\n");
10065 printf("user_priority region config error: (%s)\n",
10070 cmdline_parse_token_string_t cmd_user_priority_region_set =
10071 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10073 cmdline_parse_token_string_t cmd_user_priority_region_port =
10074 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10076 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10077 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10079 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10080 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10081 cmd, "queue-region");
10082 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10083 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10084 user_priority, "UP");
10085 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10086 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10087 user_priority_id, UINT8);
10088 cmdline_parse_token_string_t cmd_user_priority_region_region =
10089 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10090 region, "region_id");
10091 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10092 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10095 cmdline_parse_inst_t cmd_user_priority_region = {
10096 .f = cmd_user_priority_region_parsed,
10098 .help_str = "set port <port_id> queue-region UP <value> "
10099 "region_id <value>: Set the mapping of User Priority (UP) "
10100 "to queue region (region_id) ",
10102 (void *)&cmd_user_priority_region_set,
10103 (void *)&cmd_user_priority_region_port,
10104 (void *)&cmd_user_priority_region_port_index,
10105 (void *)&cmd_user_priority_region_cmd,
10106 (void *)&cmd_user_priority_region_UP,
10107 (void *)&cmd_user_priority_region_UP_id,
10108 (void *)&cmd_user_priority_region_region,
10109 (void *)&cmd_user_priority_region_region_id,
10114 /* *** flush all queue region related configuration *** */
10115 struct cmd_flush_queue_region_result {
10116 cmdline_fixed_string_t set;
10117 cmdline_fixed_string_t port;
10119 cmdline_fixed_string_t cmd;
10120 cmdline_fixed_string_t flush;
10121 cmdline_fixed_string_t what;
10125 cmd_flush_queue_region_parsed(void *parsed_result,
10126 __rte_unused struct cmdline *cl,
10127 __rte_unused void *data)
10129 struct cmd_flush_queue_region_result *res = parsed_result;
10130 int ret = -ENOTSUP;
10131 #ifdef RTE_LIBRTE_I40E_PMD
10132 struct rte_pmd_i40e_queue_region_conf region_conf;
10133 enum rte_pmd_i40e_queue_region_op op_type;
10136 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10139 #ifdef RTE_LIBRTE_I40E_PMD
10140 memset(®ion_conf, 0, sizeof(region_conf));
10142 if (strcmp(res->what, "on") == 0)
10143 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10145 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10147 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10148 op_type, ®ion_conf);
10155 printf("function not implemented or supported\n");
10158 printf("queue region config flush error: (%s)\n",
10163 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10164 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10166 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10167 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10169 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10170 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10172 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10173 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10174 cmd, "queue-region");
10175 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10176 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10178 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10179 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10182 cmdline_parse_inst_t cmd_flush_queue_region = {
10183 .f = cmd_flush_queue_region_parsed,
10185 .help_str = "set port <port_id> queue-region flush on|off"
10186 ": flush all queue region related configuration",
10188 (void *)&cmd_flush_queue_region_set,
10189 (void *)&cmd_flush_queue_region_port,
10190 (void *)&cmd_flush_queue_region_port_index,
10191 (void *)&cmd_flush_queue_region_cmd,
10192 (void *)&cmd_flush_queue_region_flush,
10193 (void *)&cmd_flush_queue_region_what,
10198 /* *** get all queue region related configuration info *** */
10199 struct cmd_show_queue_region_info {
10200 cmdline_fixed_string_t show;
10201 cmdline_fixed_string_t port;
10203 cmdline_fixed_string_t cmd;
10207 cmd_show_queue_region_info_parsed(void *parsed_result,
10208 __rte_unused struct cmdline *cl,
10209 __rte_unused void *data)
10211 struct cmd_show_queue_region_info *res = parsed_result;
10212 int ret = -ENOTSUP;
10213 #ifdef RTE_LIBRTE_I40E_PMD
10214 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10215 enum rte_pmd_i40e_queue_region_op op_type;
10218 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10221 #ifdef RTE_LIBRTE_I40E_PMD
10222 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10224 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10226 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10227 op_type, &rte_pmd_regions);
10229 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10236 printf("function not implemented or supported\n");
10239 printf("queue region config info show error: (%s)\n",
10244 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10245 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10247 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10248 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10250 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10251 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10253 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10254 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10255 cmd, "queue-region");
10257 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10258 .f = cmd_show_queue_region_info_parsed,
10260 .help_str = "show port <port_id> queue-region"
10261 ": show all queue region related configuration info",
10263 (void *)&cmd_show_queue_region_info_get,
10264 (void *)&cmd_show_queue_region_info_port,
10265 (void *)&cmd_show_queue_region_info_port_index,
10266 (void *)&cmd_show_queue_region_info_cmd,
10271 /* *** ADD/REMOVE A 2tuple FILTER *** */
10272 struct cmd_2tuple_filter_result {
10273 cmdline_fixed_string_t filter;
10275 cmdline_fixed_string_t ops;
10276 cmdline_fixed_string_t dst_port;
10277 uint16_t dst_port_value;
10278 cmdline_fixed_string_t protocol;
10279 uint8_t protocol_value;
10280 cmdline_fixed_string_t mask;
10281 uint8_t mask_value;
10282 cmdline_fixed_string_t tcp_flags;
10283 uint8_t tcp_flags_value;
10284 cmdline_fixed_string_t priority;
10285 uint8_t priority_value;
10286 cmdline_fixed_string_t queue;
10291 cmd_2tuple_filter_parsed(void *parsed_result,
10292 __rte_unused struct cmdline *cl,
10293 __rte_unused void *data)
10295 struct rte_eth_ntuple_filter filter;
10296 struct cmd_2tuple_filter_result *res = parsed_result;
10299 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10301 printf("ntuple filter is not supported on port %u.\n",
10306 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10308 filter.flags = RTE_2TUPLE_FLAGS;
10309 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10310 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10311 filter.proto = res->protocol_value;
10312 filter.priority = res->priority_value;
10313 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10314 printf("nonzero tcp_flags is only meaningful"
10315 " when protocol is TCP.\n");
10318 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10319 printf("invalid TCP flags.\n");
10323 if (res->tcp_flags_value != 0) {
10324 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10325 filter.tcp_flags = res->tcp_flags_value;
10328 /* need convert to big endian. */
10329 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10330 filter.queue = res->queue_id;
10332 if (!strcmp(res->ops, "add"))
10333 ret = rte_eth_dev_filter_ctrl(res->port_id,
10334 RTE_ETH_FILTER_NTUPLE,
10335 RTE_ETH_FILTER_ADD,
10338 ret = rte_eth_dev_filter_ctrl(res->port_id,
10339 RTE_ETH_FILTER_NTUPLE,
10340 RTE_ETH_FILTER_DELETE,
10343 printf("2tuple filter programming error: (%s)\n",
10348 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10349 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10350 filter, "2tuple_filter");
10351 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10352 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10354 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10355 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10357 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10358 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10359 dst_port, "dst_port");
10360 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10361 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10362 dst_port_value, UINT16);
10363 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10364 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10365 protocol, "protocol");
10366 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10367 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10368 protocol_value, UINT8);
10369 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10370 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10372 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10373 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10375 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10376 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10377 tcp_flags, "tcp_flags");
10378 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10379 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10380 tcp_flags_value, UINT8);
10381 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10382 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10383 priority, "priority");
10384 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10385 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10386 priority_value, UINT8);
10387 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10388 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10390 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10391 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10394 cmdline_parse_inst_t cmd_2tuple_filter = {
10395 .f = cmd_2tuple_filter_parsed,
10397 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10398 "<value> mask <value> tcp_flags <value> priority <value> queue "
10399 "<queue_id>: Add a 2tuple filter",
10401 (void *)&cmd_2tuple_filter_filter,
10402 (void *)&cmd_2tuple_filter_port_id,
10403 (void *)&cmd_2tuple_filter_ops,
10404 (void *)&cmd_2tuple_filter_dst_port,
10405 (void *)&cmd_2tuple_filter_dst_port_value,
10406 (void *)&cmd_2tuple_filter_protocol,
10407 (void *)&cmd_2tuple_filter_protocol_value,
10408 (void *)&cmd_2tuple_filter_mask,
10409 (void *)&cmd_2tuple_filter_mask_value,
10410 (void *)&cmd_2tuple_filter_tcp_flags,
10411 (void *)&cmd_2tuple_filter_tcp_flags_value,
10412 (void *)&cmd_2tuple_filter_priority,
10413 (void *)&cmd_2tuple_filter_priority_value,
10414 (void *)&cmd_2tuple_filter_queue,
10415 (void *)&cmd_2tuple_filter_queue_id,
10420 /* *** ADD/REMOVE A 5tuple FILTER *** */
10421 struct cmd_5tuple_filter_result {
10422 cmdline_fixed_string_t filter;
10424 cmdline_fixed_string_t ops;
10425 cmdline_fixed_string_t dst_ip;
10426 cmdline_ipaddr_t dst_ip_value;
10427 cmdline_fixed_string_t src_ip;
10428 cmdline_ipaddr_t src_ip_value;
10429 cmdline_fixed_string_t dst_port;
10430 uint16_t dst_port_value;
10431 cmdline_fixed_string_t src_port;
10432 uint16_t src_port_value;
10433 cmdline_fixed_string_t protocol;
10434 uint8_t protocol_value;
10435 cmdline_fixed_string_t mask;
10436 uint8_t mask_value;
10437 cmdline_fixed_string_t tcp_flags;
10438 uint8_t tcp_flags_value;
10439 cmdline_fixed_string_t priority;
10440 uint8_t priority_value;
10441 cmdline_fixed_string_t queue;
10446 cmd_5tuple_filter_parsed(void *parsed_result,
10447 __rte_unused struct cmdline *cl,
10448 __rte_unused void *data)
10450 struct rte_eth_ntuple_filter filter;
10451 struct cmd_5tuple_filter_result *res = parsed_result;
10454 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10456 printf("ntuple filter is not supported on port %u.\n",
10461 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10463 filter.flags = RTE_5TUPLE_FLAGS;
10464 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10465 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10466 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10467 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10468 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10469 filter.proto = res->protocol_value;
10470 filter.priority = res->priority_value;
10471 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10472 printf("nonzero tcp_flags is only meaningful"
10473 " when protocol is TCP.\n");
10476 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10477 printf("invalid TCP flags.\n");
10481 if (res->tcp_flags_value != 0) {
10482 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10483 filter.tcp_flags = res->tcp_flags_value;
10486 if (res->dst_ip_value.family == AF_INET)
10487 /* no need to convert, already big endian. */
10488 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10490 if (filter.dst_ip_mask == 0) {
10491 printf("can not support ipv6 involved compare.\n");
10497 if (res->src_ip_value.family == AF_INET)
10498 /* no need to convert, already big endian. */
10499 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10501 if (filter.src_ip_mask == 0) {
10502 printf("can not support ipv6 involved compare.\n");
10507 /* need convert to big endian. */
10508 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10509 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10510 filter.queue = res->queue_id;
10512 if (!strcmp(res->ops, "add"))
10513 ret = rte_eth_dev_filter_ctrl(res->port_id,
10514 RTE_ETH_FILTER_NTUPLE,
10515 RTE_ETH_FILTER_ADD,
10518 ret = rte_eth_dev_filter_ctrl(res->port_id,
10519 RTE_ETH_FILTER_NTUPLE,
10520 RTE_ETH_FILTER_DELETE,
10523 printf("5tuple filter programming error: (%s)\n",
10527 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10528 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10529 filter, "5tuple_filter");
10530 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10531 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10533 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10534 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10536 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10537 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10539 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10540 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10542 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10543 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10545 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10546 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10548 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10549 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10550 dst_port, "dst_port");
10551 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10552 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10553 dst_port_value, UINT16);
10554 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10555 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10556 src_port, "src_port");
10557 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10558 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10559 src_port_value, UINT16);
10560 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10561 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10562 protocol, "protocol");
10563 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10564 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10565 protocol_value, UINT8);
10566 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10567 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10569 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10570 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10572 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10573 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10574 tcp_flags, "tcp_flags");
10575 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10576 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10577 tcp_flags_value, UINT8);
10578 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10579 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10580 priority, "priority");
10581 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10582 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10583 priority_value, UINT8);
10584 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10585 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10587 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10588 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10591 cmdline_parse_inst_t cmd_5tuple_filter = {
10592 .f = cmd_5tuple_filter_parsed,
10594 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10595 "src_ip <value> dst_port <value> src_port <value> "
10596 "protocol <value> mask <value> tcp_flags <value> "
10597 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10599 (void *)&cmd_5tuple_filter_filter,
10600 (void *)&cmd_5tuple_filter_port_id,
10601 (void *)&cmd_5tuple_filter_ops,
10602 (void *)&cmd_5tuple_filter_dst_ip,
10603 (void *)&cmd_5tuple_filter_dst_ip_value,
10604 (void *)&cmd_5tuple_filter_src_ip,
10605 (void *)&cmd_5tuple_filter_src_ip_value,
10606 (void *)&cmd_5tuple_filter_dst_port,
10607 (void *)&cmd_5tuple_filter_dst_port_value,
10608 (void *)&cmd_5tuple_filter_src_port,
10609 (void *)&cmd_5tuple_filter_src_port_value,
10610 (void *)&cmd_5tuple_filter_protocol,
10611 (void *)&cmd_5tuple_filter_protocol_value,
10612 (void *)&cmd_5tuple_filter_mask,
10613 (void *)&cmd_5tuple_filter_mask_value,
10614 (void *)&cmd_5tuple_filter_tcp_flags,
10615 (void *)&cmd_5tuple_filter_tcp_flags_value,
10616 (void *)&cmd_5tuple_filter_priority,
10617 (void *)&cmd_5tuple_filter_priority_value,
10618 (void *)&cmd_5tuple_filter_queue,
10619 (void *)&cmd_5tuple_filter_queue_id,
10624 /* *** ADD/REMOVE A flex FILTER *** */
10625 struct cmd_flex_filter_result {
10626 cmdline_fixed_string_t filter;
10627 cmdline_fixed_string_t ops;
10629 cmdline_fixed_string_t len;
10631 cmdline_fixed_string_t bytes;
10632 cmdline_fixed_string_t bytes_value;
10633 cmdline_fixed_string_t mask;
10634 cmdline_fixed_string_t mask_value;
10635 cmdline_fixed_string_t priority;
10636 uint8_t priority_value;
10637 cmdline_fixed_string_t queue;
10641 static int xdigit2val(unsigned char c)
10646 else if (isupper(c))
10647 val = c - 'A' + 10;
10649 val = c - 'a' + 10;
10654 cmd_flex_filter_parsed(void *parsed_result,
10655 __rte_unused struct cmdline *cl,
10656 __rte_unused void *data)
10659 struct rte_eth_flex_filter filter;
10660 struct cmd_flex_filter_result *res = parsed_result;
10661 char *bytes_ptr, *mask_ptr;
10662 uint16_t len, i, j = 0;
10667 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10668 printf("the len exceed the max length 128\n");
10671 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10672 filter.len = res->len_value;
10673 filter.priority = res->priority_value;
10674 filter.queue = res->queue_id;
10675 bytes_ptr = res->bytes_value;
10676 mask_ptr = res->mask_value;
10678 /* translate bytes string to array. */
10679 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10680 (bytes_ptr[1] == 'X')))
10682 len = strnlen(bytes_ptr, res->len_value * 2);
10683 if (len == 0 || (len % 8 != 0)) {
10684 printf("please check len and bytes input\n");
10687 for (i = 0; i < len; i++) {
10689 if (isxdigit(c) == 0) {
10690 /* invalid characters. */
10691 printf("invalid input\n");
10694 val = xdigit2val(c);
10697 filter.bytes[j] = byte;
10698 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10705 /* translate mask string to uint8_t array. */
10706 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10707 (mask_ptr[1] == 'X')))
10709 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10711 printf("invalid input\n");
10716 for (i = 0; i < len; i++) {
10718 if (isxdigit(c) == 0) {
10719 /* invalid characters. */
10720 printf("invalid input\n");
10723 val = xdigit2val(c);
10726 filter.mask[j] = byte;
10727 printf("mask[%d]:%02x ", j, filter.mask[j]);
10735 if (!strcmp(res->ops, "add"))
10736 ret = rte_eth_dev_filter_ctrl(res->port_id,
10737 RTE_ETH_FILTER_FLEXIBLE,
10738 RTE_ETH_FILTER_ADD,
10741 ret = rte_eth_dev_filter_ctrl(res->port_id,
10742 RTE_ETH_FILTER_FLEXIBLE,
10743 RTE_ETH_FILTER_DELETE,
10747 printf("flex filter setting error: (%s)\n", strerror(-ret));
10750 cmdline_parse_token_string_t cmd_flex_filter_filter =
10751 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10752 filter, "flex_filter");
10753 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10754 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10756 cmdline_parse_token_string_t cmd_flex_filter_ops =
10757 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10759 cmdline_parse_token_string_t cmd_flex_filter_len =
10760 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10762 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10763 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10765 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10766 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10768 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10769 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10770 bytes_value, NULL);
10771 cmdline_parse_token_string_t cmd_flex_filter_mask =
10772 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10774 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10775 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10777 cmdline_parse_token_string_t cmd_flex_filter_priority =
10778 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10779 priority, "priority");
10780 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10781 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10782 priority_value, UINT8);
10783 cmdline_parse_token_string_t cmd_flex_filter_queue =
10784 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10786 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10787 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10789 cmdline_parse_inst_t cmd_flex_filter = {
10790 .f = cmd_flex_filter_parsed,
10792 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10793 "<value> mask <value> priority <value> queue <queue_id>: "
10794 "Add/Del a flex filter",
10796 (void *)&cmd_flex_filter_filter,
10797 (void *)&cmd_flex_filter_port_id,
10798 (void *)&cmd_flex_filter_ops,
10799 (void *)&cmd_flex_filter_len,
10800 (void *)&cmd_flex_filter_len_value,
10801 (void *)&cmd_flex_filter_bytes,
10802 (void *)&cmd_flex_filter_bytes_value,
10803 (void *)&cmd_flex_filter_mask,
10804 (void *)&cmd_flex_filter_mask_value,
10805 (void *)&cmd_flex_filter_priority,
10806 (void *)&cmd_flex_filter_priority_value,
10807 (void *)&cmd_flex_filter_queue,
10808 (void *)&cmd_flex_filter_queue_id,
10813 /* *** Filters Control *** */
10815 /* *** deal with ethertype filter *** */
10816 struct cmd_ethertype_filter_result {
10817 cmdline_fixed_string_t filter;
10819 cmdline_fixed_string_t ops;
10820 cmdline_fixed_string_t mac;
10821 struct rte_ether_addr mac_addr;
10822 cmdline_fixed_string_t ethertype;
10823 uint16_t ethertype_value;
10824 cmdline_fixed_string_t drop;
10825 cmdline_fixed_string_t queue;
10829 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10830 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10831 filter, "ethertype_filter");
10832 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10833 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10835 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10836 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10838 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10839 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10840 mac, "mac_addr#mac_ignr");
10841 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10842 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10844 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10845 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10846 ethertype, "ethertype");
10847 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10848 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10849 ethertype_value, UINT16);
10850 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10851 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10853 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10854 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10856 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10857 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10861 cmd_ethertype_filter_parsed(void *parsed_result,
10862 __rte_unused struct cmdline *cl,
10863 __rte_unused void *data)
10865 struct cmd_ethertype_filter_result *res = parsed_result;
10866 struct rte_eth_ethertype_filter filter;
10869 ret = rte_eth_dev_filter_supported(res->port_id,
10870 RTE_ETH_FILTER_ETHERTYPE);
10872 printf("ethertype filter is not supported on port %u.\n",
10877 memset(&filter, 0, sizeof(filter));
10878 if (!strcmp(res->mac, "mac_addr")) {
10879 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10880 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10881 sizeof(struct rte_ether_addr));
10883 if (!strcmp(res->drop, "drop"))
10884 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10885 filter.ether_type = res->ethertype_value;
10886 filter.queue = res->queue_id;
10888 if (!strcmp(res->ops, "add"))
10889 ret = rte_eth_dev_filter_ctrl(res->port_id,
10890 RTE_ETH_FILTER_ETHERTYPE,
10891 RTE_ETH_FILTER_ADD,
10894 ret = rte_eth_dev_filter_ctrl(res->port_id,
10895 RTE_ETH_FILTER_ETHERTYPE,
10896 RTE_ETH_FILTER_DELETE,
10899 printf("ethertype filter programming error: (%s)\n",
10903 cmdline_parse_inst_t cmd_ethertype_filter = {
10904 .f = cmd_ethertype_filter_parsed,
10906 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10907 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10908 "Add or delete an ethertype filter entry",
10910 (void *)&cmd_ethertype_filter_filter,
10911 (void *)&cmd_ethertype_filter_port_id,
10912 (void *)&cmd_ethertype_filter_ops,
10913 (void *)&cmd_ethertype_filter_mac,
10914 (void *)&cmd_ethertype_filter_mac_addr,
10915 (void *)&cmd_ethertype_filter_ethertype,
10916 (void *)&cmd_ethertype_filter_ethertype_value,
10917 (void *)&cmd_ethertype_filter_drop,
10918 (void *)&cmd_ethertype_filter_queue,
10919 (void *)&cmd_ethertype_filter_queue_id,
10924 /* *** deal with flow director filter *** */
10925 struct cmd_flow_director_result {
10926 cmdline_fixed_string_t flow_director_filter;
10928 cmdline_fixed_string_t mode;
10929 cmdline_fixed_string_t mode_value;
10930 cmdline_fixed_string_t ops;
10931 cmdline_fixed_string_t flow;
10932 cmdline_fixed_string_t flow_type;
10933 cmdline_fixed_string_t ether;
10934 uint16_t ether_type;
10935 cmdline_fixed_string_t src;
10936 cmdline_ipaddr_t ip_src;
10938 cmdline_fixed_string_t dst;
10939 cmdline_ipaddr_t ip_dst;
10941 cmdline_fixed_string_t verify_tag;
10942 uint32_t verify_tag_value;
10943 cmdline_fixed_string_t tos;
10945 cmdline_fixed_string_t proto;
10946 uint8_t proto_value;
10947 cmdline_fixed_string_t ttl;
10949 cmdline_fixed_string_t vlan;
10950 uint16_t vlan_value;
10951 cmdline_fixed_string_t flexbytes;
10952 cmdline_fixed_string_t flexbytes_value;
10953 cmdline_fixed_string_t pf_vf;
10954 cmdline_fixed_string_t drop;
10955 cmdline_fixed_string_t queue;
10957 cmdline_fixed_string_t fd_id;
10958 uint32_t fd_id_value;
10959 cmdline_fixed_string_t mac;
10960 struct rte_ether_addr mac_addr;
10961 cmdline_fixed_string_t tunnel;
10962 cmdline_fixed_string_t tunnel_type;
10963 cmdline_fixed_string_t tunnel_id;
10964 uint32_t tunnel_id_value;
10965 cmdline_fixed_string_t packet;
10970 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10973 const char *p, *p0 = q_arg;
10975 unsigned long int_fld;
10976 char *str_fld[max_num];
10981 p = strchr(p0, '(');
10985 p0 = strchr(p, ')');
10990 if (size >= sizeof(s))
10993 snprintf(s, sizeof(s), "%.*s", size, p);
10994 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10995 if (ret < 0 || ret > max_num)
10997 for (i = 0; i < ret; i++) {
10999 int_fld = strtoul(str_fld[i], &end, 0);
11000 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11002 flexbytes[i] = (uint8_t)int_fld;
11008 str2flowtype(char *string)
11011 static const struct {
11014 } flowtype_str[] = {
11015 {"raw", RTE_ETH_FLOW_RAW},
11016 {"ipv4", RTE_ETH_FLOW_IPV4},
11017 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11018 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11019 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11020 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11021 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11022 {"ipv6", RTE_ETH_FLOW_IPV6},
11023 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11024 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11025 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11026 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11027 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11028 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11031 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11032 if (!strcmp(flowtype_str[i].str, string))
11033 return flowtype_str[i].type;
11036 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11037 return (uint16_t)atoi(string);
11039 return RTE_ETH_FLOW_UNKNOWN;
11042 static enum rte_eth_fdir_tunnel_type
11043 str2fdir_tunneltype(char *string)
11047 static const struct {
11049 enum rte_eth_fdir_tunnel_type type;
11050 } tunneltype_str[] = {
11051 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11052 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11055 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11056 if (!strcmp(tunneltype_str[i].str, string))
11057 return tunneltype_str[i].type;
11059 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11062 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11064 if ((ip_addr).family == AF_INET) \
11065 (ip) = (ip_addr).addr.ipv4.s_addr; \
11067 printf("invalid parameter.\n"); \
11072 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11074 if ((ip_addr).family == AF_INET6) \
11075 rte_memcpy(&(ip), \
11076 &((ip_addr).addr.ipv6), \
11077 sizeof(struct in6_addr)); \
11079 printf("invalid parameter.\n"); \
11085 cmd_flow_director_filter_parsed(void *parsed_result,
11086 __rte_unused struct cmdline *cl,
11087 __rte_unused void *data)
11089 struct cmd_flow_director_result *res = parsed_result;
11090 struct rte_eth_fdir_filter entry;
11091 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11093 unsigned long vf_id;
11096 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11098 printf("flow director is not supported on port %u.\n",
11102 memset(flexbytes, 0, sizeof(flexbytes));
11103 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11105 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11106 if (strcmp(res->mode_value, "MAC-VLAN")) {
11107 printf("Please set mode to MAC-VLAN.\n");
11110 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11111 if (strcmp(res->mode_value, "Tunnel")) {
11112 printf("Please set mode to Tunnel.\n");
11116 if (!strcmp(res->mode_value, "raw")) {
11117 #ifdef RTE_LIBRTE_I40E_PMD
11118 struct rte_pmd_i40e_flow_type_mapping
11119 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11120 struct rte_pmd_i40e_pkt_template_conf conf;
11121 uint16_t flow_type = str2flowtype(res->flow_type);
11122 uint16_t i, port = res->port_id;
11125 memset(&conf, 0, sizeof(conf));
11127 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11128 printf("Invalid flow type specified.\n");
11131 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11135 if (mapping[flow_type].pctype == 0ULL) {
11136 printf("Invalid flow type specified.\n");
11139 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11140 if (mapping[flow_type].pctype & (1ULL << i)) {
11141 conf.input.pctype = i;
11146 conf.input.packet = open_file(res->filepath,
11147 &conf.input.length);
11148 if (!conf.input.packet)
11150 if (!strcmp(res->drop, "drop"))
11151 conf.action.behavior =
11152 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11154 conf.action.behavior =
11155 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11156 conf.action.report_status =
11157 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11158 conf.action.rx_queue = res->queue_id;
11159 conf.soft_id = res->fd_id_value;
11160 add = strcmp(res->ops, "del") ? 1 : 0;
11161 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11165 printf("flow director config error: (%s)\n",
11167 close_file(conf.input.packet);
11170 } else if (strcmp(res->mode_value, "IP")) {
11171 printf("Please set mode to IP or raw.\n");
11174 entry.input.flow_type = str2flowtype(res->flow_type);
11177 ret = parse_flexbytes(res->flexbytes_value,
11179 RTE_ETH_FDIR_MAX_FLEXLEN);
11181 printf("error: Cannot parse flexbytes input.\n");
11185 switch (entry.input.flow_type) {
11186 case RTE_ETH_FLOW_FRAG_IPV4:
11187 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11188 entry.input.flow.ip4_flow.proto = res->proto_value;
11190 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11191 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11192 IPV4_ADDR_TO_UINT(res->ip_dst,
11193 entry.input.flow.ip4_flow.dst_ip);
11194 IPV4_ADDR_TO_UINT(res->ip_src,
11195 entry.input.flow.ip4_flow.src_ip);
11196 entry.input.flow.ip4_flow.tos = res->tos_value;
11197 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11198 /* need convert to big endian. */
11199 entry.input.flow.udp4_flow.dst_port =
11200 rte_cpu_to_be_16(res->port_dst);
11201 entry.input.flow.udp4_flow.src_port =
11202 rte_cpu_to_be_16(res->port_src);
11204 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11205 IPV4_ADDR_TO_UINT(res->ip_dst,
11206 entry.input.flow.sctp4_flow.ip.dst_ip);
11207 IPV4_ADDR_TO_UINT(res->ip_src,
11208 entry.input.flow.sctp4_flow.ip.src_ip);
11209 entry.input.flow.ip4_flow.tos = res->tos_value;
11210 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11211 /* need convert to big endian. */
11212 entry.input.flow.sctp4_flow.dst_port =
11213 rte_cpu_to_be_16(res->port_dst);
11214 entry.input.flow.sctp4_flow.src_port =
11215 rte_cpu_to_be_16(res->port_src);
11216 entry.input.flow.sctp4_flow.verify_tag =
11217 rte_cpu_to_be_32(res->verify_tag_value);
11219 case RTE_ETH_FLOW_FRAG_IPV6:
11220 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11221 entry.input.flow.ipv6_flow.proto = res->proto_value;
11223 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11224 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11225 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11226 entry.input.flow.ipv6_flow.dst_ip);
11227 IPV6_ADDR_TO_ARRAY(res->ip_src,
11228 entry.input.flow.ipv6_flow.src_ip);
11229 entry.input.flow.ipv6_flow.tc = res->tos_value;
11230 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11231 /* need convert to big endian. */
11232 entry.input.flow.udp6_flow.dst_port =
11233 rte_cpu_to_be_16(res->port_dst);
11234 entry.input.flow.udp6_flow.src_port =
11235 rte_cpu_to_be_16(res->port_src);
11237 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11238 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11239 entry.input.flow.sctp6_flow.ip.dst_ip);
11240 IPV6_ADDR_TO_ARRAY(res->ip_src,
11241 entry.input.flow.sctp6_flow.ip.src_ip);
11242 entry.input.flow.ipv6_flow.tc = res->tos_value;
11243 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11244 /* need convert to big endian. */
11245 entry.input.flow.sctp6_flow.dst_port =
11246 rte_cpu_to_be_16(res->port_dst);
11247 entry.input.flow.sctp6_flow.src_port =
11248 rte_cpu_to_be_16(res->port_src);
11249 entry.input.flow.sctp6_flow.verify_tag =
11250 rte_cpu_to_be_32(res->verify_tag_value);
11252 case RTE_ETH_FLOW_L2_PAYLOAD:
11253 entry.input.flow.l2_flow.ether_type =
11254 rte_cpu_to_be_16(res->ether_type);
11260 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11261 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11263 sizeof(struct rte_ether_addr));
11265 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11266 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11268 sizeof(struct rte_ether_addr));
11269 entry.input.flow.tunnel_flow.tunnel_type =
11270 str2fdir_tunneltype(res->tunnel_type);
11271 entry.input.flow.tunnel_flow.tunnel_id =
11272 rte_cpu_to_be_32(res->tunnel_id_value);
11275 rte_memcpy(entry.input.flow_ext.flexbytes,
11277 RTE_ETH_FDIR_MAX_FLEXLEN);
11279 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11281 entry.action.flex_off = 0; /*use 0 by default */
11282 if (!strcmp(res->drop, "drop"))
11283 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11285 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11287 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11288 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11289 if (!strcmp(res->pf_vf, "pf"))
11290 entry.input.flow_ext.is_vf = 0;
11291 else if (!strncmp(res->pf_vf, "vf", 2)) {
11292 struct rte_eth_dev_info dev_info;
11294 ret = eth_dev_info_get_print_err(res->port_id,
11300 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11301 if (errno != 0 || *end != '\0' ||
11302 vf_id >= dev_info.max_vfs) {
11303 printf("invalid parameter %s.\n", res->pf_vf);
11306 entry.input.flow_ext.is_vf = 1;
11307 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11309 printf("invalid parameter %s.\n", res->pf_vf);
11314 /* set to report FD ID by default */
11315 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11316 entry.action.rx_queue = res->queue_id;
11317 entry.soft_id = res->fd_id_value;
11318 if (!strcmp(res->ops, "add"))
11319 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11320 RTE_ETH_FILTER_ADD, &entry);
11321 else if (!strcmp(res->ops, "del"))
11322 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11323 RTE_ETH_FILTER_DELETE, &entry);
11325 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11326 RTE_ETH_FILTER_UPDATE, &entry);
11328 printf("flow director programming error: (%s)\n",
11332 cmdline_parse_token_string_t cmd_flow_director_filter =
11333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11334 flow_director_filter, "flow_director_filter");
11335 cmdline_parse_token_num_t cmd_flow_director_port_id =
11336 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11338 cmdline_parse_token_string_t cmd_flow_director_ops =
11339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11340 ops, "add#del#update");
11341 cmdline_parse_token_string_t cmd_flow_director_flow =
11342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11344 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11347 cmdline_parse_token_string_t cmd_flow_director_ether =
11348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11350 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11351 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11352 ether_type, UINT16);
11353 cmdline_parse_token_string_t cmd_flow_director_src =
11354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11356 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11357 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11359 cmdline_parse_token_num_t cmd_flow_director_port_src =
11360 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11362 cmdline_parse_token_string_t cmd_flow_director_dst =
11363 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11365 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11366 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11368 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11369 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11371 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11372 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11373 verify_tag, "verify_tag");
11374 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11375 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11376 verify_tag_value, UINT32);
11377 cmdline_parse_token_string_t cmd_flow_director_tos =
11378 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11380 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11381 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11383 cmdline_parse_token_string_t cmd_flow_director_proto =
11384 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11386 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11387 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11388 proto_value, UINT8);
11389 cmdline_parse_token_string_t cmd_flow_director_ttl =
11390 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11392 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11393 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11395 cmdline_parse_token_string_t cmd_flow_director_vlan =
11396 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11398 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11399 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11400 vlan_value, UINT16);
11401 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11402 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11403 flexbytes, "flexbytes");
11404 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11406 flexbytes_value, NULL);
11407 cmdline_parse_token_string_t cmd_flow_director_drop =
11408 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11410 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11411 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11413 cmdline_parse_token_string_t cmd_flow_director_queue =
11414 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11416 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11417 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11419 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11420 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11422 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11423 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11424 fd_id_value, UINT32);
11426 cmdline_parse_token_string_t cmd_flow_director_mode =
11427 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11429 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11432 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11433 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11434 mode_value, "MAC-VLAN");
11435 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11437 mode_value, "Tunnel");
11438 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11439 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11440 mode_value, "raw");
11441 cmdline_parse_token_string_t cmd_flow_director_mac =
11442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11444 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11445 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11447 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11448 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11450 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11451 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11452 tunnel_type, "NVGRE#VxLAN");
11453 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11455 tunnel_id, "tunnel-id");
11456 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11457 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11458 tunnel_id_value, UINT32);
11459 cmdline_parse_token_string_t cmd_flow_director_packet =
11460 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11462 cmdline_parse_token_string_t cmd_flow_director_filepath =
11463 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11466 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11467 .f = cmd_flow_director_filter_parsed,
11469 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11470 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11471 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11472 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11473 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11474 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11475 "fd_id <fd_id_value>: "
11476 "Add or delete an ip flow director entry on NIC",
11478 (void *)&cmd_flow_director_filter,
11479 (void *)&cmd_flow_director_port_id,
11480 (void *)&cmd_flow_director_mode,
11481 (void *)&cmd_flow_director_mode_ip,
11482 (void *)&cmd_flow_director_ops,
11483 (void *)&cmd_flow_director_flow,
11484 (void *)&cmd_flow_director_flow_type,
11485 (void *)&cmd_flow_director_src,
11486 (void *)&cmd_flow_director_ip_src,
11487 (void *)&cmd_flow_director_dst,
11488 (void *)&cmd_flow_director_ip_dst,
11489 (void *)&cmd_flow_director_tos,
11490 (void *)&cmd_flow_director_tos_value,
11491 (void *)&cmd_flow_director_proto,
11492 (void *)&cmd_flow_director_proto_value,
11493 (void *)&cmd_flow_director_ttl,
11494 (void *)&cmd_flow_director_ttl_value,
11495 (void *)&cmd_flow_director_vlan,
11496 (void *)&cmd_flow_director_vlan_value,
11497 (void *)&cmd_flow_director_flexbytes,
11498 (void *)&cmd_flow_director_flexbytes_value,
11499 (void *)&cmd_flow_director_drop,
11500 (void *)&cmd_flow_director_pf_vf,
11501 (void *)&cmd_flow_director_queue,
11502 (void *)&cmd_flow_director_queue_id,
11503 (void *)&cmd_flow_director_fd_id,
11504 (void *)&cmd_flow_director_fd_id_value,
11509 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11510 .f = cmd_flow_director_filter_parsed,
11512 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11513 "director entry on NIC",
11515 (void *)&cmd_flow_director_filter,
11516 (void *)&cmd_flow_director_port_id,
11517 (void *)&cmd_flow_director_mode,
11518 (void *)&cmd_flow_director_mode_ip,
11519 (void *)&cmd_flow_director_ops,
11520 (void *)&cmd_flow_director_flow,
11521 (void *)&cmd_flow_director_flow_type,
11522 (void *)&cmd_flow_director_src,
11523 (void *)&cmd_flow_director_ip_src,
11524 (void *)&cmd_flow_director_port_src,
11525 (void *)&cmd_flow_director_dst,
11526 (void *)&cmd_flow_director_ip_dst,
11527 (void *)&cmd_flow_director_port_dst,
11528 (void *)&cmd_flow_director_tos,
11529 (void *)&cmd_flow_director_tos_value,
11530 (void *)&cmd_flow_director_ttl,
11531 (void *)&cmd_flow_director_ttl_value,
11532 (void *)&cmd_flow_director_vlan,
11533 (void *)&cmd_flow_director_vlan_value,
11534 (void *)&cmd_flow_director_flexbytes,
11535 (void *)&cmd_flow_director_flexbytes_value,
11536 (void *)&cmd_flow_director_drop,
11537 (void *)&cmd_flow_director_pf_vf,
11538 (void *)&cmd_flow_director_queue,
11539 (void *)&cmd_flow_director_queue_id,
11540 (void *)&cmd_flow_director_fd_id,
11541 (void *)&cmd_flow_director_fd_id_value,
11546 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11547 .f = cmd_flow_director_filter_parsed,
11549 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11550 "director entry on NIC",
11552 (void *)&cmd_flow_director_filter,
11553 (void *)&cmd_flow_director_port_id,
11554 (void *)&cmd_flow_director_mode,
11555 (void *)&cmd_flow_director_mode_ip,
11556 (void *)&cmd_flow_director_ops,
11557 (void *)&cmd_flow_director_flow,
11558 (void *)&cmd_flow_director_flow_type,
11559 (void *)&cmd_flow_director_src,
11560 (void *)&cmd_flow_director_ip_src,
11561 (void *)&cmd_flow_director_port_src,
11562 (void *)&cmd_flow_director_dst,
11563 (void *)&cmd_flow_director_ip_dst,
11564 (void *)&cmd_flow_director_port_dst,
11565 (void *)&cmd_flow_director_verify_tag,
11566 (void *)&cmd_flow_director_verify_tag_value,
11567 (void *)&cmd_flow_director_tos,
11568 (void *)&cmd_flow_director_tos_value,
11569 (void *)&cmd_flow_director_ttl,
11570 (void *)&cmd_flow_director_ttl_value,
11571 (void *)&cmd_flow_director_vlan,
11572 (void *)&cmd_flow_director_vlan_value,
11573 (void *)&cmd_flow_director_flexbytes,
11574 (void *)&cmd_flow_director_flexbytes_value,
11575 (void *)&cmd_flow_director_drop,
11576 (void *)&cmd_flow_director_pf_vf,
11577 (void *)&cmd_flow_director_queue,
11578 (void *)&cmd_flow_director_queue_id,
11579 (void *)&cmd_flow_director_fd_id,
11580 (void *)&cmd_flow_director_fd_id_value,
11585 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11586 .f = cmd_flow_director_filter_parsed,
11588 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11589 "director entry on NIC",
11591 (void *)&cmd_flow_director_filter,
11592 (void *)&cmd_flow_director_port_id,
11593 (void *)&cmd_flow_director_mode,
11594 (void *)&cmd_flow_director_mode_ip,
11595 (void *)&cmd_flow_director_ops,
11596 (void *)&cmd_flow_director_flow,
11597 (void *)&cmd_flow_director_flow_type,
11598 (void *)&cmd_flow_director_ether,
11599 (void *)&cmd_flow_director_ether_type,
11600 (void *)&cmd_flow_director_flexbytes,
11601 (void *)&cmd_flow_director_flexbytes_value,
11602 (void *)&cmd_flow_director_drop,
11603 (void *)&cmd_flow_director_pf_vf,
11604 (void *)&cmd_flow_director_queue,
11605 (void *)&cmd_flow_director_queue_id,
11606 (void *)&cmd_flow_director_fd_id,
11607 (void *)&cmd_flow_director_fd_id_value,
11612 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11613 .f = cmd_flow_director_filter_parsed,
11615 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11616 "director entry on NIC",
11618 (void *)&cmd_flow_director_filter,
11619 (void *)&cmd_flow_director_port_id,
11620 (void *)&cmd_flow_director_mode,
11621 (void *)&cmd_flow_director_mode_mac_vlan,
11622 (void *)&cmd_flow_director_ops,
11623 (void *)&cmd_flow_director_mac,
11624 (void *)&cmd_flow_director_mac_addr,
11625 (void *)&cmd_flow_director_vlan,
11626 (void *)&cmd_flow_director_vlan_value,
11627 (void *)&cmd_flow_director_flexbytes,
11628 (void *)&cmd_flow_director_flexbytes_value,
11629 (void *)&cmd_flow_director_drop,
11630 (void *)&cmd_flow_director_queue,
11631 (void *)&cmd_flow_director_queue_id,
11632 (void *)&cmd_flow_director_fd_id,
11633 (void *)&cmd_flow_director_fd_id_value,
11638 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11639 .f = cmd_flow_director_filter_parsed,
11641 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11642 "director entry on NIC",
11644 (void *)&cmd_flow_director_filter,
11645 (void *)&cmd_flow_director_port_id,
11646 (void *)&cmd_flow_director_mode,
11647 (void *)&cmd_flow_director_mode_tunnel,
11648 (void *)&cmd_flow_director_ops,
11649 (void *)&cmd_flow_director_mac,
11650 (void *)&cmd_flow_director_mac_addr,
11651 (void *)&cmd_flow_director_vlan,
11652 (void *)&cmd_flow_director_vlan_value,
11653 (void *)&cmd_flow_director_tunnel,
11654 (void *)&cmd_flow_director_tunnel_type,
11655 (void *)&cmd_flow_director_tunnel_id,
11656 (void *)&cmd_flow_director_tunnel_id_value,
11657 (void *)&cmd_flow_director_flexbytes,
11658 (void *)&cmd_flow_director_flexbytes_value,
11659 (void *)&cmd_flow_director_drop,
11660 (void *)&cmd_flow_director_queue,
11661 (void *)&cmd_flow_director_queue_id,
11662 (void *)&cmd_flow_director_fd_id,
11663 (void *)&cmd_flow_director_fd_id_value,
11668 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11669 .f = cmd_flow_director_filter_parsed,
11671 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11672 "director entry on NIC",
11674 (void *)&cmd_flow_director_filter,
11675 (void *)&cmd_flow_director_port_id,
11676 (void *)&cmd_flow_director_mode,
11677 (void *)&cmd_flow_director_mode_raw,
11678 (void *)&cmd_flow_director_ops,
11679 (void *)&cmd_flow_director_flow,
11680 (void *)&cmd_flow_director_flow_type,
11681 (void *)&cmd_flow_director_drop,
11682 (void *)&cmd_flow_director_queue,
11683 (void *)&cmd_flow_director_queue_id,
11684 (void *)&cmd_flow_director_fd_id,
11685 (void *)&cmd_flow_director_fd_id_value,
11686 (void *)&cmd_flow_director_packet,
11687 (void *)&cmd_flow_director_filepath,
11692 struct cmd_flush_flow_director_result {
11693 cmdline_fixed_string_t flush_flow_director;
11697 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11698 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11699 flush_flow_director, "flush_flow_director");
11700 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11701 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11705 cmd_flush_flow_director_parsed(void *parsed_result,
11706 __rte_unused struct cmdline *cl,
11707 __rte_unused void *data)
11709 struct cmd_flow_director_result *res = parsed_result;
11712 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11714 printf("flow director is not supported on port %u.\n",
11719 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11720 RTE_ETH_FILTER_FLUSH, NULL);
11722 printf("flow director table flushing error: (%s)\n",
11726 cmdline_parse_inst_t cmd_flush_flow_director = {
11727 .f = cmd_flush_flow_director_parsed,
11729 .help_str = "flush_flow_director <port_id>: "
11730 "Flush all flow director entries of a device on NIC",
11732 (void *)&cmd_flush_flow_director_flush,
11733 (void *)&cmd_flush_flow_director_port_id,
11738 /* *** deal with flow director mask *** */
11739 struct cmd_flow_director_mask_result {
11740 cmdline_fixed_string_t flow_director_mask;
11742 cmdline_fixed_string_t mode;
11743 cmdline_fixed_string_t mode_value;
11744 cmdline_fixed_string_t vlan;
11745 uint16_t vlan_mask;
11746 cmdline_fixed_string_t src_mask;
11747 cmdline_ipaddr_t ipv4_src;
11748 cmdline_ipaddr_t ipv6_src;
11750 cmdline_fixed_string_t dst_mask;
11751 cmdline_ipaddr_t ipv4_dst;
11752 cmdline_ipaddr_t ipv6_dst;
11754 cmdline_fixed_string_t mac;
11755 uint8_t mac_addr_byte_mask;
11756 cmdline_fixed_string_t tunnel_id;
11757 uint32_t tunnel_id_mask;
11758 cmdline_fixed_string_t tunnel_type;
11759 uint8_t tunnel_type_mask;
11763 cmd_flow_director_mask_parsed(void *parsed_result,
11764 __rte_unused struct cmdline *cl,
11765 __rte_unused void *data)
11767 struct cmd_flow_director_mask_result *res = parsed_result;
11768 struct rte_eth_fdir_masks *mask;
11769 struct rte_port *port;
11771 port = &ports[res->port_id];
11772 /** Check if the port is not started **/
11773 if (port->port_status != RTE_PORT_STOPPED) {
11774 printf("Please stop port %d first\n", res->port_id);
11778 mask = &port->dev_conf.fdir_conf.mask;
11780 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11781 if (strcmp(res->mode_value, "MAC-VLAN")) {
11782 printf("Please set mode to MAC-VLAN.\n");
11786 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11787 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11788 if (strcmp(res->mode_value, "Tunnel")) {
11789 printf("Please set mode to Tunnel.\n");
11793 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11794 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11795 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11796 mask->tunnel_type_mask = res->tunnel_type_mask;
11798 if (strcmp(res->mode_value, "IP")) {
11799 printf("Please set mode to IP.\n");
11803 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11804 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11805 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11806 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11807 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11808 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11809 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11812 cmd_reconfig_device_queue(res->port_id, 1, 1);
11815 cmdline_parse_token_string_t cmd_flow_director_mask =
11816 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11817 flow_director_mask, "flow_director_mask");
11818 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11819 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11821 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11822 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11824 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11825 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11826 vlan_mask, UINT16);
11827 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11829 src_mask, "src_mask");
11830 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11831 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11833 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11834 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11836 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11837 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11839 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11841 dst_mask, "dst_mask");
11842 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11843 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11845 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11846 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11848 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11849 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11852 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11855 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11858 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11859 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11860 mode_value, "MAC-VLAN");
11861 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11863 mode_value, "Tunnel");
11864 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11867 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11868 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11869 mac_addr_byte_mask, UINT8);
11870 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11872 tunnel_type, "tunnel-type");
11873 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11874 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11875 tunnel_type_mask, UINT8);
11876 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11877 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11878 tunnel_id, "tunnel-id");
11879 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11880 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11881 tunnel_id_mask, UINT32);
11883 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11884 .f = cmd_flow_director_mask_parsed,
11886 .help_str = "flow_director_mask ... : "
11887 "Set IP mode flow director's mask on NIC",
11889 (void *)&cmd_flow_director_mask,
11890 (void *)&cmd_flow_director_mask_port_id,
11891 (void *)&cmd_flow_director_mask_mode,
11892 (void *)&cmd_flow_director_mask_mode_ip,
11893 (void *)&cmd_flow_director_mask_vlan,
11894 (void *)&cmd_flow_director_mask_vlan_value,
11895 (void *)&cmd_flow_director_mask_src,
11896 (void *)&cmd_flow_director_mask_ipv4_src,
11897 (void *)&cmd_flow_director_mask_ipv6_src,
11898 (void *)&cmd_flow_director_mask_port_src,
11899 (void *)&cmd_flow_director_mask_dst,
11900 (void *)&cmd_flow_director_mask_ipv4_dst,
11901 (void *)&cmd_flow_director_mask_ipv6_dst,
11902 (void *)&cmd_flow_director_mask_port_dst,
11907 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11908 .f = cmd_flow_director_mask_parsed,
11910 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11911 "flow director's mask on NIC",
11913 (void *)&cmd_flow_director_mask,
11914 (void *)&cmd_flow_director_mask_port_id,
11915 (void *)&cmd_flow_director_mask_mode,
11916 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11917 (void *)&cmd_flow_director_mask_vlan,
11918 (void *)&cmd_flow_director_mask_vlan_value,
11923 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11924 .f = cmd_flow_director_mask_parsed,
11926 .help_str = "flow_director_mask ... : Set tunnel mode "
11927 "flow director's mask on NIC",
11929 (void *)&cmd_flow_director_mask,
11930 (void *)&cmd_flow_director_mask_port_id,
11931 (void *)&cmd_flow_director_mask_mode,
11932 (void *)&cmd_flow_director_mask_mode_tunnel,
11933 (void *)&cmd_flow_director_mask_vlan,
11934 (void *)&cmd_flow_director_mask_vlan_value,
11935 (void *)&cmd_flow_director_mask_mac,
11936 (void *)&cmd_flow_director_mask_mac_value,
11937 (void *)&cmd_flow_director_mask_tunnel_type,
11938 (void *)&cmd_flow_director_mask_tunnel_type_value,
11939 (void *)&cmd_flow_director_mask_tunnel_id,
11940 (void *)&cmd_flow_director_mask_tunnel_id_value,
11945 /* *** deal with flow director mask on flexible payload *** */
11946 struct cmd_flow_director_flex_mask_result {
11947 cmdline_fixed_string_t flow_director_flexmask;
11949 cmdline_fixed_string_t flow;
11950 cmdline_fixed_string_t flow_type;
11951 cmdline_fixed_string_t mask;
11955 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11956 __rte_unused struct cmdline *cl,
11957 __rte_unused void *data)
11959 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11960 struct rte_eth_fdir_info fdir_info;
11961 struct rte_eth_fdir_flex_mask flex_mask;
11962 struct rte_port *port;
11963 uint64_t flow_type_mask;
11967 port = &ports[res->port_id];
11968 /** Check if the port is not started **/
11969 if (port->port_status != RTE_PORT_STOPPED) {
11970 printf("Please stop port %d first\n", res->port_id);
11974 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11975 ret = parse_flexbytes(res->mask,
11977 RTE_ETH_FDIR_MAX_FLEXLEN);
11979 printf("error: Cannot parse mask input.\n");
11983 memset(&fdir_info, 0, sizeof(fdir_info));
11984 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11985 RTE_ETH_FILTER_INFO, &fdir_info);
11987 printf("Cannot get FDir filter info\n");
11991 if (!strcmp(res->flow_type, "none")) {
11992 /* means don't specify the flow type */
11993 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11994 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11995 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11996 0, sizeof(struct rte_eth_fdir_flex_mask));
11997 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11998 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12000 sizeof(struct rte_eth_fdir_flex_mask));
12001 cmd_reconfig_device_queue(res->port_id, 1, 1);
12004 flow_type_mask = fdir_info.flow_types_mask[0];
12005 if (!strcmp(res->flow_type, "all")) {
12006 if (!flow_type_mask) {
12007 printf("No flow type supported\n");
12010 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12011 if (flow_type_mask & (1ULL << i)) {
12012 flex_mask.flow_type = i;
12013 fdir_set_flex_mask(res->port_id, &flex_mask);
12016 cmd_reconfig_device_queue(res->port_id, 1, 1);
12019 flex_mask.flow_type = str2flowtype(res->flow_type);
12020 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12021 printf("Flow type %s not supported on port %d\n",
12022 res->flow_type, res->port_id);
12025 fdir_set_flex_mask(res->port_id, &flex_mask);
12026 cmd_reconfig_device_queue(res->port_id, 1, 1);
12029 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12030 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12031 flow_director_flexmask,
12032 "flow_director_flex_mask");
12033 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12034 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12036 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12037 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12039 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12040 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12041 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12042 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12043 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12044 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12047 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12048 .f = cmd_flow_director_flex_mask_parsed,
12050 .help_str = "flow_director_flex_mask ... : "
12051 "Set flow director's flex mask on NIC",
12053 (void *)&cmd_flow_director_flexmask,
12054 (void *)&cmd_flow_director_flexmask_port_id,
12055 (void *)&cmd_flow_director_flexmask_flow,
12056 (void *)&cmd_flow_director_flexmask_flow_type,
12057 (void *)&cmd_flow_director_flexmask_mask,
12062 /* *** deal with flow director flexible payload configuration *** */
12063 struct cmd_flow_director_flexpayload_result {
12064 cmdline_fixed_string_t flow_director_flexpayload;
12066 cmdline_fixed_string_t payload_layer;
12067 cmdline_fixed_string_t payload_cfg;
12071 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12074 const char *p, *p0 = q_arg;
12076 unsigned long int_fld;
12077 char *str_fld[max_num];
12082 p = strchr(p0, '(');
12086 p0 = strchr(p, ')');
12091 if (size >= sizeof(s))
12094 snprintf(s, sizeof(s), "%.*s", size, p);
12095 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12096 if (ret < 0 || ret > max_num)
12098 for (i = 0; i < ret; i++) {
12100 int_fld = strtoul(str_fld[i], &end, 0);
12101 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12103 offsets[i] = (uint16_t)int_fld;
12109 cmd_flow_director_flxpld_parsed(void *parsed_result,
12110 __rte_unused struct cmdline *cl,
12111 __rte_unused void *data)
12113 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12114 struct rte_eth_flex_payload_cfg flex_cfg;
12115 struct rte_port *port;
12118 port = &ports[res->port_id];
12119 /** Check if the port is not started **/
12120 if (port->port_status != RTE_PORT_STOPPED) {
12121 printf("Please stop port %d first\n", res->port_id);
12125 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12127 if (!strcmp(res->payload_layer, "raw"))
12128 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12129 else if (!strcmp(res->payload_layer, "l2"))
12130 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12131 else if (!strcmp(res->payload_layer, "l3"))
12132 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12133 else if (!strcmp(res->payload_layer, "l4"))
12134 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12136 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12137 RTE_ETH_FDIR_MAX_FLEXLEN);
12139 printf("error: Cannot parse flex payload input.\n");
12143 fdir_set_flex_payload(res->port_id, &flex_cfg);
12144 cmd_reconfig_device_queue(res->port_id, 1, 1);
12147 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12148 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12149 flow_director_flexpayload,
12150 "flow_director_flex_payload");
12151 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12152 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12154 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12156 payload_layer, "raw#l2#l3#l4");
12157 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12158 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12159 payload_cfg, NULL);
12161 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12162 .f = cmd_flow_director_flxpld_parsed,
12164 .help_str = "flow_director_flexpayload ... : "
12165 "Set flow director's flex payload on NIC",
12167 (void *)&cmd_flow_director_flexpayload,
12168 (void *)&cmd_flow_director_flexpayload_port_id,
12169 (void *)&cmd_flow_director_flexpayload_payload_layer,
12170 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12175 /* Generic flow interface command. */
12176 extern cmdline_parse_inst_t cmd_flow;
12178 /* *** Classification Filters Control *** */
12179 /* *** Get symmetric hash enable per port *** */
12180 struct cmd_get_sym_hash_ena_per_port_result {
12181 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12186 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12187 __rte_unused struct cmdline *cl,
12188 __rte_unused void *data)
12190 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12191 struct rte_eth_hash_filter_info info;
12194 if (rte_eth_dev_filter_supported(res->port_id,
12195 RTE_ETH_FILTER_HASH) < 0) {
12196 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12201 memset(&info, 0, sizeof(info));
12202 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12203 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12204 RTE_ETH_FILTER_GET, &info);
12207 printf("Cannot get symmetric hash enable per port "
12208 "on port %u\n", res->port_id);
12212 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12213 "enabled" : "disabled", res->port_id);
12216 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12217 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12218 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12219 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12220 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12223 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12224 .f = cmd_get_sym_hash_per_port_parsed,
12226 .help_str = "get_sym_hash_ena_per_port <port_id>",
12228 (void *)&cmd_get_sym_hash_ena_per_port_all,
12229 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12234 /* *** Set symmetric hash enable per port *** */
12235 struct cmd_set_sym_hash_ena_per_port_result {
12236 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12237 cmdline_fixed_string_t enable;
12242 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12243 __rte_unused struct cmdline *cl,
12244 __rte_unused void *data)
12246 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12247 struct rte_eth_hash_filter_info info;
12250 if (rte_eth_dev_filter_supported(res->port_id,
12251 RTE_ETH_FILTER_HASH) < 0) {
12252 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12257 memset(&info, 0, sizeof(info));
12258 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12259 if (!strcmp(res->enable, "enable"))
12260 info.info.enable = 1;
12261 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12262 RTE_ETH_FILTER_SET, &info);
12264 printf("Cannot set symmetric hash enable per port on "
12265 "port %u\n", res->port_id);
12268 printf("Symmetric hash has been set to %s on port %u\n",
12269 res->enable, res->port_id);
12272 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12273 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12274 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12275 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12276 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12278 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12279 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12280 enable, "enable#disable");
12282 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12283 .f = cmd_set_sym_hash_per_port_parsed,
12285 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12287 (void *)&cmd_set_sym_hash_ena_per_port_all,
12288 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12289 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12294 /* Get global config of hash function */
12295 struct cmd_get_hash_global_config_result {
12296 cmdline_fixed_string_t get_hash_global_config;
12301 flowtype_to_str(uint16_t ftype)
12307 } ftype_table[] = {
12308 {"ipv4", RTE_ETH_FLOW_IPV4},
12309 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12310 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12311 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12312 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12313 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12314 {"ipv6", RTE_ETH_FLOW_IPV6},
12315 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12316 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12317 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12318 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12319 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12320 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12321 {"port", RTE_ETH_FLOW_PORT},
12322 {"vxlan", RTE_ETH_FLOW_VXLAN},
12323 {"geneve", RTE_ETH_FLOW_GENEVE},
12324 {"nvgre", RTE_ETH_FLOW_NVGRE},
12325 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12328 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12329 if (ftype_table[i].ftype == ftype)
12330 return ftype_table[i].str;
12337 cmd_get_hash_global_config_parsed(void *parsed_result,
12338 __rte_unused struct cmdline *cl,
12339 __rte_unused void *data)
12341 struct cmd_get_hash_global_config_result *res = parsed_result;
12342 struct rte_eth_hash_filter_info info;
12343 uint32_t idx, offset;
12348 if (rte_eth_dev_filter_supported(res->port_id,
12349 RTE_ETH_FILTER_HASH) < 0) {
12350 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12355 memset(&info, 0, sizeof(info));
12356 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12357 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12358 RTE_ETH_FILTER_GET, &info);
12360 printf("Cannot get hash global configurations by port %d\n",
12365 switch (info.info.global_conf.hash_func) {
12366 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12367 printf("Hash function is Toeplitz\n");
12369 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12370 printf("Hash function is Simple XOR\n");
12372 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12373 printf("Hash function is Symmetric Toeplitz\n");
12376 printf("Unknown hash function\n");
12380 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12381 idx = i / UINT64_BIT;
12382 offset = i % UINT64_BIT;
12383 if (!(info.info.global_conf.valid_bit_mask[idx] &
12386 str = flowtype_to_str(i);
12389 printf("Symmetric hash is %s globally for flow type %s "
12391 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12392 (1ULL << offset)) ? "enabled" : "disabled"), str,
12397 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12398 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12399 get_hash_global_config, "get_hash_global_config");
12400 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12401 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12404 cmdline_parse_inst_t cmd_get_hash_global_config = {
12405 .f = cmd_get_hash_global_config_parsed,
12407 .help_str = "get_hash_global_config <port_id>",
12409 (void *)&cmd_get_hash_global_config_all,
12410 (void *)&cmd_get_hash_global_config_port_id,
12415 /* Set global config of hash function */
12416 struct cmd_set_hash_global_config_result {
12417 cmdline_fixed_string_t set_hash_global_config;
12419 cmdline_fixed_string_t hash_func;
12420 cmdline_fixed_string_t flow_type;
12421 cmdline_fixed_string_t enable;
12425 cmd_set_hash_global_config_parsed(void *parsed_result,
12426 __rte_unused struct cmdline *cl,
12427 __rte_unused void *data)
12429 struct cmd_set_hash_global_config_result *res = parsed_result;
12430 struct rte_eth_hash_filter_info info;
12431 uint32_t ftype, idx, offset;
12434 if (rte_eth_dev_filter_supported(res->port_id,
12435 RTE_ETH_FILTER_HASH) < 0) {
12436 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12440 memset(&info, 0, sizeof(info));
12441 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12442 if (!strcmp(res->hash_func, "toeplitz"))
12443 info.info.global_conf.hash_func =
12444 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12445 else if (!strcmp(res->hash_func, "simple_xor"))
12446 info.info.global_conf.hash_func =
12447 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12448 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12449 info.info.global_conf.hash_func =
12450 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12451 else if (!strcmp(res->hash_func, "default"))
12452 info.info.global_conf.hash_func =
12453 RTE_ETH_HASH_FUNCTION_DEFAULT;
12455 ftype = str2flowtype(res->flow_type);
12456 idx = ftype / UINT64_BIT;
12457 offset = ftype % UINT64_BIT;
12458 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12459 if (!strcmp(res->enable, "enable"))
12460 info.info.global_conf.sym_hash_enable_mask[idx] |=
12462 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12463 RTE_ETH_FILTER_SET, &info);
12465 printf("Cannot set global hash configurations by port %d\n",
12468 printf("Global hash configurations have been set "
12469 "successfully by port %d\n", res->port_id);
12472 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12473 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12474 set_hash_global_config, "set_hash_global_config");
12475 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12476 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12478 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12479 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12480 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12481 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12482 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12484 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12485 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12486 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12487 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12488 enable, "enable#disable");
12490 cmdline_parse_inst_t cmd_set_hash_global_config = {
12491 .f = cmd_set_hash_global_config_parsed,
12493 .help_str = "set_hash_global_config <port_id> "
12494 "toeplitz|simple_xor|symmetric_toeplitz|default "
12495 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12496 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12497 "l2_payload enable|disable",
12499 (void *)&cmd_set_hash_global_config_all,
12500 (void *)&cmd_set_hash_global_config_port_id,
12501 (void *)&cmd_set_hash_global_config_hash_func,
12502 (void *)&cmd_set_hash_global_config_flow_type,
12503 (void *)&cmd_set_hash_global_config_enable,
12508 /* Set hash input set */
12509 struct cmd_set_hash_input_set_result {
12510 cmdline_fixed_string_t set_hash_input_set;
12512 cmdline_fixed_string_t flow_type;
12513 cmdline_fixed_string_t inset_field;
12514 cmdline_fixed_string_t select;
12517 static enum rte_eth_input_set_field
12518 str2inset(char *string)
12522 static const struct {
12524 enum rte_eth_input_set_field inset;
12525 } inset_table[] = {
12526 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12527 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12528 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12529 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12530 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12531 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12532 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12533 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12534 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12535 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12536 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12537 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12538 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12539 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12540 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12541 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12542 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12543 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12544 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12545 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12546 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12547 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12548 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12549 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12550 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12551 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12552 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12553 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12554 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12555 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12556 {"none", RTE_ETH_INPUT_SET_NONE},
12559 for (i = 0; i < RTE_DIM(inset_table); i++) {
12560 if (!strcmp(string, inset_table[i].str))
12561 return inset_table[i].inset;
12564 return RTE_ETH_INPUT_SET_UNKNOWN;
12568 cmd_set_hash_input_set_parsed(void *parsed_result,
12569 __rte_unused struct cmdline *cl,
12570 __rte_unused void *data)
12572 struct cmd_set_hash_input_set_result *res = parsed_result;
12573 struct rte_eth_hash_filter_info info;
12575 memset(&info, 0, sizeof(info));
12576 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12577 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12578 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12579 info.info.input_set_conf.inset_size = 1;
12580 if (!strcmp(res->select, "select"))
12581 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12582 else if (!strcmp(res->select, "add"))
12583 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12584 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12585 RTE_ETH_FILTER_SET, &info);
12588 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12589 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12590 set_hash_input_set, "set_hash_input_set");
12591 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12592 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12594 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12595 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12597 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12598 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12600 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12601 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12602 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12603 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12604 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12606 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12607 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12608 select, "select#add");
12610 cmdline_parse_inst_t cmd_set_hash_input_set = {
12611 .f = cmd_set_hash_input_set_parsed,
12613 .help_str = "set_hash_input_set <port_id> "
12614 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12615 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12616 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12617 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12618 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12619 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12620 "fld-7th|fld-8th|none select|add",
12622 (void *)&cmd_set_hash_input_set_cmd,
12623 (void *)&cmd_set_hash_input_set_port_id,
12624 (void *)&cmd_set_hash_input_set_flow_type,
12625 (void *)&cmd_set_hash_input_set_field,
12626 (void *)&cmd_set_hash_input_set_select,
12631 /* Set flow director input set */
12632 struct cmd_set_fdir_input_set_result {
12633 cmdline_fixed_string_t set_fdir_input_set;
12635 cmdline_fixed_string_t flow_type;
12636 cmdline_fixed_string_t inset_field;
12637 cmdline_fixed_string_t select;
12641 cmd_set_fdir_input_set_parsed(void *parsed_result,
12642 __rte_unused struct cmdline *cl,
12643 __rte_unused void *data)
12645 struct cmd_set_fdir_input_set_result *res = parsed_result;
12646 struct rte_eth_fdir_filter_info info;
12648 memset(&info, 0, sizeof(info));
12649 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12650 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12651 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12652 info.info.input_set_conf.inset_size = 1;
12653 if (!strcmp(res->select, "select"))
12654 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12655 else if (!strcmp(res->select, "add"))
12656 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12657 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12658 RTE_ETH_FILTER_SET, &info);
12661 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12662 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12663 set_fdir_input_set, "set_fdir_input_set");
12664 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12665 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12667 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12668 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12670 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12671 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12672 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12673 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12675 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12676 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12677 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12678 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12679 "sctp-veri-tag#none");
12680 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12681 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12682 select, "select#add");
12684 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12685 .f = cmd_set_fdir_input_set_parsed,
12687 .help_str = "set_fdir_input_set <port_id> "
12688 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12689 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
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 select|add",
12696 (void *)&cmd_set_fdir_input_set_cmd,
12697 (void *)&cmd_set_fdir_input_set_port_id,
12698 (void *)&cmd_set_fdir_input_set_flow_type,
12699 (void *)&cmd_set_fdir_input_set_field,
12700 (void *)&cmd_set_fdir_input_set_select,
12705 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12706 struct cmd_mcast_addr_result {
12707 cmdline_fixed_string_t mcast_addr_cmd;
12708 cmdline_fixed_string_t what;
12710 struct rte_ether_addr mc_addr;
12713 static void cmd_mcast_addr_parsed(void *parsed_result,
12714 __rte_unused struct cmdline *cl,
12715 __rte_unused void *data)
12717 struct cmd_mcast_addr_result *res = parsed_result;
12719 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12720 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12721 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12722 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12723 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12726 if (strcmp(res->what, "add") == 0)
12727 mcast_addr_add(res->port_num, &res->mc_addr);
12729 mcast_addr_remove(res->port_num, &res->mc_addr);
12732 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12733 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12734 mcast_addr_cmd, "mcast_addr");
12735 cmdline_parse_token_string_t cmd_mcast_addr_what =
12736 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12738 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12739 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12740 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12741 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12743 cmdline_parse_inst_t cmd_mcast_addr = {
12744 .f = cmd_mcast_addr_parsed,
12746 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12747 "Add/Remove multicast MAC address on port_id",
12749 (void *)&cmd_mcast_addr_cmd,
12750 (void *)&cmd_mcast_addr_what,
12751 (void *)&cmd_mcast_addr_portnum,
12752 (void *)&cmd_mcast_addr_addr,
12757 /* l2 tunnel config
12758 * only support E-tag now.
12761 /* Ether type config */
12762 struct cmd_config_l2_tunnel_eth_type_result {
12763 cmdline_fixed_string_t port;
12764 cmdline_fixed_string_t config;
12765 cmdline_fixed_string_t all;
12767 cmdline_fixed_string_t l2_tunnel;
12768 cmdline_fixed_string_t l2_tunnel_type;
12769 cmdline_fixed_string_t eth_type;
12770 uint16_t eth_type_val;
12773 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12774 TOKEN_STRING_INITIALIZER
12775 (struct cmd_config_l2_tunnel_eth_type_result,
12777 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12778 TOKEN_STRING_INITIALIZER
12779 (struct cmd_config_l2_tunnel_eth_type_result,
12781 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12782 TOKEN_STRING_INITIALIZER
12783 (struct cmd_config_l2_tunnel_eth_type_result,
12785 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12786 TOKEN_NUM_INITIALIZER
12787 (struct cmd_config_l2_tunnel_eth_type_result,
12789 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12790 TOKEN_STRING_INITIALIZER
12791 (struct cmd_config_l2_tunnel_eth_type_result,
12792 l2_tunnel, "l2-tunnel");
12793 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12794 TOKEN_STRING_INITIALIZER
12795 (struct cmd_config_l2_tunnel_eth_type_result,
12796 l2_tunnel_type, "E-tag");
12797 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12798 TOKEN_STRING_INITIALIZER
12799 (struct cmd_config_l2_tunnel_eth_type_result,
12800 eth_type, "ether-type");
12801 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12802 TOKEN_NUM_INITIALIZER
12803 (struct cmd_config_l2_tunnel_eth_type_result,
12804 eth_type_val, UINT16);
12806 static enum rte_eth_tunnel_type
12807 str2fdir_l2_tunnel_type(char *string)
12811 static const struct {
12813 enum rte_eth_tunnel_type type;
12814 } l2_tunnel_type_str[] = {
12815 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12818 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12819 if (!strcmp(l2_tunnel_type_str[i].str, string))
12820 return l2_tunnel_type_str[i].type;
12822 return RTE_TUNNEL_TYPE_NONE;
12825 /* ether type config for all ports */
12827 cmd_config_l2_tunnel_eth_type_all_parsed
12828 (void *parsed_result,
12829 __rte_unused struct cmdline *cl,
12830 __rte_unused void *data)
12832 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12833 struct rte_eth_l2_tunnel_conf entry;
12836 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12837 entry.ether_type = res->eth_type_val;
12839 RTE_ETH_FOREACH_DEV(pid) {
12840 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12844 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12845 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12847 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12849 (void *)&cmd_config_l2_tunnel_eth_type_port,
12850 (void *)&cmd_config_l2_tunnel_eth_type_config,
12851 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12852 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12853 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12854 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12855 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12860 /* ether type config for a specific port */
12862 cmd_config_l2_tunnel_eth_type_specific_parsed(
12863 void *parsed_result,
12864 __rte_unused struct cmdline *cl,
12865 __rte_unused void *data)
12867 struct cmd_config_l2_tunnel_eth_type_result *res =
12869 struct rte_eth_l2_tunnel_conf entry;
12871 if (port_id_is_invalid(res->id, ENABLED_WARN))
12874 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12875 entry.ether_type = res->eth_type_val;
12877 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12880 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12881 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12883 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12885 (void *)&cmd_config_l2_tunnel_eth_type_port,
12886 (void *)&cmd_config_l2_tunnel_eth_type_config,
12887 (void *)&cmd_config_l2_tunnel_eth_type_id,
12888 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12889 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12890 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12891 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12896 /* Enable/disable l2 tunnel */
12897 struct cmd_config_l2_tunnel_en_dis_result {
12898 cmdline_fixed_string_t port;
12899 cmdline_fixed_string_t config;
12900 cmdline_fixed_string_t all;
12902 cmdline_fixed_string_t l2_tunnel;
12903 cmdline_fixed_string_t l2_tunnel_type;
12904 cmdline_fixed_string_t en_dis;
12907 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12908 TOKEN_STRING_INITIALIZER
12909 (struct cmd_config_l2_tunnel_en_dis_result,
12911 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12912 TOKEN_STRING_INITIALIZER
12913 (struct cmd_config_l2_tunnel_en_dis_result,
12915 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12916 TOKEN_STRING_INITIALIZER
12917 (struct cmd_config_l2_tunnel_en_dis_result,
12919 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12920 TOKEN_NUM_INITIALIZER
12921 (struct cmd_config_l2_tunnel_en_dis_result,
12923 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12924 TOKEN_STRING_INITIALIZER
12925 (struct cmd_config_l2_tunnel_en_dis_result,
12926 l2_tunnel, "l2-tunnel");
12927 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12928 TOKEN_STRING_INITIALIZER
12929 (struct cmd_config_l2_tunnel_en_dis_result,
12930 l2_tunnel_type, "E-tag");
12931 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12932 TOKEN_STRING_INITIALIZER
12933 (struct cmd_config_l2_tunnel_en_dis_result,
12934 en_dis, "enable#disable");
12936 /* enable/disable l2 tunnel for all ports */
12938 cmd_config_l2_tunnel_en_dis_all_parsed(
12939 void *parsed_result,
12940 __rte_unused struct cmdline *cl,
12941 __rte_unused void *data)
12943 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12944 struct rte_eth_l2_tunnel_conf entry;
12948 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12950 if (!strcmp("enable", res->en_dis))
12955 RTE_ETH_FOREACH_DEV(pid) {
12956 rte_eth_dev_l2_tunnel_offload_set(pid,
12958 ETH_L2_TUNNEL_ENABLE_MASK,
12963 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12964 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12966 .help_str = "port config all l2-tunnel E-tag enable|disable",
12968 (void *)&cmd_config_l2_tunnel_en_dis_port,
12969 (void *)&cmd_config_l2_tunnel_en_dis_config,
12970 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12971 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12972 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12973 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12978 /* enable/disable l2 tunnel for a port */
12980 cmd_config_l2_tunnel_en_dis_specific_parsed(
12981 void *parsed_result,
12982 __rte_unused struct cmdline *cl,
12983 __rte_unused void *data)
12985 struct cmd_config_l2_tunnel_en_dis_result *res =
12987 struct rte_eth_l2_tunnel_conf entry;
12989 if (port_id_is_invalid(res->id, ENABLED_WARN))
12992 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12994 if (!strcmp("enable", res->en_dis))
12995 rte_eth_dev_l2_tunnel_offload_set(res->id,
12997 ETH_L2_TUNNEL_ENABLE_MASK,
13000 rte_eth_dev_l2_tunnel_offload_set(res->id,
13002 ETH_L2_TUNNEL_ENABLE_MASK,
13006 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13007 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13009 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13011 (void *)&cmd_config_l2_tunnel_en_dis_port,
13012 (void *)&cmd_config_l2_tunnel_en_dis_config,
13013 (void *)&cmd_config_l2_tunnel_en_dis_id,
13014 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13015 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13016 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13021 /* E-tag configuration */
13023 /* Common result structure for all E-tag configuration */
13024 struct cmd_config_e_tag_result {
13025 cmdline_fixed_string_t e_tag;
13026 cmdline_fixed_string_t set;
13027 cmdline_fixed_string_t insertion;
13028 cmdline_fixed_string_t stripping;
13029 cmdline_fixed_string_t forwarding;
13030 cmdline_fixed_string_t filter;
13031 cmdline_fixed_string_t add;
13032 cmdline_fixed_string_t del;
13033 cmdline_fixed_string_t on;
13034 cmdline_fixed_string_t off;
13035 cmdline_fixed_string_t on_off;
13036 cmdline_fixed_string_t port_tag_id;
13037 uint32_t port_tag_id_val;
13038 cmdline_fixed_string_t e_tag_id;
13039 uint16_t e_tag_id_val;
13040 cmdline_fixed_string_t dst_pool;
13041 uint8_t dst_pool_val;
13042 cmdline_fixed_string_t port;
13044 cmdline_fixed_string_t vf;
13048 /* Common CLI fields for all E-tag configuration */
13049 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13050 TOKEN_STRING_INITIALIZER
13051 (struct cmd_config_e_tag_result,
13053 cmdline_parse_token_string_t cmd_config_e_tag_set =
13054 TOKEN_STRING_INITIALIZER
13055 (struct cmd_config_e_tag_result,
13057 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13058 TOKEN_STRING_INITIALIZER
13059 (struct cmd_config_e_tag_result,
13060 insertion, "insertion");
13061 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13062 TOKEN_STRING_INITIALIZER
13063 (struct cmd_config_e_tag_result,
13064 stripping, "stripping");
13065 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13066 TOKEN_STRING_INITIALIZER
13067 (struct cmd_config_e_tag_result,
13068 forwarding, "forwarding");
13069 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13070 TOKEN_STRING_INITIALIZER
13071 (struct cmd_config_e_tag_result,
13073 cmdline_parse_token_string_t cmd_config_e_tag_add =
13074 TOKEN_STRING_INITIALIZER
13075 (struct cmd_config_e_tag_result,
13077 cmdline_parse_token_string_t cmd_config_e_tag_del =
13078 TOKEN_STRING_INITIALIZER
13079 (struct cmd_config_e_tag_result,
13081 cmdline_parse_token_string_t cmd_config_e_tag_on =
13082 TOKEN_STRING_INITIALIZER
13083 (struct cmd_config_e_tag_result,
13085 cmdline_parse_token_string_t cmd_config_e_tag_off =
13086 TOKEN_STRING_INITIALIZER
13087 (struct cmd_config_e_tag_result,
13089 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13090 TOKEN_STRING_INITIALIZER
13091 (struct cmd_config_e_tag_result,
13093 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13094 TOKEN_STRING_INITIALIZER
13095 (struct cmd_config_e_tag_result,
13096 port_tag_id, "port-tag-id");
13097 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13098 TOKEN_NUM_INITIALIZER
13099 (struct cmd_config_e_tag_result,
13100 port_tag_id_val, UINT32);
13101 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13102 TOKEN_STRING_INITIALIZER
13103 (struct cmd_config_e_tag_result,
13104 e_tag_id, "e-tag-id");
13105 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13106 TOKEN_NUM_INITIALIZER
13107 (struct cmd_config_e_tag_result,
13108 e_tag_id_val, UINT16);
13109 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13110 TOKEN_STRING_INITIALIZER
13111 (struct cmd_config_e_tag_result,
13112 dst_pool, "dst-pool");
13113 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13114 TOKEN_NUM_INITIALIZER
13115 (struct cmd_config_e_tag_result,
13116 dst_pool_val, UINT8);
13117 cmdline_parse_token_string_t cmd_config_e_tag_port =
13118 TOKEN_STRING_INITIALIZER
13119 (struct cmd_config_e_tag_result,
13121 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13122 TOKEN_NUM_INITIALIZER
13123 (struct cmd_config_e_tag_result,
13125 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13126 TOKEN_STRING_INITIALIZER
13127 (struct cmd_config_e_tag_result,
13129 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13130 TOKEN_NUM_INITIALIZER
13131 (struct cmd_config_e_tag_result,
13134 /* E-tag insertion configuration */
13136 cmd_config_e_tag_insertion_en_parsed(
13137 void *parsed_result,
13138 __rte_unused struct cmdline *cl,
13139 __rte_unused void *data)
13141 struct cmd_config_e_tag_result *res =
13143 struct rte_eth_l2_tunnel_conf entry;
13145 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13148 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13149 entry.tunnel_id = res->port_tag_id_val;
13150 entry.vf_id = res->vf_id;
13151 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13153 ETH_L2_TUNNEL_INSERTION_MASK,
13158 cmd_config_e_tag_insertion_dis_parsed(
13159 void *parsed_result,
13160 __rte_unused struct cmdline *cl,
13161 __rte_unused void *data)
13163 struct cmd_config_e_tag_result *res =
13165 struct rte_eth_l2_tunnel_conf entry;
13167 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13170 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13171 entry.vf_id = res->vf_id;
13173 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13175 ETH_L2_TUNNEL_INSERTION_MASK,
13179 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13180 .f = cmd_config_e_tag_insertion_en_parsed,
13182 .help_str = "E-tag ... : E-tag insertion enable",
13184 (void *)&cmd_config_e_tag_e_tag,
13185 (void *)&cmd_config_e_tag_set,
13186 (void *)&cmd_config_e_tag_insertion,
13187 (void *)&cmd_config_e_tag_on,
13188 (void *)&cmd_config_e_tag_port_tag_id,
13189 (void *)&cmd_config_e_tag_port_tag_id_val,
13190 (void *)&cmd_config_e_tag_port,
13191 (void *)&cmd_config_e_tag_port_id,
13192 (void *)&cmd_config_e_tag_vf,
13193 (void *)&cmd_config_e_tag_vf_id,
13198 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13199 .f = cmd_config_e_tag_insertion_dis_parsed,
13201 .help_str = "E-tag ... : E-tag insertion disable",
13203 (void *)&cmd_config_e_tag_e_tag,
13204 (void *)&cmd_config_e_tag_set,
13205 (void *)&cmd_config_e_tag_insertion,
13206 (void *)&cmd_config_e_tag_off,
13207 (void *)&cmd_config_e_tag_port,
13208 (void *)&cmd_config_e_tag_port_id,
13209 (void *)&cmd_config_e_tag_vf,
13210 (void *)&cmd_config_e_tag_vf_id,
13215 /* E-tag stripping configuration */
13217 cmd_config_e_tag_stripping_parsed(
13218 void *parsed_result,
13219 __rte_unused struct cmdline *cl,
13220 __rte_unused void *data)
13222 struct cmd_config_e_tag_result *res =
13224 struct rte_eth_l2_tunnel_conf entry;
13226 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13229 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13231 if (!strcmp(res->on_off, "on"))
13232 rte_eth_dev_l2_tunnel_offload_set
13235 ETH_L2_TUNNEL_STRIPPING_MASK,
13238 rte_eth_dev_l2_tunnel_offload_set
13241 ETH_L2_TUNNEL_STRIPPING_MASK,
13245 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13246 .f = cmd_config_e_tag_stripping_parsed,
13248 .help_str = "E-tag ... : E-tag stripping enable/disable",
13250 (void *)&cmd_config_e_tag_e_tag,
13251 (void *)&cmd_config_e_tag_set,
13252 (void *)&cmd_config_e_tag_stripping,
13253 (void *)&cmd_config_e_tag_on_off,
13254 (void *)&cmd_config_e_tag_port,
13255 (void *)&cmd_config_e_tag_port_id,
13260 /* E-tag forwarding configuration */
13262 cmd_config_e_tag_forwarding_parsed(
13263 void *parsed_result,
13264 __rte_unused struct cmdline *cl,
13265 __rte_unused void *data)
13267 struct cmd_config_e_tag_result *res = parsed_result;
13268 struct rte_eth_l2_tunnel_conf entry;
13270 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13273 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13275 if (!strcmp(res->on_off, "on"))
13276 rte_eth_dev_l2_tunnel_offload_set
13279 ETH_L2_TUNNEL_FORWARDING_MASK,
13282 rte_eth_dev_l2_tunnel_offload_set
13285 ETH_L2_TUNNEL_FORWARDING_MASK,
13289 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13290 .f = cmd_config_e_tag_forwarding_parsed,
13292 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13294 (void *)&cmd_config_e_tag_e_tag,
13295 (void *)&cmd_config_e_tag_set,
13296 (void *)&cmd_config_e_tag_forwarding,
13297 (void *)&cmd_config_e_tag_on_off,
13298 (void *)&cmd_config_e_tag_port,
13299 (void *)&cmd_config_e_tag_port_id,
13304 /* E-tag filter configuration */
13306 cmd_config_e_tag_filter_add_parsed(
13307 void *parsed_result,
13308 __rte_unused struct cmdline *cl,
13309 __rte_unused void *data)
13311 struct cmd_config_e_tag_result *res = parsed_result;
13312 struct rte_eth_l2_tunnel_conf entry;
13315 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13318 if (res->e_tag_id_val > 0x3fff) {
13319 printf("e-tag-id must be equal or less than 0x3fff.\n");
13323 ret = rte_eth_dev_filter_supported(res->port_id,
13324 RTE_ETH_FILTER_L2_TUNNEL);
13326 printf("E-tag filter is not supported on port %u.\n",
13331 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13332 entry.tunnel_id = res->e_tag_id_val;
13333 entry.pool = res->dst_pool_val;
13335 ret = rte_eth_dev_filter_ctrl(res->port_id,
13336 RTE_ETH_FILTER_L2_TUNNEL,
13337 RTE_ETH_FILTER_ADD,
13340 printf("E-tag filter programming error: (%s)\n",
13344 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13345 .f = cmd_config_e_tag_filter_add_parsed,
13347 .help_str = "E-tag ... : E-tag filter add",
13349 (void *)&cmd_config_e_tag_e_tag,
13350 (void *)&cmd_config_e_tag_set,
13351 (void *)&cmd_config_e_tag_filter,
13352 (void *)&cmd_config_e_tag_add,
13353 (void *)&cmd_config_e_tag_e_tag_id,
13354 (void *)&cmd_config_e_tag_e_tag_id_val,
13355 (void *)&cmd_config_e_tag_dst_pool,
13356 (void *)&cmd_config_e_tag_dst_pool_val,
13357 (void *)&cmd_config_e_tag_port,
13358 (void *)&cmd_config_e_tag_port_id,
13364 cmd_config_e_tag_filter_del_parsed(
13365 void *parsed_result,
13366 __rte_unused struct cmdline *cl,
13367 __rte_unused void *data)
13369 struct cmd_config_e_tag_result *res = parsed_result;
13370 struct rte_eth_l2_tunnel_conf entry;
13373 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13376 if (res->e_tag_id_val > 0x3fff) {
13377 printf("e-tag-id must be less than 0x3fff.\n");
13381 ret = rte_eth_dev_filter_supported(res->port_id,
13382 RTE_ETH_FILTER_L2_TUNNEL);
13384 printf("E-tag filter is not supported on port %u.\n",
13389 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13390 entry.tunnel_id = res->e_tag_id_val;
13392 ret = rte_eth_dev_filter_ctrl(res->port_id,
13393 RTE_ETH_FILTER_L2_TUNNEL,
13394 RTE_ETH_FILTER_DELETE,
13397 printf("E-tag filter programming error: (%s)\n",
13401 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13402 .f = cmd_config_e_tag_filter_del_parsed,
13404 .help_str = "E-tag ... : E-tag filter delete",
13406 (void *)&cmd_config_e_tag_e_tag,
13407 (void *)&cmd_config_e_tag_set,
13408 (void *)&cmd_config_e_tag_filter,
13409 (void *)&cmd_config_e_tag_del,
13410 (void *)&cmd_config_e_tag_e_tag_id,
13411 (void *)&cmd_config_e_tag_e_tag_id_val,
13412 (void *)&cmd_config_e_tag_port,
13413 (void *)&cmd_config_e_tag_port_id,
13418 /* vf vlan anti spoof configuration */
13420 /* Common result structure for vf vlan anti spoof */
13421 struct cmd_vf_vlan_anti_spoof_result {
13422 cmdline_fixed_string_t set;
13423 cmdline_fixed_string_t vf;
13424 cmdline_fixed_string_t vlan;
13425 cmdline_fixed_string_t antispoof;
13428 cmdline_fixed_string_t on_off;
13431 /* Common CLI fields for vf vlan anti spoof enable disable */
13432 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13433 TOKEN_STRING_INITIALIZER
13434 (struct cmd_vf_vlan_anti_spoof_result,
13436 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13437 TOKEN_STRING_INITIALIZER
13438 (struct cmd_vf_vlan_anti_spoof_result,
13440 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13441 TOKEN_STRING_INITIALIZER
13442 (struct cmd_vf_vlan_anti_spoof_result,
13444 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13445 TOKEN_STRING_INITIALIZER
13446 (struct cmd_vf_vlan_anti_spoof_result,
13447 antispoof, "antispoof");
13448 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13449 TOKEN_NUM_INITIALIZER
13450 (struct cmd_vf_vlan_anti_spoof_result,
13452 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13453 TOKEN_NUM_INITIALIZER
13454 (struct cmd_vf_vlan_anti_spoof_result,
13456 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13457 TOKEN_STRING_INITIALIZER
13458 (struct cmd_vf_vlan_anti_spoof_result,
13462 cmd_set_vf_vlan_anti_spoof_parsed(
13463 void *parsed_result,
13464 __rte_unused struct cmdline *cl,
13465 __rte_unused void *data)
13467 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13468 int ret = -ENOTSUP;
13470 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13472 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13475 #ifdef RTE_LIBRTE_IXGBE_PMD
13476 if (ret == -ENOTSUP)
13477 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13478 res->vf_id, is_on);
13480 #ifdef RTE_LIBRTE_I40E_PMD
13481 if (ret == -ENOTSUP)
13482 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13483 res->vf_id, is_on);
13485 #ifdef RTE_LIBRTE_BNXT_PMD
13486 if (ret == -ENOTSUP)
13487 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13488 res->vf_id, is_on);
13495 printf("invalid vf_id %d\n", res->vf_id);
13498 printf("invalid port_id %d\n", res->port_id);
13501 printf("function not implemented\n");
13504 printf("programming error: (%s)\n", strerror(-ret));
13508 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13509 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13511 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13513 (void *)&cmd_vf_vlan_anti_spoof_set,
13514 (void *)&cmd_vf_vlan_anti_spoof_vf,
13515 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13516 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13517 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13518 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13519 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13524 /* vf mac anti spoof configuration */
13526 /* Common result structure for vf mac anti spoof */
13527 struct cmd_vf_mac_anti_spoof_result {
13528 cmdline_fixed_string_t set;
13529 cmdline_fixed_string_t vf;
13530 cmdline_fixed_string_t mac;
13531 cmdline_fixed_string_t antispoof;
13534 cmdline_fixed_string_t on_off;
13537 /* Common CLI fields for vf mac anti spoof enable disable */
13538 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13539 TOKEN_STRING_INITIALIZER
13540 (struct cmd_vf_mac_anti_spoof_result,
13542 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13543 TOKEN_STRING_INITIALIZER
13544 (struct cmd_vf_mac_anti_spoof_result,
13546 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13547 TOKEN_STRING_INITIALIZER
13548 (struct cmd_vf_mac_anti_spoof_result,
13550 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13551 TOKEN_STRING_INITIALIZER
13552 (struct cmd_vf_mac_anti_spoof_result,
13553 antispoof, "antispoof");
13554 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13555 TOKEN_NUM_INITIALIZER
13556 (struct cmd_vf_mac_anti_spoof_result,
13558 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13559 TOKEN_NUM_INITIALIZER
13560 (struct cmd_vf_mac_anti_spoof_result,
13562 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13563 TOKEN_STRING_INITIALIZER
13564 (struct cmd_vf_mac_anti_spoof_result,
13568 cmd_set_vf_mac_anti_spoof_parsed(
13569 void *parsed_result,
13570 __rte_unused struct cmdline *cl,
13571 __rte_unused void *data)
13573 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13574 int ret = -ENOTSUP;
13576 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13578 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13581 #ifdef RTE_LIBRTE_IXGBE_PMD
13582 if (ret == -ENOTSUP)
13583 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13584 res->vf_id, is_on);
13586 #ifdef RTE_LIBRTE_I40E_PMD
13587 if (ret == -ENOTSUP)
13588 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13589 res->vf_id, is_on);
13591 #ifdef RTE_LIBRTE_BNXT_PMD
13592 if (ret == -ENOTSUP)
13593 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13594 res->vf_id, is_on);
13601 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13604 printf("invalid port_id %d\n", res->port_id);
13607 printf("function not implemented\n");
13610 printf("programming error: (%s)\n", strerror(-ret));
13614 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13615 .f = cmd_set_vf_mac_anti_spoof_parsed,
13617 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13619 (void *)&cmd_vf_mac_anti_spoof_set,
13620 (void *)&cmd_vf_mac_anti_spoof_vf,
13621 (void *)&cmd_vf_mac_anti_spoof_mac,
13622 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13623 (void *)&cmd_vf_mac_anti_spoof_port_id,
13624 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13625 (void *)&cmd_vf_mac_anti_spoof_on_off,
13630 /* vf vlan strip queue configuration */
13632 /* Common result structure for vf mac anti spoof */
13633 struct cmd_vf_vlan_stripq_result {
13634 cmdline_fixed_string_t set;
13635 cmdline_fixed_string_t vf;
13636 cmdline_fixed_string_t vlan;
13637 cmdline_fixed_string_t stripq;
13640 cmdline_fixed_string_t on_off;
13643 /* Common CLI fields for vf vlan strip enable disable */
13644 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13645 TOKEN_STRING_INITIALIZER
13646 (struct cmd_vf_vlan_stripq_result,
13648 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13649 TOKEN_STRING_INITIALIZER
13650 (struct cmd_vf_vlan_stripq_result,
13652 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13653 TOKEN_STRING_INITIALIZER
13654 (struct cmd_vf_vlan_stripq_result,
13656 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13657 TOKEN_STRING_INITIALIZER
13658 (struct cmd_vf_vlan_stripq_result,
13660 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13661 TOKEN_NUM_INITIALIZER
13662 (struct cmd_vf_vlan_stripq_result,
13664 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13665 TOKEN_NUM_INITIALIZER
13666 (struct cmd_vf_vlan_stripq_result,
13668 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13669 TOKEN_STRING_INITIALIZER
13670 (struct cmd_vf_vlan_stripq_result,
13674 cmd_set_vf_vlan_stripq_parsed(
13675 void *parsed_result,
13676 __rte_unused struct cmdline *cl,
13677 __rte_unused void *data)
13679 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13680 int ret = -ENOTSUP;
13682 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13684 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13687 #ifdef RTE_LIBRTE_IXGBE_PMD
13688 if (ret == -ENOTSUP)
13689 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13690 res->vf_id, is_on);
13692 #ifdef RTE_LIBRTE_I40E_PMD
13693 if (ret == -ENOTSUP)
13694 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13695 res->vf_id, is_on);
13697 #ifdef RTE_LIBRTE_BNXT_PMD
13698 if (ret == -ENOTSUP)
13699 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13700 res->vf_id, is_on);
13707 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13710 printf("invalid port_id %d\n", res->port_id);
13713 printf("function not implemented\n");
13716 printf("programming error: (%s)\n", strerror(-ret));
13720 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13721 .f = cmd_set_vf_vlan_stripq_parsed,
13723 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13725 (void *)&cmd_vf_vlan_stripq_set,
13726 (void *)&cmd_vf_vlan_stripq_vf,
13727 (void *)&cmd_vf_vlan_stripq_vlan,
13728 (void *)&cmd_vf_vlan_stripq_stripq,
13729 (void *)&cmd_vf_vlan_stripq_port_id,
13730 (void *)&cmd_vf_vlan_stripq_vf_id,
13731 (void *)&cmd_vf_vlan_stripq_on_off,
13736 /* vf vlan insert configuration */
13738 /* Common result structure for vf vlan insert */
13739 struct cmd_vf_vlan_insert_result {
13740 cmdline_fixed_string_t set;
13741 cmdline_fixed_string_t vf;
13742 cmdline_fixed_string_t vlan;
13743 cmdline_fixed_string_t insert;
13749 /* Common CLI fields for vf vlan insert enable disable */
13750 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13751 TOKEN_STRING_INITIALIZER
13752 (struct cmd_vf_vlan_insert_result,
13754 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13755 TOKEN_STRING_INITIALIZER
13756 (struct cmd_vf_vlan_insert_result,
13758 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13759 TOKEN_STRING_INITIALIZER
13760 (struct cmd_vf_vlan_insert_result,
13762 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13763 TOKEN_STRING_INITIALIZER
13764 (struct cmd_vf_vlan_insert_result,
13766 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13767 TOKEN_NUM_INITIALIZER
13768 (struct cmd_vf_vlan_insert_result,
13770 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13771 TOKEN_NUM_INITIALIZER
13772 (struct cmd_vf_vlan_insert_result,
13774 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13775 TOKEN_NUM_INITIALIZER
13776 (struct cmd_vf_vlan_insert_result,
13780 cmd_set_vf_vlan_insert_parsed(
13781 void *parsed_result,
13782 __rte_unused struct cmdline *cl,
13783 __rte_unused void *data)
13785 struct cmd_vf_vlan_insert_result *res = parsed_result;
13786 int ret = -ENOTSUP;
13788 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13791 #ifdef RTE_LIBRTE_IXGBE_PMD
13792 if (ret == -ENOTSUP)
13793 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13796 #ifdef RTE_LIBRTE_I40E_PMD
13797 if (ret == -ENOTSUP)
13798 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13801 #ifdef RTE_LIBRTE_BNXT_PMD
13802 if (ret == -ENOTSUP)
13803 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13811 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13814 printf("invalid port_id %d\n", res->port_id);
13817 printf("function not implemented\n");
13820 printf("programming error: (%s)\n", strerror(-ret));
13824 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13825 .f = cmd_set_vf_vlan_insert_parsed,
13827 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13829 (void *)&cmd_vf_vlan_insert_set,
13830 (void *)&cmd_vf_vlan_insert_vf,
13831 (void *)&cmd_vf_vlan_insert_vlan,
13832 (void *)&cmd_vf_vlan_insert_insert,
13833 (void *)&cmd_vf_vlan_insert_port_id,
13834 (void *)&cmd_vf_vlan_insert_vf_id,
13835 (void *)&cmd_vf_vlan_insert_vlan_id,
13840 /* tx loopback configuration */
13842 /* Common result structure for tx loopback */
13843 struct cmd_tx_loopback_result {
13844 cmdline_fixed_string_t set;
13845 cmdline_fixed_string_t tx;
13846 cmdline_fixed_string_t loopback;
13848 cmdline_fixed_string_t on_off;
13851 /* Common CLI fields for tx loopback enable disable */
13852 cmdline_parse_token_string_t cmd_tx_loopback_set =
13853 TOKEN_STRING_INITIALIZER
13854 (struct cmd_tx_loopback_result,
13856 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13857 TOKEN_STRING_INITIALIZER
13858 (struct cmd_tx_loopback_result,
13860 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13861 TOKEN_STRING_INITIALIZER
13862 (struct cmd_tx_loopback_result,
13863 loopback, "loopback");
13864 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13865 TOKEN_NUM_INITIALIZER
13866 (struct cmd_tx_loopback_result,
13868 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13869 TOKEN_STRING_INITIALIZER
13870 (struct cmd_tx_loopback_result,
13874 cmd_set_tx_loopback_parsed(
13875 void *parsed_result,
13876 __rte_unused struct cmdline *cl,
13877 __rte_unused void *data)
13879 struct cmd_tx_loopback_result *res = parsed_result;
13880 int ret = -ENOTSUP;
13882 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13884 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13887 #ifdef RTE_LIBRTE_IXGBE_PMD
13888 if (ret == -ENOTSUP)
13889 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13891 #ifdef RTE_LIBRTE_I40E_PMD
13892 if (ret == -ENOTSUP)
13893 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13895 #ifdef RTE_LIBRTE_BNXT_PMD
13896 if (ret == -ENOTSUP)
13897 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13899 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13900 if (ret == -ENOTSUP)
13901 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13908 printf("invalid is_on %d\n", is_on);
13911 printf("invalid port_id %d\n", res->port_id);
13914 printf("function not implemented\n");
13917 printf("programming error: (%s)\n", strerror(-ret));
13921 cmdline_parse_inst_t cmd_set_tx_loopback = {
13922 .f = cmd_set_tx_loopback_parsed,
13924 .help_str = "set tx loopback <port_id> on|off",
13926 (void *)&cmd_tx_loopback_set,
13927 (void *)&cmd_tx_loopback_tx,
13928 (void *)&cmd_tx_loopback_loopback,
13929 (void *)&cmd_tx_loopback_port_id,
13930 (void *)&cmd_tx_loopback_on_off,
13935 /* all queues drop enable configuration */
13937 /* Common result structure for all queues drop enable */
13938 struct cmd_all_queues_drop_en_result {
13939 cmdline_fixed_string_t set;
13940 cmdline_fixed_string_t all;
13941 cmdline_fixed_string_t queues;
13942 cmdline_fixed_string_t drop;
13944 cmdline_fixed_string_t on_off;
13947 /* Common CLI fields for tx loopback enable disable */
13948 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13949 TOKEN_STRING_INITIALIZER
13950 (struct cmd_all_queues_drop_en_result,
13952 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13953 TOKEN_STRING_INITIALIZER
13954 (struct cmd_all_queues_drop_en_result,
13956 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13957 TOKEN_STRING_INITIALIZER
13958 (struct cmd_all_queues_drop_en_result,
13960 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13961 TOKEN_STRING_INITIALIZER
13962 (struct cmd_all_queues_drop_en_result,
13964 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13965 TOKEN_NUM_INITIALIZER
13966 (struct cmd_all_queues_drop_en_result,
13968 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13969 TOKEN_STRING_INITIALIZER
13970 (struct cmd_all_queues_drop_en_result,
13974 cmd_set_all_queues_drop_en_parsed(
13975 void *parsed_result,
13976 __rte_unused struct cmdline *cl,
13977 __rte_unused void *data)
13979 struct cmd_all_queues_drop_en_result *res = parsed_result;
13980 int ret = -ENOTSUP;
13981 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13983 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13986 #ifdef RTE_LIBRTE_IXGBE_PMD
13987 if (ret == -ENOTSUP)
13988 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13990 #ifdef RTE_LIBRTE_BNXT_PMD
13991 if (ret == -ENOTSUP)
13992 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13998 printf("invalid is_on %d\n", is_on);
14001 printf("invalid port_id %d\n", res->port_id);
14004 printf("function not implemented\n");
14007 printf("programming error: (%s)\n", strerror(-ret));
14011 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14012 .f = cmd_set_all_queues_drop_en_parsed,
14014 .help_str = "set all queues drop <port_id> on|off",
14016 (void *)&cmd_all_queues_drop_en_set,
14017 (void *)&cmd_all_queues_drop_en_all,
14018 (void *)&cmd_all_queues_drop_en_queues,
14019 (void *)&cmd_all_queues_drop_en_drop,
14020 (void *)&cmd_all_queues_drop_en_port_id,
14021 (void *)&cmd_all_queues_drop_en_on_off,
14026 /* vf split drop enable configuration */
14028 /* Common result structure for vf split drop enable */
14029 struct cmd_vf_split_drop_en_result {
14030 cmdline_fixed_string_t set;
14031 cmdline_fixed_string_t vf;
14032 cmdline_fixed_string_t split;
14033 cmdline_fixed_string_t drop;
14036 cmdline_fixed_string_t on_off;
14039 /* Common CLI fields for vf split drop enable disable */
14040 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14041 TOKEN_STRING_INITIALIZER
14042 (struct cmd_vf_split_drop_en_result,
14044 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14045 TOKEN_STRING_INITIALIZER
14046 (struct cmd_vf_split_drop_en_result,
14048 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14049 TOKEN_STRING_INITIALIZER
14050 (struct cmd_vf_split_drop_en_result,
14052 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14053 TOKEN_STRING_INITIALIZER
14054 (struct cmd_vf_split_drop_en_result,
14056 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14057 TOKEN_NUM_INITIALIZER
14058 (struct cmd_vf_split_drop_en_result,
14060 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14061 TOKEN_NUM_INITIALIZER
14062 (struct cmd_vf_split_drop_en_result,
14064 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14065 TOKEN_STRING_INITIALIZER
14066 (struct cmd_vf_split_drop_en_result,
14070 cmd_set_vf_split_drop_en_parsed(
14071 void *parsed_result,
14072 __rte_unused struct cmdline *cl,
14073 __rte_unused void *data)
14075 struct cmd_vf_split_drop_en_result *res = parsed_result;
14076 int ret = -ENOTSUP;
14077 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14079 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14082 #ifdef RTE_LIBRTE_IXGBE_PMD
14083 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14090 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14093 printf("invalid port_id %d\n", res->port_id);
14096 printf("not supported on port %d\n", res->port_id);
14099 printf("programming error: (%s)\n", strerror(-ret));
14103 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14104 .f = cmd_set_vf_split_drop_en_parsed,
14106 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14108 (void *)&cmd_vf_split_drop_en_set,
14109 (void *)&cmd_vf_split_drop_en_vf,
14110 (void *)&cmd_vf_split_drop_en_split,
14111 (void *)&cmd_vf_split_drop_en_drop,
14112 (void *)&cmd_vf_split_drop_en_port_id,
14113 (void *)&cmd_vf_split_drop_en_vf_id,
14114 (void *)&cmd_vf_split_drop_en_on_off,
14119 /* vf mac address configuration */
14121 /* Common result structure for vf mac address */
14122 struct cmd_set_vf_mac_addr_result {
14123 cmdline_fixed_string_t set;
14124 cmdline_fixed_string_t vf;
14125 cmdline_fixed_string_t mac;
14126 cmdline_fixed_string_t addr;
14129 struct rte_ether_addr mac_addr;
14133 /* Common CLI fields for vf split drop enable disable */
14134 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14135 TOKEN_STRING_INITIALIZER
14136 (struct cmd_set_vf_mac_addr_result,
14138 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14139 TOKEN_STRING_INITIALIZER
14140 (struct cmd_set_vf_mac_addr_result,
14142 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14143 TOKEN_STRING_INITIALIZER
14144 (struct cmd_set_vf_mac_addr_result,
14146 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14147 TOKEN_STRING_INITIALIZER
14148 (struct cmd_set_vf_mac_addr_result,
14150 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14151 TOKEN_NUM_INITIALIZER
14152 (struct cmd_set_vf_mac_addr_result,
14154 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14155 TOKEN_NUM_INITIALIZER
14156 (struct cmd_set_vf_mac_addr_result,
14158 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14159 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14163 cmd_set_vf_mac_addr_parsed(
14164 void *parsed_result,
14165 __rte_unused struct cmdline *cl,
14166 __rte_unused void *data)
14168 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14169 int ret = -ENOTSUP;
14171 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14174 #ifdef RTE_LIBRTE_IXGBE_PMD
14175 if (ret == -ENOTSUP)
14176 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14179 #ifdef RTE_LIBRTE_I40E_PMD
14180 if (ret == -ENOTSUP)
14181 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14184 #ifdef RTE_LIBRTE_BNXT_PMD
14185 if (ret == -ENOTSUP)
14186 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14194 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14197 printf("invalid port_id %d\n", res->port_id);
14200 printf("function not implemented\n");
14203 printf("programming error: (%s)\n", strerror(-ret));
14207 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14208 .f = cmd_set_vf_mac_addr_parsed,
14210 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14212 (void *)&cmd_set_vf_mac_addr_set,
14213 (void *)&cmd_set_vf_mac_addr_vf,
14214 (void *)&cmd_set_vf_mac_addr_mac,
14215 (void *)&cmd_set_vf_mac_addr_addr,
14216 (void *)&cmd_set_vf_mac_addr_port_id,
14217 (void *)&cmd_set_vf_mac_addr_vf_id,
14218 (void *)&cmd_set_vf_mac_addr_mac_addr,
14223 /* MACsec configuration */
14225 /* Common result structure for MACsec offload enable */
14226 struct cmd_macsec_offload_on_result {
14227 cmdline_fixed_string_t set;
14228 cmdline_fixed_string_t macsec;
14229 cmdline_fixed_string_t offload;
14231 cmdline_fixed_string_t on;
14232 cmdline_fixed_string_t encrypt;
14233 cmdline_fixed_string_t en_on_off;
14234 cmdline_fixed_string_t replay_protect;
14235 cmdline_fixed_string_t rp_on_off;
14238 /* Common CLI fields for MACsec offload disable */
14239 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14240 TOKEN_STRING_INITIALIZER
14241 (struct cmd_macsec_offload_on_result,
14243 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14244 TOKEN_STRING_INITIALIZER
14245 (struct cmd_macsec_offload_on_result,
14247 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14248 TOKEN_STRING_INITIALIZER
14249 (struct cmd_macsec_offload_on_result,
14250 offload, "offload");
14251 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14252 TOKEN_NUM_INITIALIZER
14253 (struct cmd_macsec_offload_on_result,
14255 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14256 TOKEN_STRING_INITIALIZER
14257 (struct cmd_macsec_offload_on_result,
14259 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14260 TOKEN_STRING_INITIALIZER
14261 (struct cmd_macsec_offload_on_result,
14262 encrypt, "encrypt");
14263 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14264 TOKEN_STRING_INITIALIZER
14265 (struct cmd_macsec_offload_on_result,
14266 en_on_off, "on#off");
14267 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14268 TOKEN_STRING_INITIALIZER
14269 (struct cmd_macsec_offload_on_result,
14270 replay_protect, "replay-protect");
14271 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14272 TOKEN_STRING_INITIALIZER
14273 (struct cmd_macsec_offload_on_result,
14274 rp_on_off, "on#off");
14277 cmd_set_macsec_offload_on_parsed(
14278 void *parsed_result,
14279 __rte_unused struct cmdline *cl,
14280 __rte_unused void *data)
14282 struct cmd_macsec_offload_on_result *res = parsed_result;
14283 int ret = -ENOTSUP;
14284 portid_t port_id = res->port_id;
14285 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14286 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14287 struct rte_eth_dev_info dev_info;
14289 if (port_id_is_invalid(port_id, ENABLED_WARN))
14291 if (!port_is_stopped(port_id)) {
14292 printf("Please stop port %d first\n", port_id);
14296 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14300 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14301 #ifdef RTE_LIBRTE_IXGBE_PMD
14302 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14310 ports[port_id].dev_conf.txmode.offloads |=
14311 DEV_TX_OFFLOAD_MACSEC_INSERT;
14312 cmd_reconfig_device_queue(port_id, 1, 1);
14315 printf("invalid port_id %d\n", port_id);
14318 printf("not supported on port %d\n", port_id);
14321 printf("programming error: (%s)\n", strerror(-ret));
14325 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14326 .f = cmd_set_macsec_offload_on_parsed,
14328 .help_str = "set macsec offload <port_id> on "
14329 "encrypt on|off replay-protect on|off",
14331 (void *)&cmd_macsec_offload_on_set,
14332 (void *)&cmd_macsec_offload_on_macsec,
14333 (void *)&cmd_macsec_offload_on_offload,
14334 (void *)&cmd_macsec_offload_on_port_id,
14335 (void *)&cmd_macsec_offload_on_on,
14336 (void *)&cmd_macsec_offload_on_encrypt,
14337 (void *)&cmd_macsec_offload_on_en_on_off,
14338 (void *)&cmd_macsec_offload_on_replay_protect,
14339 (void *)&cmd_macsec_offload_on_rp_on_off,
14344 /* Common result structure for MACsec offload disable */
14345 struct cmd_macsec_offload_off_result {
14346 cmdline_fixed_string_t set;
14347 cmdline_fixed_string_t macsec;
14348 cmdline_fixed_string_t offload;
14350 cmdline_fixed_string_t off;
14353 /* Common CLI fields for MACsec offload disable */
14354 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14355 TOKEN_STRING_INITIALIZER
14356 (struct cmd_macsec_offload_off_result,
14358 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14359 TOKEN_STRING_INITIALIZER
14360 (struct cmd_macsec_offload_off_result,
14362 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14363 TOKEN_STRING_INITIALIZER
14364 (struct cmd_macsec_offload_off_result,
14365 offload, "offload");
14366 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14367 TOKEN_NUM_INITIALIZER
14368 (struct cmd_macsec_offload_off_result,
14370 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14371 TOKEN_STRING_INITIALIZER
14372 (struct cmd_macsec_offload_off_result,
14376 cmd_set_macsec_offload_off_parsed(
14377 void *parsed_result,
14378 __rte_unused struct cmdline *cl,
14379 __rte_unused void *data)
14381 struct cmd_macsec_offload_off_result *res = parsed_result;
14382 int ret = -ENOTSUP;
14383 struct rte_eth_dev_info dev_info;
14384 portid_t port_id = res->port_id;
14386 if (port_id_is_invalid(port_id, ENABLED_WARN))
14388 if (!port_is_stopped(port_id)) {
14389 printf("Please stop port %d first\n", port_id);
14393 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14397 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14398 #ifdef RTE_LIBRTE_IXGBE_PMD
14399 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14404 ports[port_id].dev_conf.txmode.offloads &=
14405 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14406 cmd_reconfig_device_queue(port_id, 1, 1);
14409 printf("invalid port_id %d\n", port_id);
14412 printf("not supported on port %d\n", port_id);
14415 printf("programming error: (%s)\n", strerror(-ret));
14419 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14420 .f = cmd_set_macsec_offload_off_parsed,
14422 .help_str = "set macsec offload <port_id> off",
14424 (void *)&cmd_macsec_offload_off_set,
14425 (void *)&cmd_macsec_offload_off_macsec,
14426 (void *)&cmd_macsec_offload_off_offload,
14427 (void *)&cmd_macsec_offload_off_port_id,
14428 (void *)&cmd_macsec_offload_off_off,
14433 /* Common result structure for MACsec secure connection configure */
14434 struct cmd_macsec_sc_result {
14435 cmdline_fixed_string_t set;
14436 cmdline_fixed_string_t macsec;
14437 cmdline_fixed_string_t sc;
14438 cmdline_fixed_string_t tx_rx;
14440 struct rte_ether_addr mac;
14444 /* Common CLI fields for MACsec secure connection configure */
14445 cmdline_parse_token_string_t cmd_macsec_sc_set =
14446 TOKEN_STRING_INITIALIZER
14447 (struct cmd_macsec_sc_result,
14449 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14450 TOKEN_STRING_INITIALIZER
14451 (struct cmd_macsec_sc_result,
14453 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14454 TOKEN_STRING_INITIALIZER
14455 (struct cmd_macsec_sc_result,
14457 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14458 TOKEN_STRING_INITIALIZER
14459 (struct cmd_macsec_sc_result,
14461 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14462 TOKEN_NUM_INITIALIZER
14463 (struct cmd_macsec_sc_result,
14465 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14466 TOKEN_ETHERADDR_INITIALIZER
14467 (struct cmd_macsec_sc_result,
14469 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14470 TOKEN_NUM_INITIALIZER
14471 (struct cmd_macsec_sc_result,
14475 cmd_set_macsec_sc_parsed(
14476 void *parsed_result,
14477 __rte_unused struct cmdline *cl,
14478 __rte_unused void *data)
14480 struct cmd_macsec_sc_result *res = parsed_result;
14481 int ret = -ENOTSUP;
14482 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14484 #ifdef RTE_LIBRTE_IXGBE_PMD
14486 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14487 res->mac.addr_bytes) :
14488 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14489 res->mac.addr_bytes, res->pi);
14491 RTE_SET_USED(is_tx);
14497 printf("invalid port_id %d\n", res->port_id);
14500 printf("not supported on port %d\n", res->port_id);
14503 printf("programming error: (%s)\n", strerror(-ret));
14507 cmdline_parse_inst_t cmd_set_macsec_sc = {
14508 .f = cmd_set_macsec_sc_parsed,
14510 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14512 (void *)&cmd_macsec_sc_set,
14513 (void *)&cmd_macsec_sc_macsec,
14514 (void *)&cmd_macsec_sc_sc,
14515 (void *)&cmd_macsec_sc_tx_rx,
14516 (void *)&cmd_macsec_sc_port_id,
14517 (void *)&cmd_macsec_sc_mac,
14518 (void *)&cmd_macsec_sc_pi,
14523 /* Common result structure for MACsec secure connection configure */
14524 struct cmd_macsec_sa_result {
14525 cmdline_fixed_string_t set;
14526 cmdline_fixed_string_t macsec;
14527 cmdline_fixed_string_t sa;
14528 cmdline_fixed_string_t tx_rx;
14533 cmdline_fixed_string_t key;
14536 /* Common CLI fields for MACsec secure connection configure */
14537 cmdline_parse_token_string_t cmd_macsec_sa_set =
14538 TOKEN_STRING_INITIALIZER
14539 (struct cmd_macsec_sa_result,
14541 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14542 TOKEN_STRING_INITIALIZER
14543 (struct cmd_macsec_sa_result,
14545 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14546 TOKEN_STRING_INITIALIZER
14547 (struct cmd_macsec_sa_result,
14549 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14550 TOKEN_STRING_INITIALIZER
14551 (struct cmd_macsec_sa_result,
14553 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14554 TOKEN_NUM_INITIALIZER
14555 (struct cmd_macsec_sa_result,
14557 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14558 TOKEN_NUM_INITIALIZER
14559 (struct cmd_macsec_sa_result,
14561 cmdline_parse_token_num_t cmd_macsec_sa_an =
14562 TOKEN_NUM_INITIALIZER
14563 (struct cmd_macsec_sa_result,
14565 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14566 TOKEN_NUM_INITIALIZER
14567 (struct cmd_macsec_sa_result,
14569 cmdline_parse_token_string_t cmd_macsec_sa_key =
14570 TOKEN_STRING_INITIALIZER
14571 (struct cmd_macsec_sa_result,
14575 cmd_set_macsec_sa_parsed(
14576 void *parsed_result,
14577 __rte_unused struct cmdline *cl,
14578 __rte_unused void *data)
14580 struct cmd_macsec_sa_result *res = parsed_result;
14581 int ret = -ENOTSUP;
14582 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14583 uint8_t key[16] = { 0 };
14589 key_len = strlen(res->key) / 2;
14593 for (i = 0; i < key_len; i++) {
14594 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14597 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14600 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14603 #ifdef RTE_LIBRTE_IXGBE_PMD
14605 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14606 res->idx, res->an, res->pn, key) :
14607 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14608 res->idx, res->an, res->pn, key);
14610 RTE_SET_USED(is_tx);
14617 printf("invalid idx %d or an %d\n", res->idx, res->an);
14620 printf("invalid port_id %d\n", res->port_id);
14623 printf("not supported on port %d\n", res->port_id);
14626 printf("programming error: (%s)\n", strerror(-ret));
14630 cmdline_parse_inst_t cmd_set_macsec_sa = {
14631 .f = cmd_set_macsec_sa_parsed,
14633 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14635 (void *)&cmd_macsec_sa_set,
14636 (void *)&cmd_macsec_sa_macsec,
14637 (void *)&cmd_macsec_sa_sa,
14638 (void *)&cmd_macsec_sa_tx_rx,
14639 (void *)&cmd_macsec_sa_port_id,
14640 (void *)&cmd_macsec_sa_idx,
14641 (void *)&cmd_macsec_sa_an,
14642 (void *)&cmd_macsec_sa_pn,
14643 (void *)&cmd_macsec_sa_key,
14648 /* VF unicast promiscuous mode configuration */
14650 /* Common result structure for VF unicast promiscuous mode */
14651 struct cmd_vf_promisc_result {
14652 cmdline_fixed_string_t set;
14653 cmdline_fixed_string_t vf;
14654 cmdline_fixed_string_t promisc;
14657 cmdline_fixed_string_t on_off;
14660 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14661 cmdline_parse_token_string_t cmd_vf_promisc_set =
14662 TOKEN_STRING_INITIALIZER
14663 (struct cmd_vf_promisc_result,
14665 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14666 TOKEN_STRING_INITIALIZER
14667 (struct cmd_vf_promisc_result,
14669 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14670 TOKEN_STRING_INITIALIZER
14671 (struct cmd_vf_promisc_result,
14672 promisc, "promisc");
14673 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14674 TOKEN_NUM_INITIALIZER
14675 (struct cmd_vf_promisc_result,
14677 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14678 TOKEN_NUM_INITIALIZER
14679 (struct cmd_vf_promisc_result,
14681 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14682 TOKEN_STRING_INITIALIZER
14683 (struct cmd_vf_promisc_result,
14687 cmd_set_vf_promisc_parsed(
14688 void *parsed_result,
14689 __rte_unused struct cmdline *cl,
14690 __rte_unused void *data)
14692 struct cmd_vf_promisc_result *res = parsed_result;
14693 int ret = -ENOTSUP;
14695 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14697 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14700 #ifdef RTE_LIBRTE_I40E_PMD
14701 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14702 res->vf_id, is_on);
14709 printf("invalid vf_id %d\n", res->vf_id);
14712 printf("invalid port_id %d\n", res->port_id);
14715 printf("function not implemented\n");
14718 printf("programming error: (%s)\n", strerror(-ret));
14722 cmdline_parse_inst_t cmd_set_vf_promisc = {
14723 .f = cmd_set_vf_promisc_parsed,
14725 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14726 "Set unicast promiscuous mode for a VF from the PF",
14728 (void *)&cmd_vf_promisc_set,
14729 (void *)&cmd_vf_promisc_vf,
14730 (void *)&cmd_vf_promisc_promisc,
14731 (void *)&cmd_vf_promisc_port_id,
14732 (void *)&cmd_vf_promisc_vf_id,
14733 (void *)&cmd_vf_promisc_on_off,
14738 /* VF multicast promiscuous mode configuration */
14740 /* Common result structure for VF multicast promiscuous mode */
14741 struct cmd_vf_allmulti_result {
14742 cmdline_fixed_string_t set;
14743 cmdline_fixed_string_t vf;
14744 cmdline_fixed_string_t allmulti;
14747 cmdline_fixed_string_t on_off;
14750 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14751 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14752 TOKEN_STRING_INITIALIZER
14753 (struct cmd_vf_allmulti_result,
14755 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14756 TOKEN_STRING_INITIALIZER
14757 (struct cmd_vf_allmulti_result,
14759 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14760 TOKEN_STRING_INITIALIZER
14761 (struct cmd_vf_allmulti_result,
14762 allmulti, "allmulti");
14763 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14764 TOKEN_NUM_INITIALIZER
14765 (struct cmd_vf_allmulti_result,
14767 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14768 TOKEN_NUM_INITIALIZER
14769 (struct cmd_vf_allmulti_result,
14771 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14772 TOKEN_STRING_INITIALIZER
14773 (struct cmd_vf_allmulti_result,
14777 cmd_set_vf_allmulti_parsed(
14778 void *parsed_result,
14779 __rte_unused struct cmdline *cl,
14780 __rte_unused void *data)
14782 struct cmd_vf_allmulti_result *res = parsed_result;
14783 int ret = -ENOTSUP;
14785 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14787 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14790 #ifdef RTE_LIBRTE_I40E_PMD
14791 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14792 res->vf_id, is_on);
14799 printf("invalid vf_id %d\n", res->vf_id);
14802 printf("invalid port_id %d\n", res->port_id);
14805 printf("function not implemented\n");
14808 printf("programming error: (%s)\n", strerror(-ret));
14812 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14813 .f = cmd_set_vf_allmulti_parsed,
14815 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14816 "Set multicast promiscuous mode for a VF from the PF",
14818 (void *)&cmd_vf_allmulti_set,
14819 (void *)&cmd_vf_allmulti_vf,
14820 (void *)&cmd_vf_allmulti_allmulti,
14821 (void *)&cmd_vf_allmulti_port_id,
14822 (void *)&cmd_vf_allmulti_vf_id,
14823 (void *)&cmd_vf_allmulti_on_off,
14828 /* vf broadcast mode configuration */
14830 /* Common result structure for vf broadcast */
14831 struct cmd_set_vf_broadcast_result {
14832 cmdline_fixed_string_t set;
14833 cmdline_fixed_string_t vf;
14834 cmdline_fixed_string_t broadcast;
14837 cmdline_fixed_string_t on_off;
14840 /* Common CLI fields for vf broadcast enable disable */
14841 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14842 TOKEN_STRING_INITIALIZER
14843 (struct cmd_set_vf_broadcast_result,
14845 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14846 TOKEN_STRING_INITIALIZER
14847 (struct cmd_set_vf_broadcast_result,
14849 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14850 TOKEN_STRING_INITIALIZER
14851 (struct cmd_set_vf_broadcast_result,
14852 broadcast, "broadcast");
14853 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14854 TOKEN_NUM_INITIALIZER
14855 (struct cmd_set_vf_broadcast_result,
14857 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14858 TOKEN_NUM_INITIALIZER
14859 (struct cmd_set_vf_broadcast_result,
14861 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14862 TOKEN_STRING_INITIALIZER
14863 (struct cmd_set_vf_broadcast_result,
14867 cmd_set_vf_broadcast_parsed(
14868 void *parsed_result,
14869 __rte_unused struct cmdline *cl,
14870 __rte_unused void *data)
14872 struct cmd_set_vf_broadcast_result *res = parsed_result;
14873 int ret = -ENOTSUP;
14875 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14877 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14880 #ifdef RTE_LIBRTE_I40E_PMD
14881 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14882 res->vf_id, is_on);
14889 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14892 printf("invalid port_id %d\n", res->port_id);
14895 printf("function not implemented\n");
14898 printf("programming error: (%s)\n", strerror(-ret));
14902 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14903 .f = cmd_set_vf_broadcast_parsed,
14905 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14907 (void *)&cmd_set_vf_broadcast_set,
14908 (void *)&cmd_set_vf_broadcast_vf,
14909 (void *)&cmd_set_vf_broadcast_broadcast,
14910 (void *)&cmd_set_vf_broadcast_port_id,
14911 (void *)&cmd_set_vf_broadcast_vf_id,
14912 (void *)&cmd_set_vf_broadcast_on_off,
14917 /* vf vlan tag configuration */
14919 /* Common result structure for vf vlan tag */
14920 struct cmd_set_vf_vlan_tag_result {
14921 cmdline_fixed_string_t set;
14922 cmdline_fixed_string_t vf;
14923 cmdline_fixed_string_t vlan;
14924 cmdline_fixed_string_t tag;
14927 cmdline_fixed_string_t on_off;
14930 /* Common CLI fields for vf vlan tag enable disable */
14931 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14932 TOKEN_STRING_INITIALIZER
14933 (struct cmd_set_vf_vlan_tag_result,
14935 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14936 TOKEN_STRING_INITIALIZER
14937 (struct cmd_set_vf_vlan_tag_result,
14939 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14940 TOKEN_STRING_INITIALIZER
14941 (struct cmd_set_vf_vlan_tag_result,
14943 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14944 TOKEN_STRING_INITIALIZER
14945 (struct cmd_set_vf_vlan_tag_result,
14947 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14948 TOKEN_NUM_INITIALIZER
14949 (struct cmd_set_vf_vlan_tag_result,
14951 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14952 TOKEN_NUM_INITIALIZER
14953 (struct cmd_set_vf_vlan_tag_result,
14955 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14956 TOKEN_STRING_INITIALIZER
14957 (struct cmd_set_vf_vlan_tag_result,
14961 cmd_set_vf_vlan_tag_parsed(
14962 void *parsed_result,
14963 __rte_unused struct cmdline *cl,
14964 __rte_unused void *data)
14966 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14967 int ret = -ENOTSUP;
14969 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14971 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14974 #ifdef RTE_LIBRTE_I40E_PMD
14975 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14976 res->vf_id, is_on);
14983 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14986 printf("invalid port_id %d\n", res->port_id);
14989 printf("function not implemented\n");
14992 printf("programming error: (%s)\n", strerror(-ret));
14996 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14997 .f = cmd_set_vf_vlan_tag_parsed,
14999 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15001 (void *)&cmd_set_vf_vlan_tag_set,
15002 (void *)&cmd_set_vf_vlan_tag_vf,
15003 (void *)&cmd_set_vf_vlan_tag_vlan,
15004 (void *)&cmd_set_vf_vlan_tag_tag,
15005 (void *)&cmd_set_vf_vlan_tag_port_id,
15006 (void *)&cmd_set_vf_vlan_tag_vf_id,
15007 (void *)&cmd_set_vf_vlan_tag_on_off,
15012 /* Common definition of VF and TC TX bandwidth configuration */
15013 struct cmd_vf_tc_bw_result {
15014 cmdline_fixed_string_t set;
15015 cmdline_fixed_string_t vf;
15016 cmdline_fixed_string_t tc;
15017 cmdline_fixed_string_t tx;
15018 cmdline_fixed_string_t min_bw;
15019 cmdline_fixed_string_t max_bw;
15020 cmdline_fixed_string_t strict_link_prio;
15025 cmdline_fixed_string_t bw_list;
15029 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15030 TOKEN_STRING_INITIALIZER
15031 (struct cmd_vf_tc_bw_result,
15033 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15034 TOKEN_STRING_INITIALIZER
15035 (struct cmd_vf_tc_bw_result,
15037 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15038 TOKEN_STRING_INITIALIZER
15039 (struct cmd_vf_tc_bw_result,
15041 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15042 TOKEN_STRING_INITIALIZER
15043 (struct cmd_vf_tc_bw_result,
15045 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15046 TOKEN_STRING_INITIALIZER
15047 (struct cmd_vf_tc_bw_result,
15048 strict_link_prio, "strict-link-priority");
15049 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15050 TOKEN_STRING_INITIALIZER
15051 (struct cmd_vf_tc_bw_result,
15052 min_bw, "min-bandwidth");
15053 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15054 TOKEN_STRING_INITIALIZER
15055 (struct cmd_vf_tc_bw_result,
15056 max_bw, "max-bandwidth");
15057 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15058 TOKEN_NUM_INITIALIZER
15059 (struct cmd_vf_tc_bw_result,
15061 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15062 TOKEN_NUM_INITIALIZER
15063 (struct cmd_vf_tc_bw_result,
15065 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15066 TOKEN_NUM_INITIALIZER
15067 (struct cmd_vf_tc_bw_result,
15069 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15070 TOKEN_NUM_INITIALIZER
15071 (struct cmd_vf_tc_bw_result,
15073 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15074 TOKEN_STRING_INITIALIZER
15075 (struct cmd_vf_tc_bw_result,
15077 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15078 TOKEN_NUM_INITIALIZER
15079 (struct cmd_vf_tc_bw_result,
15082 /* VF max bandwidth setting */
15084 cmd_vf_max_bw_parsed(
15085 void *parsed_result,
15086 __rte_unused struct cmdline *cl,
15087 __rte_unused void *data)
15089 struct cmd_vf_tc_bw_result *res = parsed_result;
15090 int ret = -ENOTSUP;
15092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15095 #ifdef RTE_LIBRTE_I40E_PMD
15096 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15097 res->vf_id, res->bw);
15104 printf("invalid vf_id %d or bandwidth %d\n",
15105 res->vf_id, res->bw);
15108 printf("invalid port_id %d\n", res->port_id);
15111 printf("function not implemented\n");
15114 printf("programming error: (%s)\n", strerror(-ret));
15118 cmdline_parse_inst_t cmd_vf_max_bw = {
15119 .f = cmd_vf_max_bw_parsed,
15121 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15123 (void *)&cmd_vf_tc_bw_set,
15124 (void *)&cmd_vf_tc_bw_vf,
15125 (void *)&cmd_vf_tc_bw_tx,
15126 (void *)&cmd_vf_tc_bw_max_bw,
15127 (void *)&cmd_vf_tc_bw_port_id,
15128 (void *)&cmd_vf_tc_bw_vf_id,
15129 (void *)&cmd_vf_tc_bw_bw,
15135 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15140 const char *p, *p0 = str;
15147 p = strchr(p0, '(');
15149 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15153 p0 = strchr(p, ')');
15155 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15159 if (size >= sizeof(s)) {
15160 printf("The string size exceeds the internal buffer size\n");
15163 snprintf(s, sizeof(s), "%.*s", size, p);
15164 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15166 printf("Failed to get the bandwidth list. ");
15170 for (i = 0; i < ret; i++)
15171 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15176 /* TC min bandwidth setting */
15178 cmd_vf_tc_min_bw_parsed(
15179 void *parsed_result,
15180 __rte_unused struct cmdline *cl,
15181 __rte_unused void *data)
15183 struct cmd_vf_tc_bw_result *res = parsed_result;
15186 int ret = -ENOTSUP;
15188 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15191 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15195 #ifdef RTE_LIBRTE_I40E_PMD
15196 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15204 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15207 printf("invalid port_id %d\n", res->port_id);
15210 printf("function not implemented\n");
15213 printf("programming error: (%s)\n", strerror(-ret));
15217 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15218 .f = cmd_vf_tc_min_bw_parsed,
15220 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15221 " <bw1, bw2, ...>",
15223 (void *)&cmd_vf_tc_bw_set,
15224 (void *)&cmd_vf_tc_bw_vf,
15225 (void *)&cmd_vf_tc_bw_tc,
15226 (void *)&cmd_vf_tc_bw_tx,
15227 (void *)&cmd_vf_tc_bw_min_bw,
15228 (void *)&cmd_vf_tc_bw_port_id,
15229 (void *)&cmd_vf_tc_bw_vf_id,
15230 (void *)&cmd_vf_tc_bw_bw_list,
15236 cmd_tc_min_bw_parsed(
15237 void *parsed_result,
15238 __rte_unused struct cmdline *cl,
15239 __rte_unused void *data)
15241 struct cmd_vf_tc_bw_result *res = parsed_result;
15242 struct rte_port *port;
15245 int ret = -ENOTSUP;
15247 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15250 port = &ports[res->port_id];
15251 /** Check if the port is not started **/
15252 if (port->port_status != RTE_PORT_STOPPED) {
15253 printf("Please stop port %d first\n", res->port_id);
15257 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15261 #ifdef RTE_LIBRTE_IXGBE_PMD
15262 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15269 printf("invalid bandwidth\n");
15272 printf("invalid port_id %d\n", res->port_id);
15275 printf("function not implemented\n");
15278 printf("programming error: (%s)\n", strerror(-ret));
15282 cmdline_parse_inst_t cmd_tc_min_bw = {
15283 .f = cmd_tc_min_bw_parsed,
15285 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15287 (void *)&cmd_vf_tc_bw_set,
15288 (void *)&cmd_vf_tc_bw_tc,
15289 (void *)&cmd_vf_tc_bw_tx,
15290 (void *)&cmd_vf_tc_bw_min_bw,
15291 (void *)&cmd_vf_tc_bw_port_id,
15292 (void *)&cmd_vf_tc_bw_bw_list,
15297 /* TC max bandwidth setting */
15299 cmd_vf_tc_max_bw_parsed(
15300 void *parsed_result,
15301 __rte_unused struct cmdline *cl,
15302 __rte_unused void *data)
15304 struct cmd_vf_tc_bw_result *res = parsed_result;
15305 int ret = -ENOTSUP;
15307 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15310 #ifdef RTE_LIBRTE_I40E_PMD
15311 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15312 res->tc_no, res->bw);
15319 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15320 res->vf_id, res->tc_no, res->bw);
15323 printf("invalid port_id %d\n", res->port_id);
15326 printf("function not implemented\n");
15329 printf("programming error: (%s)\n", strerror(-ret));
15333 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15334 .f = cmd_vf_tc_max_bw_parsed,
15336 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15339 (void *)&cmd_vf_tc_bw_set,
15340 (void *)&cmd_vf_tc_bw_vf,
15341 (void *)&cmd_vf_tc_bw_tc,
15342 (void *)&cmd_vf_tc_bw_tx,
15343 (void *)&cmd_vf_tc_bw_max_bw,
15344 (void *)&cmd_vf_tc_bw_port_id,
15345 (void *)&cmd_vf_tc_bw_vf_id,
15346 (void *)&cmd_vf_tc_bw_tc_no,
15347 (void *)&cmd_vf_tc_bw_bw,
15353 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15355 /* *** Set Port default Traffic Management Hierarchy *** */
15356 struct cmd_set_port_tm_hierarchy_default_result {
15357 cmdline_fixed_string_t set;
15358 cmdline_fixed_string_t port;
15359 cmdline_fixed_string_t tm;
15360 cmdline_fixed_string_t hierarchy;
15361 cmdline_fixed_string_t def;
15365 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15366 TOKEN_STRING_INITIALIZER(
15367 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15368 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15369 TOKEN_STRING_INITIALIZER(
15370 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15371 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15372 TOKEN_STRING_INITIALIZER(
15373 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15374 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15375 TOKEN_STRING_INITIALIZER(
15376 struct cmd_set_port_tm_hierarchy_default_result,
15377 hierarchy, "hierarchy");
15378 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15379 TOKEN_STRING_INITIALIZER(
15380 struct cmd_set_port_tm_hierarchy_default_result,
15382 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15383 TOKEN_NUM_INITIALIZER(
15384 struct cmd_set_port_tm_hierarchy_default_result,
15387 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15388 __rte_unused struct cmdline *cl,
15389 __rte_unused void *data)
15391 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15392 struct rte_port *p;
15393 portid_t port_id = res->port_id;
15395 if (port_id_is_invalid(port_id, ENABLED_WARN))
15398 p = &ports[port_id];
15400 /* Forward mode: tm */
15401 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15402 printf(" softnicfwd mode not enabled(error)\n");
15406 /* Set the default tm hierarchy */
15407 p->softport.default_tm_hierarchy_enable = 1;
15410 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15411 .f = cmd_set_port_tm_hierarchy_default_parsed,
15413 .help_str = "set port tm hierarchy default <port_id>",
15415 (void *)&cmd_set_port_tm_hierarchy_default_set,
15416 (void *)&cmd_set_port_tm_hierarchy_default_port,
15417 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15418 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15419 (void *)&cmd_set_port_tm_hierarchy_default_default,
15420 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15426 /** Set VXLAN encapsulation details */
15427 struct cmd_set_vxlan_result {
15428 cmdline_fixed_string_t set;
15429 cmdline_fixed_string_t vxlan;
15430 cmdline_fixed_string_t pos_token;
15431 cmdline_fixed_string_t ip_version;
15432 uint32_t vlan_present:1;
15436 cmdline_ipaddr_t ip_src;
15437 cmdline_ipaddr_t ip_dst;
15441 struct rte_ether_addr eth_src;
15442 struct rte_ether_addr eth_dst;
15445 cmdline_parse_token_string_t cmd_set_vxlan_set =
15446 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15447 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15448 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15449 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15450 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15452 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15453 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15454 "vxlan-with-vlan");
15455 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15456 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15458 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15459 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15461 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15462 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15464 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15465 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15466 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15467 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15469 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15470 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15471 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15472 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15474 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15475 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15476 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15477 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15479 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15480 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15481 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15482 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15484 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15485 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15486 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15487 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15489 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15490 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15491 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15492 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15494 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15495 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15496 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15497 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15499 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15500 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15501 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15502 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15504 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15505 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15506 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15507 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15509 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15510 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15512 static void cmd_set_vxlan_parsed(void *parsed_result,
15513 __rte_unused struct cmdline *cl,
15514 __rte_unused void *data)
15516 struct cmd_set_vxlan_result *res = parsed_result;
15521 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15524 vxlan_encap_conf.select_tos_ttl = 0;
15525 if (strcmp(res->vxlan, "vxlan") == 0)
15526 vxlan_encap_conf.select_vlan = 0;
15527 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15528 vxlan_encap_conf.select_vlan = 1;
15529 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15530 vxlan_encap_conf.select_vlan = 0;
15531 vxlan_encap_conf.select_tos_ttl = 1;
15533 if (strcmp(res->ip_version, "ipv4") == 0)
15534 vxlan_encap_conf.select_ipv4 = 1;
15535 else if (strcmp(res->ip_version, "ipv6") == 0)
15536 vxlan_encap_conf.select_ipv4 = 0;
15539 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15540 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15541 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15542 vxlan_encap_conf.ip_tos = res->tos;
15543 vxlan_encap_conf.ip_ttl = res->ttl;
15544 if (vxlan_encap_conf.select_ipv4) {
15545 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15546 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15548 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15549 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15551 if (vxlan_encap_conf.select_vlan)
15552 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15553 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15554 RTE_ETHER_ADDR_LEN);
15555 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15556 RTE_ETHER_ADDR_LEN);
15559 cmdline_parse_inst_t cmd_set_vxlan = {
15560 .f = cmd_set_vxlan_parsed,
15562 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15563 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15564 " eth-src <eth-src> eth-dst <eth-dst>",
15566 (void *)&cmd_set_vxlan_set,
15567 (void *)&cmd_set_vxlan_vxlan,
15568 (void *)&cmd_set_vxlan_ip_version,
15569 (void *)&cmd_set_vxlan_ip_version_value,
15570 (void *)&cmd_set_vxlan_vni,
15571 (void *)&cmd_set_vxlan_vni_value,
15572 (void *)&cmd_set_vxlan_udp_src,
15573 (void *)&cmd_set_vxlan_udp_src_value,
15574 (void *)&cmd_set_vxlan_udp_dst,
15575 (void *)&cmd_set_vxlan_udp_dst_value,
15576 (void *)&cmd_set_vxlan_ip_src,
15577 (void *)&cmd_set_vxlan_ip_src_value,
15578 (void *)&cmd_set_vxlan_ip_dst,
15579 (void *)&cmd_set_vxlan_ip_dst_value,
15580 (void *)&cmd_set_vxlan_eth_src,
15581 (void *)&cmd_set_vxlan_eth_src_value,
15582 (void *)&cmd_set_vxlan_eth_dst,
15583 (void *)&cmd_set_vxlan_eth_dst_value,
15588 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15589 .f = cmd_set_vxlan_parsed,
15591 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15592 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15593 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15594 " eth-dst <eth-dst>",
15596 (void *)&cmd_set_vxlan_set,
15597 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15598 (void *)&cmd_set_vxlan_ip_version,
15599 (void *)&cmd_set_vxlan_ip_version_value,
15600 (void *)&cmd_set_vxlan_vni,
15601 (void *)&cmd_set_vxlan_vni_value,
15602 (void *)&cmd_set_vxlan_udp_src,
15603 (void *)&cmd_set_vxlan_udp_src_value,
15604 (void *)&cmd_set_vxlan_udp_dst,
15605 (void *)&cmd_set_vxlan_udp_dst_value,
15606 (void *)&cmd_set_vxlan_ip_tos,
15607 (void *)&cmd_set_vxlan_ip_tos_value,
15608 (void *)&cmd_set_vxlan_ip_ttl,
15609 (void *)&cmd_set_vxlan_ip_ttl_value,
15610 (void *)&cmd_set_vxlan_ip_src,
15611 (void *)&cmd_set_vxlan_ip_src_value,
15612 (void *)&cmd_set_vxlan_ip_dst,
15613 (void *)&cmd_set_vxlan_ip_dst_value,
15614 (void *)&cmd_set_vxlan_eth_src,
15615 (void *)&cmd_set_vxlan_eth_src_value,
15616 (void *)&cmd_set_vxlan_eth_dst,
15617 (void *)&cmd_set_vxlan_eth_dst_value,
15622 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15623 .f = cmd_set_vxlan_parsed,
15625 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15626 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15627 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15630 (void *)&cmd_set_vxlan_set,
15631 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15632 (void *)&cmd_set_vxlan_ip_version,
15633 (void *)&cmd_set_vxlan_ip_version_value,
15634 (void *)&cmd_set_vxlan_vni,
15635 (void *)&cmd_set_vxlan_vni_value,
15636 (void *)&cmd_set_vxlan_udp_src,
15637 (void *)&cmd_set_vxlan_udp_src_value,
15638 (void *)&cmd_set_vxlan_udp_dst,
15639 (void *)&cmd_set_vxlan_udp_dst_value,
15640 (void *)&cmd_set_vxlan_ip_src,
15641 (void *)&cmd_set_vxlan_ip_src_value,
15642 (void *)&cmd_set_vxlan_ip_dst,
15643 (void *)&cmd_set_vxlan_ip_dst_value,
15644 (void *)&cmd_set_vxlan_vlan,
15645 (void *)&cmd_set_vxlan_vlan_value,
15646 (void *)&cmd_set_vxlan_eth_src,
15647 (void *)&cmd_set_vxlan_eth_src_value,
15648 (void *)&cmd_set_vxlan_eth_dst,
15649 (void *)&cmd_set_vxlan_eth_dst_value,
15654 /** Set NVGRE encapsulation details */
15655 struct cmd_set_nvgre_result {
15656 cmdline_fixed_string_t set;
15657 cmdline_fixed_string_t nvgre;
15658 cmdline_fixed_string_t pos_token;
15659 cmdline_fixed_string_t ip_version;
15661 cmdline_ipaddr_t ip_src;
15662 cmdline_ipaddr_t ip_dst;
15664 struct rte_ether_addr eth_src;
15665 struct rte_ether_addr eth_dst;
15668 cmdline_parse_token_string_t cmd_set_nvgre_set =
15669 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15670 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15671 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15672 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15673 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15674 "nvgre-with-vlan");
15675 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15676 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15678 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15679 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15681 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15682 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15684 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15685 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15686 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15687 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15689 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15690 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15691 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15692 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15694 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15695 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15696 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15697 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15699 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15700 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15701 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15702 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15704 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15705 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15706 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15707 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15709 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15710 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15712 static void cmd_set_nvgre_parsed(void *parsed_result,
15713 __rte_unused struct cmdline *cl,
15714 __rte_unused void *data)
15716 struct cmd_set_nvgre_result *res = parsed_result;
15718 uint32_t nvgre_tni;
15721 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15724 if (strcmp(res->nvgre, "nvgre") == 0)
15725 nvgre_encap_conf.select_vlan = 0;
15726 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15727 nvgre_encap_conf.select_vlan = 1;
15728 if (strcmp(res->ip_version, "ipv4") == 0)
15729 nvgre_encap_conf.select_ipv4 = 1;
15730 else if (strcmp(res->ip_version, "ipv6") == 0)
15731 nvgre_encap_conf.select_ipv4 = 0;
15734 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15735 if (nvgre_encap_conf.select_ipv4) {
15736 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15737 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15739 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15740 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15742 if (nvgre_encap_conf.select_vlan)
15743 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15744 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15745 RTE_ETHER_ADDR_LEN);
15746 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15747 RTE_ETHER_ADDR_LEN);
15750 cmdline_parse_inst_t cmd_set_nvgre = {
15751 .f = cmd_set_nvgre_parsed,
15753 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15754 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15755 " eth-dst <eth-dst>",
15757 (void *)&cmd_set_nvgre_set,
15758 (void *)&cmd_set_nvgre_nvgre,
15759 (void *)&cmd_set_nvgre_ip_version,
15760 (void *)&cmd_set_nvgre_ip_version_value,
15761 (void *)&cmd_set_nvgre_tni,
15762 (void *)&cmd_set_nvgre_tni_value,
15763 (void *)&cmd_set_nvgre_ip_src,
15764 (void *)&cmd_set_nvgre_ip_src_value,
15765 (void *)&cmd_set_nvgre_ip_dst,
15766 (void *)&cmd_set_nvgre_ip_dst_value,
15767 (void *)&cmd_set_nvgre_eth_src,
15768 (void *)&cmd_set_nvgre_eth_src_value,
15769 (void *)&cmd_set_nvgre_eth_dst,
15770 (void *)&cmd_set_nvgre_eth_dst_value,
15775 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15776 .f = cmd_set_nvgre_parsed,
15778 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15779 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15780 " eth-src <eth-src> eth-dst <eth-dst>",
15782 (void *)&cmd_set_nvgre_set,
15783 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15784 (void *)&cmd_set_nvgre_ip_version,
15785 (void *)&cmd_set_nvgre_ip_version_value,
15786 (void *)&cmd_set_nvgre_tni,
15787 (void *)&cmd_set_nvgre_tni_value,
15788 (void *)&cmd_set_nvgre_ip_src,
15789 (void *)&cmd_set_nvgre_ip_src_value,
15790 (void *)&cmd_set_nvgre_ip_dst,
15791 (void *)&cmd_set_nvgre_ip_dst_value,
15792 (void *)&cmd_set_nvgre_vlan,
15793 (void *)&cmd_set_nvgre_vlan_value,
15794 (void *)&cmd_set_nvgre_eth_src,
15795 (void *)&cmd_set_nvgre_eth_src_value,
15796 (void *)&cmd_set_nvgre_eth_dst,
15797 (void *)&cmd_set_nvgre_eth_dst_value,
15802 /** Set L2 encapsulation details */
15803 struct cmd_set_l2_encap_result {
15804 cmdline_fixed_string_t set;
15805 cmdline_fixed_string_t l2_encap;
15806 cmdline_fixed_string_t pos_token;
15807 cmdline_fixed_string_t ip_version;
15808 uint32_t vlan_present:1;
15810 struct rte_ether_addr eth_src;
15811 struct rte_ether_addr eth_dst;
15814 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15815 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15816 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15817 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15818 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15819 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15820 "l2_encap-with-vlan");
15821 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15822 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15824 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15825 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15827 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15828 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15830 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15831 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15832 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15833 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15835 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15836 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15837 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15838 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15840 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15841 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15843 static void cmd_set_l2_encap_parsed(void *parsed_result,
15844 __rte_unused struct cmdline *cl,
15845 __rte_unused void *data)
15847 struct cmd_set_l2_encap_result *res = parsed_result;
15849 if (strcmp(res->l2_encap, "l2_encap") == 0)
15850 l2_encap_conf.select_vlan = 0;
15851 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15852 l2_encap_conf.select_vlan = 1;
15853 if (strcmp(res->ip_version, "ipv4") == 0)
15854 l2_encap_conf.select_ipv4 = 1;
15855 else if (strcmp(res->ip_version, "ipv6") == 0)
15856 l2_encap_conf.select_ipv4 = 0;
15859 if (l2_encap_conf.select_vlan)
15860 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15861 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15862 RTE_ETHER_ADDR_LEN);
15863 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15864 RTE_ETHER_ADDR_LEN);
15867 cmdline_parse_inst_t cmd_set_l2_encap = {
15868 .f = cmd_set_l2_encap_parsed,
15870 .help_str = "set l2_encap ip-version ipv4|ipv6"
15871 " eth-src <eth-src> eth-dst <eth-dst>",
15873 (void *)&cmd_set_l2_encap_set,
15874 (void *)&cmd_set_l2_encap_l2_encap,
15875 (void *)&cmd_set_l2_encap_ip_version,
15876 (void *)&cmd_set_l2_encap_ip_version_value,
15877 (void *)&cmd_set_l2_encap_eth_src,
15878 (void *)&cmd_set_l2_encap_eth_src_value,
15879 (void *)&cmd_set_l2_encap_eth_dst,
15880 (void *)&cmd_set_l2_encap_eth_dst_value,
15885 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15886 .f = cmd_set_l2_encap_parsed,
15888 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15889 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15891 (void *)&cmd_set_l2_encap_set,
15892 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15893 (void *)&cmd_set_l2_encap_ip_version,
15894 (void *)&cmd_set_l2_encap_ip_version_value,
15895 (void *)&cmd_set_l2_encap_vlan,
15896 (void *)&cmd_set_l2_encap_vlan_value,
15897 (void *)&cmd_set_l2_encap_eth_src,
15898 (void *)&cmd_set_l2_encap_eth_src_value,
15899 (void *)&cmd_set_l2_encap_eth_dst,
15900 (void *)&cmd_set_l2_encap_eth_dst_value,
15905 /** Set L2 decapsulation details */
15906 struct cmd_set_l2_decap_result {
15907 cmdline_fixed_string_t set;
15908 cmdline_fixed_string_t l2_decap;
15909 cmdline_fixed_string_t pos_token;
15910 uint32_t vlan_present:1;
15913 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15914 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15915 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15916 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15918 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15919 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15920 "l2_decap-with-vlan");
15922 static void cmd_set_l2_decap_parsed(void *parsed_result,
15923 __rte_unused struct cmdline *cl,
15924 __rte_unused void *data)
15926 struct cmd_set_l2_decap_result *res = parsed_result;
15928 if (strcmp(res->l2_decap, "l2_decap") == 0)
15929 l2_decap_conf.select_vlan = 0;
15930 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15931 l2_decap_conf.select_vlan = 1;
15934 cmdline_parse_inst_t cmd_set_l2_decap = {
15935 .f = cmd_set_l2_decap_parsed,
15937 .help_str = "set l2_decap",
15939 (void *)&cmd_set_l2_decap_set,
15940 (void *)&cmd_set_l2_decap_l2_decap,
15945 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15946 .f = cmd_set_l2_decap_parsed,
15948 .help_str = "set l2_decap-with-vlan",
15950 (void *)&cmd_set_l2_decap_set,
15951 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15956 /** Set MPLSoGRE encapsulation details */
15957 struct cmd_set_mplsogre_encap_result {
15958 cmdline_fixed_string_t set;
15959 cmdline_fixed_string_t mplsogre;
15960 cmdline_fixed_string_t pos_token;
15961 cmdline_fixed_string_t ip_version;
15962 uint32_t vlan_present:1;
15964 cmdline_ipaddr_t ip_src;
15965 cmdline_ipaddr_t ip_dst;
15967 struct rte_ether_addr eth_src;
15968 struct rte_ether_addr eth_dst;
15971 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15972 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15974 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15975 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15977 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15978 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15979 mplsogre, "mplsogre_encap-with-vlan");
15980 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15981 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15982 pos_token, "ip-version");
15983 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15984 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15985 ip_version, "ipv4#ipv6");
15986 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15987 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15988 pos_token, "label");
15989 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15990 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15992 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15993 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15994 pos_token, "ip-src");
15995 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15996 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15997 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15998 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15999 pos_token, "ip-dst");
16000 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16001 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16002 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16003 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16004 pos_token, "vlan-tci");
16005 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16006 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16008 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16009 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16010 pos_token, "eth-src");
16011 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16012 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16014 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16015 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16016 pos_token, "eth-dst");
16017 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16018 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16021 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16022 __rte_unused struct cmdline *cl,
16023 __rte_unused void *data)
16025 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16027 uint32_t mplsogre_label;
16030 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16033 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16034 mplsogre_encap_conf.select_vlan = 0;
16035 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16036 mplsogre_encap_conf.select_vlan = 1;
16037 if (strcmp(res->ip_version, "ipv4") == 0)
16038 mplsogre_encap_conf.select_ipv4 = 1;
16039 else if (strcmp(res->ip_version, "ipv6") == 0)
16040 mplsogre_encap_conf.select_ipv4 = 0;
16043 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16044 if (mplsogre_encap_conf.select_ipv4) {
16045 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16046 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16048 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16049 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16051 if (mplsogre_encap_conf.select_vlan)
16052 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16053 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16054 RTE_ETHER_ADDR_LEN);
16055 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16056 RTE_ETHER_ADDR_LEN);
16059 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16060 .f = cmd_set_mplsogre_encap_parsed,
16062 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16063 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16064 " eth-dst <eth-dst>",
16066 (void *)&cmd_set_mplsogre_encap_set,
16067 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16068 (void *)&cmd_set_mplsogre_encap_ip_version,
16069 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16070 (void *)&cmd_set_mplsogre_encap_label,
16071 (void *)&cmd_set_mplsogre_encap_label_value,
16072 (void *)&cmd_set_mplsogre_encap_ip_src,
16073 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16074 (void *)&cmd_set_mplsogre_encap_ip_dst,
16075 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16076 (void *)&cmd_set_mplsogre_encap_eth_src,
16077 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16078 (void *)&cmd_set_mplsogre_encap_eth_dst,
16079 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16084 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16085 .f = cmd_set_mplsogre_encap_parsed,
16087 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16088 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16089 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16091 (void *)&cmd_set_mplsogre_encap_set,
16092 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16093 (void *)&cmd_set_mplsogre_encap_ip_version,
16094 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16095 (void *)&cmd_set_mplsogre_encap_label,
16096 (void *)&cmd_set_mplsogre_encap_label_value,
16097 (void *)&cmd_set_mplsogre_encap_ip_src,
16098 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16099 (void *)&cmd_set_mplsogre_encap_ip_dst,
16100 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16101 (void *)&cmd_set_mplsogre_encap_vlan,
16102 (void *)&cmd_set_mplsogre_encap_vlan_value,
16103 (void *)&cmd_set_mplsogre_encap_eth_src,
16104 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16105 (void *)&cmd_set_mplsogre_encap_eth_dst,
16106 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16111 /** Set MPLSoGRE decapsulation details */
16112 struct cmd_set_mplsogre_decap_result {
16113 cmdline_fixed_string_t set;
16114 cmdline_fixed_string_t mplsogre;
16115 cmdline_fixed_string_t pos_token;
16116 cmdline_fixed_string_t ip_version;
16117 uint32_t vlan_present:1;
16120 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16121 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16123 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16124 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16126 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16127 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16128 mplsogre, "mplsogre_decap-with-vlan");
16129 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16130 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16131 pos_token, "ip-version");
16132 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16133 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16134 ip_version, "ipv4#ipv6");
16136 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16137 __rte_unused struct cmdline *cl,
16138 __rte_unused void *data)
16140 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16142 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16143 mplsogre_decap_conf.select_vlan = 0;
16144 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16145 mplsogre_decap_conf.select_vlan = 1;
16146 if (strcmp(res->ip_version, "ipv4") == 0)
16147 mplsogre_decap_conf.select_ipv4 = 1;
16148 else if (strcmp(res->ip_version, "ipv6") == 0)
16149 mplsogre_decap_conf.select_ipv4 = 0;
16152 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16153 .f = cmd_set_mplsogre_decap_parsed,
16155 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16157 (void *)&cmd_set_mplsogre_decap_set,
16158 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16159 (void *)&cmd_set_mplsogre_decap_ip_version,
16160 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16165 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16166 .f = cmd_set_mplsogre_decap_parsed,
16168 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16170 (void *)&cmd_set_mplsogre_decap_set,
16171 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16172 (void *)&cmd_set_mplsogre_decap_ip_version,
16173 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16178 /** Set MPLSoUDP encapsulation details */
16179 struct cmd_set_mplsoudp_encap_result {
16180 cmdline_fixed_string_t set;
16181 cmdline_fixed_string_t mplsoudp;
16182 cmdline_fixed_string_t pos_token;
16183 cmdline_fixed_string_t ip_version;
16184 uint32_t vlan_present:1;
16188 cmdline_ipaddr_t ip_src;
16189 cmdline_ipaddr_t ip_dst;
16191 struct rte_ether_addr eth_src;
16192 struct rte_ether_addr eth_dst;
16195 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16196 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16198 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16199 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16201 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16202 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16203 mplsoudp, "mplsoudp_encap-with-vlan");
16204 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16205 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16206 pos_token, "ip-version");
16207 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16208 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16209 ip_version, "ipv4#ipv6");
16210 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16211 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16212 pos_token, "label");
16213 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16214 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16216 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16217 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16218 pos_token, "udp-src");
16219 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16220 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16222 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16223 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16224 pos_token, "udp-dst");
16225 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16226 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16228 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16229 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16230 pos_token, "ip-src");
16231 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16232 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16233 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16234 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16235 pos_token, "ip-dst");
16236 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16237 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16238 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16239 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16240 pos_token, "vlan-tci");
16241 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16242 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16244 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16245 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16246 pos_token, "eth-src");
16247 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16248 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16250 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16251 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16252 pos_token, "eth-dst");
16253 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16254 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16257 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16258 __rte_unused struct cmdline *cl,
16259 __rte_unused void *data)
16261 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16263 uint32_t mplsoudp_label;
16266 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16269 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16270 mplsoudp_encap_conf.select_vlan = 0;
16271 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16272 mplsoudp_encap_conf.select_vlan = 1;
16273 if (strcmp(res->ip_version, "ipv4") == 0)
16274 mplsoudp_encap_conf.select_ipv4 = 1;
16275 else if (strcmp(res->ip_version, "ipv6") == 0)
16276 mplsoudp_encap_conf.select_ipv4 = 0;
16279 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16280 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16281 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16282 if (mplsoudp_encap_conf.select_ipv4) {
16283 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16284 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16286 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16287 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16289 if (mplsoudp_encap_conf.select_vlan)
16290 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16291 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16292 RTE_ETHER_ADDR_LEN);
16293 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16294 RTE_ETHER_ADDR_LEN);
16297 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16298 .f = cmd_set_mplsoudp_encap_parsed,
16300 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16301 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16302 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16304 (void *)&cmd_set_mplsoudp_encap_set,
16305 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16306 (void *)&cmd_set_mplsoudp_encap_ip_version,
16307 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16308 (void *)&cmd_set_mplsoudp_encap_label,
16309 (void *)&cmd_set_mplsoudp_encap_label_value,
16310 (void *)&cmd_set_mplsoudp_encap_udp_src,
16311 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16312 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16313 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16314 (void *)&cmd_set_mplsoudp_encap_ip_src,
16315 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16316 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16317 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16318 (void *)&cmd_set_mplsoudp_encap_eth_src,
16319 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16320 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16321 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16326 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16327 .f = cmd_set_mplsoudp_encap_parsed,
16329 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16330 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16331 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16332 " eth-src <eth-src> eth-dst <eth-dst>",
16334 (void *)&cmd_set_mplsoudp_encap_set,
16335 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16336 (void *)&cmd_set_mplsoudp_encap_ip_version,
16337 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16338 (void *)&cmd_set_mplsoudp_encap_label,
16339 (void *)&cmd_set_mplsoudp_encap_label_value,
16340 (void *)&cmd_set_mplsoudp_encap_udp_src,
16341 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16342 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16343 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16344 (void *)&cmd_set_mplsoudp_encap_ip_src,
16345 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16346 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16347 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16348 (void *)&cmd_set_mplsoudp_encap_vlan,
16349 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16350 (void *)&cmd_set_mplsoudp_encap_eth_src,
16351 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16352 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16353 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16358 /** Set MPLSoUDP decapsulation details */
16359 struct cmd_set_mplsoudp_decap_result {
16360 cmdline_fixed_string_t set;
16361 cmdline_fixed_string_t mplsoudp;
16362 cmdline_fixed_string_t pos_token;
16363 cmdline_fixed_string_t ip_version;
16364 uint32_t vlan_present:1;
16367 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16368 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16370 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16371 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16373 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16374 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16375 mplsoudp, "mplsoudp_decap-with-vlan");
16376 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16377 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16378 pos_token, "ip-version");
16379 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16380 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16381 ip_version, "ipv4#ipv6");
16383 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16384 __rte_unused struct cmdline *cl,
16385 __rte_unused void *data)
16387 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16389 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16390 mplsoudp_decap_conf.select_vlan = 0;
16391 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16392 mplsoudp_decap_conf.select_vlan = 1;
16393 if (strcmp(res->ip_version, "ipv4") == 0)
16394 mplsoudp_decap_conf.select_ipv4 = 1;
16395 else if (strcmp(res->ip_version, "ipv6") == 0)
16396 mplsoudp_decap_conf.select_ipv4 = 0;
16399 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16400 .f = cmd_set_mplsoudp_decap_parsed,
16402 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16404 (void *)&cmd_set_mplsoudp_decap_set,
16405 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16406 (void *)&cmd_set_mplsoudp_decap_ip_version,
16407 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16412 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16413 .f = cmd_set_mplsoudp_decap_parsed,
16415 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16417 (void *)&cmd_set_mplsoudp_decap_set,
16418 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16419 (void *)&cmd_set_mplsoudp_decap_ip_version,
16420 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16425 /* Strict link priority scheduling mode setting */
16427 cmd_strict_link_prio_parsed(
16428 void *parsed_result,
16429 __rte_unused struct cmdline *cl,
16430 __rte_unused void *data)
16432 struct cmd_vf_tc_bw_result *res = parsed_result;
16433 int ret = -ENOTSUP;
16435 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16438 #ifdef RTE_LIBRTE_I40E_PMD
16439 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16446 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16449 printf("invalid port_id %d\n", res->port_id);
16452 printf("function not implemented\n");
16455 printf("programming error: (%s)\n", strerror(-ret));
16459 cmdline_parse_inst_t cmd_strict_link_prio = {
16460 .f = cmd_strict_link_prio_parsed,
16462 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16464 (void *)&cmd_vf_tc_bw_set,
16465 (void *)&cmd_vf_tc_bw_tx,
16466 (void *)&cmd_vf_tc_bw_strict_link_prio,
16467 (void *)&cmd_vf_tc_bw_port_id,
16468 (void *)&cmd_vf_tc_bw_tc_map,
16473 /* Load dynamic device personalization*/
16474 struct cmd_ddp_add_result {
16475 cmdline_fixed_string_t ddp;
16476 cmdline_fixed_string_t add;
16481 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16482 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16483 cmdline_parse_token_string_t cmd_ddp_add_add =
16484 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16485 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16486 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16487 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16488 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16491 cmd_ddp_add_parsed(
16492 void *parsed_result,
16493 __rte_unused struct cmdline *cl,
16494 __rte_unused void *data)
16496 struct cmd_ddp_add_result *res = parsed_result;
16502 int ret = -ENOTSUP;
16504 if (!all_ports_stopped()) {
16505 printf("Please stop all ports first\n");
16509 filepath = strdup(res->filepath);
16510 if (filepath == NULL) {
16511 printf("Failed to allocate memory\n");
16514 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16516 buff = open_file(file_fld[0], &size);
16518 free((void *)filepath);
16522 #ifdef RTE_LIBRTE_I40E_PMD
16523 if (ret == -ENOTSUP)
16524 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16526 RTE_PMD_I40E_PKG_OP_WR_ADD);
16529 if (ret == -EEXIST)
16530 printf("Profile has already existed.\n");
16532 printf("Failed to load profile.\n");
16533 else if (file_num == 2)
16534 save_file(file_fld[1], buff, size);
16537 free((void *)filepath);
16540 cmdline_parse_inst_t cmd_ddp_add = {
16541 .f = cmd_ddp_add_parsed,
16543 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16545 (void *)&cmd_ddp_add_ddp,
16546 (void *)&cmd_ddp_add_add,
16547 (void *)&cmd_ddp_add_port_id,
16548 (void *)&cmd_ddp_add_filepath,
16553 /* Delete dynamic device personalization*/
16554 struct cmd_ddp_del_result {
16555 cmdline_fixed_string_t ddp;
16556 cmdline_fixed_string_t del;
16561 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16562 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16563 cmdline_parse_token_string_t cmd_ddp_del_del =
16564 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16565 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16566 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16567 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16568 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16571 cmd_ddp_del_parsed(
16572 void *parsed_result,
16573 __rte_unused struct cmdline *cl,
16574 __rte_unused void *data)
16576 struct cmd_ddp_del_result *res = parsed_result;
16579 int ret = -ENOTSUP;
16581 if (!all_ports_stopped()) {
16582 printf("Please stop all ports first\n");
16586 buff = open_file(res->filepath, &size);
16590 #ifdef RTE_LIBRTE_I40E_PMD
16591 if (ret == -ENOTSUP)
16592 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16594 RTE_PMD_I40E_PKG_OP_WR_DEL);
16597 if (ret == -EACCES)
16598 printf("Profile does not exist.\n");
16600 printf("Failed to delete profile.\n");
16605 cmdline_parse_inst_t cmd_ddp_del = {
16606 .f = cmd_ddp_del_parsed,
16608 .help_str = "ddp del <port_id> <backup_profile_path>",
16610 (void *)&cmd_ddp_del_ddp,
16611 (void *)&cmd_ddp_del_del,
16612 (void *)&cmd_ddp_del_port_id,
16613 (void *)&cmd_ddp_del_filepath,
16618 /* Get dynamic device personalization profile info */
16619 struct cmd_ddp_info_result {
16620 cmdline_fixed_string_t ddp;
16621 cmdline_fixed_string_t get;
16622 cmdline_fixed_string_t info;
16626 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16627 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16628 cmdline_parse_token_string_t cmd_ddp_info_get =
16629 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16630 cmdline_parse_token_string_t cmd_ddp_info_info =
16631 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16632 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16633 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16636 cmd_ddp_info_parsed(
16637 void *parsed_result,
16638 __rte_unused struct cmdline *cl,
16639 __rte_unused void *data)
16641 struct cmd_ddp_info_result *res = parsed_result;
16644 int ret = -ENOTSUP;
16645 #ifdef RTE_LIBRTE_I40E_PMD
16648 uint32_t buff_size = 0;
16649 struct rte_pmd_i40e_profile_info info;
16650 uint32_t dev_num = 0;
16651 struct rte_pmd_i40e_ddp_device_id *devs;
16652 uint32_t proto_num = 0;
16653 struct rte_pmd_i40e_proto_info *proto = NULL;
16654 uint32_t pctype_num = 0;
16655 struct rte_pmd_i40e_ptype_info *pctype;
16656 uint32_t ptype_num = 0;
16657 struct rte_pmd_i40e_ptype_info *ptype;
16662 pkg = open_file(res->filepath, &pkg_size);
16666 #ifdef RTE_LIBRTE_I40E_PMD
16667 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16668 (uint8_t *)&info, sizeof(info),
16669 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16671 printf("Global Track id: 0x%x\n", info.track_id);
16672 printf("Global Version: %d.%d.%d.%d\n",
16673 info.version.major,
16674 info.version.minor,
16675 info.version.update,
16676 info.version.draft);
16677 printf("Global Package name: %s\n\n", info.name);
16680 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16681 (uint8_t *)&info, sizeof(info),
16682 RTE_PMD_I40E_PKG_INFO_HEADER);
16684 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16685 printf("i40e Profile Version: %d.%d.%d.%d\n",
16686 info.version.major,
16687 info.version.minor,
16688 info.version.update,
16689 info.version.draft);
16690 printf("i40e Profile name: %s\n\n", info.name);
16693 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16694 (uint8_t *)&buff_size, sizeof(buff_size),
16695 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16696 if (!ret && buff_size) {
16697 buff = (uint8_t *)malloc(buff_size);
16699 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16701 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16703 printf("Package Notes:\n%s\n\n", buff);
16708 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16709 (uint8_t *)&dev_num, sizeof(dev_num),
16710 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16711 if (!ret && dev_num) {
16712 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16713 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16715 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16716 (uint8_t *)devs, buff_size,
16717 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16719 printf("List of supported devices:\n");
16720 for (i = 0; i < dev_num; i++) {
16721 printf(" %04X:%04X %04X:%04X\n",
16722 devs[i].vendor_dev_id >> 16,
16723 devs[i].vendor_dev_id & 0xFFFF,
16724 devs[i].sub_vendor_dev_id >> 16,
16725 devs[i].sub_vendor_dev_id & 0xFFFF);
16733 /* get information about protocols and packet types */
16734 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16735 (uint8_t *)&proto_num, sizeof(proto_num),
16736 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16737 if (ret || !proto_num)
16738 goto no_print_return;
16740 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16741 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16743 goto no_print_return;
16745 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16747 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16749 printf("List of used protocols:\n");
16750 for (i = 0; i < proto_num; i++)
16751 printf(" %2u: %s\n", proto[i].proto_id,
16755 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16756 (uint8_t *)&pctype_num, sizeof(pctype_num),
16757 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16758 if (ret || !pctype_num)
16759 goto no_print_pctypes;
16761 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16762 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16764 goto no_print_pctypes;
16766 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16768 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16771 goto no_print_pctypes;
16774 printf("List of defined packet classification types:\n");
16775 for (i = 0; i < pctype_num; i++) {
16776 printf(" %2u:", pctype[i].ptype_id);
16777 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16778 proto_id = pctype[i].protocols[j];
16779 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16780 for (n = 0; n < proto_num; n++) {
16781 if (proto[n].proto_id == proto_id) {
16782 printf(" %s", proto[n].name);
16795 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16797 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16798 if (ret || !ptype_num)
16799 goto no_print_return;
16801 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16802 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16804 goto no_print_return;
16806 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16808 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16811 goto no_print_return;
16813 printf("List of defined packet types:\n");
16814 for (i = 0; i < ptype_num; i++) {
16815 printf(" %2u:", ptype[i].ptype_id);
16816 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16817 proto_id = ptype[i].protocols[j];
16818 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16819 for (n = 0; n < proto_num; n++) {
16820 if (proto[n].proto_id == proto_id) {
16821 printf(" %s", proto[n].name);
16837 if (ret == -ENOTSUP)
16838 printf("Function not supported in PMD driver\n");
16842 cmdline_parse_inst_t cmd_ddp_get_info = {
16843 .f = cmd_ddp_info_parsed,
16845 .help_str = "ddp get info <profile_path>",
16847 (void *)&cmd_ddp_info_ddp,
16848 (void *)&cmd_ddp_info_get,
16849 (void *)&cmd_ddp_info_info,
16850 (void *)&cmd_ddp_info_filepath,
16855 /* Get dynamic device personalization profile info list*/
16856 #define PROFILE_INFO_SIZE 48
16857 #define MAX_PROFILE_NUM 16
16859 struct cmd_ddp_get_list_result {
16860 cmdline_fixed_string_t ddp;
16861 cmdline_fixed_string_t get;
16862 cmdline_fixed_string_t list;
16866 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16867 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16868 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16869 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16870 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16871 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16872 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16873 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16876 cmd_ddp_get_list_parsed(
16877 __rte_unused void *parsed_result,
16878 __rte_unused struct cmdline *cl,
16879 __rte_unused void *data)
16881 #ifdef RTE_LIBRTE_I40E_PMD
16882 struct cmd_ddp_get_list_result *res = parsed_result;
16883 struct rte_pmd_i40e_profile_list *p_list;
16884 struct rte_pmd_i40e_profile_info *p_info;
16889 int ret = -ENOTSUP;
16891 #ifdef RTE_LIBRTE_I40E_PMD
16892 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16893 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16895 printf("%s: Failed to malloc buffer\n", __func__);
16899 if (ret == -ENOTSUP)
16900 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16901 (uint8_t *)p_list, size);
16904 p_num = p_list->p_count;
16905 printf("Profile number is: %d\n\n", p_num);
16907 for (i = 0; i < p_num; i++) {
16908 p_info = &p_list->p_info[i];
16909 printf("Profile %d:\n", i);
16910 printf("Track id: 0x%x\n", p_info->track_id);
16911 printf("Version: %d.%d.%d.%d\n",
16912 p_info->version.major,
16913 p_info->version.minor,
16914 p_info->version.update,
16915 p_info->version.draft);
16916 printf("Profile name: %s\n\n", p_info->name);
16924 printf("Failed to get ddp list\n");
16927 cmdline_parse_inst_t cmd_ddp_get_list = {
16928 .f = cmd_ddp_get_list_parsed,
16930 .help_str = "ddp get list <port_id>",
16932 (void *)&cmd_ddp_get_list_ddp,
16933 (void *)&cmd_ddp_get_list_get,
16934 (void *)&cmd_ddp_get_list_list,
16935 (void *)&cmd_ddp_get_list_port_id,
16940 /* Configure input set */
16941 struct cmd_cfg_input_set_result {
16942 cmdline_fixed_string_t port;
16943 cmdline_fixed_string_t cfg;
16945 cmdline_fixed_string_t pctype;
16947 cmdline_fixed_string_t inset_type;
16948 cmdline_fixed_string_t opt;
16949 cmdline_fixed_string_t field;
16954 cmd_cfg_input_set_parsed(
16955 __rte_unused void *parsed_result,
16956 __rte_unused struct cmdline *cl,
16957 __rte_unused void *data)
16959 #ifdef RTE_LIBRTE_I40E_PMD
16960 struct cmd_cfg_input_set_result *res = parsed_result;
16961 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16962 struct rte_pmd_i40e_inset inset;
16964 int ret = -ENOTSUP;
16966 if (!all_ports_stopped()) {
16967 printf("Please stop all ports first\n");
16971 #ifdef RTE_LIBRTE_I40E_PMD
16972 if (!strcmp(res->inset_type, "hash_inset"))
16973 inset_type = INSET_HASH;
16974 else if (!strcmp(res->inset_type, "fdir_inset"))
16975 inset_type = INSET_FDIR;
16976 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16977 inset_type = INSET_FDIR_FLX;
16978 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16979 &inset, inset_type);
16981 printf("Failed to get input set.\n");
16985 if (!strcmp(res->opt, "get")) {
16986 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16989 printf("Field index %d is enabled.\n", res->field_idx);
16991 printf("Field index %d is disabled.\n", res->field_idx);
16993 } else if (!strcmp(res->opt, "set"))
16994 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16996 else if (!strcmp(res->opt, "clear"))
16997 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17000 printf("Failed to configure input set field.\n");
17004 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17005 &inset, inset_type);
17007 printf("Failed to set input set.\n");
17012 if (ret == -ENOTSUP)
17013 printf("Function not supported\n");
17016 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17017 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17019 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17020 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17022 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17023 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17025 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17026 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17028 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17029 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17031 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17032 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17034 "hash_inset#fdir_inset#fdir_flx_inset");
17035 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17036 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17037 opt, "get#set#clear");
17038 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17039 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17041 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17042 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17045 cmdline_parse_inst_t cmd_cfg_input_set = {
17046 .f = cmd_cfg_input_set_parsed,
17048 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17049 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17051 (void *)&cmd_cfg_input_set_port,
17052 (void *)&cmd_cfg_input_set_cfg,
17053 (void *)&cmd_cfg_input_set_port_id,
17054 (void *)&cmd_cfg_input_set_pctype,
17055 (void *)&cmd_cfg_input_set_pctype_id,
17056 (void *)&cmd_cfg_input_set_inset_type,
17057 (void *)&cmd_cfg_input_set_opt,
17058 (void *)&cmd_cfg_input_set_field,
17059 (void *)&cmd_cfg_input_set_field_idx,
17064 /* Clear input set */
17065 struct cmd_clear_input_set_result {
17066 cmdline_fixed_string_t port;
17067 cmdline_fixed_string_t cfg;
17069 cmdline_fixed_string_t pctype;
17071 cmdline_fixed_string_t inset_type;
17072 cmdline_fixed_string_t clear;
17073 cmdline_fixed_string_t all;
17077 cmd_clear_input_set_parsed(
17078 __rte_unused void *parsed_result,
17079 __rte_unused struct cmdline *cl,
17080 __rte_unused void *data)
17082 #ifdef RTE_LIBRTE_I40E_PMD
17083 struct cmd_clear_input_set_result *res = parsed_result;
17084 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17085 struct rte_pmd_i40e_inset inset;
17087 int ret = -ENOTSUP;
17089 if (!all_ports_stopped()) {
17090 printf("Please stop all ports first\n");
17094 #ifdef RTE_LIBRTE_I40E_PMD
17095 if (!strcmp(res->inset_type, "hash_inset"))
17096 inset_type = INSET_HASH;
17097 else if (!strcmp(res->inset_type, "fdir_inset"))
17098 inset_type = INSET_FDIR;
17099 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17100 inset_type = INSET_FDIR_FLX;
17102 memset(&inset, 0, sizeof(inset));
17104 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17105 &inset, inset_type);
17107 printf("Failed to clear input set.\n");
17113 if (ret == -ENOTSUP)
17114 printf("Function not supported\n");
17117 cmdline_parse_token_string_t cmd_clear_input_set_port =
17118 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17120 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17121 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17123 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17124 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17126 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17127 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17129 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17130 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17132 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17133 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17135 "hash_inset#fdir_inset#fdir_flx_inset");
17136 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17137 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17139 cmdline_parse_token_string_t cmd_clear_input_set_all =
17140 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17143 cmdline_parse_inst_t cmd_clear_input_set = {
17144 .f = cmd_clear_input_set_parsed,
17146 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17147 "fdir_inset|fdir_flx_inset clear all",
17149 (void *)&cmd_clear_input_set_port,
17150 (void *)&cmd_clear_input_set_cfg,
17151 (void *)&cmd_clear_input_set_port_id,
17152 (void *)&cmd_clear_input_set_pctype,
17153 (void *)&cmd_clear_input_set_pctype_id,
17154 (void *)&cmd_clear_input_set_inset_type,
17155 (void *)&cmd_clear_input_set_clear,
17156 (void *)&cmd_clear_input_set_all,
17161 /* show vf stats */
17163 /* Common result structure for show vf stats */
17164 struct cmd_show_vf_stats_result {
17165 cmdline_fixed_string_t show;
17166 cmdline_fixed_string_t vf;
17167 cmdline_fixed_string_t stats;
17172 /* Common CLI fields show vf stats*/
17173 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17174 TOKEN_STRING_INITIALIZER
17175 (struct cmd_show_vf_stats_result,
17177 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17178 TOKEN_STRING_INITIALIZER
17179 (struct cmd_show_vf_stats_result,
17181 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17182 TOKEN_STRING_INITIALIZER
17183 (struct cmd_show_vf_stats_result,
17185 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17186 TOKEN_NUM_INITIALIZER
17187 (struct cmd_show_vf_stats_result,
17189 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17190 TOKEN_NUM_INITIALIZER
17191 (struct cmd_show_vf_stats_result,
17195 cmd_show_vf_stats_parsed(
17196 void *parsed_result,
17197 __rte_unused struct cmdline *cl,
17198 __rte_unused void *data)
17200 struct cmd_show_vf_stats_result *res = parsed_result;
17201 struct rte_eth_stats stats;
17202 int ret = -ENOTSUP;
17203 static const char *nic_stats_border = "########################";
17205 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17208 memset(&stats, 0, sizeof(stats));
17210 #ifdef RTE_LIBRTE_I40E_PMD
17211 if (ret == -ENOTSUP)
17212 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17216 #ifdef RTE_LIBRTE_BNXT_PMD
17217 if (ret == -ENOTSUP)
17218 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17227 printf("invalid vf_id %d\n", res->vf_id);
17230 printf("invalid port_id %d\n", res->port_id);
17233 printf("function not implemented\n");
17236 printf("programming error: (%s)\n", strerror(-ret));
17239 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17240 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17242 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17244 stats.ipackets, stats.imissed, stats.ibytes);
17245 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17246 printf(" RX-nombuf: %-10"PRIu64"\n",
17248 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17250 stats.opackets, stats.oerrors, stats.obytes);
17252 printf(" %s############################%s\n",
17253 nic_stats_border, nic_stats_border);
17256 cmdline_parse_inst_t cmd_show_vf_stats = {
17257 .f = cmd_show_vf_stats_parsed,
17259 .help_str = "show vf stats <port_id> <vf_id>",
17261 (void *)&cmd_show_vf_stats_show,
17262 (void *)&cmd_show_vf_stats_vf,
17263 (void *)&cmd_show_vf_stats_stats,
17264 (void *)&cmd_show_vf_stats_port_id,
17265 (void *)&cmd_show_vf_stats_vf_id,
17270 /* clear vf stats */
17272 /* Common result structure for clear vf stats */
17273 struct cmd_clear_vf_stats_result {
17274 cmdline_fixed_string_t clear;
17275 cmdline_fixed_string_t vf;
17276 cmdline_fixed_string_t stats;
17281 /* Common CLI fields clear vf stats*/
17282 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17283 TOKEN_STRING_INITIALIZER
17284 (struct cmd_clear_vf_stats_result,
17286 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17287 TOKEN_STRING_INITIALIZER
17288 (struct cmd_clear_vf_stats_result,
17290 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17291 TOKEN_STRING_INITIALIZER
17292 (struct cmd_clear_vf_stats_result,
17294 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17295 TOKEN_NUM_INITIALIZER
17296 (struct cmd_clear_vf_stats_result,
17298 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17299 TOKEN_NUM_INITIALIZER
17300 (struct cmd_clear_vf_stats_result,
17304 cmd_clear_vf_stats_parsed(
17305 void *parsed_result,
17306 __rte_unused struct cmdline *cl,
17307 __rte_unused void *data)
17309 struct cmd_clear_vf_stats_result *res = parsed_result;
17310 int ret = -ENOTSUP;
17312 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17315 #ifdef RTE_LIBRTE_I40E_PMD
17316 if (ret == -ENOTSUP)
17317 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17320 #ifdef RTE_LIBRTE_BNXT_PMD
17321 if (ret == -ENOTSUP)
17322 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17330 printf("invalid vf_id %d\n", res->vf_id);
17333 printf("invalid port_id %d\n", res->port_id);
17336 printf("function not implemented\n");
17339 printf("programming error: (%s)\n", strerror(-ret));
17343 cmdline_parse_inst_t cmd_clear_vf_stats = {
17344 .f = cmd_clear_vf_stats_parsed,
17346 .help_str = "clear vf stats <port_id> <vf_id>",
17348 (void *)&cmd_clear_vf_stats_clear,
17349 (void *)&cmd_clear_vf_stats_vf,
17350 (void *)&cmd_clear_vf_stats_stats,
17351 (void *)&cmd_clear_vf_stats_port_id,
17352 (void *)&cmd_clear_vf_stats_vf_id,
17357 /* port config pctype mapping reset */
17359 /* Common result structure for port config pctype mapping reset */
17360 struct cmd_pctype_mapping_reset_result {
17361 cmdline_fixed_string_t port;
17362 cmdline_fixed_string_t config;
17364 cmdline_fixed_string_t pctype;
17365 cmdline_fixed_string_t mapping;
17366 cmdline_fixed_string_t reset;
17369 /* Common CLI fields for port config pctype mapping reset*/
17370 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17371 TOKEN_STRING_INITIALIZER
17372 (struct cmd_pctype_mapping_reset_result,
17374 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17375 TOKEN_STRING_INITIALIZER
17376 (struct cmd_pctype_mapping_reset_result,
17378 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17379 TOKEN_NUM_INITIALIZER
17380 (struct cmd_pctype_mapping_reset_result,
17382 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17383 TOKEN_STRING_INITIALIZER
17384 (struct cmd_pctype_mapping_reset_result,
17386 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17387 TOKEN_STRING_INITIALIZER
17388 (struct cmd_pctype_mapping_reset_result,
17389 mapping, "mapping");
17390 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17391 TOKEN_STRING_INITIALIZER
17392 (struct cmd_pctype_mapping_reset_result,
17396 cmd_pctype_mapping_reset_parsed(
17397 void *parsed_result,
17398 __rte_unused struct cmdline *cl,
17399 __rte_unused void *data)
17401 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17402 int ret = -ENOTSUP;
17404 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17407 #ifdef RTE_LIBRTE_I40E_PMD
17408 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17415 printf("invalid port_id %d\n", res->port_id);
17418 printf("function not implemented\n");
17421 printf("programming error: (%s)\n", strerror(-ret));
17425 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17426 .f = cmd_pctype_mapping_reset_parsed,
17428 .help_str = "port config <port_id> pctype mapping reset",
17430 (void *)&cmd_pctype_mapping_reset_port,
17431 (void *)&cmd_pctype_mapping_reset_config,
17432 (void *)&cmd_pctype_mapping_reset_port_id,
17433 (void *)&cmd_pctype_mapping_reset_pctype,
17434 (void *)&cmd_pctype_mapping_reset_mapping,
17435 (void *)&cmd_pctype_mapping_reset_reset,
17440 /* show port pctype mapping */
17442 /* Common result structure for show port pctype mapping */
17443 struct cmd_pctype_mapping_get_result {
17444 cmdline_fixed_string_t show;
17445 cmdline_fixed_string_t port;
17447 cmdline_fixed_string_t pctype;
17448 cmdline_fixed_string_t mapping;
17451 /* Common CLI fields for pctype mapping get */
17452 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17453 TOKEN_STRING_INITIALIZER
17454 (struct cmd_pctype_mapping_get_result,
17456 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17457 TOKEN_STRING_INITIALIZER
17458 (struct cmd_pctype_mapping_get_result,
17460 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17461 TOKEN_NUM_INITIALIZER
17462 (struct cmd_pctype_mapping_get_result,
17464 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17465 TOKEN_STRING_INITIALIZER
17466 (struct cmd_pctype_mapping_get_result,
17468 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17469 TOKEN_STRING_INITIALIZER
17470 (struct cmd_pctype_mapping_get_result,
17471 mapping, "mapping");
17474 cmd_pctype_mapping_get_parsed(
17475 void *parsed_result,
17476 __rte_unused struct cmdline *cl,
17477 __rte_unused void *data)
17479 struct cmd_pctype_mapping_get_result *res = parsed_result;
17480 int ret = -ENOTSUP;
17481 #ifdef RTE_LIBRTE_I40E_PMD
17482 struct rte_pmd_i40e_flow_type_mapping
17483 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17484 int i, j, first_pctype;
17487 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17490 #ifdef RTE_LIBRTE_I40E_PMD
17491 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17498 printf("invalid port_id %d\n", res->port_id);
17501 printf("function not implemented\n");
17504 printf("programming error: (%s)\n", strerror(-ret));
17508 #ifdef RTE_LIBRTE_I40E_PMD
17509 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17510 if (mapping[i].pctype != 0ULL) {
17513 printf("pctype: ");
17514 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17515 if (mapping[i].pctype & (1ULL << j)) {
17516 printf(first_pctype ?
17517 "%02d" : ",%02d", j);
17521 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17527 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17528 .f = cmd_pctype_mapping_get_parsed,
17530 .help_str = "show port <port_id> pctype mapping",
17532 (void *)&cmd_pctype_mapping_get_show,
17533 (void *)&cmd_pctype_mapping_get_port,
17534 (void *)&cmd_pctype_mapping_get_port_id,
17535 (void *)&cmd_pctype_mapping_get_pctype,
17536 (void *)&cmd_pctype_mapping_get_mapping,
17541 /* port config pctype mapping update */
17543 /* Common result structure for port config pctype mapping update */
17544 struct cmd_pctype_mapping_update_result {
17545 cmdline_fixed_string_t port;
17546 cmdline_fixed_string_t config;
17548 cmdline_fixed_string_t pctype;
17549 cmdline_fixed_string_t mapping;
17550 cmdline_fixed_string_t update;
17551 cmdline_fixed_string_t pctype_list;
17552 uint16_t flow_type;
17555 /* Common CLI fields for pctype mapping update*/
17556 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17557 TOKEN_STRING_INITIALIZER
17558 (struct cmd_pctype_mapping_update_result,
17560 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17561 TOKEN_STRING_INITIALIZER
17562 (struct cmd_pctype_mapping_update_result,
17564 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17565 TOKEN_NUM_INITIALIZER
17566 (struct cmd_pctype_mapping_update_result,
17568 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17569 TOKEN_STRING_INITIALIZER
17570 (struct cmd_pctype_mapping_update_result,
17572 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17573 TOKEN_STRING_INITIALIZER
17574 (struct cmd_pctype_mapping_update_result,
17575 mapping, "mapping");
17576 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17577 TOKEN_STRING_INITIALIZER
17578 (struct cmd_pctype_mapping_update_result,
17580 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17581 TOKEN_STRING_INITIALIZER
17582 (struct cmd_pctype_mapping_update_result,
17583 pctype_list, NULL);
17584 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17585 TOKEN_NUM_INITIALIZER
17586 (struct cmd_pctype_mapping_update_result,
17587 flow_type, UINT16);
17590 cmd_pctype_mapping_update_parsed(
17591 void *parsed_result,
17592 __rte_unused struct cmdline *cl,
17593 __rte_unused void *data)
17595 struct cmd_pctype_mapping_update_result *res = parsed_result;
17596 int ret = -ENOTSUP;
17597 #ifdef RTE_LIBRTE_I40E_PMD
17598 struct rte_pmd_i40e_flow_type_mapping mapping;
17600 unsigned int nb_item;
17601 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17604 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17607 #ifdef RTE_LIBRTE_I40E_PMD
17608 nb_item = parse_item_list(res->pctype_list, "pctypes",
17609 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17610 mapping.flow_type = res->flow_type;
17611 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17612 mapping.pctype |= (1ULL << pctype_list[i]);
17613 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17623 printf("invalid pctype or flow type\n");
17626 printf("invalid port_id %d\n", res->port_id);
17629 printf("function not implemented\n");
17632 printf("programming error: (%s)\n", strerror(-ret));
17636 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17637 .f = cmd_pctype_mapping_update_parsed,
17639 .help_str = "port config <port_id> pctype mapping update"
17640 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17642 (void *)&cmd_pctype_mapping_update_port,
17643 (void *)&cmd_pctype_mapping_update_config,
17644 (void *)&cmd_pctype_mapping_update_port_id,
17645 (void *)&cmd_pctype_mapping_update_pctype,
17646 (void *)&cmd_pctype_mapping_update_mapping,
17647 (void *)&cmd_pctype_mapping_update_update,
17648 (void *)&cmd_pctype_mapping_update_pc_type,
17649 (void *)&cmd_pctype_mapping_update_flow_type,
17654 /* ptype mapping get */
17656 /* Common result structure for ptype mapping get */
17657 struct cmd_ptype_mapping_get_result {
17658 cmdline_fixed_string_t ptype;
17659 cmdline_fixed_string_t mapping;
17660 cmdline_fixed_string_t get;
17662 uint8_t valid_only;
17665 /* Common CLI fields for ptype mapping get */
17666 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17667 TOKEN_STRING_INITIALIZER
17668 (struct cmd_ptype_mapping_get_result,
17670 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17671 TOKEN_STRING_INITIALIZER
17672 (struct cmd_ptype_mapping_get_result,
17673 mapping, "mapping");
17674 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17675 TOKEN_STRING_INITIALIZER
17676 (struct cmd_ptype_mapping_get_result,
17678 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17679 TOKEN_NUM_INITIALIZER
17680 (struct cmd_ptype_mapping_get_result,
17682 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17683 TOKEN_NUM_INITIALIZER
17684 (struct cmd_ptype_mapping_get_result,
17685 valid_only, UINT8);
17688 cmd_ptype_mapping_get_parsed(
17689 void *parsed_result,
17690 __rte_unused struct cmdline *cl,
17691 __rte_unused void *data)
17693 struct cmd_ptype_mapping_get_result *res = parsed_result;
17694 int ret = -ENOTSUP;
17695 #ifdef RTE_LIBRTE_I40E_PMD
17696 int max_ptype_num = 256;
17697 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17702 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17705 #ifdef RTE_LIBRTE_I40E_PMD
17706 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17717 printf("invalid port_id %d\n", res->port_id);
17720 printf("function not implemented\n");
17723 printf("programming error: (%s)\n", strerror(-ret));
17726 #ifdef RTE_LIBRTE_I40E_PMD
17728 for (i = 0; i < count; i++)
17729 printf("%3d\t0x%08x\n",
17730 mapping[i].hw_ptype, mapping[i].sw_ptype);
17735 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17736 .f = cmd_ptype_mapping_get_parsed,
17738 .help_str = "ptype mapping get <port_id> <valid_only>",
17740 (void *)&cmd_ptype_mapping_get_ptype,
17741 (void *)&cmd_ptype_mapping_get_mapping,
17742 (void *)&cmd_ptype_mapping_get_get,
17743 (void *)&cmd_ptype_mapping_get_port_id,
17744 (void *)&cmd_ptype_mapping_get_valid_only,
17749 /* ptype mapping replace */
17751 /* Common result structure for ptype mapping replace */
17752 struct cmd_ptype_mapping_replace_result {
17753 cmdline_fixed_string_t ptype;
17754 cmdline_fixed_string_t mapping;
17755 cmdline_fixed_string_t replace;
17762 /* Common CLI fields for ptype mapping replace */
17763 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17764 TOKEN_STRING_INITIALIZER
17765 (struct cmd_ptype_mapping_replace_result,
17767 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17768 TOKEN_STRING_INITIALIZER
17769 (struct cmd_ptype_mapping_replace_result,
17770 mapping, "mapping");
17771 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17772 TOKEN_STRING_INITIALIZER
17773 (struct cmd_ptype_mapping_replace_result,
17774 replace, "replace");
17775 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17776 TOKEN_NUM_INITIALIZER
17777 (struct cmd_ptype_mapping_replace_result,
17779 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17780 TOKEN_NUM_INITIALIZER
17781 (struct cmd_ptype_mapping_replace_result,
17783 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17784 TOKEN_NUM_INITIALIZER
17785 (struct cmd_ptype_mapping_replace_result,
17787 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17788 TOKEN_NUM_INITIALIZER
17789 (struct cmd_ptype_mapping_replace_result,
17793 cmd_ptype_mapping_replace_parsed(
17794 void *parsed_result,
17795 __rte_unused struct cmdline *cl,
17796 __rte_unused void *data)
17798 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17799 int ret = -ENOTSUP;
17801 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17804 #ifdef RTE_LIBRTE_I40E_PMD
17805 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17815 printf("invalid ptype 0x%8x or 0x%8x\n",
17816 res->target, res->pkt_type);
17819 printf("invalid port_id %d\n", res->port_id);
17822 printf("function not implemented\n");
17825 printf("programming error: (%s)\n", strerror(-ret));
17829 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17830 .f = cmd_ptype_mapping_replace_parsed,
17833 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17835 (void *)&cmd_ptype_mapping_replace_ptype,
17836 (void *)&cmd_ptype_mapping_replace_mapping,
17837 (void *)&cmd_ptype_mapping_replace_replace,
17838 (void *)&cmd_ptype_mapping_replace_port_id,
17839 (void *)&cmd_ptype_mapping_replace_target,
17840 (void *)&cmd_ptype_mapping_replace_mask,
17841 (void *)&cmd_ptype_mapping_replace_pkt_type,
17846 /* ptype mapping reset */
17848 /* Common result structure for ptype mapping reset */
17849 struct cmd_ptype_mapping_reset_result {
17850 cmdline_fixed_string_t ptype;
17851 cmdline_fixed_string_t mapping;
17852 cmdline_fixed_string_t reset;
17856 /* Common CLI fields for ptype mapping reset*/
17857 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17858 TOKEN_STRING_INITIALIZER
17859 (struct cmd_ptype_mapping_reset_result,
17861 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17862 TOKEN_STRING_INITIALIZER
17863 (struct cmd_ptype_mapping_reset_result,
17864 mapping, "mapping");
17865 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17866 TOKEN_STRING_INITIALIZER
17867 (struct cmd_ptype_mapping_reset_result,
17869 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17870 TOKEN_NUM_INITIALIZER
17871 (struct cmd_ptype_mapping_reset_result,
17875 cmd_ptype_mapping_reset_parsed(
17876 void *parsed_result,
17877 __rte_unused struct cmdline *cl,
17878 __rte_unused void *data)
17880 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17881 int ret = -ENOTSUP;
17883 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17886 #ifdef RTE_LIBRTE_I40E_PMD
17887 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17894 printf("invalid port_id %d\n", res->port_id);
17897 printf("function not implemented\n");
17900 printf("programming error: (%s)\n", strerror(-ret));
17904 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17905 .f = cmd_ptype_mapping_reset_parsed,
17907 .help_str = "ptype mapping reset <port_id>",
17909 (void *)&cmd_ptype_mapping_reset_ptype,
17910 (void *)&cmd_ptype_mapping_reset_mapping,
17911 (void *)&cmd_ptype_mapping_reset_reset,
17912 (void *)&cmd_ptype_mapping_reset_port_id,
17917 /* ptype mapping update */
17919 /* Common result structure for ptype mapping update */
17920 struct cmd_ptype_mapping_update_result {
17921 cmdline_fixed_string_t ptype;
17922 cmdline_fixed_string_t mapping;
17923 cmdline_fixed_string_t reset;
17929 /* Common CLI fields for ptype mapping update*/
17930 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17931 TOKEN_STRING_INITIALIZER
17932 (struct cmd_ptype_mapping_update_result,
17934 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17935 TOKEN_STRING_INITIALIZER
17936 (struct cmd_ptype_mapping_update_result,
17937 mapping, "mapping");
17938 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17939 TOKEN_STRING_INITIALIZER
17940 (struct cmd_ptype_mapping_update_result,
17942 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17943 TOKEN_NUM_INITIALIZER
17944 (struct cmd_ptype_mapping_update_result,
17946 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17947 TOKEN_NUM_INITIALIZER
17948 (struct cmd_ptype_mapping_update_result,
17950 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17951 TOKEN_NUM_INITIALIZER
17952 (struct cmd_ptype_mapping_update_result,
17956 cmd_ptype_mapping_update_parsed(
17957 void *parsed_result,
17958 __rte_unused struct cmdline *cl,
17959 __rte_unused void *data)
17961 struct cmd_ptype_mapping_update_result *res = parsed_result;
17962 int ret = -ENOTSUP;
17963 #ifdef RTE_LIBRTE_I40E_PMD
17964 struct rte_pmd_i40e_ptype_mapping mapping;
17966 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17969 #ifdef RTE_LIBRTE_I40E_PMD
17970 mapping.hw_ptype = res->hw_ptype;
17971 mapping.sw_ptype = res->sw_ptype;
17972 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17982 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17985 printf("invalid port_id %d\n", res->port_id);
17988 printf("function not implemented\n");
17991 printf("programming error: (%s)\n", strerror(-ret));
17995 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17996 .f = cmd_ptype_mapping_update_parsed,
17998 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18000 (void *)&cmd_ptype_mapping_update_ptype,
18001 (void *)&cmd_ptype_mapping_update_mapping,
18002 (void *)&cmd_ptype_mapping_update_update,
18003 (void *)&cmd_ptype_mapping_update_port_id,
18004 (void *)&cmd_ptype_mapping_update_hw_ptype,
18005 (void *)&cmd_ptype_mapping_update_sw_ptype,
18010 /* Common result structure for file commands */
18011 struct cmd_cmdfile_result {
18012 cmdline_fixed_string_t load;
18013 cmdline_fixed_string_t filename;
18016 /* Common CLI fields for file commands */
18017 cmdline_parse_token_string_t cmd_load_cmdfile =
18018 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18019 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18020 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18023 cmd_load_from_file_parsed(
18024 void *parsed_result,
18025 __rte_unused struct cmdline *cl,
18026 __rte_unused void *data)
18028 struct cmd_cmdfile_result *res = parsed_result;
18030 cmdline_read_from_file(res->filename);
18033 cmdline_parse_inst_t cmd_load_from_file = {
18034 .f = cmd_load_from_file_parsed,
18036 .help_str = "load <filename>",
18038 (void *)&cmd_load_cmdfile,
18039 (void *)&cmd_load_cmdfile_filename,
18044 /* Get Rx offloads capabilities */
18045 struct cmd_rx_offload_get_capa_result {
18046 cmdline_fixed_string_t show;
18047 cmdline_fixed_string_t port;
18049 cmdline_fixed_string_t rx_offload;
18050 cmdline_fixed_string_t capabilities;
18053 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18054 TOKEN_STRING_INITIALIZER
18055 (struct cmd_rx_offload_get_capa_result,
18057 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18058 TOKEN_STRING_INITIALIZER
18059 (struct cmd_rx_offload_get_capa_result,
18061 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18062 TOKEN_NUM_INITIALIZER
18063 (struct cmd_rx_offload_get_capa_result,
18065 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18066 TOKEN_STRING_INITIALIZER
18067 (struct cmd_rx_offload_get_capa_result,
18068 rx_offload, "rx_offload");
18069 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18070 TOKEN_STRING_INITIALIZER
18071 (struct cmd_rx_offload_get_capa_result,
18072 capabilities, "capabilities");
18075 print_rx_offloads(uint64_t offloads)
18077 uint64_t single_offload;
18085 begin = __builtin_ctzll(offloads);
18086 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18088 single_offload = 1ULL << begin;
18089 for (bit = begin; bit < end; bit++) {
18090 if (offloads & single_offload)
18092 rte_eth_dev_rx_offload_name(single_offload));
18093 single_offload <<= 1;
18098 cmd_rx_offload_get_capa_parsed(
18099 void *parsed_result,
18100 __rte_unused struct cmdline *cl,
18101 __rte_unused void *data)
18103 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18104 struct rte_eth_dev_info dev_info;
18105 portid_t port_id = res->port_id;
18106 uint64_t queue_offloads;
18107 uint64_t port_offloads;
18110 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18114 queue_offloads = dev_info.rx_queue_offload_capa;
18115 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18117 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18118 printf(" Per Queue :");
18119 print_rx_offloads(queue_offloads);
18122 printf(" Per Port :");
18123 print_rx_offloads(port_offloads);
18127 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18128 .f = cmd_rx_offload_get_capa_parsed,
18130 .help_str = "show port <port_id> rx_offload capabilities",
18132 (void *)&cmd_rx_offload_get_capa_show,
18133 (void *)&cmd_rx_offload_get_capa_port,
18134 (void *)&cmd_rx_offload_get_capa_port_id,
18135 (void *)&cmd_rx_offload_get_capa_rx_offload,
18136 (void *)&cmd_rx_offload_get_capa_capabilities,
18141 /* Get Rx offloads configuration */
18142 struct cmd_rx_offload_get_configuration_result {
18143 cmdline_fixed_string_t show;
18144 cmdline_fixed_string_t port;
18146 cmdline_fixed_string_t rx_offload;
18147 cmdline_fixed_string_t configuration;
18150 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18151 TOKEN_STRING_INITIALIZER
18152 (struct cmd_rx_offload_get_configuration_result,
18154 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18155 TOKEN_STRING_INITIALIZER
18156 (struct cmd_rx_offload_get_configuration_result,
18158 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18159 TOKEN_NUM_INITIALIZER
18160 (struct cmd_rx_offload_get_configuration_result,
18162 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18163 TOKEN_STRING_INITIALIZER
18164 (struct cmd_rx_offload_get_configuration_result,
18165 rx_offload, "rx_offload");
18166 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18167 TOKEN_STRING_INITIALIZER
18168 (struct cmd_rx_offload_get_configuration_result,
18169 configuration, "configuration");
18172 cmd_rx_offload_get_configuration_parsed(
18173 void *parsed_result,
18174 __rte_unused struct cmdline *cl,
18175 __rte_unused void *data)
18177 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18178 struct rte_eth_dev_info dev_info;
18179 portid_t port_id = res->port_id;
18180 struct rte_port *port = &ports[port_id];
18181 uint64_t port_offloads;
18182 uint64_t queue_offloads;
18183 uint16_t nb_rx_queues;
18187 printf("Rx Offloading Configuration of port %d :\n", port_id);
18189 port_offloads = port->dev_conf.rxmode.offloads;
18191 print_rx_offloads(port_offloads);
18194 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18198 nb_rx_queues = dev_info.nb_rx_queues;
18199 for (q = 0; q < nb_rx_queues; q++) {
18200 queue_offloads = port->rx_conf[q].offloads;
18201 printf(" Queue[%2d] :", q);
18202 print_rx_offloads(queue_offloads);
18208 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18209 .f = cmd_rx_offload_get_configuration_parsed,
18211 .help_str = "show port <port_id> rx_offload configuration",
18213 (void *)&cmd_rx_offload_get_configuration_show,
18214 (void *)&cmd_rx_offload_get_configuration_port,
18215 (void *)&cmd_rx_offload_get_configuration_port_id,
18216 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18217 (void *)&cmd_rx_offload_get_configuration_configuration,
18222 /* Enable/Disable a per port offloading */
18223 struct cmd_config_per_port_rx_offload_result {
18224 cmdline_fixed_string_t port;
18225 cmdline_fixed_string_t config;
18227 cmdline_fixed_string_t rx_offload;
18228 cmdline_fixed_string_t offload;
18229 cmdline_fixed_string_t on_off;
18232 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18233 TOKEN_STRING_INITIALIZER
18234 (struct cmd_config_per_port_rx_offload_result,
18236 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18237 TOKEN_STRING_INITIALIZER
18238 (struct cmd_config_per_port_rx_offload_result,
18240 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18241 TOKEN_NUM_INITIALIZER
18242 (struct cmd_config_per_port_rx_offload_result,
18244 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18245 TOKEN_STRING_INITIALIZER
18246 (struct cmd_config_per_port_rx_offload_result,
18247 rx_offload, "rx_offload");
18248 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18249 TOKEN_STRING_INITIALIZER
18250 (struct cmd_config_per_port_rx_offload_result,
18251 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18252 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18253 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18254 "scatter#timestamp#security#keep_crc#rss_hash");
18255 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18256 TOKEN_STRING_INITIALIZER
18257 (struct cmd_config_per_port_rx_offload_result,
18261 search_rx_offload(const char *name)
18263 uint64_t single_offload;
18264 const char *single_name;
18268 single_offload = 1;
18269 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18270 single_name = rte_eth_dev_rx_offload_name(single_offload);
18271 if (!strcasecmp(single_name, name)) {
18275 single_offload <<= 1;
18279 return single_offload;
18285 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18286 __rte_unused struct cmdline *cl,
18287 __rte_unused void *data)
18289 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18290 portid_t port_id = res->port_id;
18291 struct rte_eth_dev_info dev_info;
18292 struct rte_port *port = &ports[port_id];
18293 uint64_t single_offload;
18294 uint16_t nb_rx_queues;
18298 if (port->port_status != RTE_PORT_STOPPED) {
18299 printf("Error: Can't config offload when Port %d "
18300 "is not stopped\n", port_id);
18304 single_offload = search_rx_offload(res->offload);
18305 if (single_offload == 0) {
18306 printf("Unknown offload name: %s\n", res->offload);
18310 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18314 nb_rx_queues = dev_info.nb_rx_queues;
18315 if (!strcmp(res->on_off, "on")) {
18316 port->dev_conf.rxmode.offloads |= single_offload;
18317 for (q = 0; q < nb_rx_queues; q++)
18318 port->rx_conf[q].offloads |= single_offload;
18320 port->dev_conf.rxmode.offloads &= ~single_offload;
18321 for (q = 0; q < nb_rx_queues; q++)
18322 port->rx_conf[q].offloads &= ~single_offload;
18325 cmd_reconfig_device_queue(port_id, 1, 1);
18328 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18329 .f = cmd_config_per_port_rx_offload_parsed,
18331 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18332 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18333 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18334 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18337 (void *)&cmd_config_per_port_rx_offload_result_port,
18338 (void *)&cmd_config_per_port_rx_offload_result_config,
18339 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18340 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18341 (void *)&cmd_config_per_port_rx_offload_result_offload,
18342 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18347 /* Enable/Disable a per queue offloading */
18348 struct cmd_config_per_queue_rx_offload_result {
18349 cmdline_fixed_string_t port;
18351 cmdline_fixed_string_t rxq;
18353 cmdline_fixed_string_t rx_offload;
18354 cmdline_fixed_string_t offload;
18355 cmdline_fixed_string_t on_off;
18358 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18359 TOKEN_STRING_INITIALIZER
18360 (struct cmd_config_per_queue_rx_offload_result,
18362 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18363 TOKEN_NUM_INITIALIZER
18364 (struct cmd_config_per_queue_rx_offload_result,
18366 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18367 TOKEN_STRING_INITIALIZER
18368 (struct cmd_config_per_queue_rx_offload_result,
18370 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18371 TOKEN_NUM_INITIALIZER
18372 (struct cmd_config_per_queue_rx_offload_result,
18374 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18375 TOKEN_STRING_INITIALIZER
18376 (struct cmd_config_per_queue_rx_offload_result,
18377 rx_offload, "rx_offload");
18378 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18379 TOKEN_STRING_INITIALIZER
18380 (struct cmd_config_per_queue_rx_offload_result,
18381 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18382 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18383 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18384 "scatter#timestamp#security#keep_crc");
18385 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18386 TOKEN_STRING_INITIALIZER
18387 (struct cmd_config_per_queue_rx_offload_result,
18391 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18392 __rte_unused struct cmdline *cl,
18393 __rte_unused void *data)
18395 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18396 struct rte_eth_dev_info dev_info;
18397 portid_t port_id = res->port_id;
18398 uint16_t queue_id = res->queue_id;
18399 struct rte_port *port = &ports[port_id];
18400 uint64_t single_offload;
18403 if (port->port_status != RTE_PORT_STOPPED) {
18404 printf("Error: Can't config offload when Port %d "
18405 "is not stopped\n", port_id);
18409 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18413 if (queue_id >= dev_info.nb_rx_queues) {
18414 printf("Error: input queue_id should be 0 ... "
18415 "%d\n", dev_info.nb_rx_queues - 1);
18419 single_offload = search_rx_offload(res->offload);
18420 if (single_offload == 0) {
18421 printf("Unknown offload name: %s\n", res->offload);
18425 if (!strcmp(res->on_off, "on"))
18426 port->rx_conf[queue_id].offloads |= single_offload;
18428 port->rx_conf[queue_id].offloads &= ~single_offload;
18430 cmd_reconfig_device_queue(port_id, 1, 1);
18433 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18434 .f = cmd_config_per_queue_rx_offload_parsed,
18436 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18437 "vlan_strip|ipv4_cksum|"
18438 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18439 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18440 "jumbo_frame|scatter|timestamp|security|keep_crc "
18443 (void *)&cmd_config_per_queue_rx_offload_result_port,
18444 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18445 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18446 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18447 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18448 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18449 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18454 /* Get Tx offloads capabilities */
18455 struct cmd_tx_offload_get_capa_result {
18456 cmdline_fixed_string_t show;
18457 cmdline_fixed_string_t port;
18459 cmdline_fixed_string_t tx_offload;
18460 cmdline_fixed_string_t capabilities;
18463 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18464 TOKEN_STRING_INITIALIZER
18465 (struct cmd_tx_offload_get_capa_result,
18467 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18468 TOKEN_STRING_INITIALIZER
18469 (struct cmd_tx_offload_get_capa_result,
18471 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18472 TOKEN_NUM_INITIALIZER
18473 (struct cmd_tx_offload_get_capa_result,
18475 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18476 TOKEN_STRING_INITIALIZER
18477 (struct cmd_tx_offload_get_capa_result,
18478 tx_offload, "tx_offload");
18479 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18480 TOKEN_STRING_INITIALIZER
18481 (struct cmd_tx_offload_get_capa_result,
18482 capabilities, "capabilities");
18485 print_tx_offloads(uint64_t offloads)
18487 uint64_t single_offload;
18495 begin = __builtin_ctzll(offloads);
18496 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18498 single_offload = 1ULL << begin;
18499 for (bit = begin; bit < end; bit++) {
18500 if (offloads & single_offload)
18502 rte_eth_dev_tx_offload_name(single_offload));
18503 single_offload <<= 1;
18508 cmd_tx_offload_get_capa_parsed(
18509 void *parsed_result,
18510 __rte_unused struct cmdline *cl,
18511 __rte_unused void *data)
18513 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18514 struct rte_eth_dev_info dev_info;
18515 portid_t port_id = res->port_id;
18516 uint64_t queue_offloads;
18517 uint64_t port_offloads;
18520 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18524 queue_offloads = dev_info.tx_queue_offload_capa;
18525 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18527 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18528 printf(" Per Queue :");
18529 print_tx_offloads(queue_offloads);
18532 printf(" Per Port :");
18533 print_tx_offloads(port_offloads);
18537 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18538 .f = cmd_tx_offload_get_capa_parsed,
18540 .help_str = "show port <port_id> tx_offload capabilities",
18542 (void *)&cmd_tx_offload_get_capa_show,
18543 (void *)&cmd_tx_offload_get_capa_port,
18544 (void *)&cmd_tx_offload_get_capa_port_id,
18545 (void *)&cmd_tx_offload_get_capa_tx_offload,
18546 (void *)&cmd_tx_offload_get_capa_capabilities,
18551 /* Get Tx offloads configuration */
18552 struct cmd_tx_offload_get_configuration_result {
18553 cmdline_fixed_string_t show;
18554 cmdline_fixed_string_t port;
18556 cmdline_fixed_string_t tx_offload;
18557 cmdline_fixed_string_t configuration;
18560 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18561 TOKEN_STRING_INITIALIZER
18562 (struct cmd_tx_offload_get_configuration_result,
18564 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18565 TOKEN_STRING_INITIALIZER
18566 (struct cmd_tx_offload_get_configuration_result,
18568 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18569 TOKEN_NUM_INITIALIZER
18570 (struct cmd_tx_offload_get_configuration_result,
18572 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18573 TOKEN_STRING_INITIALIZER
18574 (struct cmd_tx_offload_get_configuration_result,
18575 tx_offload, "tx_offload");
18576 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18577 TOKEN_STRING_INITIALIZER
18578 (struct cmd_tx_offload_get_configuration_result,
18579 configuration, "configuration");
18582 cmd_tx_offload_get_configuration_parsed(
18583 void *parsed_result,
18584 __rte_unused struct cmdline *cl,
18585 __rte_unused void *data)
18587 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18588 struct rte_eth_dev_info dev_info;
18589 portid_t port_id = res->port_id;
18590 struct rte_port *port = &ports[port_id];
18591 uint64_t port_offloads;
18592 uint64_t queue_offloads;
18593 uint16_t nb_tx_queues;
18597 printf("Tx Offloading Configuration of port %d :\n", port_id);
18599 port_offloads = port->dev_conf.txmode.offloads;
18601 print_tx_offloads(port_offloads);
18604 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18608 nb_tx_queues = dev_info.nb_tx_queues;
18609 for (q = 0; q < nb_tx_queues; q++) {
18610 queue_offloads = port->tx_conf[q].offloads;
18611 printf(" Queue[%2d] :", q);
18612 print_tx_offloads(queue_offloads);
18618 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18619 .f = cmd_tx_offload_get_configuration_parsed,
18621 .help_str = "show port <port_id> tx_offload configuration",
18623 (void *)&cmd_tx_offload_get_configuration_show,
18624 (void *)&cmd_tx_offload_get_configuration_port,
18625 (void *)&cmd_tx_offload_get_configuration_port_id,
18626 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18627 (void *)&cmd_tx_offload_get_configuration_configuration,
18632 /* Enable/Disable a per port offloading */
18633 struct cmd_config_per_port_tx_offload_result {
18634 cmdline_fixed_string_t port;
18635 cmdline_fixed_string_t config;
18637 cmdline_fixed_string_t tx_offload;
18638 cmdline_fixed_string_t offload;
18639 cmdline_fixed_string_t on_off;
18642 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18643 TOKEN_STRING_INITIALIZER
18644 (struct cmd_config_per_port_tx_offload_result,
18646 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18647 TOKEN_STRING_INITIALIZER
18648 (struct cmd_config_per_port_tx_offload_result,
18650 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18651 TOKEN_NUM_INITIALIZER
18652 (struct cmd_config_per_port_tx_offload_result,
18654 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18655 TOKEN_STRING_INITIALIZER
18656 (struct cmd_config_per_port_tx_offload_result,
18657 tx_offload, "tx_offload");
18658 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18659 TOKEN_STRING_INITIALIZER
18660 (struct cmd_config_per_port_tx_offload_result,
18661 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18662 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18663 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18664 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18665 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18666 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18667 TOKEN_STRING_INITIALIZER
18668 (struct cmd_config_per_port_tx_offload_result,
18672 search_tx_offload(const char *name)
18674 uint64_t single_offload;
18675 const char *single_name;
18679 single_offload = 1;
18680 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18681 single_name = rte_eth_dev_tx_offload_name(single_offload);
18682 if (single_name == NULL)
18684 if (!strcasecmp(single_name, name)) {
18687 } else if (!strcasecmp(single_name, "UNKNOWN"))
18689 single_offload <<= 1;
18693 return single_offload;
18699 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18700 __rte_unused struct cmdline *cl,
18701 __rte_unused void *data)
18703 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18704 portid_t port_id = res->port_id;
18705 struct rte_eth_dev_info dev_info;
18706 struct rte_port *port = &ports[port_id];
18707 uint64_t single_offload;
18708 uint16_t nb_tx_queues;
18712 if (port->port_status != RTE_PORT_STOPPED) {
18713 printf("Error: Can't config offload when Port %d "
18714 "is not stopped\n", port_id);
18718 single_offload = search_tx_offload(res->offload);
18719 if (single_offload == 0) {
18720 printf("Unknown offload name: %s\n", res->offload);
18724 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18728 nb_tx_queues = dev_info.nb_tx_queues;
18729 if (!strcmp(res->on_off, "on")) {
18730 port->dev_conf.txmode.offloads |= single_offload;
18731 for (q = 0; q < nb_tx_queues; q++)
18732 port->tx_conf[q].offloads |= single_offload;
18734 port->dev_conf.txmode.offloads &= ~single_offload;
18735 for (q = 0; q < nb_tx_queues; q++)
18736 port->tx_conf[q].offloads &= ~single_offload;
18739 cmd_reconfig_device_queue(port_id, 1, 1);
18742 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18743 .f = cmd_config_per_port_tx_offload_parsed,
18745 .help_str = "port config <port_id> tx_offload "
18746 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18747 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18748 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18749 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18750 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18752 (void *)&cmd_config_per_port_tx_offload_result_port,
18753 (void *)&cmd_config_per_port_tx_offload_result_config,
18754 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18755 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18756 (void *)&cmd_config_per_port_tx_offload_result_offload,
18757 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18762 /* Enable/Disable a per queue offloading */
18763 struct cmd_config_per_queue_tx_offload_result {
18764 cmdline_fixed_string_t port;
18766 cmdline_fixed_string_t txq;
18768 cmdline_fixed_string_t tx_offload;
18769 cmdline_fixed_string_t offload;
18770 cmdline_fixed_string_t on_off;
18773 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18774 TOKEN_STRING_INITIALIZER
18775 (struct cmd_config_per_queue_tx_offload_result,
18777 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18778 TOKEN_NUM_INITIALIZER
18779 (struct cmd_config_per_queue_tx_offload_result,
18781 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18782 TOKEN_STRING_INITIALIZER
18783 (struct cmd_config_per_queue_tx_offload_result,
18785 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18786 TOKEN_NUM_INITIALIZER
18787 (struct cmd_config_per_queue_tx_offload_result,
18789 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18790 TOKEN_STRING_INITIALIZER
18791 (struct cmd_config_per_queue_tx_offload_result,
18792 tx_offload, "tx_offload");
18793 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18794 TOKEN_STRING_INITIALIZER
18795 (struct cmd_config_per_queue_tx_offload_result,
18796 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18797 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18798 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18799 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18800 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18801 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18802 TOKEN_STRING_INITIALIZER
18803 (struct cmd_config_per_queue_tx_offload_result,
18807 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18808 __rte_unused struct cmdline *cl,
18809 __rte_unused void *data)
18811 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18812 struct rte_eth_dev_info dev_info;
18813 portid_t port_id = res->port_id;
18814 uint16_t queue_id = res->queue_id;
18815 struct rte_port *port = &ports[port_id];
18816 uint64_t single_offload;
18819 if (port->port_status != RTE_PORT_STOPPED) {
18820 printf("Error: Can't config offload when Port %d "
18821 "is not stopped\n", port_id);
18825 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18829 if (queue_id >= dev_info.nb_tx_queues) {
18830 printf("Error: input queue_id should be 0 ... "
18831 "%d\n", dev_info.nb_tx_queues - 1);
18835 single_offload = search_tx_offload(res->offload);
18836 if (single_offload == 0) {
18837 printf("Unknown offload name: %s\n", res->offload);
18841 if (!strcmp(res->on_off, "on"))
18842 port->tx_conf[queue_id].offloads |= single_offload;
18844 port->tx_conf[queue_id].offloads &= ~single_offload;
18846 cmd_reconfig_device_queue(port_id, 1, 1);
18849 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18850 .f = cmd_config_per_queue_tx_offload_parsed,
18852 .help_str = "port <port_id> txq <queue_id> tx_offload "
18853 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18854 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18855 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18856 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18857 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18860 (void *)&cmd_config_per_queue_tx_offload_result_port,
18861 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18862 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18863 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18864 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18865 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18866 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18871 /* *** configure tx_metadata for specific port *** */
18872 struct cmd_config_tx_metadata_specific_result {
18873 cmdline_fixed_string_t port;
18874 cmdline_fixed_string_t keyword;
18876 cmdline_fixed_string_t item;
18881 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18882 __rte_unused struct cmdline *cl,
18883 __rte_unused void *data)
18885 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18889 ports[res->port_id].tx_metadata = res->value;
18890 /* Add/remove callback to insert valid metadata in every Tx packet. */
18891 if (ports[res->port_id].tx_metadata)
18892 add_tx_md_callback(res->port_id);
18894 remove_tx_md_callback(res->port_id);
18895 rte_flow_dynf_metadata_register();
18898 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18899 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18901 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18902 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18903 keyword, "config");
18904 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18905 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18907 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18908 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18909 item, "tx_metadata");
18910 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18911 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18914 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18915 .f = cmd_config_tx_metadata_specific_parsed,
18917 .help_str = "port config <port_id> tx_metadata <value>",
18919 (void *)&cmd_config_tx_metadata_specific_port,
18920 (void *)&cmd_config_tx_metadata_specific_keyword,
18921 (void *)&cmd_config_tx_metadata_specific_id,
18922 (void *)&cmd_config_tx_metadata_specific_item,
18923 (void *)&cmd_config_tx_metadata_specific_value,
18928 /* *** set dynf *** */
18929 struct cmd_config_tx_dynf_specific_result {
18930 cmdline_fixed_string_t port;
18931 cmdline_fixed_string_t keyword;
18933 cmdline_fixed_string_t item;
18934 cmdline_fixed_string_t name;
18935 cmdline_fixed_string_t value;
18939 cmd_config_dynf_specific_parsed(void *parsed_result,
18940 __rte_unused struct cmdline *cl,
18941 __rte_unused void *data)
18943 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18944 struct rte_mbuf_dynflag desc_flag;
18946 uint64_t old_port_flags;
18948 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18950 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18952 if (strlcpy(desc_flag.name, res->name,
18953 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18954 printf("Flag name too long\n");
18957 desc_flag.flags = 0;
18958 flag = rte_mbuf_dynflag_register(&desc_flag);
18960 printf("Can't register flag\n");
18963 strcpy(dynf_names[flag], desc_flag.name);
18965 old_port_flags = ports[res->port_id].mbuf_dynf;
18966 if (!strcmp(res->value, "set")) {
18967 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18968 if (old_port_flags == 0)
18969 add_tx_dynf_callback(res->port_id);
18971 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18972 if (ports[res->port_id].mbuf_dynf == 0)
18973 remove_tx_dynf_callback(res->port_id);
18977 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18978 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18980 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18981 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18982 keyword, "config");
18983 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18984 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18986 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18987 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18989 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18990 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18992 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18993 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18994 value, "set#clear");
18996 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18997 .f = cmd_config_dynf_specific_parsed,
18999 .help_str = "port config <port id> dynf <name> set|clear",
19001 (void *)&cmd_config_tx_dynf_specific_port,
19002 (void *)&cmd_config_tx_dynf_specific_keyword,
19003 (void *)&cmd_config_tx_dynf_specific_port_id,
19004 (void *)&cmd_config_tx_dynf_specific_item,
19005 (void *)&cmd_config_tx_dynf_specific_name,
19006 (void *)&cmd_config_tx_dynf_specific_value,
19011 /* *** display tx_metadata per port configuration *** */
19012 struct cmd_show_tx_metadata_result {
19013 cmdline_fixed_string_t cmd_show;
19014 cmdline_fixed_string_t cmd_port;
19015 cmdline_fixed_string_t cmd_keyword;
19020 cmd_show_tx_metadata_parsed(void *parsed_result,
19021 __rte_unused struct cmdline *cl,
19022 __rte_unused void *data)
19024 struct cmd_show_tx_metadata_result *res = parsed_result;
19026 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19027 printf("invalid port id %u\n", res->cmd_pid);
19030 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19031 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19032 ports[res->cmd_pid].tx_metadata);
19036 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19037 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19039 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19040 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19042 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19043 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19045 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19046 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19047 cmd_keyword, "tx_metadata");
19049 cmdline_parse_inst_t cmd_show_tx_metadata = {
19050 .f = cmd_show_tx_metadata_parsed,
19052 .help_str = "show port <port_id> tx_metadata",
19054 (void *)&cmd_show_tx_metadata_show,
19055 (void *)&cmd_show_tx_metadata_port,
19056 (void *)&cmd_show_tx_metadata_pid,
19057 (void *)&cmd_show_tx_metadata_keyword,
19062 /* show port supported ptypes */
19064 /* Common result structure for show port ptypes */
19065 struct cmd_show_port_supported_ptypes_result {
19066 cmdline_fixed_string_t show;
19067 cmdline_fixed_string_t port;
19069 cmdline_fixed_string_t ptypes;
19072 /* Common CLI fields for show port ptypes */
19073 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19074 TOKEN_STRING_INITIALIZER
19075 (struct cmd_show_port_supported_ptypes_result,
19077 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19078 TOKEN_STRING_INITIALIZER
19079 (struct cmd_show_port_supported_ptypes_result,
19081 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19082 TOKEN_NUM_INITIALIZER
19083 (struct cmd_show_port_supported_ptypes_result,
19085 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19086 TOKEN_STRING_INITIALIZER
19087 (struct cmd_show_port_supported_ptypes_result,
19091 cmd_show_port_supported_ptypes_parsed(
19092 void *parsed_result,
19093 __rte_unused struct cmdline *cl,
19094 __rte_unused void *data)
19096 #define RSVD_PTYPE_MASK 0xf0000000
19097 #define MAX_PTYPES_PER_LAYER 16
19098 #define LTYPE_NAMESIZE 32
19099 #define PTYPE_NAMESIZE 256
19100 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19101 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19102 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19103 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19104 uint16_t port_id = res->port_id;
19107 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19111 while (ptype_mask != RSVD_PTYPE_MASK) {
19113 switch (ptype_mask) {
19114 case RTE_PTYPE_L2_MASK:
19115 strlcpy(ltype, "L2", sizeof(ltype));
19117 case RTE_PTYPE_L3_MASK:
19118 strlcpy(ltype, "L3", sizeof(ltype));
19120 case RTE_PTYPE_L4_MASK:
19121 strlcpy(ltype, "L4", sizeof(ltype));
19123 case RTE_PTYPE_TUNNEL_MASK:
19124 strlcpy(ltype, "Tunnel", sizeof(ltype));
19126 case RTE_PTYPE_INNER_L2_MASK:
19127 strlcpy(ltype, "Inner L2", sizeof(ltype));
19129 case RTE_PTYPE_INNER_L3_MASK:
19130 strlcpy(ltype, "Inner L3", sizeof(ltype));
19132 case RTE_PTYPE_INNER_L4_MASK:
19133 strlcpy(ltype, "Inner L4", sizeof(ltype));
19139 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19140 ptype_mask, ptypes,
19141 MAX_PTYPES_PER_LAYER);
19144 printf("Supported %s ptypes:\n", ltype);
19146 printf("%s ptypes unsupported\n", ltype);
19148 for (i = 0; i < ret; ++i) {
19149 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19150 printf("%s\n", buf);
19157 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19158 .f = cmd_show_port_supported_ptypes_parsed,
19160 .help_str = "show port <port_id> ptypes",
19162 (void *)&cmd_show_port_supported_ptypes_show,
19163 (void *)&cmd_show_port_supported_ptypes_port,
19164 (void *)&cmd_show_port_supported_ptypes_port_id,
19165 (void *)&cmd_show_port_supported_ptypes_ptypes,
19170 /* *** display rx/tx descriptor status *** */
19171 struct cmd_show_rx_tx_desc_status_result {
19172 cmdline_fixed_string_t cmd_show;
19173 cmdline_fixed_string_t cmd_port;
19174 cmdline_fixed_string_t cmd_keyword;
19175 cmdline_fixed_string_t cmd_desc;
19176 cmdline_fixed_string_t cmd_status;
19183 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19184 __rte_unused struct cmdline *cl,
19185 __rte_unused void *data)
19187 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19190 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19191 printf("invalid port id %u\n", res->cmd_pid);
19195 if (!strcmp(res->cmd_keyword, "rxq")) {
19196 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19199 printf("Invalid queueid = %d\n", res->cmd_qid);
19202 if (rc == RTE_ETH_RX_DESC_AVAIL)
19203 printf("Desc status = AVAILABLE\n");
19204 else if (rc == RTE_ETH_RX_DESC_DONE)
19205 printf("Desc status = DONE\n");
19207 printf("Desc status = UNAVAILABLE\n");
19208 } else if (!strcmp(res->cmd_keyword, "txq")) {
19209 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19212 printf("Invalid queueid = %d\n", res->cmd_qid);
19215 if (rc == RTE_ETH_TX_DESC_FULL)
19216 printf("Desc status = FULL\n");
19217 else if (rc == RTE_ETH_TX_DESC_DONE)
19218 printf("Desc status = DONE\n");
19220 printf("Desc status = UNAVAILABLE\n");
19224 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19225 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19227 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19228 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19230 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19231 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19233 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19234 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19235 cmd_keyword, "rxq#txq");
19236 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19237 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19239 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19240 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19242 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19243 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19245 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19246 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19247 cmd_status, "status");
19248 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19249 .f = cmd_show_rx_tx_desc_status_parsed,
19251 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19254 (void *)&cmd_show_rx_tx_desc_status_show,
19255 (void *)&cmd_show_rx_tx_desc_status_port,
19256 (void *)&cmd_show_rx_tx_desc_status_pid,
19257 (void *)&cmd_show_rx_tx_desc_status_keyword,
19258 (void *)&cmd_show_rx_tx_desc_status_qid,
19259 (void *)&cmd_show_rx_tx_desc_status_desc,
19260 (void *)&cmd_show_rx_tx_desc_status_did,
19261 (void *)&cmd_show_rx_tx_desc_status_status,
19266 /* Common result structure for set port ptypes */
19267 struct cmd_set_port_ptypes_result {
19268 cmdline_fixed_string_t set;
19269 cmdline_fixed_string_t port;
19271 cmdline_fixed_string_t ptype_mask;
19275 /* Common CLI fields for set port ptypes */
19276 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19277 TOKEN_STRING_INITIALIZER
19278 (struct cmd_set_port_ptypes_result,
19280 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19281 TOKEN_STRING_INITIALIZER
19282 (struct cmd_set_port_ptypes_result,
19284 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19285 TOKEN_NUM_INITIALIZER
19286 (struct cmd_set_port_ptypes_result,
19288 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19289 TOKEN_STRING_INITIALIZER
19290 (struct cmd_set_port_ptypes_result,
19291 ptype_mask, "ptype_mask");
19292 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19293 TOKEN_NUM_INITIALIZER
19294 (struct cmd_set_port_ptypes_result,
19298 cmd_set_port_ptypes_parsed(
19299 void *parsed_result,
19300 __rte_unused struct cmdline *cl,
19301 __rte_unused void *data)
19303 struct cmd_set_port_ptypes_result *res = parsed_result;
19304 #define PTYPE_NAMESIZE 256
19305 char ptype_name[PTYPE_NAMESIZE];
19306 uint16_t port_id = res->port_id;
19307 uint32_t ptype_mask = res->mask;
19310 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19313 printf("Port %d doesn't support any ptypes.\n", port_id);
19317 uint32_t ptypes[ret];
19319 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19321 printf("Unable to set requested ptypes for Port %d\n", port_id);
19325 printf("Successfully set following ptypes for Port %d\n", port_id);
19326 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19327 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19328 printf("%s\n", ptype_name);
19331 clear_ptypes = false;
19334 cmdline_parse_inst_t cmd_set_port_ptypes = {
19335 .f = cmd_set_port_ptypes_parsed,
19337 .help_str = "set port <port_id> ptype_mask <mask>",
19339 (void *)&cmd_set_port_ptypes_set,
19340 (void *)&cmd_set_port_ptypes_port,
19341 (void *)&cmd_set_port_ptypes_port_id,
19342 (void *)&cmd_set_port_ptypes_mask_str,
19343 (void *)&cmd_set_port_ptypes_mask_u32,
19348 /* *** display mac addresses added to a port *** */
19349 struct cmd_showport_macs_result {
19350 cmdline_fixed_string_t cmd_show;
19351 cmdline_fixed_string_t cmd_port;
19352 cmdline_fixed_string_t cmd_keyword;
19357 cmd_showport_macs_parsed(void *parsed_result,
19358 __rte_unused struct cmdline *cl,
19359 __rte_unused void *data)
19361 struct cmd_showport_macs_result *res = parsed_result;
19363 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19366 if (!strcmp(res->cmd_keyword, "macs"))
19367 show_macs(res->cmd_pid);
19368 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19369 show_mcast_macs(res->cmd_pid);
19372 cmdline_parse_token_string_t cmd_showport_macs_show =
19373 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19375 cmdline_parse_token_string_t cmd_showport_macs_port =
19376 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19378 cmdline_parse_token_num_t cmd_showport_macs_pid =
19379 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19381 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19382 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19383 cmd_keyword, "macs#mcast_macs");
19385 cmdline_parse_inst_t cmd_showport_macs = {
19386 .f = cmd_showport_macs_parsed,
19388 .help_str = "show port <port_id> macs|mcast_macs",
19390 (void *)&cmd_showport_macs_show,
19391 (void *)&cmd_showport_macs_port,
19392 (void *)&cmd_showport_macs_pid,
19393 (void *)&cmd_showport_macs_keyword,
19398 /* ******************************************************************************** */
19400 /* list of instructions */
19401 cmdline_parse_ctx_t main_ctx[] = {
19402 (cmdline_parse_inst_t *)&cmd_help_brief,
19403 (cmdline_parse_inst_t *)&cmd_help_long,
19404 (cmdline_parse_inst_t *)&cmd_quit,
19405 (cmdline_parse_inst_t *)&cmd_load_from_file,
19406 (cmdline_parse_inst_t *)&cmd_showport,
19407 (cmdline_parse_inst_t *)&cmd_showqueue,
19408 (cmdline_parse_inst_t *)&cmd_showportall,
19409 (cmdline_parse_inst_t *)&cmd_showdevice,
19410 (cmdline_parse_inst_t *)&cmd_showcfg,
19411 (cmdline_parse_inst_t *)&cmd_showfwdall,
19412 (cmdline_parse_inst_t *)&cmd_start,
19413 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19414 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19415 (cmdline_parse_inst_t *)&cmd_set_link_up,
19416 (cmdline_parse_inst_t *)&cmd_set_link_down,
19417 (cmdline_parse_inst_t *)&cmd_reset,
19418 (cmdline_parse_inst_t *)&cmd_set_numbers,
19419 (cmdline_parse_inst_t *)&cmd_set_log,
19420 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19421 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19422 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19423 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19424 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19425 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19426 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19427 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19428 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19429 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19430 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19431 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19432 (cmdline_parse_inst_t *)&cmd_set_link_check,
19433 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19434 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19435 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19436 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19437 #ifdef RTE_LIBRTE_PMD_BOND
19438 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19439 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19440 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19441 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19442 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19443 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19444 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19445 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19446 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19447 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19448 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19450 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19451 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19452 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19453 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19454 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19455 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19456 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19457 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19458 (cmdline_parse_inst_t *)&cmd_csum_set,
19459 (cmdline_parse_inst_t *)&cmd_csum_show,
19460 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19461 (cmdline_parse_inst_t *)&cmd_tso_set,
19462 (cmdline_parse_inst_t *)&cmd_tso_show,
19463 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19464 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19465 (cmdline_parse_inst_t *)&cmd_gro_enable,
19466 (cmdline_parse_inst_t *)&cmd_gro_flush,
19467 (cmdline_parse_inst_t *)&cmd_gro_show,
19468 (cmdline_parse_inst_t *)&cmd_gso_enable,
19469 (cmdline_parse_inst_t *)&cmd_gso_size,
19470 (cmdline_parse_inst_t *)&cmd_gso_show,
19471 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19472 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19473 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19474 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19475 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19476 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19477 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19478 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19479 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19480 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19481 (cmdline_parse_inst_t *)&cmd_config_dcb,
19482 (cmdline_parse_inst_t *)&cmd_read_reg,
19483 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19484 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19485 (cmdline_parse_inst_t *)&cmd_write_reg,
19486 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19487 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19488 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19489 (cmdline_parse_inst_t *)&cmd_stop,
19490 (cmdline_parse_inst_t *)&cmd_mac_addr,
19491 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19492 (cmdline_parse_inst_t *)&cmd_set_qmap,
19493 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19494 (cmdline_parse_inst_t *)&cmd_operate_port,
19495 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19496 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19497 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19498 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19499 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19500 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19501 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19502 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19503 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19504 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19505 (cmdline_parse_inst_t *)&cmd_config_mtu,
19506 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19507 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19508 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19509 (cmdline_parse_inst_t *)&cmd_config_rss,
19510 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19511 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19512 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19513 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19514 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19515 (cmdline_parse_inst_t *)&cmd_showport_reta,
19516 (cmdline_parse_inst_t *)&cmd_showport_macs,
19517 (cmdline_parse_inst_t *)&cmd_config_burst,
19518 (cmdline_parse_inst_t *)&cmd_config_thresh,
19519 (cmdline_parse_inst_t *)&cmd_config_threshold,
19520 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19521 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19522 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19523 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19524 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19525 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19526 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19527 (cmdline_parse_inst_t *)&cmd_global_config,
19528 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19529 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19530 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19531 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19532 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19533 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19534 (cmdline_parse_inst_t *)&cmd_dump,
19535 (cmdline_parse_inst_t *)&cmd_dump_one,
19536 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19537 (cmdline_parse_inst_t *)&cmd_syn_filter,
19538 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19539 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19540 (cmdline_parse_inst_t *)&cmd_flex_filter,
19541 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19542 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19543 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19544 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19545 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19546 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19547 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19548 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19549 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19550 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19551 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19552 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19553 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19554 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19555 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19556 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19557 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19558 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19559 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19560 (cmdline_parse_inst_t *)&cmd_flow,
19561 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19562 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19563 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19564 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19565 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19566 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19567 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19568 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19569 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19570 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19571 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19572 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19573 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19574 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19575 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19576 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19577 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19578 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19579 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19580 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19581 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19582 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19583 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19584 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19585 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19586 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19587 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19588 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19589 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19590 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19591 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19592 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19593 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19594 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19595 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19596 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19597 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19598 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19599 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19600 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19601 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19602 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19603 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19604 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19605 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19606 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19607 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19608 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19609 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19610 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19611 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19613 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19614 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19615 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19616 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19617 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19618 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19619 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19620 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19621 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19622 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19623 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19624 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19625 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19626 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19627 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19628 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19629 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19630 (cmdline_parse_inst_t *)&cmd_ddp_add,
19631 (cmdline_parse_inst_t *)&cmd_ddp_del,
19632 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19633 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19634 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19635 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19636 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19637 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19638 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19639 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19640 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19641 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19642 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19643 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19645 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19646 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19647 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19648 (cmdline_parse_inst_t *)&cmd_queue_region,
19649 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19650 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19651 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19652 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19653 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19654 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19655 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19656 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19657 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19658 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19659 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19660 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19661 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19662 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19663 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19664 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19665 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19666 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19667 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19668 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19669 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19670 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19671 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19672 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19673 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19674 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19675 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19676 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19677 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19678 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19679 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19680 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19681 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19682 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19683 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19684 #ifdef RTE_LIBRTE_BPF
19685 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19686 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19688 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19689 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19690 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19691 (cmdline_parse_inst_t *)&cmd_set_raw,
19692 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19693 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19694 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19698 /* read cmdline commands from file */
19700 cmdline_read_from_file(const char *filename)
19702 struct cmdline *cl;
19704 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19706 printf("Failed to create file based cmdline context: %s\n",
19711 cmdline_interact(cl);
19716 printf("Read CLI commands from %s\n", filename);
19719 /* prompt function, called from main on MASTER lcore */
19723 /* initialize non-constant commands */
19724 cmd_set_fwd_mode_init();
19725 cmd_set_fwd_retry_mode_init();
19727 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19728 if (testpmd_cl == NULL)
19730 cmdline_interact(testpmd_cl);
19731 cmdline_stdin_exit(testpmd_cl);
19737 if (testpmd_cl != NULL)
19738 cmdline_quit(testpmd_cl);
19742 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19744 if (id == (portid_t)RTE_PORT_ALL) {
19747 RTE_ETH_FOREACH_DEV(pid) {
19748 /* check if need_reconfig has been set to 1 */
19749 if (ports[pid].need_reconfig == 0)
19750 ports[pid].need_reconfig = dev;
19751 /* check if need_reconfig_queues has been set to 1 */
19752 if (ports[pid].need_reconfig_queues == 0)
19753 ports[pid].need_reconfig_queues = queue;
19755 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19756 /* check if need_reconfig has been set to 1 */
19757 if (ports[id].need_reconfig == 0)
19758 ports[id].need_reconfig = dev;
19759 /* check if need_reconfig_queues has been set to 1 */
19760 if (ports[id].need_reconfig_queues == 0)
19761 ports[id].need_reconfig_queues = queue;