1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
53 #ifdef RTE_LIBRTE_PMD_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
58 #include <rte_pmd_dpaa.h>
60 #ifdef RTE_LIBRTE_IXGBE_PMD
61 #include <rte_pmd_ixgbe.h>
63 #ifdef RTE_LIBRTE_I40E_PMD
64 #include <rte_pmd_i40e.h>
66 #ifdef RTE_LIBRTE_BNXT_PMD
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
85 __rte_unused void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commmands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port X rss reta (size) (mask0,mask1,...)\n"
170 " Display the rss redirection table entry indicated"
171 " by masks on port X. size is used to indicate the"
172 " hardware supported reta size\n\n"
174 "show port (port_id) rss-hash [key]\n"
175 " Display the RSS hash functions and RSS hash key of port\n\n"
177 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
178 " Clear information for port_id, or all.\n\n"
180 "show (rxq|txq) info (port_id) (queue_id)\n"
181 " Display information for configured RX/TX queue.\n\n"
183 "show config (rxtx|cores|fwd|txpkts)\n"
184 " Display the given configuration.\n\n"
186 "read rxd (port_id) (queue_id) (rxd_id)\n"
187 " Display an RX descriptor of a port RX queue.\n\n"
189 "read txd (port_id) (queue_id) (txd_id)\n"
190 " Display a TX descriptor of a port TX queue.\n\n"
192 "ddp get list (port_id)\n"
193 " Get ddp profile info list\n\n"
195 "ddp get info (profile_path)\n"
196 " Get ddp profile information.\n\n"
198 "show vf stats (port_id) (vf_id)\n"
199 " Display a VF's statistics.\n\n"
201 "clear vf stats (port_id) (vf_id)\n"
202 " Reset a VF's statistics.\n\n"
204 "show port (port_id) pctype mapping\n"
205 " Get flow ptype to pctype mapping on a port\n\n"
207 "show port meter stats (port_id) (meter_id) (clear)\n"
208 " Get meter stats on a port\n\n"
210 "show fwd stats all\n"
211 " Display statistics for all fwd engines.\n\n"
213 "clear fwd stats all\n"
214 " Clear statistics for all fwd engines.\n\n"
216 "show port (port_id) rx_offload capabilities\n"
217 " List all per queue and per port Rx offloading"
218 " capabilities of a port\n\n"
220 "show port (port_id) rx_offload configuration\n"
221 " List port level and all queue level"
222 " Rx offloading configuration\n\n"
224 "show port (port_id) tx_offload capabilities\n"
225 " List all per queue and per port"
226 " Tx offloading capabilities of a port\n\n"
228 "show port (port_id) tx_offload configuration\n"
229 " List port level and all queue level"
230 " Tx offloading configuration\n\n"
232 "show port (port_id) tx_metadata\n"
233 " Show Tx metadata value set"
234 " for a specific port\n\n"
236 "show port (port_id) ptypes\n"
237 " Show port supported ptypes"
238 " for a specific port\n\n"
240 "show device info (<identifier>|all)"
241 " Show general information about devices probed.\n\n"
243 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
244 " Show status of rx|tx descriptor.\n\n"
246 "show port (port_id) macs|mcast_macs"
247 " Display list of mac addresses added to port.\n\n"
251 if (show_all || !strcmp(res->section, "config")) {
257 "Configuration changes only become active when"
258 " forwarding is started/restarted.\n\n"
261 " Reset forwarding to the default configuration.\n\n"
263 "set verbose (level)\n"
264 " Set the debug verbosity level X.\n\n"
266 "set log global|(type) (level)\n"
267 " Set the log level.\n\n"
270 " Set number of ports.\n\n"
273 " Set number of cores.\n\n"
275 "set coremask (mask)\n"
276 " Set the forwarding cores hexadecimal mask.\n\n"
278 "set portmask (mask)\n"
279 " Set the forwarding ports hexadecimal mask.\n\n"
282 " Set number of packets per burst.\n\n"
284 "set burst tx delay (microseconds) retry (num)\n"
285 " Set the transmit delay time and number of retries,"
286 " effective when retry is enabled.\n\n"
288 "set txpkts (x[,y]*)\n"
289 " Set the length of each segment of TXONLY"
290 " and optionally CSUM packets.\n\n"
292 "set txsplit (off|on|rand)\n"
293 " Set the split policy for the TX packets."
294 " Right now only applicable for CSUM and TXONLY"
297 "set corelist (x[,y]*)\n"
298 " Set the list of forwarding cores.\n\n"
300 "set portlist (x[,y]*)\n"
301 " Set the list of forwarding ports.\n\n"
303 "set port setup on (iterator|event)\n"
304 " Select how attached port is retrieved for setup.\n\n"
306 "set tx loopback (port_id) (on|off)\n"
307 " Enable or disable tx loopback.\n\n"
309 "set all queues drop (port_id) (on|off)\n"
310 " Set drop enable bit for all queues.\n\n"
312 "set vf split drop (port_id) (vf_id) (on|off)\n"
313 " Set split drop enable bit for a VF from the PF.\n\n"
315 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
316 " Set MAC antispoof for a VF from the PF.\n\n"
318 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
319 " Enable MACsec offload.\n\n"
321 "set macsec offload (port_id) off\n"
322 " Disable MACsec offload.\n\n"
324 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
325 " Configure MACsec secure connection (SC).\n\n"
327 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
328 " Configure MACsec secure association (SA).\n\n"
330 "set vf broadcast (port_id) (vf_id) (on|off)\n"
331 " Set VF broadcast for a VF from the PF.\n\n"
333 "vlan set stripq (on|off) (port_id,queue_id)\n"
334 " Set the VLAN strip for a queue on a port.\n\n"
336 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
337 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
339 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
340 " Set VLAN insert for a VF from the PF.\n\n"
342 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
343 " Set VLAN antispoof for a VF from the PF.\n\n"
345 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
346 " Set VLAN tag for a VF from the PF.\n\n"
348 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
349 " Set a VF's max bandwidth(Mbps).\n\n"
351 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
352 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
354 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
355 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
357 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
358 " Set some TCs' strict link priority mode on a physical port.\n\n"
360 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
361 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
363 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
364 " Set the VLAN strip or filter or qinq strip or extend\n\n"
366 "vlan set (inner|outer) tpid (value) (port_id)\n"
367 " Set the VLAN TPID for Packet Filtering on"
370 "rx_vlan add (vlan_id|all) (port_id)\n"
371 " Add a vlan_id, or all identifiers, to the set"
372 " of VLAN identifiers filtered by port_id.\n\n"
374 "rx_vlan rm (vlan_id|all) (port_id)\n"
375 " Remove a vlan_id, or all identifiers, from the set"
376 " of VLAN identifiers filtered by port_id.\n\n"
378 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
379 " Add a vlan_id, to the set of VLAN identifiers"
380 "filtered for VF(s) from port_id.\n\n"
382 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
383 " Remove a vlan_id, to the set of VLAN identifiers"
384 "filtered for VF(s) from port_id.\n\n"
386 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
387 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
388 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
389 " add a tunnel filter of a port.\n\n"
391 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
392 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
393 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
394 " remove a tunnel filter of a port.\n\n"
396 "rx_vxlan_port add (udp_port) (port_id)\n"
397 " Add an UDP port for VXLAN packet filter on a port\n\n"
399 "rx_vxlan_port rm (udp_port) (port_id)\n"
400 " Remove an UDP port for VXLAN packet filter on a port\n\n"
402 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
403 " Set hardware insertion of VLAN IDs (single or double VLAN "
404 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
406 "tx_vlan set pvid port_id vlan_id (on|off)\n"
407 " Set port based TX VLAN insertion.\n\n"
409 "tx_vlan reset (port_id)\n"
410 " Disable hardware insertion of a VLAN header in"
411 " packets sent on a port.\n\n"
413 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
414 " Select hardware or software calculation of the"
415 " checksum when transmitting a packet using the"
416 " csum forward engine.\n"
417 " ip|udp|tcp|sctp always concern the inner layer.\n"
418 " outer-ip concerns the outer IP layer in"
419 " outer-udp concerns the outer UDP layer in"
420 " case the packet is recognized as a tunnel packet by"
421 " the forward engine (vxlan, gre and ipip are supported)\n"
422 " Please check the NIC datasheet for HW limits.\n\n"
424 "csum parse-tunnel (on|off) (tx_port_id)\n"
425 " If disabled, treat tunnel packets as non-tunneled"
426 " packets (treat inner headers as payload). The port\n"
427 " argument is the port used for TX in csum forward"
430 "csum show (port_id)\n"
431 " Display tx checksum offload configuration\n\n"
433 "tso set (segsize) (portid)\n"
434 " Enable TCP Segmentation Offload in csum forward"
436 " Please check the NIC datasheet for HW limits.\n\n"
439 " Display the status of TCP Segmentation Offload.\n\n"
441 "set port (port_id) gro on|off\n"
442 " Enable or disable Generic Receive Offload in"
443 " csum forwarding engine.\n\n"
445 "show port (port_id) gro\n"
446 " Display GRO configuration.\n\n"
448 "set gro flush (cycles)\n"
449 " Set the cycle to flush GROed packets from"
450 " reassembly tables.\n\n"
452 "set port (port_id) gso (on|off)"
453 " Enable or disable Generic Segmentation Offload in"
454 " csum forwarding engine.\n\n"
456 "set gso segsz (length)\n"
457 " Set max packet length for output GSO segments,"
458 " including packet header and payload.\n\n"
460 "show port (port_id) gso\n"
461 " Show GSO configuration.\n\n"
464 " Set packet forwarding mode.\n\n"
466 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
467 " Add a MAC address on port_id.\n\n"
469 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
470 " Remove a MAC address from port_id.\n\n"
472 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
473 " Set the default MAC address for port_id.\n\n"
475 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
476 " Add a MAC address for a VF on the port.\n\n"
478 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
479 " Set the MAC address for a VF from the PF.\n\n"
481 "set eth-peer (port_id) (peer_addr)\n"
482 " set the peer address for certain port.\n\n"
484 "set port (port_id) uta (mac_address|all) (on|off)\n"
485 " Add/Remove a or all unicast hash filter(s)"
488 "set promisc (port_id|all) (on|off)\n"
489 " Set the promiscuous mode on port_id, or all.\n\n"
491 "set allmulti (port_id|all) (on|off)\n"
492 " Set the allmulti mode on port_id, or all.\n\n"
494 "set vf promisc (port_id) (vf_id) (on|off)\n"
495 " Set unicast promiscuous mode for a VF from the PF.\n\n"
497 "set vf allmulti (port_id) (vf_id) (on|off)\n"
498 " Set multicast promiscuous mode for a VF from the PF.\n\n"
500 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
501 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
502 " (on|off) autoneg (on|off) (port_id)\n"
503 "set flow_ctrl rx (on|off) (portid)\n"
504 "set flow_ctrl tx (on|off) (portid)\n"
505 "set flow_ctrl high_water (high_water) (portid)\n"
506 "set flow_ctrl low_water (low_water) (portid)\n"
507 "set flow_ctrl pause_time (pause_time) (portid)\n"
508 "set flow_ctrl send_xon (send_xon) (portid)\n"
509 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
510 "set flow_ctrl autoneg (on|off) (port_id)\n"
511 " Set the link flow control parameter on a port.\n\n"
513 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
514 " (low_water) (pause_time) (priority) (port_id)\n"
515 " Set the priority flow control parameter on a"
518 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
519 " Set statistics mapping (qmapping 0..15) for RX/TX"
521 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
522 " on port 0 to mapping 5.\n\n"
524 "set xstats-hide-zero on|off\n"
525 " Set the option to hide the zero values"
526 " for xstats display.\n"
528 "set port (port_id) vf (vf_id) rx|tx on|off\n"
529 " Enable/Disable a VF receive/tranmit from a port\n\n"
531 "set port (port_id) vf (vf_id) (mac_addr)"
532 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
533 " Add/Remove unicast or multicast MAC addr filter"
536 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
538 " AUPE:accepts untagged VLAN;"
539 "ROPE:accept unicast hash\n\n"
540 " BAM:accepts broadcast packets;"
541 "MPE:accepts all multicast packets\n\n"
542 " Enable/Disable a VF receive mode of a port\n\n"
544 "set port (port_id) queue (queue_id) rate (rate_num)\n"
545 " Set rate limit for a queue of a port\n\n"
547 "set port (port_id) vf (vf_id) rate (rate_num) "
548 "queue_mask (queue_mask_value)\n"
549 " Set rate limit for queues in VF of a port\n\n"
551 "set port (port_id) mirror-rule (rule_id)"
552 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
553 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
554 " Set pool or vlan type mirror rule on a port.\n"
555 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
556 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
559 "set port (port_id) mirror-rule (rule_id)"
560 " (uplink-mirror|downlink-mirror) dst-pool"
561 " (pool_id) (on|off)\n"
562 " Set uplink or downlink type mirror rule on a port.\n"
563 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
564 " 0 on' enable mirror income traffic to pool 0.\n\n"
566 "reset port (port_id) mirror-rule (rule_id)\n"
567 " Reset a mirror rule.\n\n"
569 "set flush_rx (on|off)\n"
570 " Flush (default) or don't flush RX streams before"
571 " forwarding. Mainly used with PCAP drivers.\n\n"
573 "set bypass mode (normal|bypass|isolate) (port_id)\n"
574 " Set the bypass mode for the lowest port on bypass enabled"
577 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
578 "mode (normal|bypass|isolate) (port_id)\n"
579 " Set the event required to initiate specified bypass mode for"
580 " the lowest port on a bypass enabled NIC where:\n"
581 " timeout = enable bypass after watchdog timeout.\n"
582 " os_on = enable bypass when OS/board is powered on.\n"
583 " os_off = enable bypass when OS/board is powered off.\n"
584 " power_on = enable bypass when power supply is turned on.\n"
585 " power_off = enable bypass when power supply is turned off."
588 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
589 " Set the bypass watchdog timeout to 'n' seconds"
590 " where 0 = instant.\n\n"
592 "show bypass config (port_id)\n"
593 " Show the bypass configuration for a bypass enabled NIC"
594 " using the lowest port on the NIC.\n\n"
596 #ifdef RTE_LIBRTE_PMD_BOND
597 "create bonded device (mode) (socket)\n"
598 " Create a new bonded device with specific bonding mode and socket.\n\n"
600 "add bonding slave (slave_id) (port_id)\n"
601 " Add a slave device to a bonded device.\n\n"
603 "remove bonding slave (slave_id) (port_id)\n"
604 " Remove a slave device from a bonded device.\n\n"
606 "set bonding mode (value) (port_id)\n"
607 " Set the bonding mode on a bonded device.\n\n"
609 "set bonding primary (slave_id) (port_id)\n"
610 " Set the primary slave for a bonded device.\n\n"
612 "show bonding config (port_id)\n"
613 " Show the bonding config for port_id.\n\n"
615 "set bonding mac_addr (port_id) (address)\n"
616 " Set the MAC address of a bonded device.\n\n"
618 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
619 " Set Aggregation mode for IEEE802.3AD (mode 4)"
621 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
622 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
624 "set bonding mon_period (port_id) (value)\n"
625 " Set the bonding link status monitoring polling period in ms.\n\n"
627 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
628 " Enable/disable dedicated queues for LACP control traffic.\n\n"
631 "set link-up port (port_id)\n"
632 " Set link up for a port.\n\n"
634 "set link-down port (port_id)\n"
635 " Set link down for a port.\n\n"
637 "E-tag set insertion on port-tag-id (value)"
638 " port (port_id) vf (vf_id)\n"
639 " Enable E-tag insertion for a VF on a port\n\n"
641 "E-tag set insertion off port (port_id) vf (vf_id)\n"
642 " Disable E-tag insertion for a VF on a port\n\n"
644 "E-tag set stripping (on|off) port (port_id)\n"
645 " Enable/disable E-tag stripping on a port\n\n"
647 "E-tag set forwarding (on|off) port (port_id)\n"
648 " Enable/disable E-tag based forwarding"
651 "E-tag set filter add e-tag-id (value) dst-pool"
652 " (pool_id) port (port_id)\n"
653 " Add an E-tag forwarding filter on a port\n\n"
655 "E-tag set filter del e-tag-id (value) port (port_id)\n"
656 " Delete an E-tag forwarding filter on a port\n\n"
658 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
659 " Load a profile package on a port\n\n"
661 "ddp del (port_id) (backup_profile_path)\n"
662 " Delete a profile package from a port\n\n"
664 "ptype mapping get (port_id) (valid_only)\n"
665 " Get ptype mapping on a port\n\n"
667 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
668 " Replace target with the pkt_type in ptype mapping\n\n"
670 "ptype mapping reset (port_id)\n"
671 " Reset ptype mapping on a port\n\n"
673 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
674 " Update a ptype mapping item on a port\n\n"
676 "set port (port_id) ptype_mask (ptype_mask)\n"
677 " set packet types classification for a specific port\n\n"
679 "set port (port_id) queue-region region_id (value) "
680 "queue_start_index (value) queue_num (value)\n"
681 " Set a queue region on a port\n\n"
683 "set port (port_id) queue-region region_id (value) "
685 " Set a flowtype region index on a port\n\n"
687 "set port (port_id) queue-region UP (value) region_id (value)\n"
688 " Set the mapping of User Priority to "
689 "queue region on a port\n\n"
691 "set port (port_id) queue-region flush (on|off)\n"
692 " flush all queue region related configuration\n\n"
694 "show port meter cap (port_id)\n"
695 " Show port meter capability information\n\n"
697 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
698 " meter profile add - srtcm rfc 2697\n\n"
700 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
701 " meter profile add - trtcm rfc 2698\n\n"
703 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
704 " meter profile add - trtcm rfc 4115\n\n"
706 "del port meter profile (port_id) (profile_id)\n"
707 " meter profile delete\n\n"
709 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
710 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
711 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
712 "(dscp_tbl_entry63)]\n"
715 "enable port meter (port_id) (mtr_id)\n"
718 "disable port meter (port_id) (mtr_id)\n"
721 "del port meter (port_id) (mtr_id)\n"
724 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
725 " meter update meter profile\n\n"
727 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
728 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
729 " update meter dscp table entries\n\n"
731 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
732 "(action0) [(action1) (action2)]\n"
733 " meter update policer action\n\n"
735 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
736 " meter update stats\n\n"
738 "show port (port_id) queue-region\n"
739 " show all queue region related configuration info\n\n"
741 , list_pkt_forwarding_modes()
745 if (show_all || !strcmp(res->section, "ports")) {
751 "----------------\n\n"
753 "port start (port_id|all)\n"
754 " Start all ports or port_id.\n\n"
756 "port stop (port_id|all)\n"
757 " Stop all ports or port_id.\n\n"
759 "port close (port_id|all)\n"
760 " Close all ports or port_id.\n\n"
762 "port reset (port_id|all)\n"
763 " Reset all ports or port_id.\n\n"
765 "port attach (ident)\n"
766 " Attach physical or virtual dev by pci address or virtual device name\n\n"
768 "port detach (port_id)\n"
769 " Detach physical or virtual dev by port_id\n\n"
771 "port config (port_id|all)"
772 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
773 " duplex (half|full|auto)\n"
774 " Set speed and duplex for all ports or port_id\n\n"
776 "port config (port_id|all) loopback (mode)\n"
777 " Set loopback mode for all ports or port_id\n\n"
779 "port config all (rxq|txq|rxd|txd) (value)\n"
780 " Set number for rxq/txq/rxd/txd.\n\n"
782 "port config all max-pkt-len (value)\n"
783 " Set the max packet length.\n\n"
785 "port config all max-lro-pkt-size (value)\n"
786 " Set the max LRO aggregated packet size.\n\n"
788 "port config all drop-en (on|off)\n"
789 " Enable or disable packet drop on all RX queues of all ports when no "
790 "receive buffers available.\n\n"
792 "port config all rss (all|default|ip|tcp|udp|sctp|"
793 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
794 " Set the RSS mode.\n\n"
796 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
797 " Set the RSS redirection table.\n\n"
799 "port config (port_id) dcb vt (on|off) (traffic_class)"
801 " Set the DCB mode.\n\n"
803 "port config all burst (value)\n"
804 " Set the number of packets per burst.\n\n"
806 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
808 " Set the ring prefetch/host/writeback threshold"
809 " for tx/rx queue.\n\n"
811 "port config all (txfreet|txrst|rxfreet) (value)\n"
812 " Set free threshold for rx/tx, or set"
813 " tx rs bit threshold.\n\n"
814 "port config mtu X value\n"
815 " Set the MTU of port X to a given value\n\n"
817 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
818 " Set a rx/tx queue's ring size configuration, the new"
819 " value will take effect after command that (re-)start the port"
820 " or command that setup the specific queue\n\n"
822 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
823 " Start/stop a rx/tx queue of port X. Only take effect"
824 " when port X is started\n\n"
826 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
827 " Switch on/off a deferred start of port X rx/tx queue. Only"
828 " take effect when port X is stopped.\n\n"
830 "port (port_id) (rxq|txq) (queue_id) setup\n"
831 " Setup a rx/tx queue of port X.\n\n"
833 "port config (port_id|all) l2-tunnel E-tag ether-type"
835 " Set the value of E-tag ether-type.\n\n"
837 "port config (port_id|all) l2-tunnel E-tag"
838 " (enable|disable)\n"
839 " Enable/disable the E-tag support.\n\n"
841 "port config (port_id) pctype mapping reset\n"
842 " Reset flow type to pctype mapping on a port\n\n"
844 "port config (port_id) pctype mapping update"
845 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
846 " Update a flow type to pctype mapping item on a port\n\n"
848 "port config (port_id) pctype (pctype_id) hash_inset|"
849 "fdir_inset|fdir_flx_inset get|set|clear field\n"
851 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
853 "port config (port_id) pctype (pctype_id) hash_inset|"
854 "fdir_inset|fdir_flx_inset clear all"
855 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
857 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
858 " Add/remove UDP tunnel port for tunneling offload\n\n"
860 "port config <port_id> rx_offload vlan_strip|"
861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 "outer_ipv4_cksum|macsec_strip|header_split|"
863 "vlan_filter|vlan_extend|jumbo_frame|"
864 "scatter|timestamp|security|keep_crc on|off\n"
865 " Enable or disable a per port Rx offloading"
866 " on all Rx queues of a port\n\n"
868 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
869 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 "outer_ipv4_cksum|macsec_strip|header_split|"
871 "vlan_filter|vlan_extend|jumbo_frame|"
872 "scatter|timestamp|security|keep_crc on|off\n"
873 " Enable or disable a per queue Rx offloading"
874 " only on a specific Rx queue\n\n"
876 "port config (port_id) tx_offload vlan_insert|"
877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
880 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
882 " Enable or disable a per port Tx offloading"
883 " on all Tx queues of a port\n\n"
885 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
886 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
889 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
891 " Enable or disable a per queue Tx offloading"
892 " only on a specific Tx queue\n\n"
894 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
895 " Load an eBPF program as a callback"
896 " for particular RX/TX queue\n\n"
898 "bpf-unload rx|tx (port) (queue)\n"
899 " Unload previously loaded eBPF program"
900 " for particular RX/TX queue\n\n"
902 "port config (port_id) tx_metadata (value)\n"
903 " Set Tx metadata value per port. Testpmd will add this value"
904 " to any Tx packet sent from this port\n\n"
906 "port config (port_id) dynf (name) set|clear\n"
907 " Register a dynf and Set/clear this flag on Tx. "
908 "Testpmd will set this value to any Tx packet "
909 "sent from this port\n\n"
913 if (show_all || !strcmp(res->section, "registers")) {
921 "read reg (port_id) (address)\n"
922 " Display value of a port register.\n\n"
924 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
925 " Display a port register bit field.\n\n"
927 "read regbit (port_id) (address) (bit_x)\n"
928 " Display a single port register bit.\n\n"
930 "write reg (port_id) (address) (value)\n"
931 " Set value of a port register.\n\n"
933 "write regfield (port_id) (address) (bit_x) (bit_y)"
935 " Set bit field of a port register.\n\n"
937 "write regbit (port_id) (address) (bit_x) (value)\n"
938 " Set single bit value of a port register.\n\n"
941 if (show_all || !strcmp(res->section, "filters")) {
949 "ethertype_filter (port_id) (add|del)"
950 " (mac_addr|mac_ignr) (mac_address) ethertype"
951 " (ether_type) (drop|fwd) queue (queue_id)\n"
952 " Add/Del an ethertype filter.\n\n"
954 "2tuple_filter (port_id) (add|del)"
955 " dst_port (dst_port_value) protocol (protocol_value)"
956 " mask (mask_value) tcp_flags (tcp_flags_value)"
957 " priority (prio_value) queue (queue_id)\n"
958 " Add/Del a 2tuple filter.\n\n"
960 "5tuple_filter (port_id) (add|del)"
961 " dst_ip (dst_address) src_ip (src_address)"
962 " dst_port (dst_port_value) src_port (src_port_value)"
963 " protocol (protocol_value)"
964 " mask (mask_value) tcp_flags (tcp_flags_value)"
965 " priority (prio_value) queue (queue_id)\n"
966 " Add/Del a 5tuple filter.\n\n"
968 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
969 " Add/Del syn filter.\n\n"
971 "flex_filter (port_id) (add|del) len (len_value)"
972 " bytes (bytes_value) mask (mask_value)"
973 " priority (prio_value) queue (queue_id)\n"
974 " Add/Del a flex filter.\n\n"
976 "flow_director_filter (port_id) mode IP (add|del|update)"
977 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
978 " src (src_ip_address) dst (dst_ip_address)"
979 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
980 " vlan (vlan_value) flexbytes (flexbytes_value)"
981 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
982 " fd_id (fd_id_value)\n"
983 " Add/Del an IP type flow director filter.\n\n"
985 "flow_director_filter (port_id) mode IP (add|del|update)"
986 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
987 " src (src_ip_address) (src_port)"
988 " dst (dst_ip_address) (dst_port)"
989 " tos (tos_value) ttl (ttl_value)"
990 " vlan (vlan_value) flexbytes (flexbytes_value)"
991 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
992 " fd_id (fd_id_value)\n"
993 " Add/Del an UDP/TCP type flow director filter.\n\n"
995 "flow_director_filter (port_id) mode IP (add|del|update)"
996 " flow (ipv4-sctp|ipv6-sctp)"
997 " src (src_ip_address) (src_port)"
998 " dst (dst_ip_address) (dst_port)"
999 " tag (verification_tag) "
1000 " tos (tos_value) ttl (ttl_value)"
1001 " vlan (vlan_value)"
1002 " flexbytes (flexbytes_value) (drop|fwd)"
1003 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1004 " Add/Del a SCTP type flow director filter.\n\n"
1006 "flow_director_filter (port_id) mode IP (add|del|update)"
1007 " flow l2_payload ether (ethertype)"
1008 " flexbytes (flexbytes_value) (drop|fwd)"
1009 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1010 " Add/Del a l2 payload type flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1013 " mac (mac_address) vlan (vlan_value)"
1014 " flexbytes (flexbytes_value) (drop|fwd)"
1015 " queue (queue_id) fd_id (fd_id_value)\n"
1016 " Add/Del a MAC-VLAN flow director filter.\n\n"
1018 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1019 " mac (mac_address) vlan (vlan_value)"
1020 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1021 " flexbytes (flexbytes_value) (drop|fwd)"
1022 " queue (queue_id) fd_id (fd_id_value)\n"
1023 " Add/Del a Tunnel flow director filter.\n\n"
1025 "flow_director_filter (port_id) mode raw (add|del|update)"
1026 " flow (flow_id) (drop|fwd) queue (queue_id)"
1027 " fd_id (fd_id_value) packet (packet file name)\n"
1028 " Add/Del a raw type flow director filter.\n\n"
1030 "flush_flow_director (port_id)\n"
1031 " Flush all flow director entries of a device.\n\n"
1033 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1034 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1035 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1036 " Set flow director IP mask.\n\n"
1038 "flow_director_mask (port_id) mode MAC-VLAN"
1039 " vlan (vlan_value)\n"
1040 " Set flow director MAC-VLAN mask.\n\n"
1042 "flow_director_mask (port_id) mode Tunnel"
1043 " vlan (vlan_value) mac (mac_value)"
1044 " tunnel-type (tunnel_type_value)"
1045 " tunnel-id (tunnel_id_value)\n"
1046 " Set flow director Tunnel mask.\n\n"
1048 "flow_director_flex_mask (port_id)"
1049 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1050 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1052 " Configure mask of flex payload.\n\n"
1054 "flow_director_flex_payload (port_id)"
1055 " (raw|l2|l3|l4) (config)\n"
1056 " Configure flex payload selection.\n\n"
1058 "get_sym_hash_ena_per_port (port_id)\n"
1059 " get symmetric hash enable configuration per port.\n\n"
1061 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1062 " set symmetric hash enable configuration per port"
1063 " to enable or disable.\n\n"
1065 "get_hash_global_config (port_id)\n"
1066 " Get the global configurations of hash filters.\n\n"
1068 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1069 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1070 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1071 " (enable|disable)\n"
1072 " Set the global configurations of hash filters.\n\n"
1074 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1075 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1076 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1077 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1078 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1079 "ipv6-next-header|udp-src-port|udp-dst-port|"
1080 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1081 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1082 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1083 "fld-8th|none) (select|add)\n"
1084 " Set the input set for hash.\n\n"
1086 "set_fdir_input_set (port_id) "
1087 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1088 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1089 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1090 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1091 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1092 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1093 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1095 " Set the input set for FDir.\n\n"
1097 "flow validate {port_id}"
1098 " [group {group_id}] [priority {level}]"
1099 " [ingress] [egress]"
1100 " pattern {item} [/ {item} [...]] / end"
1101 " actions {action} [/ {action} [...]] / end\n"
1102 " Check whether a flow rule can be created.\n\n"
1104 "flow create {port_id}"
1105 " [group {group_id}] [priority {level}]"
1106 " [ingress] [egress]"
1107 " pattern {item} [/ {item} [...]] / end"
1108 " actions {action} [/ {action} [...]] / end\n"
1109 " Create a flow rule.\n\n"
1111 "flow destroy {port_id} rule {rule_id} [...]\n"
1112 " Destroy specific flow rules.\n\n"
1114 "flow flush {port_id}\n"
1115 " Destroy all flow rules.\n\n"
1117 "flow query {port_id} {rule_id} {action}\n"
1118 " Query an existing flow rule.\n\n"
1120 "flow list {port_id} [group {group_id}] [...]\n"
1121 " List existing flow rules sorted by priority,"
1122 " filtered by group identifiers.\n\n"
1124 "flow isolate {port_id} {boolean}\n"
1125 " Restrict ingress traffic to the defined"
1128 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1129 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1130 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1131 " Configure the VXLAN encapsulation for flows.\n\n"
1133 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1134 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1135 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1136 " eth-dst (eth-dst)\n"
1137 " Configure the VXLAN encapsulation for flows.\n\n"
1139 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1140 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1141 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1142 " eth-dst (eth-dst)\n"
1143 " Configure the VXLAN encapsulation for flows.\n\n"
1145 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1146 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1148 " Configure the NVGRE encapsulation for flows.\n\n"
1150 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1151 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1152 " eth-src (eth-src) eth-dst (eth-dst)\n"
1153 " Configure the NVGRE encapsulation for flows.\n\n"
1155 "set raw_encap {flow items}\n"
1156 " Configure the encapsulation with raw data.\n\n"
1158 "set raw_decap {flow items}\n"
1159 " Configure the decapsulation with raw data.\n\n"
1164 if (show_all || !strcmp(res->section, "traffic_management")) {
1168 "Traffic Management:\n"
1170 "show port tm cap (port_id)\n"
1171 " Display the port TM capability.\n\n"
1173 "show port tm level cap (port_id) (level_id)\n"
1174 " Display the port TM hierarchical level capability.\n\n"
1176 "show port tm node cap (port_id) (node_id)\n"
1177 " Display the port TM node capability.\n\n"
1179 "show port tm node type (port_id) (node_id)\n"
1180 " Display the port TM node type.\n\n"
1182 "show port tm node stats (port_id) (node_id) (clear)\n"
1183 " Display the port TM node stats.\n\n"
1185 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1186 "set port tm hierarchy default (port_id)\n"
1187 " Set default traffic Management hierarchy on a port\n\n"
1190 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1191 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1192 " (packet_length_adjust)\n"
1193 " Add port tm node private shaper profile.\n\n"
1195 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1196 " Delete port tm node private shaper profile.\n\n"
1198 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1199 " (shaper_profile_id)\n"
1200 " Add/update port tm node shared shaper.\n\n"
1202 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1203 " Delete port tm node shared shaper.\n\n"
1205 "set port tm node shaper profile (port_id) (node_id)"
1206 " (shaper_profile_id)\n"
1207 " Set port tm node shaper profile.\n\n"
1209 "add port tm node wred profile (port_id) (wred_profile_id)"
1210 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1211 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1212 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1213 " Add port tm node wred profile.\n\n"
1215 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1216 " Delete port tm node wred profile.\n\n"
1218 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1219 " (priority) (weight) (level_id) (shaper_profile_id)"
1220 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1221 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1222 " Add port tm nonleaf node.\n\n"
1224 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1225 " (priority) (weight) (level_id) (shaper_profile_id)"
1226 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1227 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1228 " Add port tm leaf node.\n\n"
1230 "del port tm node (port_id) (node_id)\n"
1231 " Delete port tm node.\n\n"
1233 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1234 " (priority) (weight)\n"
1235 " Set port tm node parent.\n\n"
1237 "suspend port tm node (port_id) (node_id)"
1238 " Suspend tm node.\n\n"
1240 "resume port tm node (port_id) (node_id)"
1241 " Resume tm node.\n\n"
1243 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1244 " Commit tm hierarchy.\n\n"
1246 "set port tm mark ip_ecn (port) (green) (yellow)"
1248 " Enables/Disables the traffic management marking"
1249 " for IP ECN (Explicit Congestion Notification)"
1250 " packets on a given port\n\n"
1252 "set port tm mark ip_dscp (port) (green) (yellow)"
1254 " Enables/Disables the traffic management marking"
1255 " on the port for IP dscp packets\n\n"
1257 "set port tm mark vlan_dei (port) (green) (yellow)"
1259 " Enables/Disables the traffic management marking"
1260 " on the port for VLAN packets with DEI enabled\n\n"
1264 if (show_all || !strcmp(res->section, "devices")) {
1268 "Device Operations:\n"
1270 "device detach (identifier)\n"
1271 " Detach device by identifier.\n\n"
1277 cmdline_parse_token_string_t cmd_help_long_help =
1278 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1280 cmdline_parse_token_string_t cmd_help_long_section =
1281 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1282 "all#control#display#config#"
1283 "ports#registers#filters#traffic_management#devices");
1285 cmdline_parse_inst_t cmd_help_long = {
1286 .f = cmd_help_long_parsed,
1288 .help_str = "help all|control|display|config|ports|register|"
1289 "filters|traffic_management|devices: "
1292 (void *)&cmd_help_long_help,
1293 (void *)&cmd_help_long_section,
1299 /* *** start/stop/close all ports *** */
1300 struct cmd_operate_port_result {
1301 cmdline_fixed_string_t keyword;
1302 cmdline_fixed_string_t name;
1303 cmdline_fixed_string_t value;
1306 static void cmd_operate_port_parsed(void *parsed_result,
1307 __rte_unused struct cmdline *cl,
1308 __rte_unused void *data)
1310 struct cmd_operate_port_result *res = parsed_result;
1312 if (!strcmp(res->name, "start"))
1313 start_port(RTE_PORT_ALL);
1314 else if (!strcmp(res->name, "stop"))
1315 stop_port(RTE_PORT_ALL);
1316 else if (!strcmp(res->name, "close"))
1317 close_port(RTE_PORT_ALL);
1318 else if (!strcmp(res->name, "reset"))
1319 reset_port(RTE_PORT_ALL);
1321 printf("Unknown parameter\n");
1324 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1325 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1327 cmdline_parse_token_string_t cmd_operate_port_all_port =
1328 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1329 "start#stop#close#reset");
1330 cmdline_parse_token_string_t cmd_operate_port_all_all =
1331 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1333 cmdline_parse_inst_t cmd_operate_port = {
1334 .f = cmd_operate_port_parsed,
1336 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1338 (void *)&cmd_operate_port_all_cmd,
1339 (void *)&cmd_operate_port_all_port,
1340 (void *)&cmd_operate_port_all_all,
1345 /* *** start/stop/close specific port *** */
1346 struct cmd_operate_specific_port_result {
1347 cmdline_fixed_string_t keyword;
1348 cmdline_fixed_string_t name;
1352 static void cmd_operate_specific_port_parsed(void *parsed_result,
1353 __rte_unused struct cmdline *cl,
1354 __rte_unused void *data)
1356 struct cmd_operate_specific_port_result *res = parsed_result;
1358 if (!strcmp(res->name, "start"))
1359 start_port(res->value);
1360 else if (!strcmp(res->name, "stop"))
1361 stop_port(res->value);
1362 else if (!strcmp(res->name, "close"))
1363 close_port(res->value);
1364 else if (!strcmp(res->name, "reset"))
1365 reset_port(res->value);
1367 printf("Unknown parameter\n");
1370 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1371 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1373 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1374 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1375 name, "start#stop#close#reset");
1376 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1377 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1380 cmdline_parse_inst_t cmd_operate_specific_port = {
1381 .f = cmd_operate_specific_port_parsed,
1383 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1385 (void *)&cmd_operate_specific_port_cmd,
1386 (void *)&cmd_operate_specific_port_port,
1387 (void *)&cmd_operate_specific_port_id,
1392 /* *** enable port setup (after attach) via iterator or event *** */
1393 struct cmd_set_port_setup_on_result {
1394 cmdline_fixed_string_t set;
1395 cmdline_fixed_string_t port;
1396 cmdline_fixed_string_t setup;
1397 cmdline_fixed_string_t on;
1398 cmdline_fixed_string_t mode;
1401 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1402 __rte_unused struct cmdline *cl,
1403 __rte_unused void *data)
1405 struct cmd_set_port_setup_on_result *res = parsed_result;
1407 if (strcmp(res->mode, "event") == 0)
1408 setup_on_probe_event = true;
1409 else if (strcmp(res->mode, "iterator") == 0)
1410 setup_on_probe_event = false;
1412 printf("Unknown mode\n");
1415 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1416 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1418 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1419 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1421 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1422 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1424 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1425 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1427 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1428 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1429 mode, "iterator#event");
1431 cmdline_parse_inst_t cmd_set_port_setup_on = {
1432 .f = cmd_set_port_setup_on_parsed,
1434 .help_str = "set port setup on iterator|event",
1436 (void *)&cmd_set_port_setup_on_set,
1437 (void *)&cmd_set_port_setup_on_port,
1438 (void *)&cmd_set_port_setup_on_setup,
1439 (void *)&cmd_set_port_setup_on_on,
1440 (void *)&cmd_set_port_setup_on_mode,
1445 /* *** attach a specified port *** */
1446 struct cmd_operate_attach_port_result {
1447 cmdline_fixed_string_t port;
1448 cmdline_fixed_string_t keyword;
1449 cmdline_multi_string_t identifier;
1452 static void cmd_operate_attach_port_parsed(void *parsed_result,
1453 __rte_unused struct cmdline *cl,
1454 __rte_unused void *data)
1456 struct cmd_operate_attach_port_result *res = parsed_result;
1458 if (!strcmp(res->keyword, "attach"))
1459 attach_port(res->identifier);
1461 printf("Unknown parameter\n");
1464 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1465 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1467 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1468 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1470 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1471 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1472 identifier, TOKEN_STRING_MULTI);
1474 cmdline_parse_inst_t cmd_operate_attach_port = {
1475 .f = cmd_operate_attach_port_parsed,
1477 .help_str = "port attach <identifier>: "
1478 "(identifier: pci address or virtual dev name)",
1480 (void *)&cmd_operate_attach_port_port,
1481 (void *)&cmd_operate_attach_port_keyword,
1482 (void *)&cmd_operate_attach_port_identifier,
1487 /* *** detach a specified port *** */
1488 struct cmd_operate_detach_port_result {
1489 cmdline_fixed_string_t port;
1490 cmdline_fixed_string_t keyword;
1494 static void cmd_operate_detach_port_parsed(void *parsed_result,
1495 __rte_unused struct cmdline *cl,
1496 __rte_unused void *data)
1498 struct cmd_operate_detach_port_result *res = parsed_result;
1500 if (!strcmp(res->keyword, "detach")) {
1501 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1502 detach_port_device(res->port_id);
1504 printf("Unknown parameter\n");
1508 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1509 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1511 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1512 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1514 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1515 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1518 cmdline_parse_inst_t cmd_operate_detach_port = {
1519 .f = cmd_operate_detach_port_parsed,
1521 .help_str = "port detach <port_id>",
1523 (void *)&cmd_operate_detach_port_port,
1524 (void *)&cmd_operate_detach_port_keyword,
1525 (void *)&cmd_operate_detach_port_port_id,
1530 /* *** detach device by identifier *** */
1531 struct cmd_operate_detach_device_result {
1532 cmdline_fixed_string_t device;
1533 cmdline_fixed_string_t keyword;
1534 cmdline_fixed_string_t identifier;
1537 static void cmd_operate_detach_device_parsed(void *parsed_result,
1538 __rte_unused struct cmdline *cl,
1539 __rte_unused void *data)
1541 struct cmd_operate_detach_device_result *res = parsed_result;
1543 if (!strcmp(res->keyword, "detach"))
1544 detach_devargs(res->identifier);
1546 printf("Unknown parameter\n");
1549 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1550 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1552 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1553 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1555 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1556 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1559 cmdline_parse_inst_t cmd_operate_detach_device = {
1560 .f = cmd_operate_detach_device_parsed,
1562 .help_str = "device detach <identifier>:"
1563 "(identifier: pci address or virtual dev name)",
1565 (void *)&cmd_operate_detach_device_device,
1566 (void *)&cmd_operate_detach_device_keyword,
1567 (void *)&cmd_operate_detach_device_identifier,
1571 /* *** configure speed for all ports *** */
1572 struct cmd_config_speed_all {
1573 cmdline_fixed_string_t port;
1574 cmdline_fixed_string_t keyword;
1575 cmdline_fixed_string_t all;
1576 cmdline_fixed_string_t item1;
1577 cmdline_fixed_string_t item2;
1578 cmdline_fixed_string_t value1;
1579 cmdline_fixed_string_t value2;
1583 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1588 if (!strcmp(duplexstr, "half")) {
1589 duplex = ETH_LINK_HALF_DUPLEX;
1590 } else if (!strcmp(duplexstr, "full")) {
1591 duplex = ETH_LINK_FULL_DUPLEX;
1592 } else if (!strcmp(duplexstr, "auto")) {
1593 duplex = ETH_LINK_FULL_DUPLEX;
1595 printf("Unknown duplex parameter\n");
1599 if (!strcmp(speedstr, "10")) {
1600 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1601 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1602 } else if (!strcmp(speedstr, "100")) {
1603 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1604 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1606 if (duplex != ETH_LINK_FULL_DUPLEX) {
1607 printf("Invalid speed/duplex parameters\n");
1610 if (!strcmp(speedstr, "1000")) {
1611 *speed = ETH_LINK_SPEED_1G;
1612 } else if (!strcmp(speedstr, "10000")) {
1613 *speed = ETH_LINK_SPEED_10G;
1614 } else if (!strcmp(speedstr, "25000")) {
1615 *speed = ETH_LINK_SPEED_25G;
1616 } else if (!strcmp(speedstr, "40000")) {
1617 *speed = ETH_LINK_SPEED_40G;
1618 } else if (!strcmp(speedstr, "50000")) {
1619 *speed = ETH_LINK_SPEED_50G;
1620 } else if (!strcmp(speedstr, "100000")) {
1621 *speed = ETH_LINK_SPEED_100G;
1622 } else if (!strcmp(speedstr, "auto")) {
1623 *speed = ETH_LINK_SPEED_AUTONEG;
1625 printf("Unknown speed parameter\n");
1634 cmd_config_speed_all_parsed(void *parsed_result,
1635 __rte_unused struct cmdline *cl,
1636 __rte_unused void *data)
1638 struct cmd_config_speed_all *res = parsed_result;
1639 uint32_t link_speed;
1642 if (!all_ports_stopped()) {
1643 printf("Please stop all ports first\n");
1647 if (parse_and_check_speed_duplex(res->value1, res->value2,
1651 RTE_ETH_FOREACH_DEV(pid) {
1652 ports[pid].dev_conf.link_speeds = link_speed;
1655 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1658 cmdline_parse_token_string_t cmd_config_speed_all_port =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1660 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1663 cmdline_parse_token_string_t cmd_config_speed_all_all =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1665 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1667 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1669 "10#100#1000#10000#25000#40000#50000#100000#auto");
1670 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1672 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1673 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1676 cmdline_parse_inst_t cmd_config_speed_all = {
1677 .f = cmd_config_speed_all_parsed,
1679 .help_str = "port config all speed "
1680 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1683 (void *)&cmd_config_speed_all_port,
1684 (void *)&cmd_config_speed_all_keyword,
1685 (void *)&cmd_config_speed_all_all,
1686 (void *)&cmd_config_speed_all_item1,
1687 (void *)&cmd_config_speed_all_value1,
1688 (void *)&cmd_config_speed_all_item2,
1689 (void *)&cmd_config_speed_all_value2,
1694 /* *** configure speed for specific port *** */
1695 struct cmd_config_speed_specific {
1696 cmdline_fixed_string_t port;
1697 cmdline_fixed_string_t keyword;
1699 cmdline_fixed_string_t item1;
1700 cmdline_fixed_string_t item2;
1701 cmdline_fixed_string_t value1;
1702 cmdline_fixed_string_t value2;
1706 cmd_config_speed_specific_parsed(void *parsed_result,
1707 __rte_unused struct cmdline *cl,
1708 __rte_unused void *data)
1710 struct cmd_config_speed_specific *res = parsed_result;
1711 uint32_t link_speed;
1713 if (!all_ports_stopped()) {
1714 printf("Please stop all ports first\n");
1718 if (port_id_is_invalid(res->id, ENABLED_WARN))
1721 if (parse_and_check_speed_duplex(res->value1, res->value2,
1725 ports[res->id].dev_conf.link_speeds = link_speed;
1727 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1731 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1734 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1735 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1737 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1738 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1739 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1740 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1742 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1743 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1744 "10#100#1000#10000#25000#40000#50000#100000#auto");
1745 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1746 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1748 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1749 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1752 cmdline_parse_inst_t cmd_config_speed_specific = {
1753 .f = cmd_config_speed_specific_parsed,
1755 .help_str = "port config <port_id> speed "
1756 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1759 (void *)&cmd_config_speed_specific_port,
1760 (void *)&cmd_config_speed_specific_keyword,
1761 (void *)&cmd_config_speed_specific_id,
1762 (void *)&cmd_config_speed_specific_item1,
1763 (void *)&cmd_config_speed_specific_value1,
1764 (void *)&cmd_config_speed_specific_item2,
1765 (void *)&cmd_config_speed_specific_value2,
1770 /* *** configure loopback for all ports *** */
1771 struct cmd_config_loopback_all {
1772 cmdline_fixed_string_t port;
1773 cmdline_fixed_string_t keyword;
1774 cmdline_fixed_string_t all;
1775 cmdline_fixed_string_t item;
1780 cmd_config_loopback_all_parsed(void *parsed_result,
1781 __rte_unused struct cmdline *cl,
1782 __rte_unused void *data)
1784 struct cmd_config_loopback_all *res = parsed_result;
1787 if (!all_ports_stopped()) {
1788 printf("Please stop all ports first\n");
1792 RTE_ETH_FOREACH_DEV(pid) {
1793 ports[pid].dev_conf.lpbk_mode = res->mode;
1796 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1799 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1801 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1802 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1804 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1805 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1806 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1807 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1809 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1810 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1812 cmdline_parse_inst_t cmd_config_loopback_all = {
1813 .f = cmd_config_loopback_all_parsed,
1815 .help_str = "port config all loopback <mode>",
1817 (void *)&cmd_config_loopback_all_port,
1818 (void *)&cmd_config_loopback_all_keyword,
1819 (void *)&cmd_config_loopback_all_all,
1820 (void *)&cmd_config_loopback_all_item,
1821 (void *)&cmd_config_loopback_all_mode,
1826 /* *** configure loopback for specific port *** */
1827 struct cmd_config_loopback_specific {
1828 cmdline_fixed_string_t port;
1829 cmdline_fixed_string_t keyword;
1831 cmdline_fixed_string_t item;
1836 cmd_config_loopback_specific_parsed(void *parsed_result,
1837 __rte_unused struct cmdline *cl,
1838 __rte_unused void *data)
1840 struct cmd_config_loopback_specific *res = parsed_result;
1842 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1845 if (!port_is_stopped(res->port_id)) {
1846 printf("Please stop port %u first\n", res->port_id);
1850 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1852 cmd_reconfig_device_queue(res->port_id, 1, 1);
1856 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1859 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1862 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1863 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1865 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1868 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1869 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1872 cmdline_parse_inst_t cmd_config_loopback_specific = {
1873 .f = cmd_config_loopback_specific_parsed,
1875 .help_str = "port config <port_id> loopback <mode>",
1877 (void *)&cmd_config_loopback_specific_port,
1878 (void *)&cmd_config_loopback_specific_keyword,
1879 (void *)&cmd_config_loopback_specific_id,
1880 (void *)&cmd_config_loopback_specific_item,
1881 (void *)&cmd_config_loopback_specific_mode,
1886 /* *** configure txq/rxq, txd/rxd *** */
1887 struct cmd_config_rx_tx {
1888 cmdline_fixed_string_t port;
1889 cmdline_fixed_string_t keyword;
1890 cmdline_fixed_string_t all;
1891 cmdline_fixed_string_t name;
1896 cmd_config_rx_tx_parsed(void *parsed_result,
1897 __rte_unused struct cmdline *cl,
1898 __rte_unused void *data)
1900 struct cmd_config_rx_tx *res = parsed_result;
1902 if (!all_ports_stopped()) {
1903 printf("Please stop all ports first\n");
1906 if (!strcmp(res->name, "rxq")) {
1907 if (!res->value && !nb_txq) {
1908 printf("Warning: Either rx or tx queues should be non zero\n");
1911 if (check_nb_rxq(res->value) != 0)
1913 nb_rxq = res->value;
1915 else if (!strcmp(res->name, "txq")) {
1916 if (!res->value && !nb_rxq) {
1917 printf("Warning: Either rx or tx queues should be non zero\n");
1920 if (check_nb_txq(res->value) != 0)
1922 nb_txq = res->value;
1924 else if (!strcmp(res->name, "rxd")) {
1925 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1926 printf("rxd %d invalid - must be > 0 && <= %d\n",
1927 res->value, RTE_TEST_RX_DESC_MAX);
1930 nb_rxd = res->value;
1931 } else if (!strcmp(res->name, "txd")) {
1932 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1933 printf("txd %d invalid - must be > 0 && <= %d\n",
1934 res->value, RTE_TEST_TX_DESC_MAX);
1937 nb_txd = res->value;
1939 printf("Unknown parameter\n");
1947 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1950 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1952 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1953 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1954 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1956 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1957 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1959 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1960 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1962 cmdline_parse_inst_t cmd_config_rx_tx = {
1963 .f = cmd_config_rx_tx_parsed,
1965 .help_str = "port config all rxq|txq|rxd|txd <value>",
1967 (void *)&cmd_config_rx_tx_port,
1968 (void *)&cmd_config_rx_tx_keyword,
1969 (void *)&cmd_config_rx_tx_all,
1970 (void *)&cmd_config_rx_tx_name,
1971 (void *)&cmd_config_rx_tx_value,
1976 /* *** config max packet length *** */
1977 struct cmd_config_max_pkt_len_result {
1978 cmdline_fixed_string_t port;
1979 cmdline_fixed_string_t keyword;
1980 cmdline_fixed_string_t all;
1981 cmdline_fixed_string_t name;
1986 cmd_config_max_pkt_len_parsed(void *parsed_result,
1987 __rte_unused struct cmdline *cl,
1988 __rte_unused void *data)
1990 struct cmd_config_max_pkt_len_result *res = parsed_result;
1993 if (!all_ports_stopped()) {
1994 printf("Please stop all ports first\n");
1998 RTE_ETH_FOREACH_DEV(pid) {
1999 struct rte_port *port = &ports[pid];
2000 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2002 if (!strcmp(res->name, "max-pkt-len")) {
2003 if (res->value < RTE_ETHER_MIN_LEN) {
2004 printf("max-pkt-len can not be less than %d\n",
2008 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2011 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2012 if (res->value > RTE_ETHER_MAX_LEN)
2013 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2015 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2016 port->dev_conf.rxmode.offloads = rx_offloads;
2018 printf("Unknown parameter\n");
2025 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2028 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2029 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2031 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2032 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2034 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2035 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2037 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2038 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2040 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2041 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2044 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2045 .f = cmd_config_max_pkt_len_parsed,
2047 .help_str = "port config all max-pkt-len <value>",
2049 (void *)&cmd_config_max_pkt_len_port,
2050 (void *)&cmd_config_max_pkt_len_keyword,
2051 (void *)&cmd_config_max_pkt_len_all,
2052 (void *)&cmd_config_max_pkt_len_name,
2053 (void *)&cmd_config_max_pkt_len_value,
2058 /* *** config max LRO aggregated packet size *** */
2059 struct cmd_config_max_lro_pkt_size_result {
2060 cmdline_fixed_string_t port;
2061 cmdline_fixed_string_t keyword;
2062 cmdline_fixed_string_t all;
2063 cmdline_fixed_string_t name;
2068 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2069 __rte_unused struct cmdline *cl,
2070 __rte_unused void *data)
2072 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2075 if (!all_ports_stopped()) {
2076 printf("Please stop all ports first\n");
2080 RTE_ETH_FOREACH_DEV(pid) {
2081 struct rte_port *port = &ports[pid];
2083 if (!strcmp(res->name, "max-lro-pkt-size")) {
2085 port->dev_conf.rxmode.max_lro_pkt_size)
2088 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2090 printf("Unknown parameter\n");
2097 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2100 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2101 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2103 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2104 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2106 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2107 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2109 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2110 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2111 name, "max-lro-pkt-size");
2112 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2113 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2116 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2117 .f = cmd_config_max_lro_pkt_size_parsed,
2119 .help_str = "port config all max-lro-pkt-size <value>",
2121 (void *)&cmd_config_max_lro_pkt_size_port,
2122 (void *)&cmd_config_max_lro_pkt_size_keyword,
2123 (void *)&cmd_config_max_lro_pkt_size_all,
2124 (void *)&cmd_config_max_lro_pkt_size_name,
2125 (void *)&cmd_config_max_lro_pkt_size_value,
2130 /* *** configure port MTU *** */
2131 struct cmd_config_mtu_result {
2132 cmdline_fixed_string_t port;
2133 cmdline_fixed_string_t keyword;
2134 cmdline_fixed_string_t mtu;
2140 cmd_config_mtu_parsed(void *parsed_result,
2141 __rte_unused struct cmdline *cl,
2142 __rte_unused void *data)
2144 struct cmd_config_mtu_result *res = parsed_result;
2146 if (res->value < RTE_ETHER_MIN_LEN) {
2147 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2150 port_mtu_set(res->port_id, res->value);
2153 cmdline_parse_token_string_t cmd_config_mtu_port =
2154 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2156 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2157 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2159 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2160 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2162 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2163 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2164 cmdline_parse_token_num_t cmd_config_mtu_value =
2165 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2167 cmdline_parse_inst_t cmd_config_mtu = {
2168 .f = cmd_config_mtu_parsed,
2170 .help_str = "port config mtu <port_id> <value>",
2172 (void *)&cmd_config_mtu_port,
2173 (void *)&cmd_config_mtu_keyword,
2174 (void *)&cmd_config_mtu_mtu,
2175 (void *)&cmd_config_mtu_port_id,
2176 (void *)&cmd_config_mtu_value,
2181 /* *** configure rx mode *** */
2182 struct cmd_config_rx_mode_flag {
2183 cmdline_fixed_string_t port;
2184 cmdline_fixed_string_t keyword;
2185 cmdline_fixed_string_t all;
2186 cmdline_fixed_string_t name;
2187 cmdline_fixed_string_t value;
2191 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2192 __rte_unused struct cmdline *cl,
2193 __rte_unused void *data)
2195 struct cmd_config_rx_mode_flag *res = parsed_result;
2197 if (!all_ports_stopped()) {
2198 printf("Please stop all ports first\n");
2202 if (!strcmp(res->name, "drop-en")) {
2203 if (!strcmp(res->value, "on"))
2205 else if (!strcmp(res->value, "off"))
2208 printf("Unknown parameter\n");
2212 printf("Unknown parameter\n");
2218 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2221 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2222 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2223 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2224 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2226 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2227 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2228 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2229 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2231 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2232 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2235 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2236 .f = cmd_config_rx_mode_flag_parsed,
2238 .help_str = "port config all drop-en on|off",
2240 (void *)&cmd_config_rx_mode_flag_port,
2241 (void *)&cmd_config_rx_mode_flag_keyword,
2242 (void *)&cmd_config_rx_mode_flag_all,
2243 (void *)&cmd_config_rx_mode_flag_name,
2244 (void *)&cmd_config_rx_mode_flag_value,
2249 /* *** configure rss *** */
2250 struct cmd_config_rss {
2251 cmdline_fixed_string_t port;
2252 cmdline_fixed_string_t keyword;
2253 cmdline_fixed_string_t all;
2254 cmdline_fixed_string_t name;
2255 cmdline_fixed_string_t value;
2259 cmd_config_rss_parsed(void *parsed_result,
2260 __rte_unused struct cmdline *cl,
2261 __rte_unused void *data)
2263 struct cmd_config_rss *res = parsed_result;
2264 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2265 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2266 int use_default = 0;
2267 int all_updated = 1;
2272 if (!strcmp(res->value, "all"))
2273 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2274 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2275 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2276 ETH_RSS_AH | ETH_RSS_PFCP;
2277 else if (!strcmp(res->value, "eth"))
2278 rss_conf.rss_hf = ETH_RSS_ETH;
2279 else if (!strcmp(res->value, "vlan"))
2280 rss_conf.rss_hf = ETH_RSS_VLAN;
2281 else if (!strcmp(res->value, "ip"))
2282 rss_conf.rss_hf = ETH_RSS_IP;
2283 else if (!strcmp(res->value, "udp"))
2284 rss_conf.rss_hf = ETH_RSS_UDP;
2285 else if (!strcmp(res->value, "tcp"))
2286 rss_conf.rss_hf = ETH_RSS_TCP;
2287 else if (!strcmp(res->value, "sctp"))
2288 rss_conf.rss_hf = ETH_RSS_SCTP;
2289 else if (!strcmp(res->value, "ether"))
2290 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2291 else if (!strcmp(res->value, "port"))
2292 rss_conf.rss_hf = ETH_RSS_PORT;
2293 else if (!strcmp(res->value, "vxlan"))
2294 rss_conf.rss_hf = ETH_RSS_VXLAN;
2295 else if (!strcmp(res->value, "geneve"))
2296 rss_conf.rss_hf = ETH_RSS_GENEVE;
2297 else if (!strcmp(res->value, "nvgre"))
2298 rss_conf.rss_hf = ETH_RSS_NVGRE;
2299 else if (!strcmp(res->value, "l3-src-only"))
2300 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2301 else if (!strcmp(res->value, "l3-dst-only"))
2302 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2303 else if (!strcmp(res->value, "l4-src-only"))
2304 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2305 else if (!strcmp(res->value, "l4-dst-only"))
2306 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2307 else if (!strcmp(res->value, "l2-src-only"))
2308 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2309 else if (!strcmp(res->value, "l2-dst-only"))
2310 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2311 else if (!strcmp(res->value, "l2tpv3"))
2312 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2313 else if (!strcmp(res->value, "esp"))
2314 rss_conf.rss_hf = ETH_RSS_ESP;
2315 else if (!strcmp(res->value, "ah"))
2316 rss_conf.rss_hf = ETH_RSS_AH;
2317 else if (!strcmp(res->value, "pfcp"))
2318 rss_conf.rss_hf = ETH_RSS_PFCP;
2319 else if (!strcmp(res->value, "none"))
2320 rss_conf.rss_hf = 0;
2321 else if (!strcmp(res->value, "default"))
2323 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2324 atoi(res->value) < 64)
2325 rss_conf.rss_hf = 1ULL << atoi(res->value);
2327 printf("Unknown parameter\n");
2330 rss_conf.rss_key = NULL;
2331 /* Update global configuration for RSS types. */
2332 RTE_ETH_FOREACH_DEV(i) {
2333 struct rte_eth_rss_conf local_rss_conf;
2335 ret = eth_dev_info_get_print_err(i, &dev_info);
2340 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2342 local_rss_conf = rss_conf;
2343 local_rss_conf.rss_hf = rss_conf.rss_hf &
2344 dev_info.flow_type_rss_offloads;
2345 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2346 printf("Port %u modified RSS hash function based on hardware support,"
2347 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2348 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2350 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2353 printf("Configuration of RSS hash at ethernet port %d "
2354 "failed with error (%d): %s.\n",
2355 i, -diag, strerror(-diag));
2358 if (all_updated && !use_default) {
2359 rss_hf = rss_conf.rss_hf;
2360 printf("rss_hf %#"PRIx64"\n", rss_hf);
2364 cmdline_parse_token_string_t cmd_config_rss_port =
2365 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2366 cmdline_parse_token_string_t cmd_config_rss_keyword =
2367 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2368 cmdline_parse_token_string_t cmd_config_rss_all =
2369 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2370 cmdline_parse_token_string_t cmd_config_rss_name =
2371 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2372 cmdline_parse_token_string_t cmd_config_rss_value =
2373 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2375 cmdline_parse_inst_t cmd_config_rss = {
2376 .f = cmd_config_rss_parsed,
2378 .help_str = "port config all rss "
2379 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2380 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|<flowtype_id>",
2382 (void *)&cmd_config_rss_port,
2383 (void *)&cmd_config_rss_keyword,
2384 (void *)&cmd_config_rss_all,
2385 (void *)&cmd_config_rss_name,
2386 (void *)&cmd_config_rss_value,
2391 /* *** configure rss hash key *** */
2392 struct cmd_config_rss_hash_key {
2393 cmdline_fixed_string_t port;
2394 cmdline_fixed_string_t config;
2396 cmdline_fixed_string_t rss_hash_key;
2397 cmdline_fixed_string_t rss_type;
2398 cmdline_fixed_string_t key;
2402 hexa_digit_to_value(char hexa_digit)
2404 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2405 return (uint8_t) (hexa_digit - '0');
2406 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2407 return (uint8_t) ((hexa_digit - 'a') + 10);
2408 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2409 return (uint8_t) ((hexa_digit - 'A') + 10);
2410 /* Invalid hexa digit */
2415 parse_and_check_key_hexa_digit(char *key, int idx)
2419 hexa_v = hexa_digit_to_value(key[idx]);
2421 printf("invalid key: character %c at position %d is not a "
2422 "valid hexa digit\n", key[idx], idx);
2427 cmd_config_rss_hash_key_parsed(void *parsed_result,
2428 __rte_unused struct cmdline *cl,
2429 __rte_unused void *data)
2431 struct cmd_config_rss_hash_key *res = parsed_result;
2432 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2436 struct rte_eth_dev_info dev_info;
2437 uint8_t hash_key_size;
2441 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2445 if (dev_info.hash_key_size > 0 &&
2446 dev_info.hash_key_size <= sizeof(hash_key))
2447 hash_key_size = dev_info.hash_key_size;
2449 printf("dev_info did not provide a valid hash key size\n");
2452 /* Check the length of the RSS hash key */
2453 key_len = strlen(res->key);
2454 if (key_len != (hash_key_size * 2)) {
2455 printf("key length: %d invalid - key must be a string of %d"
2456 " hexa-decimal numbers\n",
2457 (int) key_len, hash_key_size * 2);
2460 /* Translate RSS hash key into binary representation */
2461 for (i = 0; i < hash_key_size; i++) {
2462 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2465 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2468 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2470 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2474 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2475 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2476 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2477 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2479 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2480 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2481 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2482 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2483 rss_hash_key, "rss-hash-key");
2484 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2485 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2486 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2487 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2488 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2489 "ipv6-tcp-ex#ipv6-udp-ex#"
2490 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2491 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2492 "l2tpv3#esp#ah#pfcp");
2493 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2494 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2496 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2497 .f = cmd_config_rss_hash_key_parsed,
2499 .help_str = "port config <port_id> rss-hash-key "
2500 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2501 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2502 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2503 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2504 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2505 "l2tpv3|esp|ah|pfcp "
2506 "<string of hex digits (variable length, NIC dependent)>",
2508 (void *)&cmd_config_rss_hash_key_port,
2509 (void *)&cmd_config_rss_hash_key_config,
2510 (void *)&cmd_config_rss_hash_key_port_id,
2511 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2512 (void *)&cmd_config_rss_hash_key_rss_type,
2513 (void *)&cmd_config_rss_hash_key_value,
2518 /* *** configure port rxq/txq ring size *** */
2519 struct cmd_config_rxtx_ring_size {
2520 cmdline_fixed_string_t port;
2521 cmdline_fixed_string_t config;
2523 cmdline_fixed_string_t rxtxq;
2525 cmdline_fixed_string_t rsize;
2530 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2531 __rte_unused struct cmdline *cl,
2532 __rte_unused void *data)
2534 struct cmd_config_rxtx_ring_size *res = parsed_result;
2535 struct rte_port *port;
2538 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2541 if (res->portid == (portid_t)RTE_PORT_ALL) {
2542 printf("Invalid port id\n");
2546 port = &ports[res->portid];
2548 if (!strcmp(res->rxtxq, "rxq"))
2550 else if (!strcmp(res->rxtxq, "txq"))
2553 printf("Unknown parameter\n");
2557 if (isrx && rx_queue_id_is_invalid(res->qid))
2559 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2562 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2563 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2569 port->nb_rx_desc[res->qid] = res->size;
2571 port->nb_tx_desc[res->qid] = res->size;
2573 cmd_reconfig_device_queue(res->portid, 0, 1);
2576 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2577 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2579 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2580 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2582 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2583 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2585 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2586 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2588 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2589 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2591 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2592 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2593 rsize, "ring_size");
2594 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2595 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2598 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2599 .f = cmd_config_rxtx_ring_size_parsed,
2601 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2603 (void *)&cmd_config_rxtx_ring_size_port,
2604 (void *)&cmd_config_rxtx_ring_size_config,
2605 (void *)&cmd_config_rxtx_ring_size_portid,
2606 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2607 (void *)&cmd_config_rxtx_ring_size_qid,
2608 (void *)&cmd_config_rxtx_ring_size_rsize,
2609 (void *)&cmd_config_rxtx_ring_size_size,
2614 /* *** configure port rxq/txq start/stop *** */
2615 struct cmd_config_rxtx_queue {
2616 cmdline_fixed_string_t port;
2618 cmdline_fixed_string_t rxtxq;
2620 cmdline_fixed_string_t opname;
2624 cmd_config_rxtx_queue_parsed(void *parsed_result,
2625 __rte_unused struct cmdline *cl,
2626 __rte_unused void *data)
2628 struct cmd_config_rxtx_queue *res = parsed_result;
2633 if (test_done == 0) {
2634 printf("Please stop forwarding first\n");
2638 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2641 if (port_is_started(res->portid) != 1) {
2642 printf("Please start port %u first\n", res->portid);
2646 if (!strcmp(res->rxtxq, "rxq"))
2648 else if (!strcmp(res->rxtxq, "txq"))
2651 printf("Unknown parameter\n");
2655 if (isrx && rx_queue_id_is_invalid(res->qid))
2657 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2660 if (!strcmp(res->opname, "start"))
2662 else if (!strcmp(res->opname, "stop"))
2665 printf("Unknown parameter\n");
2669 if (isstart && isrx)
2670 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2671 else if (!isstart && isrx)
2672 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2673 else if (isstart && !isrx)
2674 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2676 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2678 if (ret == -ENOTSUP)
2679 printf("Function not supported in PMD driver\n");
2682 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2683 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2684 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2685 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2686 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2687 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2688 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2689 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2690 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2691 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2694 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2695 .f = cmd_config_rxtx_queue_parsed,
2697 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2699 (void *)&cmd_config_rxtx_queue_port,
2700 (void *)&cmd_config_rxtx_queue_portid,
2701 (void *)&cmd_config_rxtx_queue_rxtxq,
2702 (void *)&cmd_config_rxtx_queue_qid,
2703 (void *)&cmd_config_rxtx_queue_opname,
2708 /* *** configure port rxq/txq deferred start on/off *** */
2709 struct cmd_config_deferred_start_rxtx_queue {
2710 cmdline_fixed_string_t port;
2712 cmdline_fixed_string_t rxtxq;
2714 cmdline_fixed_string_t opname;
2715 cmdline_fixed_string_t state;
2719 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2720 __rte_unused struct cmdline *cl,
2721 __rte_unused void *data)
2723 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2724 struct rte_port *port;
2727 uint8_t needreconfig = 0;
2729 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2732 if (port_is_started(res->port_id) != 0) {
2733 printf("Please stop port %u first\n", res->port_id);
2737 port = &ports[res->port_id];
2739 isrx = !strcmp(res->rxtxq, "rxq");
2741 if (isrx && rx_queue_id_is_invalid(res->qid))
2743 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2746 ison = !strcmp(res->state, "on");
2748 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2749 port->rx_conf[res->qid].rx_deferred_start = ison;
2751 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2752 port->tx_conf[res->qid].tx_deferred_start = ison;
2757 cmd_reconfig_device_queue(res->port_id, 0, 1);
2760 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2761 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2763 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2764 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2766 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2767 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2769 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2770 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2772 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2773 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2774 opname, "deferred_start");
2775 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2776 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2779 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2780 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2782 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2784 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2785 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2786 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2787 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2788 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2789 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2794 /* *** configure port rxq/txq setup *** */
2795 struct cmd_setup_rxtx_queue {
2796 cmdline_fixed_string_t port;
2798 cmdline_fixed_string_t rxtxq;
2800 cmdline_fixed_string_t setup;
2803 /* Common CLI fields for queue setup */
2804 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2805 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2806 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2807 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2808 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2809 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2810 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2811 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2812 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2813 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2816 cmd_setup_rxtx_queue_parsed(
2817 void *parsed_result,
2818 __rte_unused struct cmdline *cl,
2819 __rte_unused void *data)
2821 struct cmd_setup_rxtx_queue *res = parsed_result;
2822 struct rte_port *port;
2823 struct rte_mempool *mp;
2824 unsigned int socket_id;
2828 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2831 if (res->portid == (portid_t)RTE_PORT_ALL) {
2832 printf("Invalid port id\n");
2836 if (!strcmp(res->rxtxq, "rxq"))
2838 else if (!strcmp(res->rxtxq, "txq"))
2841 printf("Unknown parameter\n");
2845 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2846 printf("Invalid rx queue\n");
2848 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2849 printf("Invalid tx queue\n");
2853 port = &ports[res->portid];
2855 socket_id = rxring_numa[res->portid];
2856 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2857 socket_id = port->socket_id;
2859 mp = mbuf_pool_find(socket_id);
2861 printf("Failed to setup RX queue: "
2862 "No mempool allocation"
2863 " on the socket %d\n",
2864 rxring_numa[res->portid]);
2867 ret = rte_eth_rx_queue_setup(res->portid,
2869 port->nb_rx_desc[res->qid],
2871 &port->rx_conf[res->qid],
2874 printf("Failed to setup RX queue\n");
2876 socket_id = txring_numa[res->portid];
2877 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2878 socket_id = port->socket_id;
2880 ret = rte_eth_tx_queue_setup(res->portid,
2882 port->nb_tx_desc[res->qid],
2884 &port->tx_conf[res->qid]);
2886 printf("Failed to setup TX queue\n");
2890 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2891 .f = cmd_setup_rxtx_queue_parsed,
2893 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2895 (void *)&cmd_setup_rxtx_queue_port,
2896 (void *)&cmd_setup_rxtx_queue_portid,
2897 (void *)&cmd_setup_rxtx_queue_rxtxq,
2898 (void *)&cmd_setup_rxtx_queue_qid,
2899 (void *)&cmd_setup_rxtx_queue_setup,
2905 /* *** Configure RSS RETA *** */
2906 struct cmd_config_rss_reta {
2907 cmdline_fixed_string_t port;
2908 cmdline_fixed_string_t keyword;
2910 cmdline_fixed_string_t name;
2911 cmdline_fixed_string_t list_name;
2912 cmdline_fixed_string_t list_of_items;
2916 parse_reta_config(const char *str,
2917 struct rte_eth_rss_reta_entry64 *reta_conf,
2918 uint16_t nb_entries)
2922 uint16_t hash_index, idx, shift;
2925 const char *p, *p0 = str;
2932 unsigned long int_fld[_NUM_FLD];
2933 char *str_fld[_NUM_FLD];
2935 while ((p = strchr(p0,'(')) != NULL) {
2937 if((p0 = strchr(p,')')) == NULL)
2941 if(size >= sizeof(s))
2944 snprintf(s, sizeof(s), "%.*s", size, p);
2945 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2947 for (i = 0; i < _NUM_FLD; i++) {
2949 int_fld[i] = strtoul(str_fld[i], &end, 0);
2950 if (errno != 0 || end == str_fld[i] ||
2955 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2956 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2958 if (hash_index >= nb_entries) {
2959 printf("Invalid RETA hash index=%d\n", hash_index);
2963 idx = hash_index / RTE_RETA_GROUP_SIZE;
2964 shift = hash_index % RTE_RETA_GROUP_SIZE;
2965 reta_conf[idx].mask |= (1ULL << shift);
2966 reta_conf[idx].reta[shift] = nb_queue;
2973 cmd_set_rss_reta_parsed(void *parsed_result,
2974 __rte_unused struct cmdline *cl,
2975 __rte_unused void *data)
2978 struct rte_eth_dev_info dev_info;
2979 struct rte_eth_rss_reta_entry64 reta_conf[8];
2980 struct cmd_config_rss_reta *res = parsed_result;
2982 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2986 if (dev_info.reta_size == 0) {
2987 printf("Redirection table size is 0 which is "
2988 "invalid for RSS\n");
2991 printf("The reta size of port %d is %u\n",
2992 res->port_id, dev_info.reta_size);
2993 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2994 printf("Currently do not support more than %u entries of "
2995 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2999 memset(reta_conf, 0, sizeof(reta_conf));
3000 if (!strcmp(res->list_name, "reta")) {
3001 if (parse_reta_config(res->list_of_items, reta_conf,
3002 dev_info.reta_size)) {
3003 printf("Invalid RSS Redirection Table "
3004 "config entered\n");
3007 ret = rte_eth_dev_rss_reta_update(res->port_id,
3008 reta_conf, dev_info.reta_size);
3010 printf("Bad redirection table parameter, "
3011 "return code = %d \n", ret);
3015 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3016 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3017 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3018 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3019 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3020 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3021 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3022 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3023 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3024 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3025 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3026 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3028 cmdline_parse_inst_t cmd_config_rss_reta = {
3029 .f = cmd_set_rss_reta_parsed,
3031 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3033 (void *)&cmd_config_rss_reta_port,
3034 (void *)&cmd_config_rss_reta_keyword,
3035 (void *)&cmd_config_rss_reta_port_id,
3036 (void *)&cmd_config_rss_reta_name,
3037 (void *)&cmd_config_rss_reta_list_name,
3038 (void *)&cmd_config_rss_reta_list_of_items,
3043 /* *** SHOW PORT RETA INFO *** */
3044 struct cmd_showport_reta {
3045 cmdline_fixed_string_t show;
3046 cmdline_fixed_string_t port;
3048 cmdline_fixed_string_t rss;
3049 cmdline_fixed_string_t reta;
3051 cmdline_fixed_string_t list_of_items;
3055 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3056 uint16_t nb_entries,
3060 const char *p, *p0 = str;
3065 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3066 RTE_RETA_GROUP_SIZE;
3069 p = strchr(p0, '(');
3073 p0 = strchr(p, ')');
3077 if (size >= sizeof(s)) {
3078 printf("The string size exceeds the internal buffer size\n");
3081 snprintf(s, sizeof(s), "%.*s", size, p);
3082 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3083 if (ret <= 0 || ret != num) {
3084 printf("The bits of masks do not match the number of "
3085 "reta entries: %u\n", num);
3088 for (i = 0; i < ret; i++)
3089 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3095 cmd_showport_reta_parsed(void *parsed_result,
3096 __rte_unused struct cmdline *cl,
3097 __rte_unused void *data)
3099 struct cmd_showport_reta *res = parsed_result;
3100 struct rte_eth_rss_reta_entry64 reta_conf[8];
3101 struct rte_eth_dev_info dev_info;
3102 uint16_t max_reta_size;
3105 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3109 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3110 if (res->size == 0 || res->size > max_reta_size) {
3111 printf("Invalid redirection table size: %u (1-%u)\n",
3112 res->size, max_reta_size);
3116 memset(reta_conf, 0, sizeof(reta_conf));
3117 if (showport_parse_reta_config(reta_conf, res->size,
3118 res->list_of_items) < 0) {
3119 printf("Invalid string: %s for reta masks\n",
3120 res->list_of_items);
3123 port_rss_reta_info(res->port_id, reta_conf, res->size);
3126 cmdline_parse_token_string_t cmd_showport_reta_show =
3127 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3128 cmdline_parse_token_string_t cmd_showport_reta_port =
3129 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3130 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3131 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3132 cmdline_parse_token_string_t cmd_showport_reta_rss =
3133 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3134 cmdline_parse_token_string_t cmd_showport_reta_reta =
3135 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3136 cmdline_parse_token_num_t cmd_showport_reta_size =
3137 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3138 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3139 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3140 list_of_items, NULL);
3142 cmdline_parse_inst_t cmd_showport_reta = {
3143 .f = cmd_showport_reta_parsed,
3145 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3147 (void *)&cmd_showport_reta_show,
3148 (void *)&cmd_showport_reta_port,
3149 (void *)&cmd_showport_reta_port_id,
3150 (void *)&cmd_showport_reta_rss,
3151 (void *)&cmd_showport_reta_reta,
3152 (void *)&cmd_showport_reta_size,
3153 (void *)&cmd_showport_reta_list_of_items,
3158 /* *** Show RSS hash configuration *** */
3159 struct cmd_showport_rss_hash {
3160 cmdline_fixed_string_t show;
3161 cmdline_fixed_string_t port;
3163 cmdline_fixed_string_t rss_hash;
3164 cmdline_fixed_string_t rss_type;
3165 cmdline_fixed_string_t key; /* optional argument */
3168 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3169 __rte_unused struct cmdline *cl,
3172 struct cmd_showport_rss_hash *res = parsed_result;
3174 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3177 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3178 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3179 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3180 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3181 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3182 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3183 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3184 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3186 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3187 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3189 cmdline_parse_inst_t cmd_showport_rss_hash = {
3190 .f = cmd_showport_rss_hash_parsed,
3192 .help_str = "show port <port_id> rss-hash",
3194 (void *)&cmd_showport_rss_hash_show,
3195 (void *)&cmd_showport_rss_hash_port,
3196 (void *)&cmd_showport_rss_hash_port_id,
3197 (void *)&cmd_showport_rss_hash_rss_hash,
3202 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3203 .f = cmd_showport_rss_hash_parsed,
3205 .help_str = "show port <port_id> rss-hash key",
3207 (void *)&cmd_showport_rss_hash_show,
3208 (void *)&cmd_showport_rss_hash_port,
3209 (void *)&cmd_showport_rss_hash_port_id,
3210 (void *)&cmd_showport_rss_hash_rss_hash,
3211 (void *)&cmd_showport_rss_hash_rss_key,
3216 /* *** Configure DCB *** */
3217 struct cmd_config_dcb {
3218 cmdline_fixed_string_t port;
3219 cmdline_fixed_string_t config;
3221 cmdline_fixed_string_t dcb;
3222 cmdline_fixed_string_t vt;
3223 cmdline_fixed_string_t vt_en;
3225 cmdline_fixed_string_t pfc;
3226 cmdline_fixed_string_t pfc_en;
3230 cmd_config_dcb_parsed(void *parsed_result,
3231 __rte_unused struct cmdline *cl,
3232 __rte_unused void *data)
3234 struct cmd_config_dcb *res = parsed_result;
3235 portid_t port_id = res->port_id;
3236 struct rte_port *port;
3240 port = &ports[port_id];
3241 /** Check if the port is not started **/
3242 if (port->port_status != RTE_PORT_STOPPED) {
3243 printf("Please stop port %d first\n", port_id);
3247 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3248 printf("The invalid number of traffic class,"
3249 " only 4 or 8 allowed.\n");
3253 if (nb_fwd_lcores < res->num_tcs) {
3254 printf("nb_cores shouldn't be less than number of TCs.\n");
3257 if (!strncmp(res->pfc_en, "on", 2))
3262 /* DCB in VT mode */
3263 if (!strncmp(res->vt_en, "on", 2))
3264 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3265 (enum rte_eth_nb_tcs)res->num_tcs,
3268 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3269 (enum rte_eth_nb_tcs)res->num_tcs,
3274 printf("Cannot initialize network ports.\n");
3278 cmd_reconfig_device_queue(port_id, 1, 1);
3281 cmdline_parse_token_string_t cmd_config_dcb_port =
3282 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3283 cmdline_parse_token_string_t cmd_config_dcb_config =
3284 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3285 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3286 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3287 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3288 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3289 cmdline_parse_token_string_t cmd_config_dcb_vt =
3290 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3291 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3292 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3293 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3294 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3295 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3296 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3297 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3298 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3300 cmdline_parse_inst_t cmd_config_dcb = {
3301 .f = cmd_config_dcb_parsed,
3303 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3305 (void *)&cmd_config_dcb_port,
3306 (void *)&cmd_config_dcb_config,
3307 (void *)&cmd_config_dcb_port_id,
3308 (void *)&cmd_config_dcb_dcb,
3309 (void *)&cmd_config_dcb_vt,
3310 (void *)&cmd_config_dcb_vt_en,
3311 (void *)&cmd_config_dcb_num_tcs,
3312 (void *)&cmd_config_dcb_pfc,
3313 (void *)&cmd_config_dcb_pfc_en,
3318 /* *** configure number of packets per burst *** */
3319 struct cmd_config_burst {
3320 cmdline_fixed_string_t port;
3321 cmdline_fixed_string_t keyword;
3322 cmdline_fixed_string_t all;
3323 cmdline_fixed_string_t name;
3328 cmd_config_burst_parsed(void *parsed_result,
3329 __rte_unused struct cmdline *cl,
3330 __rte_unused void *data)
3332 struct cmd_config_burst *res = parsed_result;
3333 struct rte_eth_dev_info dev_info;
3334 uint16_t rec_nb_pkts;
3337 if (!all_ports_stopped()) {
3338 printf("Please stop all ports first\n");
3342 if (!strcmp(res->name, "burst")) {
3343 if (res->value == 0) {
3344 /* If user gives a value of zero, query the PMD for
3345 * its recommended Rx burst size. Testpmd uses a single
3346 * size for all ports, so assume all ports are the same
3347 * NIC model and use the values from Port 0.
3349 ret = eth_dev_info_get_print_err(0, &dev_info);
3353 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3355 if (rec_nb_pkts == 0) {
3356 printf("PMD does not recommend a burst size.\n"
3357 "User provided value must be between"
3358 " 1 and %d\n", MAX_PKT_BURST);
3360 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3361 printf("PMD recommended burst size of %d"
3362 " exceeds maximum value of %d\n",
3363 rec_nb_pkts, MAX_PKT_BURST);
3366 printf("Using PMD-provided burst value of %d\n",
3368 nb_pkt_per_burst = rec_nb_pkts;
3369 } else if (res->value > MAX_PKT_BURST) {
3370 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3373 nb_pkt_per_burst = res->value;
3375 printf("Unknown parameter\n");
3381 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3384 cmdline_parse_token_string_t cmd_config_burst_port =
3385 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3386 cmdline_parse_token_string_t cmd_config_burst_keyword =
3387 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3388 cmdline_parse_token_string_t cmd_config_burst_all =
3389 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3390 cmdline_parse_token_string_t cmd_config_burst_name =
3391 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3392 cmdline_parse_token_num_t cmd_config_burst_value =
3393 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3395 cmdline_parse_inst_t cmd_config_burst = {
3396 .f = cmd_config_burst_parsed,
3398 .help_str = "port config all burst <value>",
3400 (void *)&cmd_config_burst_port,
3401 (void *)&cmd_config_burst_keyword,
3402 (void *)&cmd_config_burst_all,
3403 (void *)&cmd_config_burst_name,
3404 (void *)&cmd_config_burst_value,
3409 /* *** configure rx/tx queues *** */
3410 struct cmd_config_thresh {
3411 cmdline_fixed_string_t port;
3412 cmdline_fixed_string_t keyword;
3413 cmdline_fixed_string_t all;
3414 cmdline_fixed_string_t name;
3419 cmd_config_thresh_parsed(void *parsed_result,
3420 __rte_unused struct cmdline *cl,
3421 __rte_unused void *data)
3423 struct cmd_config_thresh *res = parsed_result;
3425 if (!all_ports_stopped()) {
3426 printf("Please stop all ports first\n");
3430 if (!strcmp(res->name, "txpt"))
3431 tx_pthresh = res->value;
3432 else if(!strcmp(res->name, "txht"))
3433 tx_hthresh = res->value;
3434 else if(!strcmp(res->name, "txwt"))
3435 tx_wthresh = res->value;
3436 else if(!strcmp(res->name, "rxpt"))
3437 rx_pthresh = res->value;
3438 else if(!strcmp(res->name, "rxht"))
3439 rx_hthresh = res->value;
3440 else if(!strcmp(res->name, "rxwt"))
3441 rx_wthresh = res->value;
3443 printf("Unknown parameter\n");
3449 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3452 cmdline_parse_token_string_t cmd_config_thresh_port =
3453 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3454 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3455 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3456 cmdline_parse_token_string_t cmd_config_thresh_all =
3457 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3458 cmdline_parse_token_string_t cmd_config_thresh_name =
3459 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3460 "txpt#txht#txwt#rxpt#rxht#rxwt");
3461 cmdline_parse_token_num_t cmd_config_thresh_value =
3462 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3464 cmdline_parse_inst_t cmd_config_thresh = {
3465 .f = cmd_config_thresh_parsed,
3467 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3469 (void *)&cmd_config_thresh_port,
3470 (void *)&cmd_config_thresh_keyword,
3471 (void *)&cmd_config_thresh_all,
3472 (void *)&cmd_config_thresh_name,
3473 (void *)&cmd_config_thresh_value,
3478 /* *** configure free/rs threshold *** */
3479 struct cmd_config_threshold {
3480 cmdline_fixed_string_t port;
3481 cmdline_fixed_string_t keyword;
3482 cmdline_fixed_string_t all;
3483 cmdline_fixed_string_t name;
3488 cmd_config_threshold_parsed(void *parsed_result,
3489 __rte_unused struct cmdline *cl,
3490 __rte_unused void *data)
3492 struct cmd_config_threshold *res = parsed_result;
3494 if (!all_ports_stopped()) {
3495 printf("Please stop all ports first\n");
3499 if (!strcmp(res->name, "txfreet"))
3500 tx_free_thresh = res->value;
3501 else if (!strcmp(res->name, "txrst"))
3502 tx_rs_thresh = res->value;
3503 else if (!strcmp(res->name, "rxfreet"))
3504 rx_free_thresh = res->value;
3506 printf("Unknown parameter\n");
3512 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3515 cmdline_parse_token_string_t cmd_config_threshold_port =
3516 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3517 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3518 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3520 cmdline_parse_token_string_t cmd_config_threshold_all =
3521 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3522 cmdline_parse_token_string_t cmd_config_threshold_name =
3523 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3524 "txfreet#txrst#rxfreet");
3525 cmdline_parse_token_num_t cmd_config_threshold_value =
3526 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3528 cmdline_parse_inst_t cmd_config_threshold = {
3529 .f = cmd_config_threshold_parsed,
3531 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3533 (void *)&cmd_config_threshold_port,
3534 (void *)&cmd_config_threshold_keyword,
3535 (void *)&cmd_config_threshold_all,
3536 (void *)&cmd_config_threshold_name,
3537 (void *)&cmd_config_threshold_value,
3543 struct cmd_stop_result {
3544 cmdline_fixed_string_t stop;
3547 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3548 __rte_unused struct cmdline *cl,
3549 __rte_unused void *data)
3551 stop_packet_forwarding();
3554 cmdline_parse_token_string_t cmd_stop_stop =
3555 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3557 cmdline_parse_inst_t cmd_stop = {
3558 .f = cmd_stop_parsed,
3560 .help_str = "stop: Stop packet forwarding",
3562 (void *)&cmd_stop_stop,
3567 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3570 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3571 unsigned int *parsed_items, int check_unique_values)
3573 unsigned int nb_item;
3581 * First parse all items in the list and store their value.
3586 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3588 if ((c >= '0') && (c <= '9')) {
3589 value = (unsigned int) (value * 10 + (c - '0'));
3594 printf("character %c is not a decimal digit\n", c);
3598 printf("No valid value before comma\n");
3601 if (nb_item < max_items) {
3602 parsed_items[nb_item] = value;
3608 if (nb_item >= max_items) {
3609 printf("Number of %s = %u > %u (maximum items)\n",
3610 item_name, nb_item + 1, max_items);
3613 parsed_items[nb_item++] = value;
3614 if (! check_unique_values)
3618 * Then, check that all values in the list are differents.
3619 * No optimization here...
3621 for (i = 0; i < nb_item; i++) {
3622 for (j = i + 1; j < nb_item; j++) {
3623 if (parsed_items[j] == parsed_items[i]) {
3624 printf("duplicated %s %u at index %u and %u\n",
3625 item_name, parsed_items[i], i, j);
3633 struct cmd_set_list_result {
3634 cmdline_fixed_string_t cmd_keyword;
3635 cmdline_fixed_string_t list_name;
3636 cmdline_fixed_string_t list_of_items;
3639 static void cmd_set_list_parsed(void *parsed_result,
3640 __rte_unused struct cmdline *cl,
3641 __rte_unused void *data)
3643 struct cmd_set_list_result *res;
3645 unsigned int lcorelist[RTE_MAX_LCORE];
3646 unsigned int portlist[RTE_MAX_ETHPORTS];
3648 unsigned int nb_item;
3650 if (test_done == 0) {
3651 printf("Please stop forwarding first\n");
3655 res = parsed_result;
3656 if (!strcmp(res->list_name, "corelist")) {
3657 nb_item = parse_item_list(res->list_of_items, "core",
3659 parsed_items.lcorelist, 1);
3661 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3666 if (!strcmp(res->list_name, "portlist")) {
3667 nb_item = parse_item_list(res->list_of_items, "port",
3669 parsed_items.portlist, 1);
3671 set_fwd_ports_list(parsed_items.portlist, nb_item);
3677 cmdline_parse_token_string_t cmd_set_list_keyword =
3678 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3680 cmdline_parse_token_string_t cmd_set_list_name =
3681 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3682 "corelist#portlist");
3683 cmdline_parse_token_string_t cmd_set_list_of_items =
3684 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3687 cmdline_parse_inst_t cmd_set_fwd_list = {
3688 .f = cmd_set_list_parsed,
3690 .help_str = "set corelist|portlist <list0[,list1]*>",
3692 (void *)&cmd_set_list_keyword,
3693 (void *)&cmd_set_list_name,
3694 (void *)&cmd_set_list_of_items,
3699 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3701 struct cmd_setmask_result {
3702 cmdline_fixed_string_t set;
3703 cmdline_fixed_string_t mask;
3707 static void cmd_set_mask_parsed(void *parsed_result,
3708 __rte_unused struct cmdline *cl,
3709 __rte_unused void *data)
3711 struct cmd_setmask_result *res = parsed_result;
3713 if (test_done == 0) {
3714 printf("Please stop forwarding first\n");
3717 if (!strcmp(res->mask, "coremask")) {
3718 set_fwd_lcores_mask(res->hexavalue);
3720 } else if (!strcmp(res->mask, "portmask")) {
3721 set_fwd_ports_mask(res->hexavalue);
3726 cmdline_parse_token_string_t cmd_setmask_set =
3727 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3728 cmdline_parse_token_string_t cmd_setmask_mask =
3729 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3730 "coremask#portmask");
3731 cmdline_parse_token_num_t cmd_setmask_value =
3732 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3734 cmdline_parse_inst_t cmd_set_fwd_mask = {
3735 .f = cmd_set_mask_parsed,
3737 .help_str = "set coremask|portmask <hexadecimal value>",
3739 (void *)&cmd_setmask_set,
3740 (void *)&cmd_setmask_mask,
3741 (void *)&cmd_setmask_value,
3747 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3749 struct cmd_set_result {
3750 cmdline_fixed_string_t set;
3751 cmdline_fixed_string_t what;
3755 static void cmd_set_parsed(void *parsed_result,
3756 __rte_unused struct cmdline *cl,
3757 __rte_unused void *data)
3759 struct cmd_set_result *res = parsed_result;
3760 if (!strcmp(res->what, "nbport")) {
3761 set_fwd_ports_number(res->value);
3763 } else if (!strcmp(res->what, "nbcore")) {
3764 set_fwd_lcores_number(res->value);
3766 } else if (!strcmp(res->what, "burst"))
3767 set_nb_pkt_per_burst(res->value);
3768 else if (!strcmp(res->what, "verbose"))
3769 set_verbose_level(res->value);
3772 cmdline_parse_token_string_t cmd_set_set =
3773 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3774 cmdline_parse_token_string_t cmd_set_what =
3775 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3776 "nbport#nbcore#burst#verbose");
3777 cmdline_parse_token_num_t cmd_set_value =
3778 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3780 cmdline_parse_inst_t cmd_set_numbers = {
3781 .f = cmd_set_parsed,
3783 .help_str = "set nbport|nbcore|burst|verbose <value>",
3785 (void *)&cmd_set_set,
3786 (void *)&cmd_set_what,
3787 (void *)&cmd_set_value,
3792 /* *** SET LOG LEVEL CONFIGURATION *** */
3794 struct cmd_set_log_result {
3795 cmdline_fixed_string_t set;
3796 cmdline_fixed_string_t log;
3797 cmdline_fixed_string_t type;
3802 cmd_set_log_parsed(void *parsed_result,
3803 __rte_unused struct cmdline *cl,
3804 __rte_unused void *data)
3806 struct cmd_set_log_result *res;
3809 res = parsed_result;
3810 if (!strcmp(res->type, "global"))
3811 rte_log_set_global_level(res->level);
3813 ret = rte_log_set_level_regexp(res->type, res->level);
3815 printf("Unable to set log level\n");
3819 cmdline_parse_token_string_t cmd_set_log_set =
3820 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3821 cmdline_parse_token_string_t cmd_set_log_log =
3822 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3823 cmdline_parse_token_string_t cmd_set_log_type =
3824 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3825 cmdline_parse_token_num_t cmd_set_log_level =
3826 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3828 cmdline_parse_inst_t cmd_set_log = {
3829 .f = cmd_set_log_parsed,
3831 .help_str = "set log global|<type> <level>",
3833 (void *)&cmd_set_log_set,
3834 (void *)&cmd_set_log_log,
3835 (void *)&cmd_set_log_type,
3836 (void *)&cmd_set_log_level,
3841 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3843 struct cmd_set_txpkts_result {
3844 cmdline_fixed_string_t cmd_keyword;
3845 cmdline_fixed_string_t txpkts;
3846 cmdline_fixed_string_t seg_lengths;
3850 cmd_set_txpkts_parsed(void *parsed_result,
3851 __rte_unused struct cmdline *cl,
3852 __rte_unused void *data)
3854 struct cmd_set_txpkts_result *res;
3855 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3856 unsigned int nb_segs;
3858 res = parsed_result;
3859 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3860 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3862 set_tx_pkt_segments(seg_lengths, nb_segs);
3865 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3866 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3867 cmd_keyword, "set");
3868 cmdline_parse_token_string_t cmd_set_txpkts_name =
3869 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3871 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3872 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3875 cmdline_parse_inst_t cmd_set_txpkts = {
3876 .f = cmd_set_txpkts_parsed,
3878 .help_str = "set txpkts <len0[,len1]*>",
3880 (void *)&cmd_set_txpkts_keyword,
3881 (void *)&cmd_set_txpkts_name,
3882 (void *)&cmd_set_txpkts_lengths,
3887 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3889 struct cmd_set_txsplit_result {
3890 cmdline_fixed_string_t cmd_keyword;
3891 cmdline_fixed_string_t txsplit;
3892 cmdline_fixed_string_t mode;
3896 cmd_set_txsplit_parsed(void *parsed_result,
3897 __rte_unused struct cmdline *cl,
3898 __rte_unused void *data)
3900 struct cmd_set_txsplit_result *res;
3902 res = parsed_result;
3903 set_tx_pkt_split(res->mode);
3906 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3907 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3908 cmd_keyword, "set");
3909 cmdline_parse_token_string_t cmd_set_txsplit_name =
3910 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3911 txsplit, "txsplit");
3912 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3913 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3916 cmdline_parse_inst_t cmd_set_txsplit = {
3917 .f = cmd_set_txsplit_parsed,
3919 .help_str = "set txsplit on|off|rand",
3921 (void *)&cmd_set_txsplit_keyword,
3922 (void *)&cmd_set_txsplit_name,
3923 (void *)&cmd_set_txsplit_mode,
3928 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3929 struct cmd_rx_vlan_filter_all_result {
3930 cmdline_fixed_string_t rx_vlan;
3931 cmdline_fixed_string_t what;
3932 cmdline_fixed_string_t all;
3937 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3938 __rte_unused struct cmdline *cl,
3939 __rte_unused void *data)
3941 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3943 if (!strcmp(res->what, "add"))
3944 rx_vlan_all_filter_set(res->port_id, 1);
3946 rx_vlan_all_filter_set(res->port_id, 0);
3949 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3950 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3951 rx_vlan, "rx_vlan");
3952 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3953 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3955 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3956 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3958 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3959 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3962 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3963 .f = cmd_rx_vlan_filter_all_parsed,
3965 .help_str = "rx_vlan add|rm all <port_id>: "
3966 "Add/Remove all identifiers to/from the set of VLAN "
3967 "identifiers filtered by a port",
3969 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3970 (void *)&cmd_rx_vlan_filter_all_what,
3971 (void *)&cmd_rx_vlan_filter_all_all,
3972 (void *)&cmd_rx_vlan_filter_all_portid,
3977 /* *** VLAN OFFLOAD SET ON A PORT *** */
3978 struct cmd_vlan_offload_result {
3979 cmdline_fixed_string_t vlan;
3980 cmdline_fixed_string_t set;
3981 cmdline_fixed_string_t vlan_type;
3982 cmdline_fixed_string_t what;
3983 cmdline_fixed_string_t on;
3984 cmdline_fixed_string_t port_id;
3988 cmd_vlan_offload_parsed(void *parsed_result,
3989 __rte_unused struct cmdline *cl,
3990 __rte_unused void *data)
3993 struct cmd_vlan_offload_result *res = parsed_result;
3996 portid_t port_id = 0;
4000 len = strnlen(str, STR_TOKEN_SIZE);
4002 /* Get port_id first */
4010 tmp = strtoul(str, NULL, 0);
4011 /* If port_id greater that what portid_t can represent, return */
4012 if(tmp >= RTE_MAX_ETHPORTS)
4014 port_id = (portid_t)tmp;
4016 if (!strcmp(res->on, "on"))
4021 if (!strcmp(res->what, "strip"))
4022 rx_vlan_strip_set(port_id, on);
4023 else if(!strcmp(res->what, "stripq")){
4024 uint16_t queue_id = 0;
4026 /* No queue_id, return */
4028 printf("must specify (port,queue_id)\n");
4031 tmp = strtoul(str + i + 1, NULL, 0);
4032 /* If queue_id greater that what 16-bits can represent, return */
4036 queue_id = (uint16_t)tmp;
4037 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4039 else if (!strcmp(res->what, "filter"))
4040 rx_vlan_filter_set(port_id, on);
4041 else if (!strcmp(res->what, "qinq_strip"))
4042 rx_vlan_qinq_strip_set(port_id, on);
4044 vlan_extend_set(port_id, on);
4049 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4050 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4052 cmdline_parse_token_string_t cmd_vlan_offload_set =
4053 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4055 cmdline_parse_token_string_t cmd_vlan_offload_what =
4056 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4057 what, "strip#filter#qinq_strip#extend#stripq");
4058 cmdline_parse_token_string_t cmd_vlan_offload_on =
4059 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4061 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4062 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4065 cmdline_parse_inst_t cmd_vlan_offload = {
4066 .f = cmd_vlan_offload_parsed,
4068 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4069 "<port_id[,queue_id]>: "
4070 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4072 (void *)&cmd_vlan_offload_vlan,
4073 (void *)&cmd_vlan_offload_set,
4074 (void *)&cmd_vlan_offload_what,
4075 (void *)&cmd_vlan_offload_on,
4076 (void *)&cmd_vlan_offload_portid,
4081 /* *** VLAN TPID SET ON A PORT *** */
4082 struct cmd_vlan_tpid_result {
4083 cmdline_fixed_string_t vlan;
4084 cmdline_fixed_string_t set;
4085 cmdline_fixed_string_t vlan_type;
4086 cmdline_fixed_string_t what;
4092 cmd_vlan_tpid_parsed(void *parsed_result,
4093 __rte_unused struct cmdline *cl,
4094 __rte_unused void *data)
4096 struct cmd_vlan_tpid_result *res = parsed_result;
4097 enum rte_vlan_type vlan_type;
4099 if (!strcmp(res->vlan_type, "inner"))
4100 vlan_type = ETH_VLAN_TYPE_INNER;
4101 else if (!strcmp(res->vlan_type, "outer"))
4102 vlan_type = ETH_VLAN_TYPE_OUTER;
4104 printf("Unknown vlan type\n");
4107 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4110 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4111 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4113 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4114 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4116 cmdline_parse_token_string_t cmd_vlan_type =
4117 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4118 vlan_type, "inner#outer");
4119 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4120 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4122 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4123 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4125 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4126 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4129 cmdline_parse_inst_t cmd_vlan_tpid = {
4130 .f = cmd_vlan_tpid_parsed,
4132 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4133 "Set the VLAN Ether type",
4135 (void *)&cmd_vlan_tpid_vlan,
4136 (void *)&cmd_vlan_tpid_set,
4137 (void *)&cmd_vlan_type,
4138 (void *)&cmd_vlan_tpid_what,
4139 (void *)&cmd_vlan_tpid_tpid,
4140 (void *)&cmd_vlan_tpid_portid,
4145 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4146 struct cmd_rx_vlan_filter_result {
4147 cmdline_fixed_string_t rx_vlan;
4148 cmdline_fixed_string_t what;
4154 cmd_rx_vlan_filter_parsed(void *parsed_result,
4155 __rte_unused struct cmdline *cl,
4156 __rte_unused void *data)
4158 struct cmd_rx_vlan_filter_result *res = parsed_result;
4160 if (!strcmp(res->what, "add"))
4161 rx_vft_set(res->port_id, res->vlan_id, 1);
4163 rx_vft_set(res->port_id, res->vlan_id, 0);
4166 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4167 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4168 rx_vlan, "rx_vlan");
4169 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4170 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4172 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4173 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4175 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4176 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4179 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4180 .f = cmd_rx_vlan_filter_parsed,
4182 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4183 "Add/Remove a VLAN identifier to/from the set of VLAN "
4184 "identifiers filtered by a port",
4186 (void *)&cmd_rx_vlan_filter_rx_vlan,
4187 (void *)&cmd_rx_vlan_filter_what,
4188 (void *)&cmd_rx_vlan_filter_vlanid,
4189 (void *)&cmd_rx_vlan_filter_portid,
4194 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4195 struct cmd_tx_vlan_set_result {
4196 cmdline_fixed_string_t tx_vlan;
4197 cmdline_fixed_string_t set;
4203 cmd_tx_vlan_set_parsed(void *parsed_result,
4204 __rte_unused struct cmdline *cl,
4205 __rte_unused void *data)
4207 struct cmd_tx_vlan_set_result *res = parsed_result;
4209 if (!port_is_stopped(res->port_id)) {
4210 printf("Please stop port %d first\n", res->port_id);
4214 tx_vlan_set(res->port_id, res->vlan_id);
4216 cmd_reconfig_device_queue(res->port_id, 1, 1);
4219 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4220 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4221 tx_vlan, "tx_vlan");
4222 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4223 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4225 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4226 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4228 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4229 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4232 cmdline_parse_inst_t cmd_tx_vlan_set = {
4233 .f = cmd_tx_vlan_set_parsed,
4235 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4236 "Enable hardware insertion of a single VLAN header "
4237 "with a given TAG Identifier in packets sent on a port",
4239 (void *)&cmd_tx_vlan_set_tx_vlan,
4240 (void *)&cmd_tx_vlan_set_set,
4241 (void *)&cmd_tx_vlan_set_portid,
4242 (void *)&cmd_tx_vlan_set_vlanid,
4247 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4248 struct cmd_tx_vlan_set_qinq_result {
4249 cmdline_fixed_string_t tx_vlan;
4250 cmdline_fixed_string_t set;
4253 uint16_t vlan_id_outer;
4257 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4258 __rte_unused struct cmdline *cl,
4259 __rte_unused void *data)
4261 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4263 if (!port_is_stopped(res->port_id)) {
4264 printf("Please stop port %d first\n", res->port_id);
4268 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4270 cmd_reconfig_device_queue(res->port_id, 1, 1);
4273 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4274 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4275 tx_vlan, "tx_vlan");
4276 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4277 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4279 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4280 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4282 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4283 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4285 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4286 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4287 vlan_id_outer, UINT16);
4289 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4290 .f = cmd_tx_vlan_set_qinq_parsed,
4292 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4293 "Enable hardware insertion of double VLAN header "
4294 "with given TAG Identifiers in packets sent on a port",
4296 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4297 (void *)&cmd_tx_vlan_set_qinq_set,
4298 (void *)&cmd_tx_vlan_set_qinq_portid,
4299 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4300 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4305 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4306 struct cmd_tx_vlan_set_pvid_result {
4307 cmdline_fixed_string_t tx_vlan;
4308 cmdline_fixed_string_t set;
4309 cmdline_fixed_string_t pvid;
4312 cmdline_fixed_string_t mode;
4316 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4317 __rte_unused struct cmdline *cl,
4318 __rte_unused void *data)
4320 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4322 if (strcmp(res->mode, "on") == 0)
4323 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4325 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4328 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4329 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4330 tx_vlan, "tx_vlan");
4331 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4332 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4334 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4335 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4337 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4338 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4340 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4341 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4343 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4344 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4347 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4348 .f = cmd_tx_vlan_set_pvid_parsed,
4350 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4352 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4353 (void *)&cmd_tx_vlan_set_pvid_set,
4354 (void *)&cmd_tx_vlan_set_pvid_pvid,
4355 (void *)&cmd_tx_vlan_set_pvid_port_id,
4356 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4357 (void *)&cmd_tx_vlan_set_pvid_mode,
4362 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4363 struct cmd_tx_vlan_reset_result {
4364 cmdline_fixed_string_t tx_vlan;
4365 cmdline_fixed_string_t reset;
4370 cmd_tx_vlan_reset_parsed(void *parsed_result,
4371 __rte_unused struct cmdline *cl,
4372 __rte_unused void *data)
4374 struct cmd_tx_vlan_reset_result *res = parsed_result;
4376 if (!port_is_stopped(res->port_id)) {
4377 printf("Please stop port %d first\n", res->port_id);
4381 tx_vlan_reset(res->port_id);
4383 cmd_reconfig_device_queue(res->port_id, 1, 1);
4386 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4387 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4388 tx_vlan, "tx_vlan");
4389 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4390 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4392 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4393 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4396 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4397 .f = cmd_tx_vlan_reset_parsed,
4399 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4400 "VLAN header in packets sent on a port",
4402 (void *)&cmd_tx_vlan_reset_tx_vlan,
4403 (void *)&cmd_tx_vlan_reset_reset,
4404 (void *)&cmd_tx_vlan_reset_portid,
4410 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4411 struct cmd_csum_result {
4412 cmdline_fixed_string_t csum;
4413 cmdline_fixed_string_t mode;
4414 cmdline_fixed_string_t proto;
4415 cmdline_fixed_string_t hwsw;
4420 csum_show(int port_id)
4422 struct rte_eth_dev_info dev_info;
4423 uint64_t tx_offloads;
4426 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4427 printf("Parse tunnel is %s\n",
4428 (ports[port_id].parse_tunnel) ? "on" : "off");
4429 printf("IP checksum offload is %s\n",
4430 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4431 printf("UDP checksum offload is %s\n",
4432 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4433 printf("TCP checksum offload is %s\n",
4434 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4435 printf("SCTP checksum offload is %s\n",
4436 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4437 printf("Outer-Ip checksum offload is %s\n",
4438 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4439 printf("Outer-Udp checksum offload is %s\n",
4440 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4442 /* display warnings if configuration is not supported by the NIC */
4443 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4447 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4448 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4449 printf("Warning: hardware IP checksum enabled but not "
4450 "supported by port %d\n", port_id);
4452 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4453 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4454 printf("Warning: hardware UDP checksum enabled but not "
4455 "supported by port %d\n", port_id);
4457 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4458 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4459 printf("Warning: hardware TCP checksum enabled but not "
4460 "supported by port %d\n", port_id);
4462 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4463 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4464 printf("Warning: hardware SCTP checksum enabled but not "
4465 "supported by port %d\n", port_id);
4467 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4468 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4469 printf("Warning: hardware outer IP checksum enabled but not "
4470 "supported by port %d\n", port_id);
4472 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4473 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4475 printf("Warning: hardware outer UDP checksum enabled but not "
4476 "supported by port %d\n", port_id);
4481 cmd_config_queue_tx_offloads(struct rte_port *port)
4485 /* Apply queue tx offloads configuration */
4486 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4487 port->tx_conf[k].offloads =
4488 port->dev_conf.txmode.offloads;
4492 cmd_csum_parsed(void *parsed_result,
4493 __rte_unused struct cmdline *cl,
4494 __rte_unused void *data)
4496 struct cmd_csum_result *res = parsed_result;
4498 uint64_t csum_offloads = 0;
4499 struct rte_eth_dev_info dev_info;
4502 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4503 printf("invalid port %d\n", res->port_id);
4506 if (!port_is_stopped(res->port_id)) {
4507 printf("Please stop port %d first\n", res->port_id);
4511 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4515 if (!strcmp(res->mode, "set")) {
4517 if (!strcmp(res->hwsw, "hw"))
4520 if (!strcmp(res->proto, "ip")) {
4521 if (hw == 0 || (dev_info.tx_offload_capa &
4522 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4523 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4525 printf("IP checksum offload is not supported "
4526 "by port %u\n", res->port_id);
4528 } else if (!strcmp(res->proto, "udp")) {
4529 if (hw == 0 || (dev_info.tx_offload_capa &
4530 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4531 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4533 printf("UDP checksum offload is not supported "
4534 "by port %u\n", res->port_id);
4536 } else if (!strcmp(res->proto, "tcp")) {
4537 if (hw == 0 || (dev_info.tx_offload_capa &
4538 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4539 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4541 printf("TCP checksum offload is not supported "
4542 "by port %u\n", res->port_id);
4544 } else if (!strcmp(res->proto, "sctp")) {
4545 if (hw == 0 || (dev_info.tx_offload_capa &
4546 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4547 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4549 printf("SCTP checksum offload is not supported "
4550 "by port %u\n", res->port_id);
4552 } else if (!strcmp(res->proto, "outer-ip")) {
4553 if (hw == 0 || (dev_info.tx_offload_capa &
4554 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4556 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4558 printf("Outer IP checksum offload is not "
4559 "supported by port %u\n", res->port_id);
4561 } else if (!strcmp(res->proto, "outer-udp")) {
4562 if (hw == 0 || (dev_info.tx_offload_capa &
4563 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4565 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4567 printf("Outer UDP checksum offload is not "
4568 "supported by port %u\n", res->port_id);
4573 ports[res->port_id].dev_conf.txmode.offloads |=
4576 ports[res->port_id].dev_conf.txmode.offloads &=
4579 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4581 csum_show(res->port_id);
4583 cmd_reconfig_device_queue(res->port_id, 1, 1);
4586 cmdline_parse_token_string_t cmd_csum_csum =
4587 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4589 cmdline_parse_token_string_t cmd_csum_mode =
4590 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4592 cmdline_parse_token_string_t cmd_csum_proto =
4593 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4594 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4595 cmdline_parse_token_string_t cmd_csum_hwsw =
4596 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4598 cmdline_parse_token_num_t cmd_csum_portid =
4599 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4602 cmdline_parse_inst_t cmd_csum_set = {
4603 .f = cmd_csum_parsed,
4605 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4606 "Enable/Disable hardware calculation of L3/L4 checksum when "
4607 "using csum forward engine",
4609 (void *)&cmd_csum_csum,
4610 (void *)&cmd_csum_mode,
4611 (void *)&cmd_csum_proto,
4612 (void *)&cmd_csum_hwsw,
4613 (void *)&cmd_csum_portid,
4618 cmdline_parse_token_string_t cmd_csum_mode_show =
4619 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4622 cmdline_parse_inst_t cmd_csum_show = {
4623 .f = cmd_csum_parsed,
4625 .help_str = "csum show <port_id>: Show checksum offload configuration",
4627 (void *)&cmd_csum_csum,
4628 (void *)&cmd_csum_mode_show,
4629 (void *)&cmd_csum_portid,
4634 /* Enable/disable tunnel parsing */
4635 struct cmd_csum_tunnel_result {
4636 cmdline_fixed_string_t csum;
4637 cmdline_fixed_string_t parse;
4638 cmdline_fixed_string_t onoff;
4643 cmd_csum_tunnel_parsed(void *parsed_result,
4644 __rte_unused struct cmdline *cl,
4645 __rte_unused void *data)
4647 struct cmd_csum_tunnel_result *res = parsed_result;
4649 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4652 if (!strcmp(res->onoff, "on"))
4653 ports[res->port_id].parse_tunnel = 1;
4655 ports[res->port_id].parse_tunnel = 0;
4657 csum_show(res->port_id);
4660 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4661 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4663 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4664 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4665 parse, "parse-tunnel");
4666 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4667 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4669 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4670 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4673 cmdline_parse_inst_t cmd_csum_tunnel = {
4674 .f = cmd_csum_tunnel_parsed,
4676 .help_str = "csum parse-tunnel on|off <port_id>: "
4677 "Enable/Disable parsing of tunnels for csum engine",
4679 (void *)&cmd_csum_tunnel_csum,
4680 (void *)&cmd_csum_tunnel_parse,
4681 (void *)&cmd_csum_tunnel_onoff,
4682 (void *)&cmd_csum_tunnel_portid,
4687 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4688 struct cmd_tso_set_result {
4689 cmdline_fixed_string_t tso;
4690 cmdline_fixed_string_t mode;
4696 cmd_tso_set_parsed(void *parsed_result,
4697 __rte_unused struct cmdline *cl,
4698 __rte_unused void *data)
4700 struct cmd_tso_set_result *res = parsed_result;
4701 struct rte_eth_dev_info dev_info;
4704 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4706 if (!port_is_stopped(res->port_id)) {
4707 printf("Please stop port %d first\n", res->port_id);
4711 if (!strcmp(res->mode, "set"))
4712 ports[res->port_id].tso_segsz = res->tso_segsz;
4714 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4718 if ((ports[res->port_id].tso_segsz != 0) &&
4719 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4720 printf("Error: TSO is not supported by port %d\n",
4725 if (ports[res->port_id].tso_segsz == 0) {
4726 ports[res->port_id].dev_conf.txmode.offloads &=
4727 ~DEV_TX_OFFLOAD_TCP_TSO;
4728 printf("TSO for non-tunneled packets is disabled\n");
4730 ports[res->port_id].dev_conf.txmode.offloads |=
4731 DEV_TX_OFFLOAD_TCP_TSO;
4732 printf("TSO segment size for non-tunneled packets is %d\n",
4733 ports[res->port_id].tso_segsz);
4735 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4737 /* display warnings if configuration is not supported by the NIC */
4738 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4742 if ((ports[res->port_id].tso_segsz != 0) &&
4743 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4744 printf("Warning: TSO enabled but not "
4745 "supported by port %d\n", res->port_id);
4748 cmd_reconfig_device_queue(res->port_id, 1, 1);
4751 cmdline_parse_token_string_t cmd_tso_set_tso =
4752 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4754 cmdline_parse_token_string_t cmd_tso_set_mode =
4755 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4757 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4758 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4760 cmdline_parse_token_num_t cmd_tso_set_portid =
4761 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4764 cmdline_parse_inst_t cmd_tso_set = {
4765 .f = cmd_tso_set_parsed,
4767 .help_str = "tso set <tso_segsz> <port_id>: "
4768 "Set TSO segment size of non-tunneled packets for csum engine "
4771 (void *)&cmd_tso_set_tso,
4772 (void *)&cmd_tso_set_mode,
4773 (void *)&cmd_tso_set_tso_segsz,
4774 (void *)&cmd_tso_set_portid,
4779 cmdline_parse_token_string_t cmd_tso_show_mode =
4780 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4784 cmdline_parse_inst_t cmd_tso_show = {
4785 .f = cmd_tso_set_parsed,
4787 .help_str = "tso show <port_id>: "
4788 "Show TSO segment size of non-tunneled packets for csum engine",
4790 (void *)&cmd_tso_set_tso,
4791 (void *)&cmd_tso_show_mode,
4792 (void *)&cmd_tso_set_portid,
4797 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4798 struct cmd_tunnel_tso_set_result {
4799 cmdline_fixed_string_t tso;
4800 cmdline_fixed_string_t mode;
4805 static struct rte_eth_dev_info
4806 check_tunnel_tso_nic_support(portid_t port_id)
4808 struct rte_eth_dev_info dev_info;
4810 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4813 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4814 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4815 "not enabled for port %d\n", port_id);
4816 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4817 printf("Warning: GRE TUNNEL TSO not supported therefore "
4818 "not enabled for port %d\n", port_id);
4819 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4820 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4821 "not enabled for port %d\n", port_id);
4822 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4823 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4824 "not enabled for port %d\n", port_id);
4825 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4826 printf("Warning: IP TUNNEL TSO not supported therefore "
4827 "not enabled for port %d\n", port_id);
4828 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4829 printf("Warning: UDP TUNNEL TSO not supported therefore "
4830 "not enabled for port %d\n", port_id);
4835 cmd_tunnel_tso_set_parsed(void *parsed_result,
4836 __rte_unused struct cmdline *cl,
4837 __rte_unused void *data)
4839 struct cmd_tunnel_tso_set_result *res = parsed_result;
4840 struct rte_eth_dev_info dev_info;
4842 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4844 if (!port_is_stopped(res->port_id)) {
4845 printf("Please stop port %d first\n", res->port_id);
4849 if (!strcmp(res->mode, "set"))
4850 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4852 dev_info = check_tunnel_tso_nic_support(res->port_id);
4853 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4854 ports[res->port_id].dev_conf.txmode.offloads &=
4855 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4856 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4857 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4858 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4859 DEV_TX_OFFLOAD_IP_TNL_TSO |
4860 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4861 printf("TSO for tunneled packets is disabled\n");
4863 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4864 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4865 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4866 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4867 DEV_TX_OFFLOAD_IP_TNL_TSO |
4868 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4870 ports[res->port_id].dev_conf.txmode.offloads |=
4871 (tso_offloads & dev_info.tx_offload_capa);
4872 printf("TSO segment size for tunneled packets is %d\n",
4873 ports[res->port_id].tunnel_tso_segsz);
4875 /* Below conditions are needed to make it work:
4876 * (1) tunnel TSO is supported by the NIC;
4877 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4879 * (3) for tunneled pkts with outer L3 of IPv4,
4880 * "csum set outer-ip" must be set to hw, because after tso,
4881 * total_len of outer IP header is changed, and the checksum
4882 * of outer IP header calculated by sw should be wrong; that
4883 * is not necessary for IPv6 tunneled pkts because there's no
4884 * checksum in IP header anymore.
4887 if (!ports[res->port_id].parse_tunnel)
4888 printf("Warning: csum parse_tunnel must be set "
4889 "so that tunneled packets are recognized\n");
4890 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4891 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4892 printf("Warning: csum set outer-ip must be set to hw "
4893 "if outer L3 is IPv4; not necessary for IPv6\n");
4896 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4897 cmd_reconfig_device_queue(res->port_id, 1, 1);
4900 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4901 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4903 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4904 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4906 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4907 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4909 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4910 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4913 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4914 .f = cmd_tunnel_tso_set_parsed,
4916 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4917 "Set TSO segment size of tunneled packets for csum engine "
4920 (void *)&cmd_tunnel_tso_set_tso,
4921 (void *)&cmd_tunnel_tso_set_mode,
4922 (void *)&cmd_tunnel_tso_set_tso_segsz,
4923 (void *)&cmd_tunnel_tso_set_portid,
4928 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4929 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4933 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4934 .f = cmd_tunnel_tso_set_parsed,
4936 .help_str = "tunnel_tso show <port_id> "
4937 "Show TSO segment size of tunneled packets for csum engine",
4939 (void *)&cmd_tunnel_tso_set_tso,
4940 (void *)&cmd_tunnel_tso_show_mode,
4941 (void *)&cmd_tunnel_tso_set_portid,
4946 /* *** SET GRO FOR A PORT *** */
4947 struct cmd_gro_enable_result {
4948 cmdline_fixed_string_t cmd_set;
4949 cmdline_fixed_string_t cmd_port;
4950 cmdline_fixed_string_t cmd_keyword;
4951 cmdline_fixed_string_t cmd_onoff;
4956 cmd_gro_enable_parsed(void *parsed_result,
4957 __rte_unused struct cmdline *cl,
4958 __rte_unused void *data)
4960 struct cmd_gro_enable_result *res;
4962 res = parsed_result;
4963 if (!strcmp(res->cmd_keyword, "gro"))
4964 setup_gro(res->cmd_onoff, res->cmd_pid);
4967 cmdline_parse_token_string_t cmd_gro_enable_set =
4968 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4970 cmdline_parse_token_string_t cmd_gro_enable_port =
4971 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4972 cmd_keyword, "port");
4973 cmdline_parse_token_num_t cmd_gro_enable_pid =
4974 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4976 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4977 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4978 cmd_keyword, "gro");
4979 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4980 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4981 cmd_onoff, "on#off");
4983 cmdline_parse_inst_t cmd_gro_enable = {
4984 .f = cmd_gro_enable_parsed,
4986 .help_str = "set port <port_id> gro on|off",
4988 (void *)&cmd_gro_enable_set,
4989 (void *)&cmd_gro_enable_port,
4990 (void *)&cmd_gro_enable_pid,
4991 (void *)&cmd_gro_enable_keyword,
4992 (void *)&cmd_gro_enable_onoff,
4997 /* *** DISPLAY GRO CONFIGURATION *** */
4998 struct cmd_gro_show_result {
4999 cmdline_fixed_string_t cmd_show;
5000 cmdline_fixed_string_t cmd_port;
5001 cmdline_fixed_string_t cmd_keyword;
5006 cmd_gro_show_parsed(void *parsed_result,
5007 __rte_unused struct cmdline *cl,
5008 __rte_unused void *data)
5010 struct cmd_gro_show_result *res;
5012 res = parsed_result;
5013 if (!strcmp(res->cmd_keyword, "gro"))
5014 show_gro(res->cmd_pid);
5017 cmdline_parse_token_string_t cmd_gro_show_show =
5018 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5020 cmdline_parse_token_string_t cmd_gro_show_port =
5021 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5023 cmdline_parse_token_num_t cmd_gro_show_pid =
5024 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5026 cmdline_parse_token_string_t cmd_gro_show_keyword =
5027 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5028 cmd_keyword, "gro");
5030 cmdline_parse_inst_t cmd_gro_show = {
5031 .f = cmd_gro_show_parsed,
5033 .help_str = "show port <port_id> gro",
5035 (void *)&cmd_gro_show_show,
5036 (void *)&cmd_gro_show_port,
5037 (void *)&cmd_gro_show_pid,
5038 (void *)&cmd_gro_show_keyword,
5043 /* *** SET FLUSH CYCLES FOR GRO *** */
5044 struct cmd_gro_flush_result {
5045 cmdline_fixed_string_t cmd_set;
5046 cmdline_fixed_string_t cmd_keyword;
5047 cmdline_fixed_string_t cmd_flush;
5052 cmd_gro_flush_parsed(void *parsed_result,
5053 __rte_unused struct cmdline *cl,
5054 __rte_unused void *data)
5056 struct cmd_gro_flush_result *res;
5058 res = parsed_result;
5059 if ((!strcmp(res->cmd_keyword, "gro")) &&
5060 (!strcmp(res->cmd_flush, "flush")))
5061 setup_gro_flush_cycles(res->cmd_cycles);
5064 cmdline_parse_token_string_t cmd_gro_flush_set =
5065 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5067 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5068 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5069 cmd_keyword, "gro");
5070 cmdline_parse_token_string_t cmd_gro_flush_flush =
5071 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5072 cmd_flush, "flush");
5073 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5074 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5077 cmdline_parse_inst_t cmd_gro_flush = {
5078 .f = cmd_gro_flush_parsed,
5080 .help_str = "set gro flush <cycles>",
5082 (void *)&cmd_gro_flush_set,
5083 (void *)&cmd_gro_flush_keyword,
5084 (void *)&cmd_gro_flush_flush,
5085 (void *)&cmd_gro_flush_cycles,
5090 /* *** ENABLE/DISABLE GSO *** */
5091 struct cmd_gso_enable_result {
5092 cmdline_fixed_string_t cmd_set;
5093 cmdline_fixed_string_t cmd_port;
5094 cmdline_fixed_string_t cmd_keyword;
5095 cmdline_fixed_string_t cmd_mode;
5100 cmd_gso_enable_parsed(void *parsed_result,
5101 __rte_unused struct cmdline *cl,
5102 __rte_unused void *data)
5104 struct cmd_gso_enable_result *res;
5106 res = parsed_result;
5107 if (!strcmp(res->cmd_keyword, "gso"))
5108 setup_gso(res->cmd_mode, res->cmd_pid);
5111 cmdline_parse_token_string_t cmd_gso_enable_set =
5112 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5114 cmdline_parse_token_string_t cmd_gso_enable_port =
5115 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5117 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5118 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5119 cmd_keyword, "gso");
5120 cmdline_parse_token_string_t cmd_gso_enable_mode =
5121 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5122 cmd_mode, "on#off");
5123 cmdline_parse_token_num_t cmd_gso_enable_pid =
5124 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5127 cmdline_parse_inst_t cmd_gso_enable = {
5128 .f = cmd_gso_enable_parsed,
5130 .help_str = "set port <port_id> gso on|off",
5132 (void *)&cmd_gso_enable_set,
5133 (void *)&cmd_gso_enable_port,
5134 (void *)&cmd_gso_enable_pid,
5135 (void *)&cmd_gso_enable_keyword,
5136 (void *)&cmd_gso_enable_mode,
5141 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5142 struct cmd_gso_size_result {
5143 cmdline_fixed_string_t cmd_set;
5144 cmdline_fixed_string_t cmd_keyword;
5145 cmdline_fixed_string_t cmd_segsz;
5150 cmd_gso_size_parsed(void *parsed_result,
5151 __rte_unused struct cmdline *cl,
5152 __rte_unused void *data)
5154 struct cmd_gso_size_result *res = parsed_result;
5156 if (test_done == 0) {
5157 printf("Before setting GSO segsz, please first"
5158 " stop fowarding\n");
5162 if (!strcmp(res->cmd_keyword, "gso") &&
5163 !strcmp(res->cmd_segsz, "segsz")) {
5164 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5165 printf("gso_size should be larger than %zu."
5166 " Please input a legal value\n",
5167 RTE_GSO_SEG_SIZE_MIN);
5169 gso_max_segment_size = res->cmd_size;
5173 cmdline_parse_token_string_t cmd_gso_size_set =
5174 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5176 cmdline_parse_token_string_t cmd_gso_size_keyword =
5177 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5178 cmd_keyword, "gso");
5179 cmdline_parse_token_string_t cmd_gso_size_segsz =
5180 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5181 cmd_segsz, "segsz");
5182 cmdline_parse_token_num_t cmd_gso_size_size =
5183 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5186 cmdline_parse_inst_t cmd_gso_size = {
5187 .f = cmd_gso_size_parsed,
5189 .help_str = "set gso segsz <length>",
5191 (void *)&cmd_gso_size_set,
5192 (void *)&cmd_gso_size_keyword,
5193 (void *)&cmd_gso_size_segsz,
5194 (void *)&cmd_gso_size_size,
5199 /* *** SHOW GSO CONFIGURATION *** */
5200 struct cmd_gso_show_result {
5201 cmdline_fixed_string_t cmd_show;
5202 cmdline_fixed_string_t cmd_port;
5203 cmdline_fixed_string_t cmd_keyword;
5208 cmd_gso_show_parsed(void *parsed_result,
5209 __rte_unused struct cmdline *cl,
5210 __rte_unused void *data)
5212 struct cmd_gso_show_result *res = parsed_result;
5214 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5215 printf("invalid port id %u\n", res->cmd_pid);
5218 if (!strcmp(res->cmd_keyword, "gso")) {
5219 if (gso_ports[res->cmd_pid].enable) {
5220 printf("Max GSO'd packet size: %uB\n"
5221 "Supported GSO types: TCP/IPv4, "
5222 "UDP/IPv4, VxLAN with inner "
5223 "TCP/IPv4 packet, GRE with inner "
5224 "TCP/IPv4 packet\n",
5225 gso_max_segment_size);
5227 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5231 cmdline_parse_token_string_t cmd_gso_show_show =
5232 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5234 cmdline_parse_token_string_t cmd_gso_show_port =
5235 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5237 cmdline_parse_token_string_t cmd_gso_show_keyword =
5238 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5239 cmd_keyword, "gso");
5240 cmdline_parse_token_num_t cmd_gso_show_pid =
5241 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5244 cmdline_parse_inst_t cmd_gso_show = {
5245 .f = cmd_gso_show_parsed,
5247 .help_str = "show port <port_id> gso",
5249 (void *)&cmd_gso_show_show,
5250 (void *)&cmd_gso_show_port,
5251 (void *)&cmd_gso_show_pid,
5252 (void *)&cmd_gso_show_keyword,
5257 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5258 struct cmd_set_flush_rx {
5259 cmdline_fixed_string_t set;
5260 cmdline_fixed_string_t flush_rx;
5261 cmdline_fixed_string_t mode;
5265 cmd_set_flush_rx_parsed(void *parsed_result,
5266 __rte_unused struct cmdline *cl,
5267 __rte_unused void *data)
5269 struct cmd_set_flush_rx *res = parsed_result;
5270 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5273 cmdline_parse_token_string_t cmd_setflushrx_set =
5274 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5276 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5277 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5278 flush_rx, "flush_rx");
5279 cmdline_parse_token_string_t cmd_setflushrx_mode =
5280 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5284 cmdline_parse_inst_t cmd_set_flush_rx = {
5285 .f = cmd_set_flush_rx_parsed,
5286 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5289 (void *)&cmd_setflushrx_set,
5290 (void *)&cmd_setflushrx_flush_rx,
5291 (void *)&cmd_setflushrx_mode,
5296 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5297 struct cmd_set_link_check {
5298 cmdline_fixed_string_t set;
5299 cmdline_fixed_string_t link_check;
5300 cmdline_fixed_string_t mode;
5304 cmd_set_link_check_parsed(void *parsed_result,
5305 __rte_unused struct cmdline *cl,
5306 __rte_unused void *data)
5308 struct cmd_set_link_check *res = parsed_result;
5309 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5312 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5313 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5315 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5316 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5317 link_check, "link_check");
5318 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5319 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5323 cmdline_parse_inst_t cmd_set_link_check = {
5324 .f = cmd_set_link_check_parsed,
5325 .help_str = "set link_check on|off: Enable/Disable link status check "
5326 "when starting/stopping a port",
5329 (void *)&cmd_setlinkcheck_set,
5330 (void *)&cmd_setlinkcheck_link_check,
5331 (void *)&cmd_setlinkcheck_mode,
5336 /* *** SET NIC BYPASS MODE *** */
5337 struct cmd_set_bypass_mode_result {
5338 cmdline_fixed_string_t set;
5339 cmdline_fixed_string_t bypass;
5340 cmdline_fixed_string_t mode;
5341 cmdline_fixed_string_t value;
5346 cmd_set_bypass_mode_parsed(void *parsed_result,
5347 __rte_unused struct cmdline *cl,
5348 __rte_unused void *data)
5350 struct cmd_set_bypass_mode_result *res = parsed_result;
5351 portid_t port_id = res->port_id;
5352 int32_t rc = -EINVAL;
5354 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5355 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5357 if (!strcmp(res->value, "bypass"))
5358 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5359 else if (!strcmp(res->value, "isolate"))
5360 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5362 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5364 /* Set the bypass mode for the relevant port. */
5365 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5368 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5371 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5372 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5374 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5375 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5377 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5378 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5380 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5381 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5382 value, "normal#bypass#isolate");
5383 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5384 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5387 cmdline_parse_inst_t cmd_set_bypass_mode = {
5388 .f = cmd_set_bypass_mode_parsed,
5389 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5390 "Set the NIC bypass mode for port_id",
5393 (void *)&cmd_setbypass_mode_set,
5394 (void *)&cmd_setbypass_mode_bypass,
5395 (void *)&cmd_setbypass_mode_mode,
5396 (void *)&cmd_setbypass_mode_value,
5397 (void *)&cmd_setbypass_mode_port,
5402 /* *** SET NIC BYPASS EVENT *** */
5403 struct cmd_set_bypass_event_result {
5404 cmdline_fixed_string_t set;
5405 cmdline_fixed_string_t bypass;
5406 cmdline_fixed_string_t event;
5407 cmdline_fixed_string_t event_value;
5408 cmdline_fixed_string_t mode;
5409 cmdline_fixed_string_t mode_value;
5414 cmd_set_bypass_event_parsed(void *parsed_result,
5415 __rte_unused struct cmdline *cl,
5416 __rte_unused void *data)
5418 int32_t rc = -EINVAL;
5419 struct cmd_set_bypass_event_result *res = parsed_result;
5420 portid_t port_id = res->port_id;
5422 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5423 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5424 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5426 if (!strcmp(res->event_value, "timeout"))
5427 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5428 else if (!strcmp(res->event_value, "os_on"))
5429 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5430 else if (!strcmp(res->event_value, "os_off"))
5431 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5432 else if (!strcmp(res->event_value, "power_on"))
5433 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5434 else if (!strcmp(res->event_value, "power_off"))
5435 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5437 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5439 if (!strcmp(res->mode_value, "bypass"))
5440 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5441 else if (!strcmp(res->mode_value, "isolate"))
5442 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5444 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5446 /* Set the watchdog timeout. */
5447 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5450 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5451 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5455 printf("Failed to set timeout value %u "
5456 "for port %d, errto code: %d.\n",
5457 bypass_timeout, port_id, rc);
5461 /* Set the bypass event to transition to bypass mode. */
5462 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5467 printf("\t Failed to set bypass event for port = %d.\n",
5471 cmdline_parse_token_string_t cmd_setbypass_event_set =
5472 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5474 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5475 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5477 cmdline_parse_token_string_t cmd_setbypass_event_event =
5478 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5480 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5481 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5482 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5483 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5484 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5486 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5487 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5488 mode_value, "normal#bypass#isolate");
5489 cmdline_parse_token_num_t cmd_setbypass_event_port =
5490 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5493 cmdline_parse_inst_t cmd_set_bypass_event = {
5494 .f = cmd_set_bypass_event_parsed,
5495 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5496 "power_off mode normal|bypass|isolate <port_id>: "
5497 "Set the NIC bypass event mode for port_id",
5500 (void *)&cmd_setbypass_event_set,
5501 (void *)&cmd_setbypass_event_bypass,
5502 (void *)&cmd_setbypass_event_event,
5503 (void *)&cmd_setbypass_event_event_value,
5504 (void *)&cmd_setbypass_event_mode,
5505 (void *)&cmd_setbypass_event_mode_value,
5506 (void *)&cmd_setbypass_event_port,
5512 /* *** SET NIC BYPASS TIMEOUT *** */
5513 struct cmd_set_bypass_timeout_result {
5514 cmdline_fixed_string_t set;
5515 cmdline_fixed_string_t bypass;
5516 cmdline_fixed_string_t timeout;
5517 cmdline_fixed_string_t value;
5521 cmd_set_bypass_timeout_parsed(void *parsed_result,
5522 __rte_unused struct cmdline *cl,
5523 __rte_unused void *data)
5525 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5527 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5528 if (!strcmp(res->value, "1.5"))
5529 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5530 else if (!strcmp(res->value, "2"))
5531 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5532 else if (!strcmp(res->value, "3"))
5533 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5534 else if (!strcmp(res->value, "4"))
5535 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5536 else if (!strcmp(res->value, "8"))
5537 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5538 else if (!strcmp(res->value, "16"))
5539 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5540 else if (!strcmp(res->value, "32"))
5541 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5543 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5547 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5548 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5550 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5551 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5553 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5554 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5555 timeout, "timeout");
5556 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5557 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5558 value, "0#1.5#2#3#4#8#16#32");
5560 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5561 .f = cmd_set_bypass_timeout_parsed,
5562 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5563 "Set the NIC bypass watchdog timeout in seconds",
5566 (void *)&cmd_setbypass_timeout_set,
5567 (void *)&cmd_setbypass_timeout_bypass,
5568 (void *)&cmd_setbypass_timeout_timeout,
5569 (void *)&cmd_setbypass_timeout_value,
5574 /* *** SHOW NIC BYPASS MODE *** */
5575 struct cmd_show_bypass_config_result {
5576 cmdline_fixed_string_t show;
5577 cmdline_fixed_string_t bypass;
5578 cmdline_fixed_string_t config;
5583 cmd_show_bypass_config_parsed(void *parsed_result,
5584 __rte_unused struct cmdline *cl,
5585 __rte_unused void *data)
5587 struct cmd_show_bypass_config_result *res = parsed_result;
5588 portid_t port_id = res->port_id;
5590 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5591 uint32_t event_mode;
5592 uint32_t bypass_mode;
5593 uint32_t timeout = bypass_timeout;
5596 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5597 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5598 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5599 {"UNKNOWN", "normal", "bypass", "isolate"};
5600 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5608 /* Display the bypass mode.*/
5609 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5610 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5614 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5615 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5617 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5620 /* Display the bypass timeout.*/
5621 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5622 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5624 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5626 /* Display the bypass events and associated modes. */
5627 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5629 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5630 printf("\tFailed to get bypass mode for event = %s\n",
5633 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5634 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5636 printf("\tbypass event: %-16s = %s\n", events[i],
5642 printf("\tFailed to get bypass configuration for port = %d\n",
5646 cmdline_parse_token_string_t cmd_showbypass_config_show =
5647 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5649 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5650 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5652 cmdline_parse_token_string_t cmd_showbypass_config_config =
5653 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5655 cmdline_parse_token_num_t cmd_showbypass_config_port =
5656 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5659 cmdline_parse_inst_t cmd_show_bypass_config = {
5660 .f = cmd_show_bypass_config_parsed,
5661 .help_str = "show bypass config <port_id>: "
5662 "Show the NIC bypass config for port_id",
5665 (void *)&cmd_showbypass_config_show,
5666 (void *)&cmd_showbypass_config_bypass,
5667 (void *)&cmd_showbypass_config_config,
5668 (void *)&cmd_showbypass_config_port,
5673 #ifdef RTE_LIBRTE_PMD_BOND
5674 /* *** SET BONDING MODE *** */
5675 struct cmd_set_bonding_mode_result {
5676 cmdline_fixed_string_t set;
5677 cmdline_fixed_string_t bonding;
5678 cmdline_fixed_string_t mode;
5683 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5684 __rte_unused struct cmdline *cl,
5685 __rte_unused void *data)
5687 struct cmd_set_bonding_mode_result *res = parsed_result;
5688 portid_t port_id = res->port_id;
5690 /* Set the bonding mode for the relevant port. */
5691 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5692 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5695 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5696 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5698 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5700 bonding, "bonding");
5701 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5704 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5705 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5707 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5708 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5711 cmdline_parse_inst_t cmd_set_bonding_mode = {
5712 .f = cmd_set_bonding_mode_parsed,
5713 .help_str = "set bonding mode <mode_value> <port_id>: "
5714 "Set the bonding mode for port_id",
5717 (void *) &cmd_setbonding_mode_set,
5718 (void *) &cmd_setbonding_mode_bonding,
5719 (void *) &cmd_setbonding_mode_mode,
5720 (void *) &cmd_setbonding_mode_value,
5721 (void *) &cmd_setbonding_mode_port,
5726 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5727 struct cmd_set_bonding_lacp_dedicated_queues_result {
5728 cmdline_fixed_string_t set;
5729 cmdline_fixed_string_t bonding;
5730 cmdline_fixed_string_t lacp;
5731 cmdline_fixed_string_t dedicated_queues;
5733 cmdline_fixed_string_t mode;
5736 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5737 __rte_unused struct cmdline *cl,
5738 __rte_unused void *data)
5740 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5741 portid_t port_id = res->port_id;
5742 struct rte_port *port;
5744 port = &ports[port_id];
5746 /** Check if the port is not started **/
5747 if (port->port_status != RTE_PORT_STOPPED) {
5748 printf("Please stop port %d first\n", port_id);
5752 if (!strcmp(res->mode, "enable")) {
5753 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5754 printf("Dedicate queues for LACP control packets"
5757 printf("Enabling dedicate queues for LACP control "
5758 "packets on port %d failed\n", port_id);
5759 } else if (!strcmp(res->mode, "disable")) {
5760 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5761 printf("Dedicated queues for LACP control packets "
5764 printf("Disabling dedicated queues for LACP control "
5765 "traffic on port %d failed\n", port_id);
5769 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5770 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5772 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5773 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5774 bonding, "bonding");
5775 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5776 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5778 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5779 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5780 dedicated_queues, "dedicated_queues");
5781 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5782 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5784 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5785 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5786 mode, "enable#disable");
5788 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5789 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5790 .help_str = "set bonding lacp dedicated_queues <port_id> "
5792 "Enable/disable dedicated queues for LACP control traffic for port_id",
5795 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5796 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5797 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5798 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5799 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5800 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5805 /* *** SET BALANCE XMIT POLICY *** */
5806 struct cmd_set_bonding_balance_xmit_policy_result {
5807 cmdline_fixed_string_t set;
5808 cmdline_fixed_string_t bonding;
5809 cmdline_fixed_string_t balance_xmit_policy;
5811 cmdline_fixed_string_t policy;
5814 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5815 __rte_unused struct cmdline *cl,
5816 __rte_unused void *data)
5818 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5819 portid_t port_id = res->port_id;
5822 if (!strcmp(res->policy, "l2")) {
5823 policy = BALANCE_XMIT_POLICY_LAYER2;
5824 } else if (!strcmp(res->policy, "l23")) {
5825 policy = BALANCE_XMIT_POLICY_LAYER23;
5826 } else if (!strcmp(res->policy, "l34")) {
5827 policy = BALANCE_XMIT_POLICY_LAYER34;
5829 printf("\t Invalid xmit policy selection");
5833 /* Set the bonding mode for the relevant port. */
5834 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5835 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5840 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5843 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5845 bonding, "bonding");
5846 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5848 balance_xmit_policy, "balance_xmit_policy");
5849 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5850 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5852 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5854 policy, "l2#l23#l34");
5856 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5857 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5858 .help_str = "set bonding balance_xmit_policy <port_id> "
5860 "Set the bonding balance_xmit_policy for port_id",
5863 (void *)&cmd_setbonding_balance_xmit_policy_set,
5864 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5865 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5866 (void *)&cmd_setbonding_balance_xmit_policy_port,
5867 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5872 /* *** SHOW NIC BONDING CONFIGURATION *** */
5873 struct cmd_show_bonding_config_result {
5874 cmdline_fixed_string_t show;
5875 cmdline_fixed_string_t bonding;
5876 cmdline_fixed_string_t config;
5880 static void cmd_show_bonding_config_parsed(void *parsed_result,
5881 __rte_unused struct cmdline *cl,
5882 __rte_unused void *data)
5884 struct cmd_show_bonding_config_result *res = parsed_result;
5885 int bonding_mode, agg_mode;
5886 portid_t slaves[RTE_MAX_ETHPORTS];
5887 int num_slaves, num_active_slaves;
5890 portid_t port_id = res->port_id;
5892 /* Display the bonding mode.*/
5893 bonding_mode = rte_eth_bond_mode_get(port_id);
5894 if (bonding_mode < 0) {
5895 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5898 printf("\tBonding mode: %d\n", bonding_mode);
5900 if (bonding_mode == BONDING_MODE_BALANCE) {
5901 int balance_xmit_policy;
5903 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5904 if (balance_xmit_policy < 0) {
5905 printf("\tFailed to get balance xmit policy for port = %d\n",
5909 printf("\tBalance Xmit Policy: ");
5911 switch (balance_xmit_policy) {
5912 case BALANCE_XMIT_POLICY_LAYER2:
5913 printf("BALANCE_XMIT_POLICY_LAYER2");
5915 case BALANCE_XMIT_POLICY_LAYER23:
5916 printf("BALANCE_XMIT_POLICY_LAYER23");
5918 case BALANCE_XMIT_POLICY_LAYER34:
5919 printf("BALANCE_XMIT_POLICY_LAYER34");
5926 if (bonding_mode == BONDING_MODE_8023AD) {
5927 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5928 printf("\tIEEE802.3AD Aggregator Mode: ");
5931 printf("bandwidth");
5943 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5945 if (num_slaves < 0) {
5946 printf("\tFailed to get slave list for port = %d\n", port_id);
5949 if (num_slaves > 0) {
5950 printf("\tSlaves (%d): [", num_slaves);
5951 for (i = 0; i < num_slaves - 1; i++)
5952 printf("%d ", slaves[i]);
5954 printf("%d]\n", slaves[num_slaves - 1]);
5956 printf("\tSlaves: []\n");
5960 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5963 if (num_active_slaves < 0) {
5964 printf("\tFailed to get active slave list for port = %d\n", port_id);
5967 if (num_active_slaves > 0) {
5968 printf("\tActive Slaves (%d): [", num_active_slaves);
5969 for (i = 0; i < num_active_slaves - 1; i++)
5970 printf("%d ", slaves[i]);
5972 printf("%d]\n", slaves[num_active_slaves - 1]);
5975 printf("\tActive Slaves: []\n");
5979 primary_id = rte_eth_bond_primary_get(port_id);
5980 if (primary_id < 0) {
5981 printf("\tFailed to get primary slave for port = %d\n", port_id);
5984 printf("\tPrimary: [%d]\n", primary_id);
5988 cmdline_parse_token_string_t cmd_showbonding_config_show =
5989 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5991 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5992 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5993 bonding, "bonding");
5994 cmdline_parse_token_string_t cmd_showbonding_config_config =
5995 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5997 cmdline_parse_token_num_t cmd_showbonding_config_port =
5998 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6001 cmdline_parse_inst_t cmd_show_bonding_config = {
6002 .f = cmd_show_bonding_config_parsed,
6003 .help_str = "show bonding config <port_id>: "
6004 "Show the bonding config for port_id",
6007 (void *)&cmd_showbonding_config_show,
6008 (void *)&cmd_showbonding_config_bonding,
6009 (void *)&cmd_showbonding_config_config,
6010 (void *)&cmd_showbonding_config_port,
6015 /* *** SET BONDING PRIMARY *** */
6016 struct cmd_set_bonding_primary_result {
6017 cmdline_fixed_string_t set;
6018 cmdline_fixed_string_t bonding;
6019 cmdline_fixed_string_t primary;
6024 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6025 __rte_unused struct cmdline *cl,
6026 __rte_unused void *data)
6028 struct cmd_set_bonding_primary_result *res = parsed_result;
6029 portid_t master_port_id = res->port_id;
6030 portid_t slave_port_id = res->slave_id;
6032 /* Set the primary slave for a bonded device. */
6033 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6034 printf("\t Failed to set primary slave for port = %d.\n",
6041 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6042 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6044 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6045 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6046 bonding, "bonding");
6047 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6048 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6049 primary, "primary");
6050 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6051 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6053 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6054 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6057 cmdline_parse_inst_t cmd_set_bonding_primary = {
6058 .f = cmd_set_bonding_primary_parsed,
6059 .help_str = "set bonding primary <slave_id> <port_id>: "
6060 "Set the primary slave for port_id",
6063 (void *)&cmd_setbonding_primary_set,
6064 (void *)&cmd_setbonding_primary_bonding,
6065 (void *)&cmd_setbonding_primary_primary,
6066 (void *)&cmd_setbonding_primary_slave,
6067 (void *)&cmd_setbonding_primary_port,
6072 /* *** ADD SLAVE *** */
6073 struct cmd_add_bonding_slave_result {
6074 cmdline_fixed_string_t add;
6075 cmdline_fixed_string_t bonding;
6076 cmdline_fixed_string_t slave;
6081 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6082 __rte_unused struct cmdline *cl,
6083 __rte_unused void *data)
6085 struct cmd_add_bonding_slave_result *res = parsed_result;
6086 portid_t master_port_id = res->port_id;
6087 portid_t slave_port_id = res->slave_id;
6089 /* add the slave for a bonded device. */
6090 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6091 printf("\t Failed to add slave %d to master port = %d.\n",
6092 slave_port_id, master_port_id);
6096 set_port_slave_flag(slave_port_id);
6099 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6100 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6102 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6103 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6104 bonding, "bonding");
6105 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6106 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6108 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6109 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6111 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6112 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6115 cmdline_parse_inst_t cmd_add_bonding_slave = {
6116 .f = cmd_add_bonding_slave_parsed,
6117 .help_str = "add bonding slave <slave_id> <port_id>: "
6118 "Add a slave device to a bonded device",
6121 (void *)&cmd_addbonding_slave_add,
6122 (void *)&cmd_addbonding_slave_bonding,
6123 (void *)&cmd_addbonding_slave_slave,
6124 (void *)&cmd_addbonding_slave_slaveid,
6125 (void *)&cmd_addbonding_slave_port,
6130 /* *** REMOVE SLAVE *** */
6131 struct cmd_remove_bonding_slave_result {
6132 cmdline_fixed_string_t remove;
6133 cmdline_fixed_string_t bonding;
6134 cmdline_fixed_string_t slave;
6139 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6140 __rte_unused struct cmdline *cl,
6141 __rte_unused void *data)
6143 struct cmd_remove_bonding_slave_result *res = parsed_result;
6144 portid_t master_port_id = res->port_id;
6145 portid_t slave_port_id = res->slave_id;
6147 /* remove the slave from a bonded device. */
6148 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6149 printf("\t Failed to remove slave %d from master port = %d.\n",
6150 slave_port_id, master_port_id);
6154 clear_port_slave_flag(slave_port_id);
6157 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6158 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6160 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6161 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6162 bonding, "bonding");
6163 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6164 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6166 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6167 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6169 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6170 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6173 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6174 .f = cmd_remove_bonding_slave_parsed,
6175 .help_str = "remove bonding slave <slave_id> <port_id>: "
6176 "Remove a slave device from a bonded device",
6179 (void *)&cmd_removebonding_slave_remove,
6180 (void *)&cmd_removebonding_slave_bonding,
6181 (void *)&cmd_removebonding_slave_slave,
6182 (void *)&cmd_removebonding_slave_slaveid,
6183 (void *)&cmd_removebonding_slave_port,
6188 /* *** CREATE BONDED DEVICE *** */
6189 struct cmd_create_bonded_device_result {
6190 cmdline_fixed_string_t create;
6191 cmdline_fixed_string_t bonded;
6192 cmdline_fixed_string_t device;
6197 static int bond_dev_num = 0;
6199 static void cmd_create_bonded_device_parsed(void *parsed_result,
6200 __rte_unused struct cmdline *cl,
6201 __rte_unused void *data)
6203 struct cmd_create_bonded_device_result *res = parsed_result;
6204 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6208 if (test_done == 0) {
6209 printf("Please stop forwarding first\n");
6213 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6216 /* Create a new bonded device. */
6217 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6219 printf("\t Failed to create bonded device.\n");
6222 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6225 /* Update number of ports */
6226 nb_ports = rte_eth_dev_count_avail();
6227 reconfig(port_id, res->socket);
6228 ret = rte_eth_promiscuous_enable(port_id);
6230 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6231 port_id, rte_strerror(-ret));
6233 ports[port_id].need_setup = 0;
6234 ports[port_id].port_status = RTE_PORT_STOPPED;
6239 cmdline_parse_token_string_t cmd_createbonded_device_create =
6240 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6242 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6243 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6245 cmdline_parse_token_string_t cmd_createbonded_device_device =
6246 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6248 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6249 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6251 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6252 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6255 cmdline_parse_inst_t cmd_create_bonded_device = {
6256 .f = cmd_create_bonded_device_parsed,
6257 .help_str = "create bonded device <mode> <socket>: "
6258 "Create a new bonded device with specific bonding mode and socket",
6261 (void *)&cmd_createbonded_device_create,
6262 (void *)&cmd_createbonded_device_bonded,
6263 (void *)&cmd_createbonded_device_device,
6264 (void *)&cmd_createbonded_device_mode,
6265 (void *)&cmd_createbonded_device_socket,
6270 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6271 struct cmd_set_bond_mac_addr_result {
6272 cmdline_fixed_string_t set;
6273 cmdline_fixed_string_t bonding;
6274 cmdline_fixed_string_t mac_addr;
6276 struct rte_ether_addr address;
6279 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6280 __rte_unused struct cmdline *cl,
6281 __rte_unused void *data)
6283 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6286 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6289 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6291 /* check the return value and print it if is < 0 */
6293 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6296 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6297 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6298 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6299 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6301 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6302 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6304 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6305 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6307 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6308 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6310 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6311 .f = cmd_set_bond_mac_addr_parsed,
6313 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6315 (void *)&cmd_set_bond_mac_addr_set,
6316 (void *)&cmd_set_bond_mac_addr_bonding,
6317 (void *)&cmd_set_bond_mac_addr_mac,
6318 (void *)&cmd_set_bond_mac_addr_portnum,
6319 (void *)&cmd_set_bond_mac_addr_addr,
6325 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6326 struct cmd_set_bond_mon_period_result {
6327 cmdline_fixed_string_t set;
6328 cmdline_fixed_string_t bonding;
6329 cmdline_fixed_string_t mon_period;
6334 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6335 __rte_unused struct cmdline *cl,
6336 __rte_unused void *data)
6338 struct cmd_set_bond_mon_period_result *res = parsed_result;
6341 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6343 /* check the return value and print it if is < 0 */
6345 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6348 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6349 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6351 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6352 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6353 bonding, "bonding");
6354 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6355 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6356 mon_period, "mon_period");
6357 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6358 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6360 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6361 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6364 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6365 .f = cmd_set_bond_mon_period_parsed,
6367 .help_str = "set bonding mon_period <port_id> <period_ms>",
6369 (void *)&cmd_set_bond_mon_period_set,
6370 (void *)&cmd_set_bond_mon_period_bonding,
6371 (void *)&cmd_set_bond_mon_period_mon_period,
6372 (void *)&cmd_set_bond_mon_period_portnum,
6373 (void *)&cmd_set_bond_mon_period_period_ms,
6380 struct cmd_set_bonding_agg_mode_policy_result {
6381 cmdline_fixed_string_t set;
6382 cmdline_fixed_string_t bonding;
6383 cmdline_fixed_string_t agg_mode;
6385 cmdline_fixed_string_t policy;
6390 cmd_set_bonding_agg_mode(void *parsed_result,
6391 __rte_unused struct cmdline *cl,
6392 __rte_unused void *data)
6394 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6395 uint8_t policy = AGG_BANDWIDTH;
6397 if (!strcmp(res->policy, "bandwidth"))
6398 policy = AGG_BANDWIDTH;
6399 else if (!strcmp(res->policy, "stable"))
6400 policy = AGG_STABLE;
6401 else if (!strcmp(res->policy, "count"))
6404 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6408 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6409 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6411 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6412 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6413 bonding, "bonding");
6415 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6416 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6417 agg_mode, "agg_mode");
6419 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6420 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6423 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6424 TOKEN_STRING_INITIALIZER(
6425 struct cmd_set_bonding_balance_xmit_policy_result,
6426 policy, "stable#bandwidth#count");
6428 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6429 .f = cmd_set_bonding_agg_mode,
6431 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6433 (void *)&cmd_set_bonding_agg_mode_set,
6434 (void *)&cmd_set_bonding_agg_mode_bonding,
6435 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6436 (void *)&cmd_set_bonding_agg_mode_portnum,
6437 (void *)&cmd_set_bonding_agg_mode_policy_string,
6443 #endif /* RTE_LIBRTE_PMD_BOND */
6445 /* *** SET FORWARDING MODE *** */
6446 struct cmd_set_fwd_mode_result {
6447 cmdline_fixed_string_t set;
6448 cmdline_fixed_string_t fwd;
6449 cmdline_fixed_string_t mode;
6452 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6453 __rte_unused struct cmdline *cl,
6454 __rte_unused void *data)
6456 struct cmd_set_fwd_mode_result *res = parsed_result;
6459 set_pkt_forwarding_mode(res->mode);
6462 cmdline_parse_token_string_t cmd_setfwd_set =
6463 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6464 cmdline_parse_token_string_t cmd_setfwd_fwd =
6465 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6466 cmdline_parse_token_string_t cmd_setfwd_mode =
6467 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6468 "" /* defined at init */);
6470 cmdline_parse_inst_t cmd_set_fwd_mode = {
6471 .f = cmd_set_fwd_mode_parsed,
6473 .help_str = NULL, /* defined at init */
6475 (void *)&cmd_setfwd_set,
6476 (void *)&cmd_setfwd_fwd,
6477 (void *)&cmd_setfwd_mode,
6482 static void cmd_set_fwd_mode_init(void)
6485 static char token[128];
6486 static char help[256];
6487 cmdline_parse_token_string_t *token_struct;
6489 modes = list_pkt_forwarding_modes();
6490 snprintf(help, sizeof(help), "set fwd %s: "
6491 "Set packet forwarding mode", modes);
6492 cmd_set_fwd_mode.help_str = help;
6494 /* string token separator is # */
6495 for (c = token; *modes != '\0'; modes++)
6500 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6501 token_struct->string_data.str = token;
6504 /* *** SET RETRY FORWARDING MODE *** */
6505 struct cmd_set_fwd_retry_mode_result {
6506 cmdline_fixed_string_t set;
6507 cmdline_fixed_string_t fwd;
6508 cmdline_fixed_string_t mode;
6509 cmdline_fixed_string_t retry;
6512 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6513 __rte_unused struct cmdline *cl,
6514 __rte_unused void *data)
6516 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6519 set_pkt_forwarding_mode(res->mode);
6522 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6523 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6525 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6526 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6528 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6529 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6531 "" /* defined at init */);
6532 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6533 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6536 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6537 .f = cmd_set_fwd_retry_mode_parsed,
6539 .help_str = NULL, /* defined at init */
6541 (void *)&cmd_setfwd_retry_set,
6542 (void *)&cmd_setfwd_retry_fwd,
6543 (void *)&cmd_setfwd_retry_mode,
6544 (void *)&cmd_setfwd_retry_retry,
6549 static void cmd_set_fwd_retry_mode_init(void)
6552 static char token[128];
6553 static char help[256];
6554 cmdline_parse_token_string_t *token_struct;
6556 modes = list_pkt_forwarding_retry_modes();
6557 snprintf(help, sizeof(help), "set fwd %s retry: "
6558 "Set packet forwarding mode with retry", modes);
6559 cmd_set_fwd_retry_mode.help_str = help;
6561 /* string token separator is # */
6562 for (c = token; *modes != '\0'; modes++)
6567 token_struct = (cmdline_parse_token_string_t *)
6568 cmd_set_fwd_retry_mode.tokens[2];
6569 token_struct->string_data.str = token;
6572 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6573 struct cmd_set_burst_tx_retry_result {
6574 cmdline_fixed_string_t set;
6575 cmdline_fixed_string_t burst;
6576 cmdline_fixed_string_t tx;
6577 cmdline_fixed_string_t delay;
6579 cmdline_fixed_string_t retry;
6583 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6584 __rte_unused struct cmdline *cl,
6585 __rte_unused void *data)
6587 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6589 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6590 && !strcmp(res->tx, "tx")) {
6591 if (!strcmp(res->delay, "delay"))
6592 burst_tx_delay_time = res->time;
6593 if (!strcmp(res->retry, "retry"))
6594 burst_tx_retry_num = res->retry_num;
6599 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6600 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6601 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6602 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6604 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6605 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6606 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6607 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6608 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6609 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6610 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6611 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6612 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6613 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6615 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6616 .f = cmd_set_burst_tx_retry_parsed,
6617 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6619 (void *)&cmd_set_burst_tx_retry_set,
6620 (void *)&cmd_set_burst_tx_retry_burst,
6621 (void *)&cmd_set_burst_tx_retry_tx,
6622 (void *)&cmd_set_burst_tx_retry_delay,
6623 (void *)&cmd_set_burst_tx_retry_time,
6624 (void *)&cmd_set_burst_tx_retry_retry,
6625 (void *)&cmd_set_burst_tx_retry_retry_num,
6630 /* *** SET PROMISC MODE *** */
6631 struct cmd_set_promisc_mode_result {
6632 cmdline_fixed_string_t set;
6633 cmdline_fixed_string_t promisc;
6634 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6635 uint16_t port_num; /* valid if "allports" argument == 0 */
6636 cmdline_fixed_string_t mode;
6639 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6640 __rte_unused struct cmdline *cl,
6643 struct cmd_set_promisc_mode_result *res = parsed_result;
6647 if (!strcmp(res->mode, "on"))
6654 RTE_ETH_FOREACH_DEV(i)
6655 eth_set_promisc_mode(i, enable);
6657 eth_set_promisc_mode(res->port_num, enable);
6661 cmdline_parse_token_string_t cmd_setpromisc_set =
6662 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6663 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6664 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6666 cmdline_parse_token_string_t cmd_setpromisc_portall =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6669 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6670 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6672 cmdline_parse_token_string_t cmd_setpromisc_mode =
6673 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6676 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6677 .f = cmd_set_promisc_mode_parsed,
6679 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6681 (void *)&cmd_setpromisc_set,
6682 (void *)&cmd_setpromisc_promisc,
6683 (void *)&cmd_setpromisc_portall,
6684 (void *)&cmd_setpromisc_mode,
6689 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6690 .f = cmd_set_promisc_mode_parsed,
6692 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6694 (void *)&cmd_setpromisc_set,
6695 (void *)&cmd_setpromisc_promisc,
6696 (void *)&cmd_setpromisc_portnum,
6697 (void *)&cmd_setpromisc_mode,
6702 /* *** SET ALLMULTI MODE *** */
6703 struct cmd_set_allmulti_mode_result {
6704 cmdline_fixed_string_t set;
6705 cmdline_fixed_string_t allmulti;
6706 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6707 uint16_t port_num; /* valid if "allports" argument == 0 */
6708 cmdline_fixed_string_t mode;
6711 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6712 __rte_unused struct cmdline *cl,
6715 struct cmd_set_allmulti_mode_result *res = parsed_result;
6719 if (!strcmp(res->mode, "on"))
6726 RTE_ETH_FOREACH_DEV(i) {
6727 eth_set_allmulticast_mode(i, enable);
6731 eth_set_allmulticast_mode(res->port_num, enable);
6735 cmdline_parse_token_string_t cmd_setallmulti_set =
6736 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6737 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6738 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6740 cmdline_parse_token_string_t cmd_setallmulti_portall =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6743 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6744 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6746 cmdline_parse_token_string_t cmd_setallmulti_mode =
6747 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6750 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6751 .f = cmd_set_allmulti_mode_parsed,
6753 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6755 (void *)&cmd_setallmulti_set,
6756 (void *)&cmd_setallmulti_allmulti,
6757 (void *)&cmd_setallmulti_portall,
6758 (void *)&cmd_setallmulti_mode,
6763 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6764 .f = cmd_set_allmulti_mode_parsed,
6766 .help_str = "set allmulti <port_id> on|off: "
6767 "Set allmulti mode on port_id",
6769 (void *)&cmd_setallmulti_set,
6770 (void *)&cmd_setallmulti_allmulti,
6771 (void *)&cmd_setallmulti_portnum,
6772 (void *)&cmd_setallmulti_mode,
6777 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6778 struct cmd_link_flow_ctrl_set_result {
6779 cmdline_fixed_string_t set;
6780 cmdline_fixed_string_t flow_ctrl;
6781 cmdline_fixed_string_t rx;
6782 cmdline_fixed_string_t rx_lfc_mode;
6783 cmdline_fixed_string_t tx;
6784 cmdline_fixed_string_t tx_lfc_mode;
6785 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6786 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6787 cmdline_fixed_string_t autoneg_str;
6788 cmdline_fixed_string_t autoneg;
6789 cmdline_fixed_string_t hw_str;
6790 uint32_t high_water;
6791 cmdline_fixed_string_t lw_str;
6793 cmdline_fixed_string_t pt_str;
6794 uint16_t pause_time;
6795 cmdline_fixed_string_t xon_str;
6800 cmdline_parse_token_string_t cmd_lfc_set_set =
6801 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6803 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6804 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6805 flow_ctrl, "flow_ctrl");
6806 cmdline_parse_token_string_t cmd_lfc_set_rx =
6807 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6809 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6810 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6811 rx_lfc_mode, "on#off");
6812 cmdline_parse_token_string_t cmd_lfc_set_tx =
6813 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6815 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6816 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6817 tx_lfc_mode, "on#off");
6818 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6819 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6820 hw_str, "high_water");
6821 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6822 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6823 high_water, UINT32);
6824 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6825 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6826 lw_str, "low_water");
6827 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6828 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6830 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6831 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6832 pt_str, "pause_time");
6833 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6834 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6835 pause_time, UINT16);
6836 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6837 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6838 xon_str, "send_xon");
6839 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6840 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6842 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6843 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6844 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6845 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6846 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6847 mac_ctrl_frame_fwd_mode, "on#off");
6848 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6849 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6850 autoneg_str, "autoneg");
6851 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6852 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6854 cmdline_parse_token_num_t cmd_lfc_set_portid =
6855 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6858 /* forward declaration */
6860 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6863 cmdline_parse_inst_t cmd_link_flow_control_set = {
6864 .f = cmd_link_flow_ctrl_set_parsed,
6866 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6867 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6868 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6870 (void *)&cmd_lfc_set_set,
6871 (void *)&cmd_lfc_set_flow_ctrl,
6872 (void *)&cmd_lfc_set_rx,
6873 (void *)&cmd_lfc_set_rx_mode,
6874 (void *)&cmd_lfc_set_tx,
6875 (void *)&cmd_lfc_set_tx_mode,
6876 (void *)&cmd_lfc_set_high_water,
6877 (void *)&cmd_lfc_set_low_water,
6878 (void *)&cmd_lfc_set_pause_time,
6879 (void *)&cmd_lfc_set_send_xon,
6880 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6881 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6882 (void *)&cmd_lfc_set_autoneg_str,
6883 (void *)&cmd_lfc_set_autoneg,
6884 (void *)&cmd_lfc_set_portid,
6889 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6890 .f = cmd_link_flow_ctrl_set_parsed,
6891 .data = (void *)&cmd_link_flow_control_set_rx,
6892 .help_str = "set flow_ctrl rx on|off <port_id>: "
6893 "Change rx flow control parameter",
6895 (void *)&cmd_lfc_set_set,
6896 (void *)&cmd_lfc_set_flow_ctrl,
6897 (void *)&cmd_lfc_set_rx,
6898 (void *)&cmd_lfc_set_rx_mode,
6899 (void *)&cmd_lfc_set_portid,
6904 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6905 .f = cmd_link_flow_ctrl_set_parsed,
6906 .data = (void *)&cmd_link_flow_control_set_tx,
6907 .help_str = "set flow_ctrl tx on|off <port_id>: "
6908 "Change tx flow control parameter",
6910 (void *)&cmd_lfc_set_set,
6911 (void *)&cmd_lfc_set_flow_ctrl,
6912 (void *)&cmd_lfc_set_tx,
6913 (void *)&cmd_lfc_set_tx_mode,
6914 (void *)&cmd_lfc_set_portid,
6919 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6920 .f = cmd_link_flow_ctrl_set_parsed,
6921 .data = (void *)&cmd_link_flow_control_set_hw,
6922 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6923 "Change high water flow control parameter",
6925 (void *)&cmd_lfc_set_set,
6926 (void *)&cmd_lfc_set_flow_ctrl,
6927 (void *)&cmd_lfc_set_high_water_str,
6928 (void *)&cmd_lfc_set_high_water,
6929 (void *)&cmd_lfc_set_portid,
6934 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6935 .f = cmd_link_flow_ctrl_set_parsed,
6936 .data = (void *)&cmd_link_flow_control_set_lw,
6937 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6938 "Change low water flow control parameter",
6940 (void *)&cmd_lfc_set_set,
6941 (void *)&cmd_lfc_set_flow_ctrl,
6942 (void *)&cmd_lfc_set_low_water_str,
6943 (void *)&cmd_lfc_set_low_water,
6944 (void *)&cmd_lfc_set_portid,
6949 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6950 .f = cmd_link_flow_ctrl_set_parsed,
6951 .data = (void *)&cmd_link_flow_control_set_pt,
6952 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6953 "Change pause time flow control parameter",
6955 (void *)&cmd_lfc_set_set,
6956 (void *)&cmd_lfc_set_flow_ctrl,
6957 (void *)&cmd_lfc_set_pause_time_str,
6958 (void *)&cmd_lfc_set_pause_time,
6959 (void *)&cmd_lfc_set_portid,
6964 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6965 .f = cmd_link_flow_ctrl_set_parsed,
6966 .data = (void *)&cmd_link_flow_control_set_xon,
6967 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6968 "Change send_xon flow control parameter",
6970 (void *)&cmd_lfc_set_set,
6971 (void *)&cmd_lfc_set_flow_ctrl,
6972 (void *)&cmd_lfc_set_send_xon_str,
6973 (void *)&cmd_lfc_set_send_xon,
6974 (void *)&cmd_lfc_set_portid,
6979 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6980 .f = cmd_link_flow_ctrl_set_parsed,
6981 .data = (void *)&cmd_link_flow_control_set_macfwd,
6982 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6983 "Change mac ctrl fwd flow control parameter",
6985 (void *)&cmd_lfc_set_set,
6986 (void *)&cmd_lfc_set_flow_ctrl,
6987 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6988 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6989 (void *)&cmd_lfc_set_portid,
6994 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6995 .f = cmd_link_flow_ctrl_set_parsed,
6996 .data = (void *)&cmd_link_flow_control_set_autoneg,
6997 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6998 "Change autoneg flow control parameter",
7000 (void *)&cmd_lfc_set_set,
7001 (void *)&cmd_lfc_set_flow_ctrl,
7002 (void *)&cmd_lfc_set_autoneg_str,
7003 (void *)&cmd_lfc_set_autoneg,
7004 (void *)&cmd_lfc_set_portid,
7010 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7011 __rte_unused struct cmdline *cl,
7014 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7015 cmdline_parse_inst_t *cmd = data;
7016 struct rte_eth_fc_conf fc_conf;
7022 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7023 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7024 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7025 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7027 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7028 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7031 /* Partial command line, retrieve current configuration */
7033 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7035 printf("cannot get current flow ctrl parameters, return"
7036 "code = %d\n", ret);
7040 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7041 (fc_conf.mode == RTE_FC_FULL))
7043 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7044 (fc_conf.mode == RTE_FC_FULL))
7048 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7049 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7051 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7052 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7054 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7056 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7057 fc_conf.high_water = res->high_water;
7059 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7060 fc_conf.low_water = res->low_water;
7062 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7063 fc_conf.pause_time = res->pause_time;
7065 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7066 fc_conf.send_xon = res->send_xon;
7068 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7069 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7070 fc_conf.mac_ctrl_frame_fwd = 1;
7072 fc_conf.mac_ctrl_frame_fwd = 0;
7075 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7076 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7078 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7080 printf("bad flow contrl parameter, return code = %d \n", ret);
7083 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7084 struct cmd_priority_flow_ctrl_set_result {
7085 cmdline_fixed_string_t set;
7086 cmdline_fixed_string_t pfc_ctrl;
7087 cmdline_fixed_string_t rx;
7088 cmdline_fixed_string_t rx_pfc_mode;
7089 cmdline_fixed_string_t tx;
7090 cmdline_fixed_string_t tx_pfc_mode;
7091 uint32_t high_water;
7093 uint16_t pause_time;
7099 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7100 __rte_unused struct cmdline *cl,
7101 __rte_unused void *data)
7103 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7104 struct rte_eth_pfc_conf pfc_conf;
7105 int rx_fc_enable, tx_fc_enable;
7109 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7110 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7111 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7112 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7114 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7115 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7118 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7119 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7120 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7121 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7122 pfc_conf.fc.high_water = res->high_water;
7123 pfc_conf.fc.low_water = res->low_water;
7124 pfc_conf.fc.pause_time = res->pause_time;
7125 pfc_conf.priority = res->priority;
7127 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7129 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7132 cmdline_parse_token_string_t cmd_pfc_set_set =
7133 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7135 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7136 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7137 pfc_ctrl, "pfc_ctrl");
7138 cmdline_parse_token_string_t cmd_pfc_set_rx =
7139 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7141 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7142 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7143 rx_pfc_mode, "on#off");
7144 cmdline_parse_token_string_t cmd_pfc_set_tx =
7145 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7147 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7148 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7149 tx_pfc_mode, "on#off");
7150 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7151 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7152 high_water, UINT32);
7153 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7154 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7156 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7157 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7158 pause_time, UINT16);
7159 cmdline_parse_token_num_t cmd_pfc_set_priority =
7160 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7162 cmdline_parse_token_num_t cmd_pfc_set_portid =
7163 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7166 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7167 .f = cmd_priority_flow_ctrl_set_parsed,
7169 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7170 "<pause_time> <priority> <port_id>: "
7171 "Configure the Ethernet priority flow control",
7173 (void *)&cmd_pfc_set_set,
7174 (void *)&cmd_pfc_set_flow_ctrl,
7175 (void *)&cmd_pfc_set_rx,
7176 (void *)&cmd_pfc_set_rx_mode,
7177 (void *)&cmd_pfc_set_tx,
7178 (void *)&cmd_pfc_set_tx_mode,
7179 (void *)&cmd_pfc_set_high_water,
7180 (void *)&cmd_pfc_set_low_water,
7181 (void *)&cmd_pfc_set_pause_time,
7182 (void *)&cmd_pfc_set_priority,
7183 (void *)&cmd_pfc_set_portid,
7188 /* *** RESET CONFIGURATION *** */
7189 struct cmd_reset_result {
7190 cmdline_fixed_string_t reset;
7191 cmdline_fixed_string_t def;
7194 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7196 __rte_unused void *data)
7198 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7199 set_def_fwd_config();
7202 cmdline_parse_token_string_t cmd_reset_set =
7203 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7204 cmdline_parse_token_string_t cmd_reset_def =
7205 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7208 cmdline_parse_inst_t cmd_reset = {
7209 .f = cmd_reset_parsed,
7211 .help_str = "set default: Reset default forwarding configuration",
7213 (void *)&cmd_reset_set,
7214 (void *)&cmd_reset_def,
7219 /* *** START FORWARDING *** */
7220 struct cmd_start_result {
7221 cmdline_fixed_string_t start;
7224 cmdline_parse_token_string_t cmd_start_start =
7225 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7227 static void cmd_start_parsed(__rte_unused void *parsed_result,
7228 __rte_unused struct cmdline *cl,
7229 __rte_unused void *data)
7231 start_packet_forwarding(0);
7234 cmdline_parse_inst_t cmd_start = {
7235 .f = cmd_start_parsed,
7237 .help_str = "start: Start packet forwarding",
7239 (void *)&cmd_start_start,
7244 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7245 struct cmd_start_tx_first_result {
7246 cmdline_fixed_string_t start;
7247 cmdline_fixed_string_t tx_first;
7251 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7252 __rte_unused struct cmdline *cl,
7253 __rte_unused void *data)
7255 start_packet_forwarding(1);
7258 cmdline_parse_token_string_t cmd_start_tx_first_start =
7259 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7261 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7262 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7263 tx_first, "tx_first");
7265 cmdline_parse_inst_t cmd_start_tx_first = {
7266 .f = cmd_start_tx_first_parsed,
7268 .help_str = "start tx_first: Start packet forwarding, "
7269 "after sending 1 burst of packets",
7271 (void *)&cmd_start_tx_first_start,
7272 (void *)&cmd_start_tx_first_tx_first,
7277 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7278 struct cmd_start_tx_first_n_result {
7279 cmdline_fixed_string_t start;
7280 cmdline_fixed_string_t tx_first;
7285 cmd_start_tx_first_n_parsed(void *parsed_result,
7286 __rte_unused struct cmdline *cl,
7287 __rte_unused void *data)
7289 struct cmd_start_tx_first_n_result *res = parsed_result;
7291 start_packet_forwarding(res->tx_num);
7294 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7295 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7297 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7298 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7299 tx_first, "tx_first");
7300 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7301 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7304 cmdline_parse_inst_t cmd_start_tx_first_n = {
7305 .f = cmd_start_tx_first_n_parsed,
7307 .help_str = "start tx_first <num>: "
7308 "packet forwarding, after sending <num> bursts of packets",
7310 (void *)&cmd_start_tx_first_n_start,
7311 (void *)&cmd_start_tx_first_n_tx_first,
7312 (void *)&cmd_start_tx_first_n_tx_num,
7317 /* *** SET LINK UP *** */
7318 struct cmd_set_link_up_result {
7319 cmdline_fixed_string_t set;
7320 cmdline_fixed_string_t link_up;
7321 cmdline_fixed_string_t port;
7325 cmdline_parse_token_string_t cmd_set_link_up_set =
7326 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7327 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7328 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7330 cmdline_parse_token_string_t cmd_set_link_up_port =
7331 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7332 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7333 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7335 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7336 __rte_unused struct cmdline *cl,
7337 __rte_unused void *data)
7339 struct cmd_set_link_up_result *res = parsed_result;
7340 dev_set_link_up(res->port_id);
7343 cmdline_parse_inst_t cmd_set_link_up = {
7344 .f = cmd_set_link_up_parsed,
7346 .help_str = "set link-up port <port id>",
7348 (void *)&cmd_set_link_up_set,
7349 (void *)&cmd_set_link_up_link_up,
7350 (void *)&cmd_set_link_up_port,
7351 (void *)&cmd_set_link_up_port_id,
7356 /* *** SET LINK DOWN *** */
7357 struct cmd_set_link_down_result {
7358 cmdline_fixed_string_t set;
7359 cmdline_fixed_string_t link_down;
7360 cmdline_fixed_string_t port;
7364 cmdline_parse_token_string_t cmd_set_link_down_set =
7365 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7366 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7367 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7369 cmdline_parse_token_string_t cmd_set_link_down_port =
7370 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7371 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7372 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7374 static void cmd_set_link_down_parsed(
7375 __rte_unused void *parsed_result,
7376 __rte_unused struct cmdline *cl,
7377 __rte_unused void *data)
7379 struct cmd_set_link_down_result *res = parsed_result;
7380 dev_set_link_down(res->port_id);
7383 cmdline_parse_inst_t cmd_set_link_down = {
7384 .f = cmd_set_link_down_parsed,
7386 .help_str = "set link-down port <port id>",
7388 (void *)&cmd_set_link_down_set,
7389 (void *)&cmd_set_link_down_link_down,
7390 (void *)&cmd_set_link_down_port,
7391 (void *)&cmd_set_link_down_port_id,
7396 /* *** SHOW CFG *** */
7397 struct cmd_showcfg_result {
7398 cmdline_fixed_string_t show;
7399 cmdline_fixed_string_t cfg;
7400 cmdline_fixed_string_t what;
7403 static void cmd_showcfg_parsed(void *parsed_result,
7404 __rte_unused struct cmdline *cl,
7405 __rte_unused void *data)
7407 struct cmd_showcfg_result *res = parsed_result;
7408 if (!strcmp(res->what, "rxtx"))
7409 rxtx_config_display();
7410 else if (!strcmp(res->what, "cores"))
7411 fwd_lcores_config_display();
7412 else if (!strcmp(res->what, "fwd"))
7413 pkt_fwd_config_display(&cur_fwd_config);
7414 else if (!strcmp(res->what, "txpkts"))
7415 show_tx_pkt_segments();
7418 cmdline_parse_token_string_t cmd_showcfg_show =
7419 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7420 cmdline_parse_token_string_t cmd_showcfg_port =
7421 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7422 cmdline_parse_token_string_t cmd_showcfg_what =
7423 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7424 "rxtx#cores#fwd#txpkts");
7426 cmdline_parse_inst_t cmd_showcfg = {
7427 .f = cmd_showcfg_parsed,
7429 .help_str = "show config rxtx|cores|fwd|txpkts",
7431 (void *)&cmd_showcfg_show,
7432 (void *)&cmd_showcfg_port,
7433 (void *)&cmd_showcfg_what,
7438 /* *** SHOW ALL PORT INFO *** */
7439 struct cmd_showportall_result {
7440 cmdline_fixed_string_t show;
7441 cmdline_fixed_string_t port;
7442 cmdline_fixed_string_t what;
7443 cmdline_fixed_string_t all;
7446 static void cmd_showportall_parsed(void *parsed_result,
7447 __rte_unused struct cmdline *cl,
7448 __rte_unused void *data)
7452 struct cmd_showportall_result *res = parsed_result;
7453 if (!strcmp(res->show, "clear")) {
7454 if (!strcmp(res->what, "stats"))
7455 RTE_ETH_FOREACH_DEV(i)
7457 else if (!strcmp(res->what, "xstats"))
7458 RTE_ETH_FOREACH_DEV(i)
7459 nic_xstats_clear(i);
7460 } else if (!strcmp(res->what, "info"))
7461 RTE_ETH_FOREACH_DEV(i)
7462 port_infos_display(i);
7463 else if (!strcmp(res->what, "summary")) {
7464 port_summary_header_display();
7465 RTE_ETH_FOREACH_DEV(i)
7466 port_summary_display(i);
7468 else if (!strcmp(res->what, "stats"))
7469 RTE_ETH_FOREACH_DEV(i)
7470 nic_stats_display(i);
7471 else if (!strcmp(res->what, "xstats"))
7472 RTE_ETH_FOREACH_DEV(i)
7473 nic_xstats_display(i);
7474 else if (!strcmp(res->what, "fdir"))
7475 RTE_ETH_FOREACH_DEV(i)
7477 else if (!strcmp(res->what, "stat_qmap"))
7478 RTE_ETH_FOREACH_DEV(i)
7479 nic_stats_mapping_display(i);
7480 else if (!strcmp(res->what, "dcb_tc"))
7481 RTE_ETH_FOREACH_DEV(i)
7482 port_dcb_info_display(i);
7483 else if (!strcmp(res->what, "cap"))
7484 RTE_ETH_FOREACH_DEV(i)
7485 port_offload_cap_display(i);
7488 cmdline_parse_token_string_t cmd_showportall_show =
7489 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7491 cmdline_parse_token_string_t cmd_showportall_port =
7492 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7493 cmdline_parse_token_string_t cmd_showportall_what =
7494 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7495 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7496 cmdline_parse_token_string_t cmd_showportall_all =
7497 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7498 cmdline_parse_inst_t cmd_showportall = {
7499 .f = cmd_showportall_parsed,
7501 .help_str = "show|clear port "
7502 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7504 (void *)&cmd_showportall_show,
7505 (void *)&cmd_showportall_port,
7506 (void *)&cmd_showportall_what,
7507 (void *)&cmd_showportall_all,
7512 /* *** SHOW PORT INFO *** */
7513 struct cmd_showport_result {
7514 cmdline_fixed_string_t show;
7515 cmdline_fixed_string_t port;
7516 cmdline_fixed_string_t what;
7520 static void cmd_showport_parsed(void *parsed_result,
7521 __rte_unused struct cmdline *cl,
7522 __rte_unused void *data)
7524 struct cmd_showport_result *res = parsed_result;
7525 if (!strcmp(res->show, "clear")) {
7526 if (!strcmp(res->what, "stats"))
7527 nic_stats_clear(res->portnum);
7528 else if (!strcmp(res->what, "xstats"))
7529 nic_xstats_clear(res->portnum);
7530 } else if (!strcmp(res->what, "info"))
7531 port_infos_display(res->portnum);
7532 else if (!strcmp(res->what, "summary")) {
7533 port_summary_header_display();
7534 port_summary_display(res->portnum);
7536 else if (!strcmp(res->what, "stats"))
7537 nic_stats_display(res->portnum);
7538 else if (!strcmp(res->what, "xstats"))
7539 nic_xstats_display(res->portnum);
7540 else if (!strcmp(res->what, "fdir"))
7541 fdir_get_infos(res->portnum);
7542 else if (!strcmp(res->what, "stat_qmap"))
7543 nic_stats_mapping_display(res->portnum);
7544 else if (!strcmp(res->what, "dcb_tc"))
7545 port_dcb_info_display(res->portnum);
7546 else if (!strcmp(res->what, "cap"))
7547 port_offload_cap_display(res->portnum);
7550 cmdline_parse_token_string_t cmd_showport_show =
7551 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7553 cmdline_parse_token_string_t cmd_showport_port =
7554 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7555 cmdline_parse_token_string_t cmd_showport_what =
7556 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7557 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7558 cmdline_parse_token_num_t cmd_showport_portnum =
7559 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7561 cmdline_parse_inst_t cmd_showport = {
7562 .f = cmd_showport_parsed,
7564 .help_str = "show|clear port "
7565 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7568 (void *)&cmd_showport_show,
7569 (void *)&cmd_showport_port,
7570 (void *)&cmd_showport_what,
7571 (void *)&cmd_showport_portnum,
7576 /* *** SHOW DEVICE INFO *** */
7577 struct cmd_showdevice_result {
7578 cmdline_fixed_string_t show;
7579 cmdline_fixed_string_t device;
7580 cmdline_fixed_string_t what;
7581 cmdline_fixed_string_t identifier;
7584 static void cmd_showdevice_parsed(void *parsed_result,
7585 __rte_unused struct cmdline *cl,
7586 __rte_unused void *data)
7588 struct cmd_showdevice_result *res = parsed_result;
7589 if (!strcmp(res->what, "info")) {
7590 if (!strcmp(res->identifier, "all"))
7591 device_infos_display(NULL);
7593 device_infos_display(res->identifier);
7597 cmdline_parse_token_string_t cmd_showdevice_show =
7598 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7600 cmdline_parse_token_string_t cmd_showdevice_device =
7601 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7602 cmdline_parse_token_string_t cmd_showdevice_what =
7603 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7605 cmdline_parse_token_string_t cmd_showdevice_identifier =
7606 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7609 cmdline_parse_inst_t cmd_showdevice = {
7610 .f = cmd_showdevice_parsed,
7612 .help_str = "show device info <identifier>|all",
7614 (void *)&cmd_showdevice_show,
7615 (void *)&cmd_showdevice_device,
7616 (void *)&cmd_showdevice_what,
7617 (void *)&cmd_showdevice_identifier,
7621 /* *** SHOW QUEUE INFO *** */
7622 struct cmd_showqueue_result {
7623 cmdline_fixed_string_t show;
7624 cmdline_fixed_string_t type;
7625 cmdline_fixed_string_t what;
7631 cmd_showqueue_parsed(void *parsed_result,
7632 __rte_unused struct cmdline *cl,
7633 __rte_unused void *data)
7635 struct cmd_showqueue_result *res = parsed_result;
7637 if (!strcmp(res->type, "rxq"))
7638 rx_queue_infos_display(res->portnum, res->queuenum);
7639 else if (!strcmp(res->type, "txq"))
7640 tx_queue_infos_display(res->portnum, res->queuenum);
7643 cmdline_parse_token_string_t cmd_showqueue_show =
7644 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7645 cmdline_parse_token_string_t cmd_showqueue_type =
7646 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7647 cmdline_parse_token_string_t cmd_showqueue_what =
7648 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7649 cmdline_parse_token_num_t cmd_showqueue_portnum =
7650 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7651 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7652 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7654 cmdline_parse_inst_t cmd_showqueue = {
7655 .f = cmd_showqueue_parsed,
7657 .help_str = "show rxq|txq info <port_id> <queue_id>",
7659 (void *)&cmd_showqueue_show,
7660 (void *)&cmd_showqueue_type,
7661 (void *)&cmd_showqueue_what,
7662 (void *)&cmd_showqueue_portnum,
7663 (void *)&cmd_showqueue_queuenum,
7668 /* show/clear fwd engine statistics */
7670 cmdline_fixed_string_t action;
7671 cmdline_fixed_string_t fwd;
7672 cmdline_fixed_string_t stats;
7673 cmdline_fixed_string_t all;
7676 cmdline_parse_token_string_t cmd_fwd_action =
7677 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7678 cmdline_parse_token_string_t cmd_fwd_fwd =
7679 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7680 cmdline_parse_token_string_t cmd_fwd_stats =
7681 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7682 cmdline_parse_token_string_t cmd_fwd_all =
7683 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7686 cmd_showfwdall_parsed(void *parsed_result,
7687 __rte_unused struct cmdline *cl,
7688 __rte_unused void *data)
7690 struct fwd_result *res = parsed_result;
7692 if (!strcmp(res->action, "show"))
7693 fwd_stats_display();
7698 static cmdline_parse_inst_t cmd_showfwdall = {
7699 .f = cmd_showfwdall_parsed,
7701 .help_str = "show|clear fwd stats all",
7703 (void *)&cmd_fwd_action,
7704 (void *)&cmd_fwd_fwd,
7705 (void *)&cmd_fwd_stats,
7706 (void *)&cmd_fwd_all,
7711 /* *** READ PORT REGISTER *** */
7712 struct cmd_read_reg_result {
7713 cmdline_fixed_string_t read;
7714 cmdline_fixed_string_t reg;
7720 cmd_read_reg_parsed(void *parsed_result,
7721 __rte_unused struct cmdline *cl,
7722 __rte_unused void *data)
7724 struct cmd_read_reg_result *res = parsed_result;
7725 port_reg_display(res->port_id, res->reg_off);
7728 cmdline_parse_token_string_t cmd_read_reg_read =
7729 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7730 cmdline_parse_token_string_t cmd_read_reg_reg =
7731 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7732 cmdline_parse_token_num_t cmd_read_reg_port_id =
7733 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7734 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7735 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7737 cmdline_parse_inst_t cmd_read_reg = {
7738 .f = cmd_read_reg_parsed,
7740 .help_str = "read reg <port_id> <reg_off>",
7742 (void *)&cmd_read_reg_read,
7743 (void *)&cmd_read_reg_reg,
7744 (void *)&cmd_read_reg_port_id,
7745 (void *)&cmd_read_reg_reg_off,
7750 /* *** READ PORT REGISTER BIT FIELD *** */
7751 struct cmd_read_reg_bit_field_result {
7752 cmdline_fixed_string_t read;
7753 cmdline_fixed_string_t regfield;
7761 cmd_read_reg_bit_field_parsed(void *parsed_result,
7762 __rte_unused struct cmdline *cl,
7763 __rte_unused void *data)
7765 struct cmd_read_reg_bit_field_result *res = parsed_result;
7766 port_reg_bit_field_display(res->port_id, res->reg_off,
7767 res->bit1_pos, res->bit2_pos);
7770 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7771 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7773 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7774 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7775 regfield, "regfield");
7776 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7777 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7779 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7780 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7782 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7783 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7785 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7786 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7789 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7790 .f = cmd_read_reg_bit_field_parsed,
7792 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7793 "Read register bit field between bit_x and bit_y included",
7795 (void *)&cmd_read_reg_bit_field_read,
7796 (void *)&cmd_read_reg_bit_field_regfield,
7797 (void *)&cmd_read_reg_bit_field_port_id,
7798 (void *)&cmd_read_reg_bit_field_reg_off,
7799 (void *)&cmd_read_reg_bit_field_bit1_pos,
7800 (void *)&cmd_read_reg_bit_field_bit2_pos,
7805 /* *** READ PORT REGISTER BIT *** */
7806 struct cmd_read_reg_bit_result {
7807 cmdline_fixed_string_t read;
7808 cmdline_fixed_string_t regbit;
7815 cmd_read_reg_bit_parsed(void *parsed_result,
7816 __rte_unused struct cmdline *cl,
7817 __rte_unused void *data)
7819 struct cmd_read_reg_bit_result *res = parsed_result;
7820 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7823 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7824 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7825 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7826 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7828 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7829 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7830 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7831 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7832 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7833 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7835 cmdline_parse_inst_t cmd_read_reg_bit = {
7836 .f = cmd_read_reg_bit_parsed,
7838 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7840 (void *)&cmd_read_reg_bit_read,
7841 (void *)&cmd_read_reg_bit_regbit,
7842 (void *)&cmd_read_reg_bit_port_id,
7843 (void *)&cmd_read_reg_bit_reg_off,
7844 (void *)&cmd_read_reg_bit_bit_pos,
7849 /* *** WRITE PORT REGISTER *** */
7850 struct cmd_write_reg_result {
7851 cmdline_fixed_string_t write;
7852 cmdline_fixed_string_t reg;
7859 cmd_write_reg_parsed(void *parsed_result,
7860 __rte_unused struct cmdline *cl,
7861 __rte_unused void *data)
7863 struct cmd_write_reg_result *res = parsed_result;
7864 port_reg_set(res->port_id, res->reg_off, res->value);
7867 cmdline_parse_token_string_t cmd_write_reg_write =
7868 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7869 cmdline_parse_token_string_t cmd_write_reg_reg =
7870 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7871 cmdline_parse_token_num_t cmd_write_reg_port_id =
7872 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7873 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7874 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7875 cmdline_parse_token_num_t cmd_write_reg_value =
7876 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7878 cmdline_parse_inst_t cmd_write_reg = {
7879 .f = cmd_write_reg_parsed,
7881 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7883 (void *)&cmd_write_reg_write,
7884 (void *)&cmd_write_reg_reg,
7885 (void *)&cmd_write_reg_port_id,
7886 (void *)&cmd_write_reg_reg_off,
7887 (void *)&cmd_write_reg_value,
7892 /* *** WRITE PORT REGISTER BIT FIELD *** */
7893 struct cmd_write_reg_bit_field_result {
7894 cmdline_fixed_string_t write;
7895 cmdline_fixed_string_t regfield;
7904 cmd_write_reg_bit_field_parsed(void *parsed_result,
7905 __rte_unused struct cmdline *cl,
7906 __rte_unused void *data)
7908 struct cmd_write_reg_bit_field_result *res = parsed_result;
7909 port_reg_bit_field_set(res->port_id, res->reg_off,
7910 res->bit1_pos, res->bit2_pos, res->value);
7913 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7914 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7916 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7917 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7918 regfield, "regfield");
7919 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7920 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7922 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7923 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7925 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7926 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7928 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7929 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7931 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7932 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7935 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7936 .f = cmd_write_reg_bit_field_parsed,
7938 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7940 "Set register bit field between bit_x and bit_y included",
7942 (void *)&cmd_write_reg_bit_field_write,
7943 (void *)&cmd_write_reg_bit_field_regfield,
7944 (void *)&cmd_write_reg_bit_field_port_id,
7945 (void *)&cmd_write_reg_bit_field_reg_off,
7946 (void *)&cmd_write_reg_bit_field_bit1_pos,
7947 (void *)&cmd_write_reg_bit_field_bit2_pos,
7948 (void *)&cmd_write_reg_bit_field_value,
7953 /* *** WRITE PORT REGISTER BIT *** */
7954 struct cmd_write_reg_bit_result {
7955 cmdline_fixed_string_t write;
7956 cmdline_fixed_string_t regbit;
7964 cmd_write_reg_bit_parsed(void *parsed_result,
7965 __rte_unused struct cmdline *cl,
7966 __rte_unused void *data)
7968 struct cmd_write_reg_bit_result *res = parsed_result;
7969 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7972 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7973 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7975 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7976 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7978 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7979 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7980 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7981 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7982 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7983 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7984 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7985 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7987 cmdline_parse_inst_t cmd_write_reg_bit = {
7988 .f = cmd_write_reg_bit_parsed,
7990 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7993 (void *)&cmd_write_reg_bit_write,
7994 (void *)&cmd_write_reg_bit_regbit,
7995 (void *)&cmd_write_reg_bit_port_id,
7996 (void *)&cmd_write_reg_bit_reg_off,
7997 (void *)&cmd_write_reg_bit_bit_pos,
7998 (void *)&cmd_write_reg_bit_value,
8003 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8004 struct cmd_read_rxd_txd_result {
8005 cmdline_fixed_string_t read;
8006 cmdline_fixed_string_t rxd_txd;
8013 cmd_read_rxd_txd_parsed(void *parsed_result,
8014 __rte_unused struct cmdline *cl,
8015 __rte_unused void *data)
8017 struct cmd_read_rxd_txd_result *res = parsed_result;
8019 if (!strcmp(res->rxd_txd, "rxd"))
8020 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8021 else if (!strcmp(res->rxd_txd, "txd"))
8022 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8025 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8026 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8027 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8028 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8030 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8031 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8032 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8033 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8034 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8035 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8037 cmdline_parse_inst_t cmd_read_rxd_txd = {
8038 .f = cmd_read_rxd_txd_parsed,
8040 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8042 (void *)&cmd_read_rxd_txd_read,
8043 (void *)&cmd_read_rxd_txd_rxd_txd,
8044 (void *)&cmd_read_rxd_txd_port_id,
8045 (void *)&cmd_read_rxd_txd_queue_id,
8046 (void *)&cmd_read_rxd_txd_desc_id,
8052 struct cmd_quit_result {
8053 cmdline_fixed_string_t quit;
8056 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8058 __rte_unused void *data)
8063 cmdline_parse_token_string_t cmd_quit_quit =
8064 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8066 cmdline_parse_inst_t cmd_quit = {
8067 .f = cmd_quit_parsed,
8069 .help_str = "quit: Exit application",
8071 (void *)&cmd_quit_quit,
8076 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8077 struct cmd_mac_addr_result {
8078 cmdline_fixed_string_t mac_addr_cmd;
8079 cmdline_fixed_string_t what;
8081 struct rte_ether_addr address;
8084 static void cmd_mac_addr_parsed(void *parsed_result,
8085 __rte_unused struct cmdline *cl,
8086 __rte_unused void *data)
8088 struct cmd_mac_addr_result *res = parsed_result;
8091 if (strcmp(res->what, "add") == 0)
8092 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8093 else if (strcmp(res->what, "set") == 0)
8094 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8097 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8099 /* check the return value and print it if is < 0 */
8101 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8105 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8106 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8108 cmdline_parse_token_string_t cmd_mac_addr_what =
8109 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8111 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8112 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8114 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8115 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8117 cmdline_parse_inst_t cmd_mac_addr = {
8118 .f = cmd_mac_addr_parsed,
8120 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8121 "Add/Remove/Set MAC address on port_id",
8123 (void *)&cmd_mac_addr_cmd,
8124 (void *)&cmd_mac_addr_what,
8125 (void *)&cmd_mac_addr_portnum,
8126 (void *)&cmd_mac_addr_addr,
8131 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8132 struct cmd_eth_peer_result {
8133 cmdline_fixed_string_t set;
8134 cmdline_fixed_string_t eth_peer;
8136 cmdline_fixed_string_t peer_addr;
8139 static void cmd_set_eth_peer_parsed(void *parsed_result,
8140 __rte_unused struct cmdline *cl,
8141 __rte_unused void *data)
8143 struct cmd_eth_peer_result *res = parsed_result;
8145 if (test_done == 0) {
8146 printf("Please stop forwarding first\n");
8149 if (!strcmp(res->eth_peer, "eth-peer")) {
8150 set_fwd_eth_peer(res->port_id, res->peer_addr);
8154 cmdline_parse_token_string_t cmd_eth_peer_set =
8155 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8156 cmdline_parse_token_string_t cmd_eth_peer =
8157 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8158 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8159 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8160 cmdline_parse_token_string_t cmd_eth_peer_addr =
8161 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8163 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8164 .f = cmd_set_eth_peer_parsed,
8166 .help_str = "set eth-peer <port_id> <peer_mac>",
8168 (void *)&cmd_eth_peer_set,
8169 (void *)&cmd_eth_peer,
8170 (void *)&cmd_eth_peer_port_id,
8171 (void *)&cmd_eth_peer_addr,
8176 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8177 struct cmd_set_qmap_result {
8178 cmdline_fixed_string_t set;
8179 cmdline_fixed_string_t qmap;
8180 cmdline_fixed_string_t what;
8187 cmd_set_qmap_parsed(void *parsed_result,
8188 __rte_unused struct cmdline *cl,
8189 __rte_unused void *data)
8191 struct cmd_set_qmap_result *res = parsed_result;
8192 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8194 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8197 cmdline_parse_token_string_t cmd_setqmap_set =
8198 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8200 cmdline_parse_token_string_t cmd_setqmap_qmap =
8201 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8203 cmdline_parse_token_string_t cmd_setqmap_what =
8204 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8206 cmdline_parse_token_num_t cmd_setqmap_portid =
8207 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8209 cmdline_parse_token_num_t cmd_setqmap_queueid =
8210 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8212 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8213 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8216 cmdline_parse_inst_t cmd_set_qmap = {
8217 .f = cmd_set_qmap_parsed,
8219 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8220 "Set statistics mapping value on tx|rx queue_id of port_id",
8222 (void *)&cmd_setqmap_set,
8223 (void *)&cmd_setqmap_qmap,
8224 (void *)&cmd_setqmap_what,
8225 (void *)&cmd_setqmap_portid,
8226 (void *)&cmd_setqmap_queueid,
8227 (void *)&cmd_setqmap_mapvalue,
8232 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8233 struct cmd_set_xstats_hide_zero_result {
8234 cmdline_fixed_string_t keyword;
8235 cmdline_fixed_string_t name;
8236 cmdline_fixed_string_t on_off;
8240 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8241 __rte_unused struct cmdline *cl,
8242 __rte_unused void *data)
8244 struct cmd_set_xstats_hide_zero_result *res;
8245 uint16_t on_off = 0;
8247 res = parsed_result;
8248 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8249 set_xstats_hide_zero(on_off);
8252 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8253 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8255 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8256 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8257 name, "xstats-hide-zero");
8258 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8259 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8262 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8263 .f = cmd_set_xstats_hide_zero_parsed,
8265 .help_str = "set xstats-hide-zero on|off",
8267 (void *)&cmd_set_xstats_hide_zero_keyword,
8268 (void *)&cmd_set_xstats_hide_zero_name,
8269 (void *)&cmd_set_xstats_hide_zero_on_off,
8274 /* *** CONFIGURE UNICAST HASH TABLE *** */
8275 struct cmd_set_uc_hash_table {
8276 cmdline_fixed_string_t set;
8277 cmdline_fixed_string_t port;
8279 cmdline_fixed_string_t what;
8280 struct rte_ether_addr address;
8281 cmdline_fixed_string_t mode;
8285 cmd_set_uc_hash_parsed(void *parsed_result,
8286 __rte_unused struct cmdline *cl,
8287 __rte_unused void *data)
8290 struct cmd_set_uc_hash_table *res = parsed_result;
8292 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8294 if (strcmp(res->what, "uta") == 0)
8295 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8296 &res->address,(uint8_t)is_on);
8298 printf("bad unicast hash table parameter, return code = %d \n", ret);
8302 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8303 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8305 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8306 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8308 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8309 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8311 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8312 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8314 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8315 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8317 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8318 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8321 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8322 .f = cmd_set_uc_hash_parsed,
8324 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8326 (void *)&cmd_set_uc_hash_set,
8327 (void *)&cmd_set_uc_hash_port,
8328 (void *)&cmd_set_uc_hash_portid,
8329 (void *)&cmd_set_uc_hash_what,
8330 (void *)&cmd_set_uc_hash_mac,
8331 (void *)&cmd_set_uc_hash_mode,
8336 struct cmd_set_uc_all_hash_table {
8337 cmdline_fixed_string_t set;
8338 cmdline_fixed_string_t port;
8340 cmdline_fixed_string_t what;
8341 cmdline_fixed_string_t value;
8342 cmdline_fixed_string_t mode;
8346 cmd_set_uc_all_hash_parsed(void *parsed_result,
8347 __rte_unused struct cmdline *cl,
8348 __rte_unused void *data)
8351 struct cmd_set_uc_all_hash_table *res = parsed_result;
8353 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8355 if ((strcmp(res->what, "uta") == 0) &&
8356 (strcmp(res->value, "all") == 0))
8357 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8359 printf("bad unicast hash table parameter,"
8360 "return code = %d \n", ret);
8363 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8364 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8366 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8367 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8369 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8370 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8372 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8373 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8375 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8376 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8378 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8379 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8382 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8383 .f = cmd_set_uc_all_hash_parsed,
8385 .help_str = "set port <port_id> uta all on|off",
8387 (void *)&cmd_set_uc_all_hash_set,
8388 (void *)&cmd_set_uc_all_hash_port,
8389 (void *)&cmd_set_uc_all_hash_portid,
8390 (void *)&cmd_set_uc_all_hash_what,
8391 (void *)&cmd_set_uc_all_hash_value,
8392 (void *)&cmd_set_uc_all_hash_mode,
8397 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8398 struct cmd_set_vf_macvlan_filter {
8399 cmdline_fixed_string_t set;
8400 cmdline_fixed_string_t port;
8402 cmdline_fixed_string_t vf;
8404 struct rte_ether_addr address;
8405 cmdline_fixed_string_t filter_type;
8406 cmdline_fixed_string_t mode;
8410 cmd_set_vf_macvlan_parsed(void *parsed_result,
8411 __rte_unused struct cmdline *cl,
8412 __rte_unused void *data)
8415 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8416 struct rte_eth_mac_filter filter;
8418 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8420 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8422 /* set VF MAC filter */
8426 filter.dst_id = res->vf_id;
8428 if (!strcmp(res->filter_type, "exact-mac"))
8429 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8430 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8431 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8432 else if (!strcmp(res->filter_type, "hashmac"))
8433 filter.filter_type = RTE_MAC_HASH_MATCH;
8434 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8435 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8437 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8440 ret = rte_eth_dev_filter_ctrl(res->port_id,
8441 RTE_ETH_FILTER_MACVLAN,
8445 ret = rte_eth_dev_filter_ctrl(res->port_id,
8446 RTE_ETH_FILTER_MACVLAN,
8447 RTE_ETH_FILTER_DELETE,
8451 printf("bad set MAC hash parameter, return code = %d\n", ret);
8455 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8456 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8458 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8459 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8461 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8462 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8464 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8465 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8467 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8468 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8470 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8471 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8473 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8474 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8475 filter_type, "exact-mac#exact-mac-vlan"
8476 "#hashmac#hashmac-vlan");
8477 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8478 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8481 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8482 .f = cmd_set_vf_macvlan_parsed,
8484 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8485 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8486 "Exact match rule: exact match of MAC or MAC and VLAN; "
8487 "hash match rule: hash match of MAC and exact match of VLAN",
8489 (void *)&cmd_set_vf_macvlan_set,
8490 (void *)&cmd_set_vf_macvlan_port,
8491 (void *)&cmd_set_vf_macvlan_portid,
8492 (void *)&cmd_set_vf_macvlan_vf,
8493 (void *)&cmd_set_vf_macvlan_vf_id,
8494 (void *)&cmd_set_vf_macvlan_mac,
8495 (void *)&cmd_set_vf_macvlan_filter_type,
8496 (void *)&cmd_set_vf_macvlan_mode,
8501 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8502 struct cmd_set_vf_traffic {
8503 cmdline_fixed_string_t set;
8504 cmdline_fixed_string_t port;
8506 cmdline_fixed_string_t vf;
8508 cmdline_fixed_string_t what;
8509 cmdline_fixed_string_t mode;
8513 cmd_set_vf_traffic_parsed(void *parsed_result,
8514 __rte_unused struct cmdline *cl,
8515 __rte_unused void *data)
8517 struct cmd_set_vf_traffic *res = parsed_result;
8518 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8519 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8521 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8524 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8525 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8527 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8528 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8530 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8531 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8533 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8534 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8536 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8537 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8539 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8540 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8542 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8543 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8546 cmdline_parse_inst_t cmd_set_vf_traffic = {
8547 .f = cmd_set_vf_traffic_parsed,
8549 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8551 (void *)&cmd_setvf_traffic_set,
8552 (void *)&cmd_setvf_traffic_port,
8553 (void *)&cmd_setvf_traffic_portid,
8554 (void *)&cmd_setvf_traffic_vf,
8555 (void *)&cmd_setvf_traffic_vfid,
8556 (void *)&cmd_setvf_traffic_what,
8557 (void *)&cmd_setvf_traffic_mode,
8562 /* *** CONFIGURE VF RECEIVE MODE *** */
8563 struct cmd_set_vf_rxmode {
8564 cmdline_fixed_string_t set;
8565 cmdline_fixed_string_t port;
8567 cmdline_fixed_string_t vf;
8569 cmdline_fixed_string_t what;
8570 cmdline_fixed_string_t mode;
8571 cmdline_fixed_string_t on;
8575 cmd_set_vf_rxmode_parsed(void *parsed_result,
8576 __rte_unused struct cmdline *cl,
8577 __rte_unused void *data)
8580 uint16_t vf_rxmode = 0;
8581 struct cmd_set_vf_rxmode *res = parsed_result;
8583 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8584 if (!strcmp(res->what,"rxmode")) {
8585 if (!strcmp(res->mode, "AUPE"))
8586 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8587 else if (!strcmp(res->mode, "ROPE"))
8588 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8589 else if (!strcmp(res->mode, "BAM"))
8590 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8591 else if (!strncmp(res->mode, "MPE",3))
8592 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8595 RTE_SET_USED(is_on);
8597 #ifdef RTE_LIBRTE_IXGBE_PMD
8598 if (ret == -ENOTSUP)
8599 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8600 vf_rxmode, (uint8_t)is_on);
8602 #ifdef RTE_LIBRTE_BNXT_PMD
8603 if (ret == -ENOTSUP)
8604 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8605 vf_rxmode, (uint8_t)is_on);
8608 printf("bad VF receive mode parameter, return code = %d \n",
8612 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8613 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8615 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8616 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8618 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8619 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8621 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8622 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8624 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8625 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8627 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8628 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8630 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8631 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8632 mode, "AUPE#ROPE#BAM#MPE");
8633 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8634 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8637 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8638 .f = cmd_set_vf_rxmode_parsed,
8640 .help_str = "set port <port_id> vf <vf_id> rxmode "
8641 "AUPE|ROPE|BAM|MPE on|off",
8643 (void *)&cmd_set_vf_rxmode_set,
8644 (void *)&cmd_set_vf_rxmode_port,
8645 (void *)&cmd_set_vf_rxmode_portid,
8646 (void *)&cmd_set_vf_rxmode_vf,
8647 (void *)&cmd_set_vf_rxmode_vfid,
8648 (void *)&cmd_set_vf_rxmode_what,
8649 (void *)&cmd_set_vf_rxmode_mode,
8650 (void *)&cmd_set_vf_rxmode_on,
8655 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8656 struct cmd_vf_mac_addr_result {
8657 cmdline_fixed_string_t mac_addr_cmd;
8658 cmdline_fixed_string_t what;
8659 cmdline_fixed_string_t port;
8661 cmdline_fixed_string_t vf;
8663 struct rte_ether_addr address;
8666 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8667 __rte_unused struct cmdline *cl,
8668 __rte_unused void *data)
8670 struct cmd_vf_mac_addr_result *res = parsed_result;
8673 if (strcmp(res->what, "add") != 0)
8676 #ifdef RTE_LIBRTE_I40E_PMD
8677 if (ret == -ENOTSUP)
8678 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8681 #ifdef RTE_LIBRTE_BNXT_PMD
8682 if (ret == -ENOTSUP)
8683 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8688 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8692 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8693 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8694 mac_addr_cmd,"mac_addr");
8695 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8696 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8698 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8699 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8701 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8702 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8704 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8705 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8707 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8708 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8710 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8711 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8714 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8715 .f = cmd_vf_mac_addr_parsed,
8717 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8718 "Add MAC address filtering for a VF on port_id",
8720 (void *)&cmd_vf_mac_addr_cmd,
8721 (void *)&cmd_vf_mac_addr_what,
8722 (void *)&cmd_vf_mac_addr_port,
8723 (void *)&cmd_vf_mac_addr_portnum,
8724 (void *)&cmd_vf_mac_addr_vf,
8725 (void *)&cmd_vf_mac_addr_vfnum,
8726 (void *)&cmd_vf_mac_addr_addr,
8731 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8732 struct cmd_vf_rx_vlan_filter {
8733 cmdline_fixed_string_t rx_vlan;
8734 cmdline_fixed_string_t what;
8736 cmdline_fixed_string_t port;
8738 cmdline_fixed_string_t vf;
8743 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8744 __rte_unused struct cmdline *cl,
8745 __rte_unused void *data)
8747 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8750 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8752 #ifdef RTE_LIBRTE_IXGBE_PMD
8753 if (ret == -ENOTSUP)
8754 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8755 res->vlan_id, res->vf_mask, is_add);
8757 #ifdef RTE_LIBRTE_I40E_PMD
8758 if (ret == -ENOTSUP)
8759 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8760 res->vlan_id, res->vf_mask, is_add);
8762 #ifdef RTE_LIBRTE_BNXT_PMD
8763 if (ret == -ENOTSUP)
8764 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8765 res->vlan_id, res->vf_mask, is_add);
8772 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8773 res->vlan_id, res->vf_mask);
8776 printf("invalid port_id %d\n", res->port_id);
8779 printf("function not implemented or supported\n");
8782 printf("programming error: (%s)\n", strerror(-ret));
8786 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8787 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8788 rx_vlan, "rx_vlan");
8789 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8790 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8792 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8793 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8795 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8796 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8798 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8799 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8801 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8802 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8804 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8805 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8808 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8809 .f = cmd_vf_rx_vlan_filter_parsed,
8811 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8812 "(vf_mask = hexadecimal VF mask)",
8814 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8815 (void *)&cmd_vf_rx_vlan_filter_what,
8816 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8817 (void *)&cmd_vf_rx_vlan_filter_port,
8818 (void *)&cmd_vf_rx_vlan_filter_portid,
8819 (void *)&cmd_vf_rx_vlan_filter_vf,
8820 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8825 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8826 struct cmd_queue_rate_limit_result {
8827 cmdline_fixed_string_t set;
8828 cmdline_fixed_string_t port;
8830 cmdline_fixed_string_t queue;
8832 cmdline_fixed_string_t rate;
8836 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8837 __rte_unused struct cmdline *cl,
8838 __rte_unused void *data)
8840 struct cmd_queue_rate_limit_result *res = parsed_result;
8843 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8844 && (strcmp(res->queue, "queue") == 0)
8845 && (strcmp(res->rate, "rate") == 0))
8846 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8849 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8853 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8854 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8856 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8857 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8859 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8860 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8862 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8863 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8865 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8866 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8868 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8869 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8871 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8872 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8875 cmdline_parse_inst_t cmd_queue_rate_limit = {
8876 .f = cmd_queue_rate_limit_parsed,
8878 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8879 "Set rate limit for a queue on port_id",
8881 (void *)&cmd_queue_rate_limit_set,
8882 (void *)&cmd_queue_rate_limit_port,
8883 (void *)&cmd_queue_rate_limit_portnum,
8884 (void *)&cmd_queue_rate_limit_queue,
8885 (void *)&cmd_queue_rate_limit_queuenum,
8886 (void *)&cmd_queue_rate_limit_rate,
8887 (void *)&cmd_queue_rate_limit_ratenum,
8892 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8893 struct cmd_vf_rate_limit_result {
8894 cmdline_fixed_string_t set;
8895 cmdline_fixed_string_t port;
8897 cmdline_fixed_string_t vf;
8899 cmdline_fixed_string_t rate;
8901 cmdline_fixed_string_t q_msk;
8905 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8906 __rte_unused struct cmdline *cl,
8907 __rte_unused void *data)
8909 struct cmd_vf_rate_limit_result *res = parsed_result;
8912 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8913 && (strcmp(res->vf, "vf") == 0)
8914 && (strcmp(res->rate, "rate") == 0)
8915 && (strcmp(res->q_msk, "queue_mask") == 0))
8916 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8917 res->rate_num, res->q_msk_val);
8919 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8923 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8924 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8926 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8927 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8929 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8930 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8932 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8933 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8935 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8936 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8938 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8939 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8941 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8942 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8944 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8945 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8946 q_msk, "queue_mask");
8947 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8948 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8951 cmdline_parse_inst_t cmd_vf_rate_limit = {
8952 .f = cmd_vf_rate_limit_parsed,
8954 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8955 "queue_mask <queue_mask_value>: "
8956 "Set rate limit for queues of VF on port_id",
8958 (void *)&cmd_vf_rate_limit_set,
8959 (void *)&cmd_vf_rate_limit_port,
8960 (void *)&cmd_vf_rate_limit_portnum,
8961 (void *)&cmd_vf_rate_limit_vf,
8962 (void *)&cmd_vf_rate_limit_vfnum,
8963 (void *)&cmd_vf_rate_limit_rate,
8964 (void *)&cmd_vf_rate_limit_ratenum,
8965 (void *)&cmd_vf_rate_limit_q_msk,
8966 (void *)&cmd_vf_rate_limit_q_msk_val,
8971 /* *** ADD TUNNEL FILTER OF A PORT *** */
8972 struct cmd_tunnel_filter_result {
8973 cmdline_fixed_string_t cmd;
8974 cmdline_fixed_string_t what;
8976 struct rte_ether_addr outer_mac;
8977 struct rte_ether_addr inner_mac;
8978 cmdline_ipaddr_t ip_value;
8979 uint16_t inner_vlan;
8980 cmdline_fixed_string_t tunnel_type;
8981 cmdline_fixed_string_t filter_type;
8987 cmd_tunnel_filter_parsed(void *parsed_result,
8988 __rte_unused struct cmdline *cl,
8989 __rte_unused void *data)
8991 struct cmd_tunnel_filter_result *res = parsed_result;
8992 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8995 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8997 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8998 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8999 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9001 if (res->ip_value.family == AF_INET) {
9002 tunnel_filter_conf.ip_addr.ipv4_addr =
9003 res->ip_value.addr.ipv4.s_addr;
9004 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9006 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9007 &(res->ip_value.addr.ipv6),
9008 sizeof(struct in6_addr));
9009 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9012 if (!strcmp(res->filter_type, "imac-ivlan"))
9013 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9014 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9015 tunnel_filter_conf.filter_type =
9016 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9017 else if (!strcmp(res->filter_type, "imac-tenid"))
9018 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9019 else if (!strcmp(res->filter_type, "imac"))
9020 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9021 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9022 tunnel_filter_conf.filter_type =
9023 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9024 else if (!strcmp(res->filter_type, "oip"))
9025 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9026 else if (!strcmp(res->filter_type, "iip"))
9027 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9029 printf("The filter type is not supported");
9033 if (!strcmp(res->tunnel_type, "vxlan"))
9034 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9035 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9036 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9037 else if (!strcmp(res->tunnel_type, "nvgre"))
9038 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9039 else if (!strcmp(res->tunnel_type, "ipingre"))
9040 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9042 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9046 tunnel_filter_conf.tenant_id = res->tenant_id;
9047 tunnel_filter_conf.queue_id = res->queue_num;
9048 if (!strcmp(res->what, "add"))
9049 ret = rte_eth_dev_filter_ctrl(res->port_id,
9050 RTE_ETH_FILTER_TUNNEL,
9052 &tunnel_filter_conf);
9054 ret = rte_eth_dev_filter_ctrl(res->port_id,
9055 RTE_ETH_FILTER_TUNNEL,
9056 RTE_ETH_FILTER_DELETE,
9057 &tunnel_filter_conf);
9059 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9063 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9064 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9065 cmd, "tunnel_filter");
9066 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9067 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9069 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9070 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9072 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9073 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9075 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9076 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9078 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9079 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9080 inner_vlan, UINT16);
9081 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9082 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9084 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9085 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9086 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9088 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9089 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9090 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9091 "imac#omac-imac-tenid");
9092 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9093 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9095 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9096 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9099 cmdline_parse_inst_t cmd_tunnel_filter = {
9100 .f = cmd_tunnel_filter_parsed,
9102 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9103 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9104 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9105 "<queue_id>: Add/Rm tunnel filter of a port",
9107 (void *)&cmd_tunnel_filter_cmd,
9108 (void *)&cmd_tunnel_filter_what,
9109 (void *)&cmd_tunnel_filter_port_id,
9110 (void *)&cmd_tunnel_filter_outer_mac,
9111 (void *)&cmd_tunnel_filter_inner_mac,
9112 (void *)&cmd_tunnel_filter_ip_value,
9113 (void *)&cmd_tunnel_filter_innner_vlan,
9114 (void *)&cmd_tunnel_filter_tunnel_type,
9115 (void *)&cmd_tunnel_filter_filter_type,
9116 (void *)&cmd_tunnel_filter_tenant_id,
9117 (void *)&cmd_tunnel_filter_queue_num,
9122 /* *** CONFIGURE TUNNEL UDP PORT *** */
9123 struct cmd_tunnel_udp_config {
9124 cmdline_fixed_string_t cmd;
9125 cmdline_fixed_string_t what;
9131 cmd_tunnel_udp_config_parsed(void *parsed_result,
9132 __rte_unused struct cmdline *cl,
9133 __rte_unused void *data)
9135 struct cmd_tunnel_udp_config *res = parsed_result;
9136 struct rte_eth_udp_tunnel tunnel_udp;
9139 tunnel_udp.udp_port = res->udp_port;
9141 if (!strcmp(res->cmd, "rx_vxlan_port"))
9142 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9144 if (!strcmp(res->what, "add"))
9145 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9148 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9152 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9155 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9156 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9157 cmd, "rx_vxlan_port");
9158 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9159 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9161 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9162 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9164 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9165 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9168 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9169 .f = cmd_tunnel_udp_config_parsed,
9171 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9172 "Add/Remove a tunneling UDP port filter",
9174 (void *)&cmd_tunnel_udp_config_cmd,
9175 (void *)&cmd_tunnel_udp_config_what,
9176 (void *)&cmd_tunnel_udp_config_udp_port,
9177 (void *)&cmd_tunnel_udp_config_port_id,
9182 struct cmd_config_tunnel_udp_port {
9183 cmdline_fixed_string_t port;
9184 cmdline_fixed_string_t config;
9186 cmdline_fixed_string_t udp_tunnel_port;
9187 cmdline_fixed_string_t action;
9188 cmdline_fixed_string_t tunnel_type;
9193 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9194 __rte_unused struct cmdline *cl,
9195 __rte_unused void *data)
9197 struct cmd_config_tunnel_udp_port *res = parsed_result;
9198 struct rte_eth_udp_tunnel tunnel_udp;
9201 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9204 tunnel_udp.udp_port = res->udp_port;
9206 if (!strcmp(res->tunnel_type, "vxlan")) {
9207 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9208 } else if (!strcmp(res->tunnel_type, "geneve")) {
9209 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9210 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9211 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9213 printf("Invalid tunnel type\n");
9217 if (!strcmp(res->action, "add"))
9218 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9221 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9225 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9228 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9229 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9231 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9232 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9234 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9235 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9237 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9238 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9241 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9242 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9244 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9245 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9246 "vxlan#geneve#vxlan-gpe");
9247 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9248 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9251 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9252 .f = cmd_cfg_tunnel_udp_port_parsed,
9254 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9256 (void *)&cmd_config_tunnel_udp_port_port,
9257 (void *)&cmd_config_tunnel_udp_port_config,
9258 (void *)&cmd_config_tunnel_udp_port_port_id,
9259 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9260 (void *)&cmd_config_tunnel_udp_port_action,
9261 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9262 (void *)&cmd_config_tunnel_udp_port_value,
9267 /* *** GLOBAL CONFIG *** */
9268 struct cmd_global_config_result {
9269 cmdline_fixed_string_t cmd;
9271 cmdline_fixed_string_t cfg_type;
9276 cmd_global_config_parsed(void *parsed_result,
9277 __rte_unused struct cmdline *cl,
9278 __rte_unused void *data)
9280 struct cmd_global_config_result *res = parsed_result;
9281 struct rte_eth_global_cfg conf;
9284 memset(&conf, 0, sizeof(conf));
9285 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9286 conf.cfg.gre_key_len = res->len;
9287 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9288 RTE_ETH_FILTER_SET, &conf);
9290 printf("Global config error\n");
9293 cmdline_parse_token_string_t cmd_global_config_cmd =
9294 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9296 cmdline_parse_token_num_t cmd_global_config_port_id =
9297 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9299 cmdline_parse_token_string_t cmd_global_config_type =
9300 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9301 cfg_type, "gre-key-len");
9302 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9303 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9306 cmdline_parse_inst_t cmd_global_config = {
9307 .f = cmd_global_config_parsed,
9308 .data = (void *)NULL,
9309 .help_str = "global_config <port_id> gre-key-len <key_len>",
9311 (void *)&cmd_global_config_cmd,
9312 (void *)&cmd_global_config_port_id,
9313 (void *)&cmd_global_config_type,
9314 (void *)&cmd_global_config_gre_key_len,
9319 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9320 struct cmd_set_mirror_mask_result {
9321 cmdline_fixed_string_t set;
9322 cmdline_fixed_string_t port;
9324 cmdline_fixed_string_t mirror;
9326 cmdline_fixed_string_t what;
9327 cmdline_fixed_string_t value;
9328 cmdline_fixed_string_t dstpool;
9330 cmdline_fixed_string_t on;
9333 cmdline_parse_token_string_t cmd_mirror_mask_set =
9334 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9336 cmdline_parse_token_string_t cmd_mirror_mask_port =
9337 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9339 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9340 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9342 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9343 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9344 mirror, "mirror-rule");
9345 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9346 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9348 cmdline_parse_token_string_t cmd_mirror_mask_what =
9349 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9350 what, "pool-mirror-up#pool-mirror-down"
9352 cmdline_parse_token_string_t cmd_mirror_mask_value =
9353 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9355 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9356 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9357 dstpool, "dst-pool");
9358 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9359 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9361 cmdline_parse_token_string_t cmd_mirror_mask_on =
9362 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9366 cmd_set_mirror_mask_parsed(void *parsed_result,
9367 __rte_unused struct cmdline *cl,
9368 __rte_unused void *data)
9371 struct cmd_set_mirror_mask_result *res = parsed_result;
9372 struct rte_eth_mirror_conf mr_conf;
9374 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9376 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9378 mr_conf.dst_pool = res->dstpool_id;
9380 if (!strcmp(res->what, "pool-mirror-up")) {
9381 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9382 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9383 } else if (!strcmp(res->what, "pool-mirror-down")) {
9384 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9385 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9386 } else if (!strcmp(res->what, "vlan-mirror")) {
9387 mr_conf.rule_type = ETH_MIRROR_VLAN;
9388 nb_item = parse_item_list(res->value, "vlan",
9389 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9393 for (i = 0; i < nb_item; i++) {
9394 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9395 printf("Invalid vlan_id: must be < 4096\n");
9399 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9400 mr_conf.vlan.vlan_mask |= 1ULL << i;
9404 if (!strcmp(res->on, "on"))
9405 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9408 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9411 printf("mirror rule add error: (%s)\n", strerror(-ret));
9414 cmdline_parse_inst_t cmd_set_mirror_mask = {
9415 .f = cmd_set_mirror_mask_parsed,
9417 .help_str = "set port <port_id> mirror-rule <rule_id> "
9418 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9419 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9421 (void *)&cmd_mirror_mask_set,
9422 (void *)&cmd_mirror_mask_port,
9423 (void *)&cmd_mirror_mask_portid,
9424 (void *)&cmd_mirror_mask_mirror,
9425 (void *)&cmd_mirror_mask_ruleid,
9426 (void *)&cmd_mirror_mask_what,
9427 (void *)&cmd_mirror_mask_value,
9428 (void *)&cmd_mirror_mask_dstpool,
9429 (void *)&cmd_mirror_mask_poolid,
9430 (void *)&cmd_mirror_mask_on,
9435 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9436 struct cmd_set_mirror_link_result {
9437 cmdline_fixed_string_t set;
9438 cmdline_fixed_string_t port;
9440 cmdline_fixed_string_t mirror;
9442 cmdline_fixed_string_t what;
9443 cmdline_fixed_string_t dstpool;
9445 cmdline_fixed_string_t on;
9448 cmdline_parse_token_string_t cmd_mirror_link_set =
9449 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9451 cmdline_parse_token_string_t cmd_mirror_link_port =
9452 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9454 cmdline_parse_token_num_t cmd_mirror_link_portid =
9455 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9457 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9458 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9459 mirror, "mirror-rule");
9460 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9461 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9463 cmdline_parse_token_string_t cmd_mirror_link_what =
9464 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9465 what, "uplink-mirror#downlink-mirror");
9466 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9467 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9468 dstpool, "dst-pool");
9469 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9470 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9472 cmdline_parse_token_string_t cmd_mirror_link_on =
9473 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9477 cmd_set_mirror_link_parsed(void *parsed_result,
9478 __rte_unused struct cmdline *cl,
9479 __rte_unused void *data)
9482 struct cmd_set_mirror_link_result *res = parsed_result;
9483 struct rte_eth_mirror_conf mr_conf;
9485 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9486 if (!strcmp(res->what, "uplink-mirror"))
9487 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9489 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9491 mr_conf.dst_pool = res->dstpool_id;
9493 if (!strcmp(res->on, "on"))
9494 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9497 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9500 /* check the return value and print it if is < 0 */
9502 printf("mirror rule add error: (%s)\n", strerror(-ret));
9506 cmdline_parse_inst_t cmd_set_mirror_link = {
9507 .f = cmd_set_mirror_link_parsed,
9509 .help_str = "set port <port_id> mirror-rule <rule_id> "
9510 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9512 (void *)&cmd_mirror_link_set,
9513 (void *)&cmd_mirror_link_port,
9514 (void *)&cmd_mirror_link_portid,
9515 (void *)&cmd_mirror_link_mirror,
9516 (void *)&cmd_mirror_link_ruleid,
9517 (void *)&cmd_mirror_link_what,
9518 (void *)&cmd_mirror_link_dstpool,
9519 (void *)&cmd_mirror_link_poolid,
9520 (void *)&cmd_mirror_link_on,
9525 /* *** RESET VM MIRROR RULE *** */
9526 struct cmd_rm_mirror_rule_result {
9527 cmdline_fixed_string_t reset;
9528 cmdline_fixed_string_t port;
9530 cmdline_fixed_string_t mirror;
9534 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9535 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9537 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9538 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9540 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9541 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9543 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9544 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9545 mirror, "mirror-rule");
9546 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9547 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9551 cmd_reset_mirror_rule_parsed(void *parsed_result,
9552 __rte_unused struct cmdline *cl,
9553 __rte_unused void *data)
9556 struct cmd_set_mirror_link_result *res = parsed_result;
9558 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9560 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9563 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9564 .f = cmd_reset_mirror_rule_parsed,
9566 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9568 (void *)&cmd_rm_mirror_rule_reset,
9569 (void *)&cmd_rm_mirror_rule_port,
9570 (void *)&cmd_rm_mirror_rule_portid,
9571 (void *)&cmd_rm_mirror_rule_mirror,
9572 (void *)&cmd_rm_mirror_rule_ruleid,
9577 /* ******************************************************************************** */
9579 struct cmd_dump_result {
9580 cmdline_fixed_string_t dump;
9584 dump_struct_sizes(void)
9586 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9587 DUMP_SIZE(struct rte_mbuf);
9588 DUMP_SIZE(struct rte_mempool);
9589 DUMP_SIZE(struct rte_ring);
9594 /* Dump the socket memory statistics on console */
9596 dump_socket_mem(FILE *f)
9598 struct rte_malloc_socket_stats socket_stats;
9603 unsigned int n_alloc = 0;
9604 unsigned int n_free = 0;
9605 static size_t last_allocs;
9606 static size_t last_total;
9609 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9610 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9611 !socket_stats.heap_totalsz_bytes)
9613 total += socket_stats.heap_totalsz_bytes;
9614 alloc += socket_stats.heap_allocsz_bytes;
9615 free += socket_stats.heap_freesz_bytes;
9616 n_alloc += socket_stats.alloc_count;
9617 n_free += socket_stats.free_count;
9619 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9621 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9622 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9623 (double)socket_stats.heap_allocsz_bytes * 100 /
9624 (double)socket_stats.heap_totalsz_bytes,
9625 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9626 socket_stats.alloc_count,
9627 socket_stats.free_count);
9630 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9631 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9632 (double)alloc * 100 / (double)total,
9633 (double)free / (1024 * 1024),
9636 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9637 ((double)total - (double)last_total) / (1024 * 1024),
9638 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9639 last_allocs = alloc;
9643 static void cmd_dump_parsed(void *parsed_result,
9644 __rte_unused struct cmdline *cl,
9645 __rte_unused void *data)
9647 struct cmd_dump_result *res = parsed_result;
9649 if (!strcmp(res->dump, "dump_physmem"))
9650 rte_dump_physmem_layout(stdout);
9651 else if (!strcmp(res->dump, "dump_socket_mem"))
9652 dump_socket_mem(stdout);
9653 else if (!strcmp(res->dump, "dump_memzone"))
9654 rte_memzone_dump(stdout);
9655 else if (!strcmp(res->dump, "dump_struct_sizes"))
9656 dump_struct_sizes();
9657 else if (!strcmp(res->dump, "dump_ring"))
9658 rte_ring_list_dump(stdout);
9659 else if (!strcmp(res->dump, "dump_mempool"))
9660 rte_mempool_list_dump(stdout);
9661 else if (!strcmp(res->dump, "dump_devargs"))
9662 rte_devargs_dump(stdout);
9663 else if (!strcmp(res->dump, "dump_log_types"))
9664 rte_log_dump(stdout);
9667 cmdline_parse_token_string_t cmd_dump_dump =
9668 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9672 "dump_struct_sizes#"
9678 cmdline_parse_inst_t cmd_dump = {
9679 .f = cmd_dump_parsed, /* function to call */
9680 .data = NULL, /* 2nd arg of func */
9681 .help_str = "Dump status",
9682 .tokens = { /* token list, NULL terminated */
9683 (void *)&cmd_dump_dump,
9688 /* ******************************************************************************** */
9690 struct cmd_dump_one_result {
9691 cmdline_fixed_string_t dump;
9692 cmdline_fixed_string_t name;
9695 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9696 __rte_unused void *data)
9698 struct cmd_dump_one_result *res = parsed_result;
9700 if (!strcmp(res->dump, "dump_ring")) {
9702 r = rte_ring_lookup(res->name);
9704 cmdline_printf(cl, "Cannot find ring\n");
9707 rte_ring_dump(stdout, r);
9708 } else if (!strcmp(res->dump, "dump_mempool")) {
9709 struct rte_mempool *mp;
9710 mp = rte_mempool_lookup(res->name);
9712 cmdline_printf(cl, "Cannot find mempool\n");
9715 rte_mempool_dump(stdout, mp);
9719 cmdline_parse_token_string_t cmd_dump_one_dump =
9720 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9721 "dump_ring#dump_mempool");
9723 cmdline_parse_token_string_t cmd_dump_one_name =
9724 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9726 cmdline_parse_inst_t cmd_dump_one = {
9727 .f = cmd_dump_one_parsed, /* function to call */
9728 .data = NULL, /* 2nd arg of func */
9729 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9730 .tokens = { /* token list, NULL terminated */
9731 (void *)&cmd_dump_one_dump,
9732 (void *)&cmd_dump_one_name,
9737 /* *** Add/Del syn filter *** */
9738 struct cmd_syn_filter_result {
9739 cmdline_fixed_string_t filter;
9741 cmdline_fixed_string_t ops;
9742 cmdline_fixed_string_t priority;
9743 cmdline_fixed_string_t high;
9744 cmdline_fixed_string_t queue;
9749 cmd_syn_filter_parsed(void *parsed_result,
9750 __rte_unused struct cmdline *cl,
9751 __rte_unused void *data)
9753 struct cmd_syn_filter_result *res = parsed_result;
9754 struct rte_eth_syn_filter syn_filter;
9757 ret = rte_eth_dev_filter_supported(res->port_id,
9758 RTE_ETH_FILTER_SYN);
9760 printf("syn filter is not supported on port %u.\n",
9765 memset(&syn_filter, 0, sizeof(syn_filter));
9767 if (!strcmp(res->ops, "add")) {
9768 if (!strcmp(res->high, "high"))
9769 syn_filter.hig_pri = 1;
9771 syn_filter.hig_pri = 0;
9773 syn_filter.queue = res->queue_id;
9774 ret = rte_eth_dev_filter_ctrl(res->port_id,
9779 ret = rte_eth_dev_filter_ctrl(res->port_id,
9781 RTE_ETH_FILTER_DELETE,
9785 printf("syn filter programming error: (%s)\n",
9789 cmdline_parse_token_string_t cmd_syn_filter_filter =
9790 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9791 filter, "syn_filter");
9792 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9793 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9795 cmdline_parse_token_string_t cmd_syn_filter_ops =
9796 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9798 cmdline_parse_token_string_t cmd_syn_filter_priority =
9799 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9800 priority, "priority");
9801 cmdline_parse_token_string_t cmd_syn_filter_high =
9802 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9804 cmdline_parse_token_string_t cmd_syn_filter_queue =
9805 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9807 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9808 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9811 cmdline_parse_inst_t cmd_syn_filter = {
9812 .f = cmd_syn_filter_parsed,
9814 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9815 "<queue_id>: Add/Delete syn filter",
9817 (void *)&cmd_syn_filter_filter,
9818 (void *)&cmd_syn_filter_port_id,
9819 (void *)&cmd_syn_filter_ops,
9820 (void *)&cmd_syn_filter_priority,
9821 (void *)&cmd_syn_filter_high,
9822 (void *)&cmd_syn_filter_queue,
9823 (void *)&cmd_syn_filter_queue_id,
9828 /* *** queue region set *** */
9829 struct cmd_queue_region_result {
9830 cmdline_fixed_string_t set;
9831 cmdline_fixed_string_t port;
9833 cmdline_fixed_string_t cmd;
9834 cmdline_fixed_string_t region;
9836 cmdline_fixed_string_t queue_start_index;
9838 cmdline_fixed_string_t queue_num;
9839 uint8_t queue_num_value;
9843 cmd_queue_region_parsed(void *parsed_result,
9844 __rte_unused struct cmdline *cl,
9845 __rte_unused void *data)
9847 struct cmd_queue_region_result *res = parsed_result;
9849 #ifdef RTE_LIBRTE_I40E_PMD
9850 struct rte_pmd_i40e_queue_region_conf region_conf;
9851 enum rte_pmd_i40e_queue_region_op op_type;
9854 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9857 #ifdef RTE_LIBRTE_I40E_PMD
9858 memset(®ion_conf, 0, sizeof(region_conf));
9859 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9860 region_conf.region_id = res->region_id;
9861 region_conf.queue_num = res->queue_num_value;
9862 region_conf.queue_start_index = res->queue_id;
9864 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9865 op_type, ®ion_conf);
9872 printf("function not implemented or supported\n");
9875 printf("queue region config error: (%s)\n", strerror(-ret));
9879 cmdline_parse_token_string_t cmd_queue_region_set =
9880 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9882 cmdline_parse_token_string_t cmd_queue_region_port =
9883 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9884 cmdline_parse_token_num_t cmd_queue_region_port_id =
9885 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9887 cmdline_parse_token_string_t cmd_queue_region_cmd =
9888 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9889 cmd, "queue-region");
9890 cmdline_parse_token_string_t cmd_queue_region_id =
9891 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9892 region, "region_id");
9893 cmdline_parse_token_num_t cmd_queue_region_index =
9894 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9896 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9897 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9898 queue_start_index, "queue_start_index");
9899 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9900 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9902 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9903 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9904 queue_num, "queue_num");
9905 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9906 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9907 queue_num_value, UINT8);
9909 cmdline_parse_inst_t cmd_queue_region = {
9910 .f = cmd_queue_region_parsed,
9912 .help_str = "set port <port_id> queue-region region_id <value> "
9913 "queue_start_index <value> queue_num <value>: Set a queue region",
9915 (void *)&cmd_queue_region_set,
9916 (void *)&cmd_queue_region_port,
9917 (void *)&cmd_queue_region_port_id,
9918 (void *)&cmd_queue_region_cmd,
9919 (void *)&cmd_queue_region_id,
9920 (void *)&cmd_queue_region_index,
9921 (void *)&cmd_queue_region_queue_start_index,
9922 (void *)&cmd_queue_region_queue_id,
9923 (void *)&cmd_queue_region_queue_num,
9924 (void *)&cmd_queue_region_queue_num_value,
9929 /* *** queue region and flowtype set *** */
9930 struct cmd_region_flowtype_result {
9931 cmdline_fixed_string_t set;
9932 cmdline_fixed_string_t port;
9934 cmdline_fixed_string_t cmd;
9935 cmdline_fixed_string_t region;
9937 cmdline_fixed_string_t flowtype;
9938 uint8_t flowtype_id;
9942 cmd_region_flowtype_parsed(void *parsed_result,
9943 __rte_unused struct cmdline *cl,
9944 __rte_unused void *data)
9946 struct cmd_region_flowtype_result *res = parsed_result;
9948 #ifdef RTE_LIBRTE_I40E_PMD
9949 struct rte_pmd_i40e_queue_region_conf region_conf;
9950 enum rte_pmd_i40e_queue_region_op op_type;
9953 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9956 #ifdef RTE_LIBRTE_I40E_PMD
9957 memset(®ion_conf, 0, sizeof(region_conf));
9959 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9960 region_conf.region_id = res->region_id;
9961 region_conf.hw_flowtype = res->flowtype_id;
9963 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9964 op_type, ®ion_conf);
9971 printf("function not implemented or supported\n");
9974 printf("region flowtype config error: (%s)\n", strerror(-ret));
9978 cmdline_parse_token_string_t cmd_region_flowtype_set =
9979 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9981 cmdline_parse_token_string_t cmd_region_flowtype_port =
9982 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9984 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9985 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9987 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9988 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9989 cmd, "queue-region");
9990 cmdline_parse_token_string_t cmd_region_flowtype_index =
9991 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9992 region, "region_id");
9993 cmdline_parse_token_num_t cmd_region_flowtype_id =
9994 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9996 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9997 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9998 flowtype, "flowtype");
9999 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10000 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10001 flowtype_id, UINT8);
10002 cmdline_parse_inst_t cmd_region_flowtype = {
10003 .f = cmd_region_flowtype_parsed,
10005 .help_str = "set port <port_id> queue-region region_id <value> "
10006 "flowtype <value>: Set a flowtype region index",
10008 (void *)&cmd_region_flowtype_set,
10009 (void *)&cmd_region_flowtype_port,
10010 (void *)&cmd_region_flowtype_port_index,
10011 (void *)&cmd_region_flowtype_cmd,
10012 (void *)&cmd_region_flowtype_index,
10013 (void *)&cmd_region_flowtype_id,
10014 (void *)&cmd_region_flowtype_flow_index,
10015 (void *)&cmd_region_flowtype_flow_id,
10020 /* *** User Priority (UP) to queue region (region_id) set *** */
10021 struct cmd_user_priority_region_result {
10022 cmdline_fixed_string_t set;
10023 cmdline_fixed_string_t port;
10025 cmdline_fixed_string_t cmd;
10026 cmdline_fixed_string_t user_priority;
10027 uint8_t user_priority_id;
10028 cmdline_fixed_string_t region;
10033 cmd_user_priority_region_parsed(void *parsed_result,
10034 __rte_unused struct cmdline *cl,
10035 __rte_unused void *data)
10037 struct cmd_user_priority_region_result *res = parsed_result;
10038 int ret = -ENOTSUP;
10039 #ifdef RTE_LIBRTE_I40E_PMD
10040 struct rte_pmd_i40e_queue_region_conf region_conf;
10041 enum rte_pmd_i40e_queue_region_op op_type;
10044 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10047 #ifdef RTE_LIBRTE_I40E_PMD
10048 memset(®ion_conf, 0, sizeof(region_conf));
10049 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10050 region_conf.user_priority = res->user_priority_id;
10051 region_conf.region_id = res->region_id;
10053 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10054 op_type, ®ion_conf);
10061 printf("function not implemented or supported\n");
10064 printf("user_priority region config error: (%s)\n",
10069 cmdline_parse_token_string_t cmd_user_priority_region_set =
10070 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10072 cmdline_parse_token_string_t cmd_user_priority_region_port =
10073 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10075 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10076 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10078 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10079 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10080 cmd, "queue-region");
10081 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10082 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10083 user_priority, "UP");
10084 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10085 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10086 user_priority_id, UINT8);
10087 cmdline_parse_token_string_t cmd_user_priority_region_region =
10088 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10089 region, "region_id");
10090 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10091 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10094 cmdline_parse_inst_t cmd_user_priority_region = {
10095 .f = cmd_user_priority_region_parsed,
10097 .help_str = "set port <port_id> queue-region UP <value> "
10098 "region_id <value>: Set the mapping of User Priority (UP) "
10099 "to queue region (region_id) ",
10101 (void *)&cmd_user_priority_region_set,
10102 (void *)&cmd_user_priority_region_port,
10103 (void *)&cmd_user_priority_region_port_index,
10104 (void *)&cmd_user_priority_region_cmd,
10105 (void *)&cmd_user_priority_region_UP,
10106 (void *)&cmd_user_priority_region_UP_id,
10107 (void *)&cmd_user_priority_region_region,
10108 (void *)&cmd_user_priority_region_region_id,
10113 /* *** flush all queue region related configuration *** */
10114 struct cmd_flush_queue_region_result {
10115 cmdline_fixed_string_t set;
10116 cmdline_fixed_string_t port;
10118 cmdline_fixed_string_t cmd;
10119 cmdline_fixed_string_t flush;
10120 cmdline_fixed_string_t what;
10124 cmd_flush_queue_region_parsed(void *parsed_result,
10125 __rte_unused struct cmdline *cl,
10126 __rte_unused void *data)
10128 struct cmd_flush_queue_region_result *res = parsed_result;
10129 int ret = -ENOTSUP;
10130 #ifdef RTE_LIBRTE_I40E_PMD
10131 struct rte_pmd_i40e_queue_region_conf region_conf;
10132 enum rte_pmd_i40e_queue_region_op op_type;
10135 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10138 #ifdef RTE_LIBRTE_I40E_PMD
10139 memset(®ion_conf, 0, sizeof(region_conf));
10141 if (strcmp(res->what, "on") == 0)
10142 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10144 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10146 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10147 op_type, ®ion_conf);
10154 printf("function not implemented or supported\n");
10157 printf("queue region config flush error: (%s)\n",
10162 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10163 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10165 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10166 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10168 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10169 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10171 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10172 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10173 cmd, "queue-region");
10174 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10175 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10177 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10178 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10181 cmdline_parse_inst_t cmd_flush_queue_region = {
10182 .f = cmd_flush_queue_region_parsed,
10184 .help_str = "set port <port_id> queue-region flush on|off"
10185 ": flush all queue region related configuration",
10187 (void *)&cmd_flush_queue_region_set,
10188 (void *)&cmd_flush_queue_region_port,
10189 (void *)&cmd_flush_queue_region_port_index,
10190 (void *)&cmd_flush_queue_region_cmd,
10191 (void *)&cmd_flush_queue_region_flush,
10192 (void *)&cmd_flush_queue_region_what,
10197 /* *** get all queue region related configuration info *** */
10198 struct cmd_show_queue_region_info {
10199 cmdline_fixed_string_t show;
10200 cmdline_fixed_string_t port;
10202 cmdline_fixed_string_t cmd;
10206 cmd_show_queue_region_info_parsed(void *parsed_result,
10207 __rte_unused struct cmdline *cl,
10208 __rte_unused void *data)
10210 struct cmd_show_queue_region_info *res = parsed_result;
10211 int ret = -ENOTSUP;
10212 #ifdef RTE_LIBRTE_I40E_PMD
10213 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10214 enum rte_pmd_i40e_queue_region_op op_type;
10217 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10220 #ifdef RTE_LIBRTE_I40E_PMD
10221 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10223 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10225 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10226 op_type, &rte_pmd_regions);
10228 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10235 printf("function not implemented or supported\n");
10238 printf("queue region config info show error: (%s)\n",
10243 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10244 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10246 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10247 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10249 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10250 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10252 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10253 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10254 cmd, "queue-region");
10256 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10257 .f = cmd_show_queue_region_info_parsed,
10259 .help_str = "show port <port_id> queue-region"
10260 ": show all queue region related configuration info",
10262 (void *)&cmd_show_queue_region_info_get,
10263 (void *)&cmd_show_queue_region_info_port,
10264 (void *)&cmd_show_queue_region_info_port_index,
10265 (void *)&cmd_show_queue_region_info_cmd,
10270 /* *** ADD/REMOVE A 2tuple FILTER *** */
10271 struct cmd_2tuple_filter_result {
10272 cmdline_fixed_string_t filter;
10274 cmdline_fixed_string_t ops;
10275 cmdline_fixed_string_t dst_port;
10276 uint16_t dst_port_value;
10277 cmdline_fixed_string_t protocol;
10278 uint8_t protocol_value;
10279 cmdline_fixed_string_t mask;
10280 uint8_t mask_value;
10281 cmdline_fixed_string_t tcp_flags;
10282 uint8_t tcp_flags_value;
10283 cmdline_fixed_string_t priority;
10284 uint8_t priority_value;
10285 cmdline_fixed_string_t queue;
10290 cmd_2tuple_filter_parsed(void *parsed_result,
10291 __rte_unused struct cmdline *cl,
10292 __rte_unused void *data)
10294 struct rte_eth_ntuple_filter filter;
10295 struct cmd_2tuple_filter_result *res = parsed_result;
10298 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10300 printf("ntuple filter is not supported on port %u.\n",
10305 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10307 filter.flags = RTE_2TUPLE_FLAGS;
10308 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10309 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10310 filter.proto = res->protocol_value;
10311 filter.priority = res->priority_value;
10312 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10313 printf("nonzero tcp_flags is only meaningful"
10314 " when protocol is TCP.\n");
10317 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10318 printf("invalid TCP flags.\n");
10322 if (res->tcp_flags_value != 0) {
10323 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10324 filter.tcp_flags = res->tcp_flags_value;
10327 /* need convert to big endian. */
10328 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10329 filter.queue = res->queue_id;
10331 if (!strcmp(res->ops, "add"))
10332 ret = rte_eth_dev_filter_ctrl(res->port_id,
10333 RTE_ETH_FILTER_NTUPLE,
10334 RTE_ETH_FILTER_ADD,
10337 ret = rte_eth_dev_filter_ctrl(res->port_id,
10338 RTE_ETH_FILTER_NTUPLE,
10339 RTE_ETH_FILTER_DELETE,
10342 printf("2tuple filter programming error: (%s)\n",
10347 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10348 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10349 filter, "2tuple_filter");
10350 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10351 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10353 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10354 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10356 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10357 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10358 dst_port, "dst_port");
10359 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10360 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10361 dst_port_value, UINT16);
10362 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10363 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10364 protocol, "protocol");
10365 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10366 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10367 protocol_value, UINT8);
10368 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10369 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10371 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10372 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10374 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10375 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10376 tcp_flags, "tcp_flags");
10377 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10378 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10379 tcp_flags_value, UINT8);
10380 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10381 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10382 priority, "priority");
10383 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10384 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10385 priority_value, UINT8);
10386 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10387 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10389 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10390 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10393 cmdline_parse_inst_t cmd_2tuple_filter = {
10394 .f = cmd_2tuple_filter_parsed,
10396 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10397 "<value> mask <value> tcp_flags <value> priority <value> queue "
10398 "<queue_id>: Add a 2tuple filter",
10400 (void *)&cmd_2tuple_filter_filter,
10401 (void *)&cmd_2tuple_filter_port_id,
10402 (void *)&cmd_2tuple_filter_ops,
10403 (void *)&cmd_2tuple_filter_dst_port,
10404 (void *)&cmd_2tuple_filter_dst_port_value,
10405 (void *)&cmd_2tuple_filter_protocol,
10406 (void *)&cmd_2tuple_filter_protocol_value,
10407 (void *)&cmd_2tuple_filter_mask,
10408 (void *)&cmd_2tuple_filter_mask_value,
10409 (void *)&cmd_2tuple_filter_tcp_flags,
10410 (void *)&cmd_2tuple_filter_tcp_flags_value,
10411 (void *)&cmd_2tuple_filter_priority,
10412 (void *)&cmd_2tuple_filter_priority_value,
10413 (void *)&cmd_2tuple_filter_queue,
10414 (void *)&cmd_2tuple_filter_queue_id,
10419 /* *** ADD/REMOVE A 5tuple FILTER *** */
10420 struct cmd_5tuple_filter_result {
10421 cmdline_fixed_string_t filter;
10423 cmdline_fixed_string_t ops;
10424 cmdline_fixed_string_t dst_ip;
10425 cmdline_ipaddr_t dst_ip_value;
10426 cmdline_fixed_string_t src_ip;
10427 cmdline_ipaddr_t src_ip_value;
10428 cmdline_fixed_string_t dst_port;
10429 uint16_t dst_port_value;
10430 cmdline_fixed_string_t src_port;
10431 uint16_t src_port_value;
10432 cmdline_fixed_string_t protocol;
10433 uint8_t protocol_value;
10434 cmdline_fixed_string_t mask;
10435 uint8_t mask_value;
10436 cmdline_fixed_string_t tcp_flags;
10437 uint8_t tcp_flags_value;
10438 cmdline_fixed_string_t priority;
10439 uint8_t priority_value;
10440 cmdline_fixed_string_t queue;
10445 cmd_5tuple_filter_parsed(void *parsed_result,
10446 __rte_unused struct cmdline *cl,
10447 __rte_unused void *data)
10449 struct rte_eth_ntuple_filter filter;
10450 struct cmd_5tuple_filter_result *res = parsed_result;
10453 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10455 printf("ntuple filter is not supported on port %u.\n",
10460 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10462 filter.flags = RTE_5TUPLE_FLAGS;
10463 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10464 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10465 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10466 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10467 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10468 filter.proto = res->protocol_value;
10469 filter.priority = res->priority_value;
10470 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10471 printf("nonzero tcp_flags is only meaningful"
10472 " when protocol is TCP.\n");
10475 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10476 printf("invalid TCP flags.\n");
10480 if (res->tcp_flags_value != 0) {
10481 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10482 filter.tcp_flags = res->tcp_flags_value;
10485 if (res->dst_ip_value.family == AF_INET)
10486 /* no need to convert, already big endian. */
10487 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10489 if (filter.dst_ip_mask == 0) {
10490 printf("can not support ipv6 involved compare.\n");
10496 if (res->src_ip_value.family == AF_INET)
10497 /* no need to convert, already big endian. */
10498 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10500 if (filter.src_ip_mask == 0) {
10501 printf("can not support ipv6 involved compare.\n");
10506 /* need convert to big endian. */
10507 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10508 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10509 filter.queue = res->queue_id;
10511 if (!strcmp(res->ops, "add"))
10512 ret = rte_eth_dev_filter_ctrl(res->port_id,
10513 RTE_ETH_FILTER_NTUPLE,
10514 RTE_ETH_FILTER_ADD,
10517 ret = rte_eth_dev_filter_ctrl(res->port_id,
10518 RTE_ETH_FILTER_NTUPLE,
10519 RTE_ETH_FILTER_DELETE,
10522 printf("5tuple filter programming error: (%s)\n",
10526 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10527 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10528 filter, "5tuple_filter");
10529 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10530 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10532 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10533 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10535 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10536 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10538 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10539 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10541 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10542 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10544 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10545 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10547 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10548 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10549 dst_port, "dst_port");
10550 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10551 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10552 dst_port_value, UINT16);
10553 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10554 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10555 src_port, "src_port");
10556 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10557 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10558 src_port_value, UINT16);
10559 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10560 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10561 protocol, "protocol");
10562 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10563 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10564 protocol_value, UINT8);
10565 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10566 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10568 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10569 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10571 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10572 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10573 tcp_flags, "tcp_flags");
10574 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10575 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10576 tcp_flags_value, UINT8);
10577 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10578 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10579 priority, "priority");
10580 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10581 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10582 priority_value, UINT8);
10583 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10584 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10586 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10587 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10590 cmdline_parse_inst_t cmd_5tuple_filter = {
10591 .f = cmd_5tuple_filter_parsed,
10593 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10594 "src_ip <value> dst_port <value> src_port <value> "
10595 "protocol <value> mask <value> tcp_flags <value> "
10596 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10598 (void *)&cmd_5tuple_filter_filter,
10599 (void *)&cmd_5tuple_filter_port_id,
10600 (void *)&cmd_5tuple_filter_ops,
10601 (void *)&cmd_5tuple_filter_dst_ip,
10602 (void *)&cmd_5tuple_filter_dst_ip_value,
10603 (void *)&cmd_5tuple_filter_src_ip,
10604 (void *)&cmd_5tuple_filter_src_ip_value,
10605 (void *)&cmd_5tuple_filter_dst_port,
10606 (void *)&cmd_5tuple_filter_dst_port_value,
10607 (void *)&cmd_5tuple_filter_src_port,
10608 (void *)&cmd_5tuple_filter_src_port_value,
10609 (void *)&cmd_5tuple_filter_protocol,
10610 (void *)&cmd_5tuple_filter_protocol_value,
10611 (void *)&cmd_5tuple_filter_mask,
10612 (void *)&cmd_5tuple_filter_mask_value,
10613 (void *)&cmd_5tuple_filter_tcp_flags,
10614 (void *)&cmd_5tuple_filter_tcp_flags_value,
10615 (void *)&cmd_5tuple_filter_priority,
10616 (void *)&cmd_5tuple_filter_priority_value,
10617 (void *)&cmd_5tuple_filter_queue,
10618 (void *)&cmd_5tuple_filter_queue_id,
10623 /* *** ADD/REMOVE A flex FILTER *** */
10624 struct cmd_flex_filter_result {
10625 cmdline_fixed_string_t filter;
10626 cmdline_fixed_string_t ops;
10628 cmdline_fixed_string_t len;
10630 cmdline_fixed_string_t bytes;
10631 cmdline_fixed_string_t bytes_value;
10632 cmdline_fixed_string_t mask;
10633 cmdline_fixed_string_t mask_value;
10634 cmdline_fixed_string_t priority;
10635 uint8_t priority_value;
10636 cmdline_fixed_string_t queue;
10640 static int xdigit2val(unsigned char c)
10645 else if (isupper(c))
10646 val = c - 'A' + 10;
10648 val = c - 'a' + 10;
10653 cmd_flex_filter_parsed(void *parsed_result,
10654 __rte_unused struct cmdline *cl,
10655 __rte_unused void *data)
10658 struct rte_eth_flex_filter filter;
10659 struct cmd_flex_filter_result *res = parsed_result;
10660 char *bytes_ptr, *mask_ptr;
10661 uint16_t len, i, j = 0;
10666 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10667 printf("the len exceed the max length 128\n");
10670 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10671 filter.len = res->len_value;
10672 filter.priority = res->priority_value;
10673 filter.queue = res->queue_id;
10674 bytes_ptr = res->bytes_value;
10675 mask_ptr = res->mask_value;
10677 /* translate bytes string to array. */
10678 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10679 (bytes_ptr[1] == 'X')))
10681 len = strnlen(bytes_ptr, res->len_value * 2);
10682 if (len == 0 || (len % 8 != 0)) {
10683 printf("please check len and bytes input\n");
10686 for (i = 0; i < len; i++) {
10688 if (isxdigit(c) == 0) {
10689 /* invalid characters. */
10690 printf("invalid input\n");
10693 val = xdigit2val(c);
10696 filter.bytes[j] = byte;
10697 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10704 /* translate mask string to uint8_t array. */
10705 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10706 (mask_ptr[1] == 'X')))
10708 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10710 printf("invalid input\n");
10715 for (i = 0; i < len; i++) {
10717 if (isxdigit(c) == 0) {
10718 /* invalid characters. */
10719 printf("invalid input\n");
10722 val = xdigit2val(c);
10725 filter.mask[j] = byte;
10726 printf("mask[%d]:%02x ", j, filter.mask[j]);
10734 if (!strcmp(res->ops, "add"))
10735 ret = rte_eth_dev_filter_ctrl(res->port_id,
10736 RTE_ETH_FILTER_FLEXIBLE,
10737 RTE_ETH_FILTER_ADD,
10740 ret = rte_eth_dev_filter_ctrl(res->port_id,
10741 RTE_ETH_FILTER_FLEXIBLE,
10742 RTE_ETH_FILTER_DELETE,
10746 printf("flex filter setting error: (%s)\n", strerror(-ret));
10749 cmdline_parse_token_string_t cmd_flex_filter_filter =
10750 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10751 filter, "flex_filter");
10752 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10753 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10755 cmdline_parse_token_string_t cmd_flex_filter_ops =
10756 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10758 cmdline_parse_token_string_t cmd_flex_filter_len =
10759 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10761 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10762 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10764 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10765 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10767 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10768 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10769 bytes_value, NULL);
10770 cmdline_parse_token_string_t cmd_flex_filter_mask =
10771 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10773 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10774 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10776 cmdline_parse_token_string_t cmd_flex_filter_priority =
10777 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10778 priority, "priority");
10779 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10780 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10781 priority_value, UINT8);
10782 cmdline_parse_token_string_t cmd_flex_filter_queue =
10783 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10785 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10786 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10788 cmdline_parse_inst_t cmd_flex_filter = {
10789 .f = cmd_flex_filter_parsed,
10791 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10792 "<value> mask <value> priority <value> queue <queue_id>: "
10793 "Add/Del a flex filter",
10795 (void *)&cmd_flex_filter_filter,
10796 (void *)&cmd_flex_filter_port_id,
10797 (void *)&cmd_flex_filter_ops,
10798 (void *)&cmd_flex_filter_len,
10799 (void *)&cmd_flex_filter_len_value,
10800 (void *)&cmd_flex_filter_bytes,
10801 (void *)&cmd_flex_filter_bytes_value,
10802 (void *)&cmd_flex_filter_mask,
10803 (void *)&cmd_flex_filter_mask_value,
10804 (void *)&cmd_flex_filter_priority,
10805 (void *)&cmd_flex_filter_priority_value,
10806 (void *)&cmd_flex_filter_queue,
10807 (void *)&cmd_flex_filter_queue_id,
10812 /* *** Filters Control *** */
10814 /* *** deal with ethertype filter *** */
10815 struct cmd_ethertype_filter_result {
10816 cmdline_fixed_string_t filter;
10818 cmdline_fixed_string_t ops;
10819 cmdline_fixed_string_t mac;
10820 struct rte_ether_addr mac_addr;
10821 cmdline_fixed_string_t ethertype;
10822 uint16_t ethertype_value;
10823 cmdline_fixed_string_t drop;
10824 cmdline_fixed_string_t queue;
10828 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10829 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10830 filter, "ethertype_filter");
10831 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10832 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10834 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10835 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10837 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10838 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10839 mac, "mac_addr#mac_ignr");
10840 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10841 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10843 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10844 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10845 ethertype, "ethertype");
10846 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10847 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10848 ethertype_value, UINT16);
10849 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10850 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10852 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10853 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10855 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10856 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10860 cmd_ethertype_filter_parsed(void *parsed_result,
10861 __rte_unused struct cmdline *cl,
10862 __rte_unused void *data)
10864 struct cmd_ethertype_filter_result *res = parsed_result;
10865 struct rte_eth_ethertype_filter filter;
10868 ret = rte_eth_dev_filter_supported(res->port_id,
10869 RTE_ETH_FILTER_ETHERTYPE);
10871 printf("ethertype filter is not supported on port %u.\n",
10876 memset(&filter, 0, sizeof(filter));
10877 if (!strcmp(res->mac, "mac_addr")) {
10878 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10879 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10880 sizeof(struct rte_ether_addr));
10882 if (!strcmp(res->drop, "drop"))
10883 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10884 filter.ether_type = res->ethertype_value;
10885 filter.queue = res->queue_id;
10887 if (!strcmp(res->ops, "add"))
10888 ret = rte_eth_dev_filter_ctrl(res->port_id,
10889 RTE_ETH_FILTER_ETHERTYPE,
10890 RTE_ETH_FILTER_ADD,
10893 ret = rte_eth_dev_filter_ctrl(res->port_id,
10894 RTE_ETH_FILTER_ETHERTYPE,
10895 RTE_ETH_FILTER_DELETE,
10898 printf("ethertype filter programming error: (%s)\n",
10902 cmdline_parse_inst_t cmd_ethertype_filter = {
10903 .f = cmd_ethertype_filter_parsed,
10905 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10906 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10907 "Add or delete an ethertype filter entry",
10909 (void *)&cmd_ethertype_filter_filter,
10910 (void *)&cmd_ethertype_filter_port_id,
10911 (void *)&cmd_ethertype_filter_ops,
10912 (void *)&cmd_ethertype_filter_mac,
10913 (void *)&cmd_ethertype_filter_mac_addr,
10914 (void *)&cmd_ethertype_filter_ethertype,
10915 (void *)&cmd_ethertype_filter_ethertype_value,
10916 (void *)&cmd_ethertype_filter_drop,
10917 (void *)&cmd_ethertype_filter_queue,
10918 (void *)&cmd_ethertype_filter_queue_id,
10923 /* *** deal with flow director filter *** */
10924 struct cmd_flow_director_result {
10925 cmdline_fixed_string_t flow_director_filter;
10927 cmdline_fixed_string_t mode;
10928 cmdline_fixed_string_t mode_value;
10929 cmdline_fixed_string_t ops;
10930 cmdline_fixed_string_t flow;
10931 cmdline_fixed_string_t flow_type;
10932 cmdline_fixed_string_t ether;
10933 uint16_t ether_type;
10934 cmdline_fixed_string_t src;
10935 cmdline_ipaddr_t ip_src;
10937 cmdline_fixed_string_t dst;
10938 cmdline_ipaddr_t ip_dst;
10940 cmdline_fixed_string_t verify_tag;
10941 uint32_t verify_tag_value;
10942 cmdline_fixed_string_t tos;
10944 cmdline_fixed_string_t proto;
10945 uint8_t proto_value;
10946 cmdline_fixed_string_t ttl;
10948 cmdline_fixed_string_t vlan;
10949 uint16_t vlan_value;
10950 cmdline_fixed_string_t flexbytes;
10951 cmdline_fixed_string_t flexbytes_value;
10952 cmdline_fixed_string_t pf_vf;
10953 cmdline_fixed_string_t drop;
10954 cmdline_fixed_string_t queue;
10956 cmdline_fixed_string_t fd_id;
10957 uint32_t fd_id_value;
10958 cmdline_fixed_string_t mac;
10959 struct rte_ether_addr mac_addr;
10960 cmdline_fixed_string_t tunnel;
10961 cmdline_fixed_string_t tunnel_type;
10962 cmdline_fixed_string_t tunnel_id;
10963 uint32_t tunnel_id_value;
10964 cmdline_fixed_string_t packet;
10969 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10972 const char *p, *p0 = q_arg;
10974 unsigned long int_fld;
10975 char *str_fld[max_num];
10980 p = strchr(p0, '(');
10984 p0 = strchr(p, ')');
10989 if (size >= sizeof(s))
10992 snprintf(s, sizeof(s), "%.*s", size, p);
10993 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10994 if (ret < 0 || ret > max_num)
10996 for (i = 0; i < ret; i++) {
10998 int_fld = strtoul(str_fld[i], &end, 0);
10999 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11001 flexbytes[i] = (uint8_t)int_fld;
11007 str2flowtype(char *string)
11010 static const struct {
11013 } flowtype_str[] = {
11014 {"raw", RTE_ETH_FLOW_RAW},
11015 {"ipv4", RTE_ETH_FLOW_IPV4},
11016 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11017 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11018 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11019 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11020 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11021 {"ipv6", RTE_ETH_FLOW_IPV6},
11022 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11023 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11024 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11025 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11026 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11027 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11030 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11031 if (!strcmp(flowtype_str[i].str, string))
11032 return flowtype_str[i].type;
11035 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11036 return (uint16_t)atoi(string);
11038 return RTE_ETH_FLOW_UNKNOWN;
11041 static enum rte_eth_fdir_tunnel_type
11042 str2fdir_tunneltype(char *string)
11046 static const struct {
11048 enum rte_eth_fdir_tunnel_type type;
11049 } tunneltype_str[] = {
11050 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11051 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11054 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11055 if (!strcmp(tunneltype_str[i].str, string))
11056 return tunneltype_str[i].type;
11058 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11061 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11063 if ((ip_addr).family == AF_INET) \
11064 (ip) = (ip_addr).addr.ipv4.s_addr; \
11066 printf("invalid parameter.\n"); \
11071 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11073 if ((ip_addr).family == AF_INET6) \
11074 rte_memcpy(&(ip), \
11075 &((ip_addr).addr.ipv6), \
11076 sizeof(struct in6_addr)); \
11078 printf("invalid parameter.\n"); \
11084 cmd_flow_director_filter_parsed(void *parsed_result,
11085 __rte_unused struct cmdline *cl,
11086 __rte_unused void *data)
11088 struct cmd_flow_director_result *res = parsed_result;
11089 struct rte_eth_fdir_filter entry;
11090 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11092 unsigned long vf_id;
11095 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11097 printf("flow director is not supported on port %u.\n",
11101 memset(flexbytes, 0, sizeof(flexbytes));
11102 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11104 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11105 if (strcmp(res->mode_value, "MAC-VLAN")) {
11106 printf("Please set mode to MAC-VLAN.\n");
11109 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11110 if (strcmp(res->mode_value, "Tunnel")) {
11111 printf("Please set mode to Tunnel.\n");
11115 if (!strcmp(res->mode_value, "raw")) {
11116 #ifdef RTE_LIBRTE_I40E_PMD
11117 struct rte_pmd_i40e_flow_type_mapping
11118 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11119 struct rte_pmd_i40e_pkt_template_conf conf;
11120 uint16_t flow_type = str2flowtype(res->flow_type);
11121 uint16_t i, port = res->port_id;
11124 memset(&conf, 0, sizeof(conf));
11126 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11127 printf("Invalid flow type specified.\n");
11130 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11134 if (mapping[flow_type].pctype == 0ULL) {
11135 printf("Invalid flow type specified.\n");
11138 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11139 if (mapping[flow_type].pctype & (1ULL << i)) {
11140 conf.input.pctype = i;
11145 conf.input.packet = open_file(res->filepath,
11146 &conf.input.length);
11147 if (!conf.input.packet)
11149 if (!strcmp(res->drop, "drop"))
11150 conf.action.behavior =
11151 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11153 conf.action.behavior =
11154 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11155 conf.action.report_status =
11156 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11157 conf.action.rx_queue = res->queue_id;
11158 conf.soft_id = res->fd_id_value;
11159 add = strcmp(res->ops, "del") ? 1 : 0;
11160 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11164 printf("flow director config error: (%s)\n",
11166 close_file(conf.input.packet);
11169 } else if (strcmp(res->mode_value, "IP")) {
11170 printf("Please set mode to IP or raw.\n");
11173 entry.input.flow_type = str2flowtype(res->flow_type);
11176 ret = parse_flexbytes(res->flexbytes_value,
11178 RTE_ETH_FDIR_MAX_FLEXLEN);
11180 printf("error: Cannot parse flexbytes input.\n");
11184 switch (entry.input.flow_type) {
11185 case RTE_ETH_FLOW_FRAG_IPV4:
11186 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11187 entry.input.flow.ip4_flow.proto = res->proto_value;
11189 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11190 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11191 IPV4_ADDR_TO_UINT(res->ip_dst,
11192 entry.input.flow.ip4_flow.dst_ip);
11193 IPV4_ADDR_TO_UINT(res->ip_src,
11194 entry.input.flow.ip4_flow.src_ip);
11195 entry.input.flow.ip4_flow.tos = res->tos_value;
11196 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11197 /* need convert to big endian. */
11198 entry.input.flow.udp4_flow.dst_port =
11199 rte_cpu_to_be_16(res->port_dst);
11200 entry.input.flow.udp4_flow.src_port =
11201 rte_cpu_to_be_16(res->port_src);
11203 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11204 IPV4_ADDR_TO_UINT(res->ip_dst,
11205 entry.input.flow.sctp4_flow.ip.dst_ip);
11206 IPV4_ADDR_TO_UINT(res->ip_src,
11207 entry.input.flow.sctp4_flow.ip.src_ip);
11208 entry.input.flow.ip4_flow.tos = res->tos_value;
11209 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11210 /* need convert to big endian. */
11211 entry.input.flow.sctp4_flow.dst_port =
11212 rte_cpu_to_be_16(res->port_dst);
11213 entry.input.flow.sctp4_flow.src_port =
11214 rte_cpu_to_be_16(res->port_src);
11215 entry.input.flow.sctp4_flow.verify_tag =
11216 rte_cpu_to_be_32(res->verify_tag_value);
11218 case RTE_ETH_FLOW_FRAG_IPV6:
11219 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11220 entry.input.flow.ipv6_flow.proto = res->proto_value;
11222 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11223 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11224 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11225 entry.input.flow.ipv6_flow.dst_ip);
11226 IPV6_ADDR_TO_ARRAY(res->ip_src,
11227 entry.input.flow.ipv6_flow.src_ip);
11228 entry.input.flow.ipv6_flow.tc = res->tos_value;
11229 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11230 /* need convert to big endian. */
11231 entry.input.flow.udp6_flow.dst_port =
11232 rte_cpu_to_be_16(res->port_dst);
11233 entry.input.flow.udp6_flow.src_port =
11234 rte_cpu_to_be_16(res->port_src);
11236 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11237 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11238 entry.input.flow.sctp6_flow.ip.dst_ip);
11239 IPV6_ADDR_TO_ARRAY(res->ip_src,
11240 entry.input.flow.sctp6_flow.ip.src_ip);
11241 entry.input.flow.ipv6_flow.tc = res->tos_value;
11242 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11243 /* need convert to big endian. */
11244 entry.input.flow.sctp6_flow.dst_port =
11245 rte_cpu_to_be_16(res->port_dst);
11246 entry.input.flow.sctp6_flow.src_port =
11247 rte_cpu_to_be_16(res->port_src);
11248 entry.input.flow.sctp6_flow.verify_tag =
11249 rte_cpu_to_be_32(res->verify_tag_value);
11251 case RTE_ETH_FLOW_L2_PAYLOAD:
11252 entry.input.flow.l2_flow.ether_type =
11253 rte_cpu_to_be_16(res->ether_type);
11259 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11260 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11262 sizeof(struct rte_ether_addr));
11264 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11265 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11267 sizeof(struct rte_ether_addr));
11268 entry.input.flow.tunnel_flow.tunnel_type =
11269 str2fdir_tunneltype(res->tunnel_type);
11270 entry.input.flow.tunnel_flow.tunnel_id =
11271 rte_cpu_to_be_32(res->tunnel_id_value);
11274 rte_memcpy(entry.input.flow_ext.flexbytes,
11276 RTE_ETH_FDIR_MAX_FLEXLEN);
11278 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11280 entry.action.flex_off = 0; /*use 0 by default */
11281 if (!strcmp(res->drop, "drop"))
11282 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11284 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11286 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11287 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11288 if (!strcmp(res->pf_vf, "pf"))
11289 entry.input.flow_ext.is_vf = 0;
11290 else if (!strncmp(res->pf_vf, "vf", 2)) {
11291 struct rte_eth_dev_info dev_info;
11293 ret = eth_dev_info_get_print_err(res->port_id,
11299 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11300 if (errno != 0 || *end != '\0' ||
11301 vf_id >= dev_info.max_vfs) {
11302 printf("invalid parameter %s.\n", res->pf_vf);
11305 entry.input.flow_ext.is_vf = 1;
11306 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11308 printf("invalid parameter %s.\n", res->pf_vf);
11313 /* set to report FD ID by default */
11314 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11315 entry.action.rx_queue = res->queue_id;
11316 entry.soft_id = res->fd_id_value;
11317 if (!strcmp(res->ops, "add"))
11318 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11319 RTE_ETH_FILTER_ADD, &entry);
11320 else if (!strcmp(res->ops, "del"))
11321 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11322 RTE_ETH_FILTER_DELETE, &entry);
11324 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11325 RTE_ETH_FILTER_UPDATE, &entry);
11327 printf("flow director programming error: (%s)\n",
11331 cmdline_parse_token_string_t cmd_flow_director_filter =
11332 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11333 flow_director_filter, "flow_director_filter");
11334 cmdline_parse_token_num_t cmd_flow_director_port_id =
11335 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11337 cmdline_parse_token_string_t cmd_flow_director_ops =
11338 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11339 ops, "add#del#update");
11340 cmdline_parse_token_string_t cmd_flow_director_flow =
11341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11343 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11344 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11346 cmdline_parse_token_string_t cmd_flow_director_ether =
11347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11349 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11350 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11351 ether_type, UINT16);
11352 cmdline_parse_token_string_t cmd_flow_director_src =
11353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11355 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11356 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11358 cmdline_parse_token_num_t cmd_flow_director_port_src =
11359 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11361 cmdline_parse_token_string_t cmd_flow_director_dst =
11362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11364 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11365 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11367 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11368 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11370 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11372 verify_tag, "verify_tag");
11373 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11374 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11375 verify_tag_value, UINT32);
11376 cmdline_parse_token_string_t cmd_flow_director_tos =
11377 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11379 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11380 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11382 cmdline_parse_token_string_t cmd_flow_director_proto =
11383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11385 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11386 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11387 proto_value, UINT8);
11388 cmdline_parse_token_string_t cmd_flow_director_ttl =
11389 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11391 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11392 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11394 cmdline_parse_token_string_t cmd_flow_director_vlan =
11395 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11397 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11398 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11399 vlan_value, UINT16);
11400 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11401 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11402 flexbytes, "flexbytes");
11403 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11404 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11405 flexbytes_value, NULL);
11406 cmdline_parse_token_string_t cmd_flow_director_drop =
11407 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11409 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11410 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11412 cmdline_parse_token_string_t cmd_flow_director_queue =
11413 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11415 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11416 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11418 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11419 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11421 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11422 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11423 fd_id_value, UINT32);
11425 cmdline_parse_token_string_t cmd_flow_director_mode =
11426 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11428 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11431 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11432 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11433 mode_value, "MAC-VLAN");
11434 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11435 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11436 mode_value, "Tunnel");
11437 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11439 mode_value, "raw");
11440 cmdline_parse_token_string_t cmd_flow_director_mac =
11441 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11443 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11444 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11446 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11447 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11449 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11450 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11451 tunnel_type, "NVGRE#VxLAN");
11452 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11453 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11454 tunnel_id, "tunnel-id");
11455 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11456 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11457 tunnel_id_value, UINT32);
11458 cmdline_parse_token_string_t cmd_flow_director_packet =
11459 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11461 cmdline_parse_token_string_t cmd_flow_director_filepath =
11462 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11465 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11466 .f = cmd_flow_director_filter_parsed,
11468 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11469 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11470 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11471 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11472 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11473 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11474 "fd_id <fd_id_value>: "
11475 "Add or delete an ip flow director entry on NIC",
11477 (void *)&cmd_flow_director_filter,
11478 (void *)&cmd_flow_director_port_id,
11479 (void *)&cmd_flow_director_mode,
11480 (void *)&cmd_flow_director_mode_ip,
11481 (void *)&cmd_flow_director_ops,
11482 (void *)&cmd_flow_director_flow,
11483 (void *)&cmd_flow_director_flow_type,
11484 (void *)&cmd_flow_director_src,
11485 (void *)&cmd_flow_director_ip_src,
11486 (void *)&cmd_flow_director_dst,
11487 (void *)&cmd_flow_director_ip_dst,
11488 (void *)&cmd_flow_director_tos,
11489 (void *)&cmd_flow_director_tos_value,
11490 (void *)&cmd_flow_director_proto,
11491 (void *)&cmd_flow_director_proto_value,
11492 (void *)&cmd_flow_director_ttl,
11493 (void *)&cmd_flow_director_ttl_value,
11494 (void *)&cmd_flow_director_vlan,
11495 (void *)&cmd_flow_director_vlan_value,
11496 (void *)&cmd_flow_director_flexbytes,
11497 (void *)&cmd_flow_director_flexbytes_value,
11498 (void *)&cmd_flow_director_drop,
11499 (void *)&cmd_flow_director_pf_vf,
11500 (void *)&cmd_flow_director_queue,
11501 (void *)&cmd_flow_director_queue_id,
11502 (void *)&cmd_flow_director_fd_id,
11503 (void *)&cmd_flow_director_fd_id_value,
11508 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11509 .f = cmd_flow_director_filter_parsed,
11511 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11512 "director entry on NIC",
11514 (void *)&cmd_flow_director_filter,
11515 (void *)&cmd_flow_director_port_id,
11516 (void *)&cmd_flow_director_mode,
11517 (void *)&cmd_flow_director_mode_ip,
11518 (void *)&cmd_flow_director_ops,
11519 (void *)&cmd_flow_director_flow,
11520 (void *)&cmd_flow_director_flow_type,
11521 (void *)&cmd_flow_director_src,
11522 (void *)&cmd_flow_director_ip_src,
11523 (void *)&cmd_flow_director_port_src,
11524 (void *)&cmd_flow_director_dst,
11525 (void *)&cmd_flow_director_ip_dst,
11526 (void *)&cmd_flow_director_port_dst,
11527 (void *)&cmd_flow_director_tos,
11528 (void *)&cmd_flow_director_tos_value,
11529 (void *)&cmd_flow_director_ttl,
11530 (void *)&cmd_flow_director_ttl_value,
11531 (void *)&cmd_flow_director_vlan,
11532 (void *)&cmd_flow_director_vlan_value,
11533 (void *)&cmd_flow_director_flexbytes,
11534 (void *)&cmd_flow_director_flexbytes_value,
11535 (void *)&cmd_flow_director_drop,
11536 (void *)&cmd_flow_director_pf_vf,
11537 (void *)&cmd_flow_director_queue,
11538 (void *)&cmd_flow_director_queue_id,
11539 (void *)&cmd_flow_director_fd_id,
11540 (void *)&cmd_flow_director_fd_id_value,
11545 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11546 .f = cmd_flow_director_filter_parsed,
11548 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11549 "director entry on NIC",
11551 (void *)&cmd_flow_director_filter,
11552 (void *)&cmd_flow_director_port_id,
11553 (void *)&cmd_flow_director_mode,
11554 (void *)&cmd_flow_director_mode_ip,
11555 (void *)&cmd_flow_director_ops,
11556 (void *)&cmd_flow_director_flow,
11557 (void *)&cmd_flow_director_flow_type,
11558 (void *)&cmd_flow_director_src,
11559 (void *)&cmd_flow_director_ip_src,
11560 (void *)&cmd_flow_director_port_src,
11561 (void *)&cmd_flow_director_dst,
11562 (void *)&cmd_flow_director_ip_dst,
11563 (void *)&cmd_flow_director_port_dst,
11564 (void *)&cmd_flow_director_verify_tag,
11565 (void *)&cmd_flow_director_verify_tag_value,
11566 (void *)&cmd_flow_director_tos,
11567 (void *)&cmd_flow_director_tos_value,
11568 (void *)&cmd_flow_director_ttl,
11569 (void *)&cmd_flow_director_ttl_value,
11570 (void *)&cmd_flow_director_vlan,
11571 (void *)&cmd_flow_director_vlan_value,
11572 (void *)&cmd_flow_director_flexbytes,
11573 (void *)&cmd_flow_director_flexbytes_value,
11574 (void *)&cmd_flow_director_drop,
11575 (void *)&cmd_flow_director_pf_vf,
11576 (void *)&cmd_flow_director_queue,
11577 (void *)&cmd_flow_director_queue_id,
11578 (void *)&cmd_flow_director_fd_id,
11579 (void *)&cmd_flow_director_fd_id_value,
11584 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11585 .f = cmd_flow_director_filter_parsed,
11587 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11588 "director entry on NIC",
11590 (void *)&cmd_flow_director_filter,
11591 (void *)&cmd_flow_director_port_id,
11592 (void *)&cmd_flow_director_mode,
11593 (void *)&cmd_flow_director_mode_ip,
11594 (void *)&cmd_flow_director_ops,
11595 (void *)&cmd_flow_director_flow,
11596 (void *)&cmd_flow_director_flow_type,
11597 (void *)&cmd_flow_director_ether,
11598 (void *)&cmd_flow_director_ether_type,
11599 (void *)&cmd_flow_director_flexbytes,
11600 (void *)&cmd_flow_director_flexbytes_value,
11601 (void *)&cmd_flow_director_drop,
11602 (void *)&cmd_flow_director_pf_vf,
11603 (void *)&cmd_flow_director_queue,
11604 (void *)&cmd_flow_director_queue_id,
11605 (void *)&cmd_flow_director_fd_id,
11606 (void *)&cmd_flow_director_fd_id_value,
11611 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11612 .f = cmd_flow_director_filter_parsed,
11614 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11615 "director entry on NIC",
11617 (void *)&cmd_flow_director_filter,
11618 (void *)&cmd_flow_director_port_id,
11619 (void *)&cmd_flow_director_mode,
11620 (void *)&cmd_flow_director_mode_mac_vlan,
11621 (void *)&cmd_flow_director_ops,
11622 (void *)&cmd_flow_director_mac,
11623 (void *)&cmd_flow_director_mac_addr,
11624 (void *)&cmd_flow_director_vlan,
11625 (void *)&cmd_flow_director_vlan_value,
11626 (void *)&cmd_flow_director_flexbytes,
11627 (void *)&cmd_flow_director_flexbytes_value,
11628 (void *)&cmd_flow_director_drop,
11629 (void *)&cmd_flow_director_queue,
11630 (void *)&cmd_flow_director_queue_id,
11631 (void *)&cmd_flow_director_fd_id,
11632 (void *)&cmd_flow_director_fd_id_value,
11637 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11638 .f = cmd_flow_director_filter_parsed,
11640 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11641 "director entry on NIC",
11643 (void *)&cmd_flow_director_filter,
11644 (void *)&cmd_flow_director_port_id,
11645 (void *)&cmd_flow_director_mode,
11646 (void *)&cmd_flow_director_mode_tunnel,
11647 (void *)&cmd_flow_director_ops,
11648 (void *)&cmd_flow_director_mac,
11649 (void *)&cmd_flow_director_mac_addr,
11650 (void *)&cmd_flow_director_vlan,
11651 (void *)&cmd_flow_director_vlan_value,
11652 (void *)&cmd_flow_director_tunnel,
11653 (void *)&cmd_flow_director_tunnel_type,
11654 (void *)&cmd_flow_director_tunnel_id,
11655 (void *)&cmd_flow_director_tunnel_id_value,
11656 (void *)&cmd_flow_director_flexbytes,
11657 (void *)&cmd_flow_director_flexbytes_value,
11658 (void *)&cmd_flow_director_drop,
11659 (void *)&cmd_flow_director_queue,
11660 (void *)&cmd_flow_director_queue_id,
11661 (void *)&cmd_flow_director_fd_id,
11662 (void *)&cmd_flow_director_fd_id_value,
11667 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11668 .f = cmd_flow_director_filter_parsed,
11670 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11671 "director entry on NIC",
11673 (void *)&cmd_flow_director_filter,
11674 (void *)&cmd_flow_director_port_id,
11675 (void *)&cmd_flow_director_mode,
11676 (void *)&cmd_flow_director_mode_raw,
11677 (void *)&cmd_flow_director_ops,
11678 (void *)&cmd_flow_director_flow,
11679 (void *)&cmd_flow_director_flow_type,
11680 (void *)&cmd_flow_director_drop,
11681 (void *)&cmd_flow_director_queue,
11682 (void *)&cmd_flow_director_queue_id,
11683 (void *)&cmd_flow_director_fd_id,
11684 (void *)&cmd_flow_director_fd_id_value,
11685 (void *)&cmd_flow_director_packet,
11686 (void *)&cmd_flow_director_filepath,
11691 struct cmd_flush_flow_director_result {
11692 cmdline_fixed_string_t flush_flow_director;
11696 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11697 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11698 flush_flow_director, "flush_flow_director");
11699 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11700 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11704 cmd_flush_flow_director_parsed(void *parsed_result,
11705 __rte_unused struct cmdline *cl,
11706 __rte_unused void *data)
11708 struct cmd_flow_director_result *res = parsed_result;
11711 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11713 printf("flow director is not supported on port %u.\n",
11718 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11719 RTE_ETH_FILTER_FLUSH, NULL);
11721 printf("flow director table flushing error: (%s)\n",
11725 cmdline_parse_inst_t cmd_flush_flow_director = {
11726 .f = cmd_flush_flow_director_parsed,
11728 .help_str = "flush_flow_director <port_id>: "
11729 "Flush all flow director entries of a device on NIC",
11731 (void *)&cmd_flush_flow_director_flush,
11732 (void *)&cmd_flush_flow_director_port_id,
11737 /* *** deal with flow director mask *** */
11738 struct cmd_flow_director_mask_result {
11739 cmdline_fixed_string_t flow_director_mask;
11741 cmdline_fixed_string_t mode;
11742 cmdline_fixed_string_t mode_value;
11743 cmdline_fixed_string_t vlan;
11744 uint16_t vlan_mask;
11745 cmdline_fixed_string_t src_mask;
11746 cmdline_ipaddr_t ipv4_src;
11747 cmdline_ipaddr_t ipv6_src;
11749 cmdline_fixed_string_t dst_mask;
11750 cmdline_ipaddr_t ipv4_dst;
11751 cmdline_ipaddr_t ipv6_dst;
11753 cmdline_fixed_string_t mac;
11754 uint8_t mac_addr_byte_mask;
11755 cmdline_fixed_string_t tunnel_id;
11756 uint32_t tunnel_id_mask;
11757 cmdline_fixed_string_t tunnel_type;
11758 uint8_t tunnel_type_mask;
11762 cmd_flow_director_mask_parsed(void *parsed_result,
11763 __rte_unused struct cmdline *cl,
11764 __rte_unused void *data)
11766 struct cmd_flow_director_mask_result *res = parsed_result;
11767 struct rte_eth_fdir_masks *mask;
11768 struct rte_port *port;
11770 port = &ports[res->port_id];
11771 /** Check if the port is not started **/
11772 if (port->port_status != RTE_PORT_STOPPED) {
11773 printf("Please stop port %d first\n", res->port_id);
11777 mask = &port->dev_conf.fdir_conf.mask;
11779 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11780 if (strcmp(res->mode_value, "MAC-VLAN")) {
11781 printf("Please set mode to MAC-VLAN.\n");
11785 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11786 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11787 if (strcmp(res->mode_value, "Tunnel")) {
11788 printf("Please set mode to Tunnel.\n");
11792 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11793 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11794 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11795 mask->tunnel_type_mask = res->tunnel_type_mask;
11797 if (strcmp(res->mode_value, "IP")) {
11798 printf("Please set mode to IP.\n");
11802 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11803 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11804 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11805 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11806 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11807 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11808 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11811 cmd_reconfig_device_queue(res->port_id, 1, 1);
11814 cmdline_parse_token_string_t cmd_flow_director_mask =
11815 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11816 flow_director_mask, "flow_director_mask");
11817 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11818 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11820 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11821 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11823 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11824 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11825 vlan_mask, UINT16);
11826 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11827 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11828 src_mask, "src_mask");
11829 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11830 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11832 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11833 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11835 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11836 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11838 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11839 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11840 dst_mask, "dst_mask");
11841 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11842 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11844 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11845 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11847 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11848 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11851 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11854 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11857 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11859 mode_value, "MAC-VLAN");
11860 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11862 mode_value, "Tunnel");
11863 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11866 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11867 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11868 mac_addr_byte_mask, UINT8);
11869 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11871 tunnel_type, "tunnel-type");
11872 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11873 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11874 tunnel_type_mask, UINT8);
11875 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11877 tunnel_id, "tunnel-id");
11878 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11879 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11880 tunnel_id_mask, UINT32);
11882 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11883 .f = cmd_flow_director_mask_parsed,
11885 .help_str = "flow_director_mask ... : "
11886 "Set IP mode flow director's mask on NIC",
11888 (void *)&cmd_flow_director_mask,
11889 (void *)&cmd_flow_director_mask_port_id,
11890 (void *)&cmd_flow_director_mask_mode,
11891 (void *)&cmd_flow_director_mask_mode_ip,
11892 (void *)&cmd_flow_director_mask_vlan,
11893 (void *)&cmd_flow_director_mask_vlan_value,
11894 (void *)&cmd_flow_director_mask_src,
11895 (void *)&cmd_flow_director_mask_ipv4_src,
11896 (void *)&cmd_flow_director_mask_ipv6_src,
11897 (void *)&cmd_flow_director_mask_port_src,
11898 (void *)&cmd_flow_director_mask_dst,
11899 (void *)&cmd_flow_director_mask_ipv4_dst,
11900 (void *)&cmd_flow_director_mask_ipv6_dst,
11901 (void *)&cmd_flow_director_mask_port_dst,
11906 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11907 .f = cmd_flow_director_mask_parsed,
11909 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11910 "flow director's mask on NIC",
11912 (void *)&cmd_flow_director_mask,
11913 (void *)&cmd_flow_director_mask_port_id,
11914 (void *)&cmd_flow_director_mask_mode,
11915 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11916 (void *)&cmd_flow_director_mask_vlan,
11917 (void *)&cmd_flow_director_mask_vlan_value,
11922 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11923 .f = cmd_flow_director_mask_parsed,
11925 .help_str = "flow_director_mask ... : Set tunnel mode "
11926 "flow director's mask on NIC",
11928 (void *)&cmd_flow_director_mask,
11929 (void *)&cmd_flow_director_mask_port_id,
11930 (void *)&cmd_flow_director_mask_mode,
11931 (void *)&cmd_flow_director_mask_mode_tunnel,
11932 (void *)&cmd_flow_director_mask_vlan,
11933 (void *)&cmd_flow_director_mask_vlan_value,
11934 (void *)&cmd_flow_director_mask_mac,
11935 (void *)&cmd_flow_director_mask_mac_value,
11936 (void *)&cmd_flow_director_mask_tunnel_type,
11937 (void *)&cmd_flow_director_mask_tunnel_type_value,
11938 (void *)&cmd_flow_director_mask_tunnel_id,
11939 (void *)&cmd_flow_director_mask_tunnel_id_value,
11944 /* *** deal with flow director mask on flexible payload *** */
11945 struct cmd_flow_director_flex_mask_result {
11946 cmdline_fixed_string_t flow_director_flexmask;
11948 cmdline_fixed_string_t flow;
11949 cmdline_fixed_string_t flow_type;
11950 cmdline_fixed_string_t mask;
11954 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11955 __rte_unused struct cmdline *cl,
11956 __rte_unused void *data)
11958 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11959 struct rte_eth_fdir_info fdir_info;
11960 struct rte_eth_fdir_flex_mask flex_mask;
11961 struct rte_port *port;
11962 uint64_t flow_type_mask;
11966 port = &ports[res->port_id];
11967 /** Check if the port is not started **/
11968 if (port->port_status != RTE_PORT_STOPPED) {
11969 printf("Please stop port %d first\n", res->port_id);
11973 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11974 ret = parse_flexbytes(res->mask,
11976 RTE_ETH_FDIR_MAX_FLEXLEN);
11978 printf("error: Cannot parse mask input.\n");
11982 memset(&fdir_info, 0, sizeof(fdir_info));
11983 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11984 RTE_ETH_FILTER_INFO, &fdir_info);
11986 printf("Cannot get FDir filter info\n");
11990 if (!strcmp(res->flow_type, "none")) {
11991 /* means don't specify the flow type */
11992 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11993 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11994 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11995 0, sizeof(struct rte_eth_fdir_flex_mask));
11996 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11997 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11999 sizeof(struct rte_eth_fdir_flex_mask));
12000 cmd_reconfig_device_queue(res->port_id, 1, 1);
12003 flow_type_mask = fdir_info.flow_types_mask[0];
12004 if (!strcmp(res->flow_type, "all")) {
12005 if (!flow_type_mask) {
12006 printf("No flow type supported\n");
12009 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12010 if (flow_type_mask & (1ULL << i)) {
12011 flex_mask.flow_type = i;
12012 fdir_set_flex_mask(res->port_id, &flex_mask);
12015 cmd_reconfig_device_queue(res->port_id, 1, 1);
12018 flex_mask.flow_type = str2flowtype(res->flow_type);
12019 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12020 printf("Flow type %s not supported on port %d\n",
12021 res->flow_type, res->port_id);
12024 fdir_set_flex_mask(res->port_id, &flex_mask);
12025 cmd_reconfig_device_queue(res->port_id, 1, 1);
12028 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12029 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12030 flow_director_flexmask,
12031 "flow_director_flex_mask");
12032 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12033 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12035 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12036 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12038 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12039 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12040 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12041 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12042 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12043 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12046 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12047 .f = cmd_flow_director_flex_mask_parsed,
12049 .help_str = "flow_director_flex_mask ... : "
12050 "Set flow director's flex mask on NIC",
12052 (void *)&cmd_flow_director_flexmask,
12053 (void *)&cmd_flow_director_flexmask_port_id,
12054 (void *)&cmd_flow_director_flexmask_flow,
12055 (void *)&cmd_flow_director_flexmask_flow_type,
12056 (void *)&cmd_flow_director_flexmask_mask,
12061 /* *** deal with flow director flexible payload configuration *** */
12062 struct cmd_flow_director_flexpayload_result {
12063 cmdline_fixed_string_t flow_director_flexpayload;
12065 cmdline_fixed_string_t payload_layer;
12066 cmdline_fixed_string_t payload_cfg;
12070 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12073 const char *p, *p0 = q_arg;
12075 unsigned long int_fld;
12076 char *str_fld[max_num];
12081 p = strchr(p0, '(');
12085 p0 = strchr(p, ')');
12090 if (size >= sizeof(s))
12093 snprintf(s, sizeof(s), "%.*s", size, p);
12094 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12095 if (ret < 0 || ret > max_num)
12097 for (i = 0; i < ret; i++) {
12099 int_fld = strtoul(str_fld[i], &end, 0);
12100 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12102 offsets[i] = (uint16_t)int_fld;
12108 cmd_flow_director_flxpld_parsed(void *parsed_result,
12109 __rte_unused struct cmdline *cl,
12110 __rte_unused void *data)
12112 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12113 struct rte_eth_flex_payload_cfg flex_cfg;
12114 struct rte_port *port;
12117 port = &ports[res->port_id];
12118 /** Check if the port is not started **/
12119 if (port->port_status != RTE_PORT_STOPPED) {
12120 printf("Please stop port %d first\n", res->port_id);
12124 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12126 if (!strcmp(res->payload_layer, "raw"))
12127 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12128 else if (!strcmp(res->payload_layer, "l2"))
12129 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12130 else if (!strcmp(res->payload_layer, "l3"))
12131 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12132 else if (!strcmp(res->payload_layer, "l4"))
12133 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12135 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12136 RTE_ETH_FDIR_MAX_FLEXLEN);
12138 printf("error: Cannot parse flex payload input.\n");
12142 fdir_set_flex_payload(res->port_id, &flex_cfg);
12143 cmd_reconfig_device_queue(res->port_id, 1, 1);
12146 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12147 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12148 flow_director_flexpayload,
12149 "flow_director_flex_payload");
12150 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12151 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12153 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12154 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12155 payload_layer, "raw#l2#l3#l4");
12156 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12157 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12158 payload_cfg, NULL);
12160 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12161 .f = cmd_flow_director_flxpld_parsed,
12163 .help_str = "flow_director_flexpayload ... : "
12164 "Set flow director's flex payload on NIC",
12166 (void *)&cmd_flow_director_flexpayload,
12167 (void *)&cmd_flow_director_flexpayload_port_id,
12168 (void *)&cmd_flow_director_flexpayload_payload_layer,
12169 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12174 /* Generic flow interface command. */
12175 extern cmdline_parse_inst_t cmd_flow;
12177 /* *** Classification Filters Control *** */
12178 /* *** Get symmetric hash enable per port *** */
12179 struct cmd_get_sym_hash_ena_per_port_result {
12180 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12185 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12186 __rte_unused struct cmdline *cl,
12187 __rte_unused void *data)
12189 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12190 struct rte_eth_hash_filter_info info;
12193 if (rte_eth_dev_filter_supported(res->port_id,
12194 RTE_ETH_FILTER_HASH) < 0) {
12195 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12200 memset(&info, 0, sizeof(info));
12201 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12202 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12203 RTE_ETH_FILTER_GET, &info);
12206 printf("Cannot get symmetric hash enable per port "
12207 "on port %u\n", res->port_id);
12211 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12212 "enabled" : "disabled", res->port_id);
12215 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12216 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12217 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12218 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12219 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12222 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12223 .f = cmd_get_sym_hash_per_port_parsed,
12225 .help_str = "get_sym_hash_ena_per_port <port_id>",
12227 (void *)&cmd_get_sym_hash_ena_per_port_all,
12228 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12233 /* *** Set symmetric hash enable per port *** */
12234 struct cmd_set_sym_hash_ena_per_port_result {
12235 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12236 cmdline_fixed_string_t enable;
12241 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12242 __rte_unused struct cmdline *cl,
12243 __rte_unused void *data)
12245 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12246 struct rte_eth_hash_filter_info info;
12249 if (rte_eth_dev_filter_supported(res->port_id,
12250 RTE_ETH_FILTER_HASH) < 0) {
12251 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12256 memset(&info, 0, sizeof(info));
12257 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12258 if (!strcmp(res->enable, "enable"))
12259 info.info.enable = 1;
12260 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12261 RTE_ETH_FILTER_SET, &info);
12263 printf("Cannot set symmetric hash enable per port on "
12264 "port %u\n", res->port_id);
12267 printf("Symmetric hash has been set to %s on port %u\n",
12268 res->enable, res->port_id);
12271 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12272 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12273 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12274 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12275 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12277 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12278 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12279 enable, "enable#disable");
12281 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12282 .f = cmd_set_sym_hash_per_port_parsed,
12284 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12286 (void *)&cmd_set_sym_hash_ena_per_port_all,
12287 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12288 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12293 /* Get global config of hash function */
12294 struct cmd_get_hash_global_config_result {
12295 cmdline_fixed_string_t get_hash_global_config;
12300 flowtype_to_str(uint16_t ftype)
12306 } ftype_table[] = {
12307 {"ipv4", RTE_ETH_FLOW_IPV4},
12308 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12309 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12310 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12311 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12312 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12313 {"ipv6", RTE_ETH_FLOW_IPV6},
12314 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12315 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12316 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12317 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12318 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12319 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12320 {"port", RTE_ETH_FLOW_PORT},
12321 {"vxlan", RTE_ETH_FLOW_VXLAN},
12322 {"geneve", RTE_ETH_FLOW_GENEVE},
12323 {"nvgre", RTE_ETH_FLOW_NVGRE},
12324 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12327 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12328 if (ftype_table[i].ftype == ftype)
12329 return ftype_table[i].str;
12336 cmd_get_hash_global_config_parsed(void *parsed_result,
12337 __rte_unused struct cmdline *cl,
12338 __rte_unused void *data)
12340 struct cmd_get_hash_global_config_result *res = parsed_result;
12341 struct rte_eth_hash_filter_info info;
12342 uint32_t idx, offset;
12347 if (rte_eth_dev_filter_supported(res->port_id,
12348 RTE_ETH_FILTER_HASH) < 0) {
12349 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12354 memset(&info, 0, sizeof(info));
12355 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12356 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12357 RTE_ETH_FILTER_GET, &info);
12359 printf("Cannot get hash global configurations by port %d\n",
12364 switch (info.info.global_conf.hash_func) {
12365 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12366 printf("Hash function is Toeplitz\n");
12368 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12369 printf("Hash function is Simple XOR\n");
12371 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12372 printf("Hash function is Symmetric Toeplitz\n");
12375 printf("Unknown hash function\n");
12379 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12380 idx = i / UINT64_BIT;
12381 offset = i % UINT64_BIT;
12382 if (!(info.info.global_conf.valid_bit_mask[idx] &
12385 str = flowtype_to_str(i);
12388 printf("Symmetric hash is %s globally for flow type %s "
12390 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12391 (1ULL << offset)) ? "enabled" : "disabled"), str,
12396 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12397 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12398 get_hash_global_config, "get_hash_global_config");
12399 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12400 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12403 cmdline_parse_inst_t cmd_get_hash_global_config = {
12404 .f = cmd_get_hash_global_config_parsed,
12406 .help_str = "get_hash_global_config <port_id>",
12408 (void *)&cmd_get_hash_global_config_all,
12409 (void *)&cmd_get_hash_global_config_port_id,
12414 /* Set global config of hash function */
12415 struct cmd_set_hash_global_config_result {
12416 cmdline_fixed_string_t set_hash_global_config;
12418 cmdline_fixed_string_t hash_func;
12419 cmdline_fixed_string_t flow_type;
12420 cmdline_fixed_string_t enable;
12424 cmd_set_hash_global_config_parsed(void *parsed_result,
12425 __rte_unused struct cmdline *cl,
12426 __rte_unused void *data)
12428 struct cmd_set_hash_global_config_result *res = parsed_result;
12429 struct rte_eth_hash_filter_info info;
12430 uint32_t ftype, idx, offset;
12433 if (rte_eth_dev_filter_supported(res->port_id,
12434 RTE_ETH_FILTER_HASH) < 0) {
12435 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12439 memset(&info, 0, sizeof(info));
12440 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12441 if (!strcmp(res->hash_func, "toeplitz"))
12442 info.info.global_conf.hash_func =
12443 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12444 else if (!strcmp(res->hash_func, "simple_xor"))
12445 info.info.global_conf.hash_func =
12446 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12447 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12448 info.info.global_conf.hash_func =
12449 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12450 else if (!strcmp(res->hash_func, "default"))
12451 info.info.global_conf.hash_func =
12452 RTE_ETH_HASH_FUNCTION_DEFAULT;
12454 ftype = str2flowtype(res->flow_type);
12455 idx = ftype / UINT64_BIT;
12456 offset = ftype % UINT64_BIT;
12457 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12458 if (!strcmp(res->enable, "enable"))
12459 info.info.global_conf.sym_hash_enable_mask[idx] |=
12461 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12462 RTE_ETH_FILTER_SET, &info);
12464 printf("Cannot set global hash configurations by port %d\n",
12467 printf("Global hash configurations have been set "
12468 "successfully by port %d\n", res->port_id);
12471 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12472 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12473 set_hash_global_config, "set_hash_global_config");
12474 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12475 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12477 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12478 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12479 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12480 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12481 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12483 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12484 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12485 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12486 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12487 enable, "enable#disable");
12489 cmdline_parse_inst_t cmd_set_hash_global_config = {
12490 .f = cmd_set_hash_global_config_parsed,
12492 .help_str = "set_hash_global_config <port_id> "
12493 "toeplitz|simple_xor|symmetric_toeplitz|default "
12494 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12495 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12496 "l2_payload enable|disable",
12498 (void *)&cmd_set_hash_global_config_all,
12499 (void *)&cmd_set_hash_global_config_port_id,
12500 (void *)&cmd_set_hash_global_config_hash_func,
12501 (void *)&cmd_set_hash_global_config_flow_type,
12502 (void *)&cmd_set_hash_global_config_enable,
12507 /* Set hash input set */
12508 struct cmd_set_hash_input_set_result {
12509 cmdline_fixed_string_t set_hash_input_set;
12511 cmdline_fixed_string_t flow_type;
12512 cmdline_fixed_string_t inset_field;
12513 cmdline_fixed_string_t select;
12516 static enum rte_eth_input_set_field
12517 str2inset(char *string)
12521 static const struct {
12523 enum rte_eth_input_set_field inset;
12524 } inset_table[] = {
12525 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12526 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12527 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12528 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12529 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12530 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12531 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12532 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12533 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12534 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12535 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12536 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12537 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12538 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12539 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12540 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12541 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12542 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12543 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12544 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12545 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12546 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12547 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12548 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12549 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12550 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12551 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12552 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12553 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12554 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12555 {"none", RTE_ETH_INPUT_SET_NONE},
12558 for (i = 0; i < RTE_DIM(inset_table); i++) {
12559 if (!strcmp(string, inset_table[i].str))
12560 return inset_table[i].inset;
12563 return RTE_ETH_INPUT_SET_UNKNOWN;
12567 cmd_set_hash_input_set_parsed(void *parsed_result,
12568 __rte_unused struct cmdline *cl,
12569 __rte_unused void *data)
12571 struct cmd_set_hash_input_set_result *res = parsed_result;
12572 struct rte_eth_hash_filter_info info;
12574 memset(&info, 0, sizeof(info));
12575 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12576 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12577 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12578 info.info.input_set_conf.inset_size = 1;
12579 if (!strcmp(res->select, "select"))
12580 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12581 else if (!strcmp(res->select, "add"))
12582 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12583 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12584 RTE_ETH_FILTER_SET, &info);
12587 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12588 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12589 set_hash_input_set, "set_hash_input_set");
12590 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12591 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12593 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12594 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12596 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12597 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12599 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12600 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12601 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12602 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12603 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12605 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12606 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12607 select, "select#add");
12609 cmdline_parse_inst_t cmd_set_hash_input_set = {
12610 .f = cmd_set_hash_input_set_parsed,
12612 .help_str = "set_hash_input_set <port_id> "
12613 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12614 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12615 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12616 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12617 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12618 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12619 "fld-7th|fld-8th|none select|add",
12621 (void *)&cmd_set_hash_input_set_cmd,
12622 (void *)&cmd_set_hash_input_set_port_id,
12623 (void *)&cmd_set_hash_input_set_flow_type,
12624 (void *)&cmd_set_hash_input_set_field,
12625 (void *)&cmd_set_hash_input_set_select,
12630 /* Set flow director input set */
12631 struct cmd_set_fdir_input_set_result {
12632 cmdline_fixed_string_t set_fdir_input_set;
12634 cmdline_fixed_string_t flow_type;
12635 cmdline_fixed_string_t inset_field;
12636 cmdline_fixed_string_t select;
12640 cmd_set_fdir_input_set_parsed(void *parsed_result,
12641 __rte_unused struct cmdline *cl,
12642 __rte_unused void *data)
12644 struct cmd_set_fdir_input_set_result *res = parsed_result;
12645 struct rte_eth_fdir_filter_info info;
12647 memset(&info, 0, sizeof(info));
12648 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12649 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12650 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12651 info.info.input_set_conf.inset_size = 1;
12652 if (!strcmp(res->select, "select"))
12653 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12654 else if (!strcmp(res->select, "add"))
12655 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12656 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12657 RTE_ETH_FILTER_SET, &info);
12660 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12661 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12662 set_fdir_input_set, "set_fdir_input_set");
12663 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12664 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12666 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12667 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12669 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12670 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12671 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12672 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12674 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12675 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12676 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12677 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12678 "sctp-veri-tag#none");
12679 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12680 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12681 select, "select#add");
12683 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12684 .f = cmd_set_fdir_input_set_parsed,
12686 .help_str = "set_fdir_input_set <port_id> "
12687 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12688 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12689 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12690 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12691 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12692 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12693 "sctp-veri-tag|none select|add",
12695 (void *)&cmd_set_fdir_input_set_cmd,
12696 (void *)&cmd_set_fdir_input_set_port_id,
12697 (void *)&cmd_set_fdir_input_set_flow_type,
12698 (void *)&cmd_set_fdir_input_set_field,
12699 (void *)&cmd_set_fdir_input_set_select,
12704 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12705 struct cmd_mcast_addr_result {
12706 cmdline_fixed_string_t mcast_addr_cmd;
12707 cmdline_fixed_string_t what;
12709 struct rte_ether_addr mc_addr;
12712 static void cmd_mcast_addr_parsed(void *parsed_result,
12713 __rte_unused struct cmdline *cl,
12714 __rte_unused void *data)
12716 struct cmd_mcast_addr_result *res = parsed_result;
12718 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12719 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12720 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12721 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12722 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12725 if (strcmp(res->what, "add") == 0)
12726 mcast_addr_add(res->port_num, &res->mc_addr);
12728 mcast_addr_remove(res->port_num, &res->mc_addr);
12731 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12732 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12733 mcast_addr_cmd, "mcast_addr");
12734 cmdline_parse_token_string_t cmd_mcast_addr_what =
12735 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12737 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12738 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12739 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12740 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12742 cmdline_parse_inst_t cmd_mcast_addr = {
12743 .f = cmd_mcast_addr_parsed,
12745 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12746 "Add/Remove multicast MAC address on port_id",
12748 (void *)&cmd_mcast_addr_cmd,
12749 (void *)&cmd_mcast_addr_what,
12750 (void *)&cmd_mcast_addr_portnum,
12751 (void *)&cmd_mcast_addr_addr,
12756 /* l2 tunnel config
12757 * only support E-tag now.
12760 /* Ether type config */
12761 struct cmd_config_l2_tunnel_eth_type_result {
12762 cmdline_fixed_string_t port;
12763 cmdline_fixed_string_t config;
12764 cmdline_fixed_string_t all;
12766 cmdline_fixed_string_t l2_tunnel;
12767 cmdline_fixed_string_t l2_tunnel_type;
12768 cmdline_fixed_string_t eth_type;
12769 uint16_t eth_type_val;
12772 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12773 TOKEN_STRING_INITIALIZER
12774 (struct cmd_config_l2_tunnel_eth_type_result,
12776 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12777 TOKEN_STRING_INITIALIZER
12778 (struct cmd_config_l2_tunnel_eth_type_result,
12780 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12781 TOKEN_STRING_INITIALIZER
12782 (struct cmd_config_l2_tunnel_eth_type_result,
12784 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12785 TOKEN_NUM_INITIALIZER
12786 (struct cmd_config_l2_tunnel_eth_type_result,
12788 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12789 TOKEN_STRING_INITIALIZER
12790 (struct cmd_config_l2_tunnel_eth_type_result,
12791 l2_tunnel, "l2-tunnel");
12792 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12793 TOKEN_STRING_INITIALIZER
12794 (struct cmd_config_l2_tunnel_eth_type_result,
12795 l2_tunnel_type, "E-tag");
12796 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12797 TOKEN_STRING_INITIALIZER
12798 (struct cmd_config_l2_tunnel_eth_type_result,
12799 eth_type, "ether-type");
12800 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12801 TOKEN_NUM_INITIALIZER
12802 (struct cmd_config_l2_tunnel_eth_type_result,
12803 eth_type_val, UINT16);
12805 static enum rte_eth_tunnel_type
12806 str2fdir_l2_tunnel_type(char *string)
12810 static const struct {
12812 enum rte_eth_tunnel_type type;
12813 } l2_tunnel_type_str[] = {
12814 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12817 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12818 if (!strcmp(l2_tunnel_type_str[i].str, string))
12819 return l2_tunnel_type_str[i].type;
12821 return RTE_TUNNEL_TYPE_NONE;
12824 /* ether type config for all ports */
12826 cmd_config_l2_tunnel_eth_type_all_parsed
12827 (void *parsed_result,
12828 __rte_unused struct cmdline *cl,
12829 __rte_unused void *data)
12831 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12832 struct rte_eth_l2_tunnel_conf entry;
12835 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12836 entry.ether_type = res->eth_type_val;
12838 RTE_ETH_FOREACH_DEV(pid) {
12839 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12843 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12844 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12846 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12848 (void *)&cmd_config_l2_tunnel_eth_type_port,
12849 (void *)&cmd_config_l2_tunnel_eth_type_config,
12850 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12851 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12852 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12853 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12854 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12859 /* ether type config for a specific port */
12861 cmd_config_l2_tunnel_eth_type_specific_parsed(
12862 void *parsed_result,
12863 __rte_unused struct cmdline *cl,
12864 __rte_unused void *data)
12866 struct cmd_config_l2_tunnel_eth_type_result *res =
12868 struct rte_eth_l2_tunnel_conf entry;
12870 if (port_id_is_invalid(res->id, ENABLED_WARN))
12873 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12874 entry.ether_type = res->eth_type_val;
12876 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12879 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12880 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12882 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12884 (void *)&cmd_config_l2_tunnel_eth_type_port,
12885 (void *)&cmd_config_l2_tunnel_eth_type_config,
12886 (void *)&cmd_config_l2_tunnel_eth_type_id,
12887 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12888 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12889 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12890 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12895 /* Enable/disable l2 tunnel */
12896 struct cmd_config_l2_tunnel_en_dis_result {
12897 cmdline_fixed_string_t port;
12898 cmdline_fixed_string_t config;
12899 cmdline_fixed_string_t all;
12901 cmdline_fixed_string_t l2_tunnel;
12902 cmdline_fixed_string_t l2_tunnel_type;
12903 cmdline_fixed_string_t en_dis;
12906 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12907 TOKEN_STRING_INITIALIZER
12908 (struct cmd_config_l2_tunnel_en_dis_result,
12910 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12911 TOKEN_STRING_INITIALIZER
12912 (struct cmd_config_l2_tunnel_en_dis_result,
12914 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12915 TOKEN_STRING_INITIALIZER
12916 (struct cmd_config_l2_tunnel_en_dis_result,
12918 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12919 TOKEN_NUM_INITIALIZER
12920 (struct cmd_config_l2_tunnel_en_dis_result,
12922 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12923 TOKEN_STRING_INITIALIZER
12924 (struct cmd_config_l2_tunnel_en_dis_result,
12925 l2_tunnel, "l2-tunnel");
12926 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12927 TOKEN_STRING_INITIALIZER
12928 (struct cmd_config_l2_tunnel_en_dis_result,
12929 l2_tunnel_type, "E-tag");
12930 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12931 TOKEN_STRING_INITIALIZER
12932 (struct cmd_config_l2_tunnel_en_dis_result,
12933 en_dis, "enable#disable");
12935 /* enable/disable l2 tunnel for all ports */
12937 cmd_config_l2_tunnel_en_dis_all_parsed(
12938 void *parsed_result,
12939 __rte_unused struct cmdline *cl,
12940 __rte_unused void *data)
12942 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12943 struct rte_eth_l2_tunnel_conf entry;
12947 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12949 if (!strcmp("enable", res->en_dis))
12954 RTE_ETH_FOREACH_DEV(pid) {
12955 rte_eth_dev_l2_tunnel_offload_set(pid,
12957 ETH_L2_TUNNEL_ENABLE_MASK,
12962 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12963 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12965 .help_str = "port config all l2-tunnel E-tag enable|disable",
12967 (void *)&cmd_config_l2_tunnel_en_dis_port,
12968 (void *)&cmd_config_l2_tunnel_en_dis_config,
12969 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12970 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12971 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12972 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12977 /* enable/disable l2 tunnel for a port */
12979 cmd_config_l2_tunnel_en_dis_specific_parsed(
12980 void *parsed_result,
12981 __rte_unused struct cmdline *cl,
12982 __rte_unused void *data)
12984 struct cmd_config_l2_tunnel_en_dis_result *res =
12986 struct rte_eth_l2_tunnel_conf entry;
12988 if (port_id_is_invalid(res->id, ENABLED_WARN))
12991 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12993 if (!strcmp("enable", res->en_dis))
12994 rte_eth_dev_l2_tunnel_offload_set(res->id,
12996 ETH_L2_TUNNEL_ENABLE_MASK,
12999 rte_eth_dev_l2_tunnel_offload_set(res->id,
13001 ETH_L2_TUNNEL_ENABLE_MASK,
13005 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13006 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13008 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13010 (void *)&cmd_config_l2_tunnel_en_dis_port,
13011 (void *)&cmd_config_l2_tunnel_en_dis_config,
13012 (void *)&cmd_config_l2_tunnel_en_dis_id,
13013 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13014 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13015 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13020 /* E-tag configuration */
13022 /* Common result structure for all E-tag configuration */
13023 struct cmd_config_e_tag_result {
13024 cmdline_fixed_string_t e_tag;
13025 cmdline_fixed_string_t set;
13026 cmdline_fixed_string_t insertion;
13027 cmdline_fixed_string_t stripping;
13028 cmdline_fixed_string_t forwarding;
13029 cmdline_fixed_string_t filter;
13030 cmdline_fixed_string_t add;
13031 cmdline_fixed_string_t del;
13032 cmdline_fixed_string_t on;
13033 cmdline_fixed_string_t off;
13034 cmdline_fixed_string_t on_off;
13035 cmdline_fixed_string_t port_tag_id;
13036 uint32_t port_tag_id_val;
13037 cmdline_fixed_string_t e_tag_id;
13038 uint16_t e_tag_id_val;
13039 cmdline_fixed_string_t dst_pool;
13040 uint8_t dst_pool_val;
13041 cmdline_fixed_string_t port;
13043 cmdline_fixed_string_t vf;
13047 /* Common CLI fields for all E-tag configuration */
13048 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13049 TOKEN_STRING_INITIALIZER
13050 (struct cmd_config_e_tag_result,
13052 cmdline_parse_token_string_t cmd_config_e_tag_set =
13053 TOKEN_STRING_INITIALIZER
13054 (struct cmd_config_e_tag_result,
13056 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13057 TOKEN_STRING_INITIALIZER
13058 (struct cmd_config_e_tag_result,
13059 insertion, "insertion");
13060 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13061 TOKEN_STRING_INITIALIZER
13062 (struct cmd_config_e_tag_result,
13063 stripping, "stripping");
13064 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13065 TOKEN_STRING_INITIALIZER
13066 (struct cmd_config_e_tag_result,
13067 forwarding, "forwarding");
13068 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13069 TOKEN_STRING_INITIALIZER
13070 (struct cmd_config_e_tag_result,
13072 cmdline_parse_token_string_t cmd_config_e_tag_add =
13073 TOKEN_STRING_INITIALIZER
13074 (struct cmd_config_e_tag_result,
13076 cmdline_parse_token_string_t cmd_config_e_tag_del =
13077 TOKEN_STRING_INITIALIZER
13078 (struct cmd_config_e_tag_result,
13080 cmdline_parse_token_string_t cmd_config_e_tag_on =
13081 TOKEN_STRING_INITIALIZER
13082 (struct cmd_config_e_tag_result,
13084 cmdline_parse_token_string_t cmd_config_e_tag_off =
13085 TOKEN_STRING_INITIALIZER
13086 (struct cmd_config_e_tag_result,
13088 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13089 TOKEN_STRING_INITIALIZER
13090 (struct cmd_config_e_tag_result,
13092 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13093 TOKEN_STRING_INITIALIZER
13094 (struct cmd_config_e_tag_result,
13095 port_tag_id, "port-tag-id");
13096 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13097 TOKEN_NUM_INITIALIZER
13098 (struct cmd_config_e_tag_result,
13099 port_tag_id_val, UINT32);
13100 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13101 TOKEN_STRING_INITIALIZER
13102 (struct cmd_config_e_tag_result,
13103 e_tag_id, "e-tag-id");
13104 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13105 TOKEN_NUM_INITIALIZER
13106 (struct cmd_config_e_tag_result,
13107 e_tag_id_val, UINT16);
13108 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13109 TOKEN_STRING_INITIALIZER
13110 (struct cmd_config_e_tag_result,
13111 dst_pool, "dst-pool");
13112 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13113 TOKEN_NUM_INITIALIZER
13114 (struct cmd_config_e_tag_result,
13115 dst_pool_val, UINT8);
13116 cmdline_parse_token_string_t cmd_config_e_tag_port =
13117 TOKEN_STRING_INITIALIZER
13118 (struct cmd_config_e_tag_result,
13120 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13121 TOKEN_NUM_INITIALIZER
13122 (struct cmd_config_e_tag_result,
13124 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13125 TOKEN_STRING_INITIALIZER
13126 (struct cmd_config_e_tag_result,
13128 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13129 TOKEN_NUM_INITIALIZER
13130 (struct cmd_config_e_tag_result,
13133 /* E-tag insertion configuration */
13135 cmd_config_e_tag_insertion_en_parsed(
13136 void *parsed_result,
13137 __rte_unused struct cmdline *cl,
13138 __rte_unused void *data)
13140 struct cmd_config_e_tag_result *res =
13142 struct rte_eth_l2_tunnel_conf entry;
13144 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13147 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13148 entry.tunnel_id = res->port_tag_id_val;
13149 entry.vf_id = res->vf_id;
13150 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13152 ETH_L2_TUNNEL_INSERTION_MASK,
13157 cmd_config_e_tag_insertion_dis_parsed(
13158 void *parsed_result,
13159 __rte_unused struct cmdline *cl,
13160 __rte_unused void *data)
13162 struct cmd_config_e_tag_result *res =
13164 struct rte_eth_l2_tunnel_conf entry;
13166 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13169 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13170 entry.vf_id = res->vf_id;
13172 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13174 ETH_L2_TUNNEL_INSERTION_MASK,
13178 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13179 .f = cmd_config_e_tag_insertion_en_parsed,
13181 .help_str = "E-tag ... : E-tag insertion enable",
13183 (void *)&cmd_config_e_tag_e_tag,
13184 (void *)&cmd_config_e_tag_set,
13185 (void *)&cmd_config_e_tag_insertion,
13186 (void *)&cmd_config_e_tag_on,
13187 (void *)&cmd_config_e_tag_port_tag_id,
13188 (void *)&cmd_config_e_tag_port_tag_id_val,
13189 (void *)&cmd_config_e_tag_port,
13190 (void *)&cmd_config_e_tag_port_id,
13191 (void *)&cmd_config_e_tag_vf,
13192 (void *)&cmd_config_e_tag_vf_id,
13197 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13198 .f = cmd_config_e_tag_insertion_dis_parsed,
13200 .help_str = "E-tag ... : E-tag insertion disable",
13202 (void *)&cmd_config_e_tag_e_tag,
13203 (void *)&cmd_config_e_tag_set,
13204 (void *)&cmd_config_e_tag_insertion,
13205 (void *)&cmd_config_e_tag_off,
13206 (void *)&cmd_config_e_tag_port,
13207 (void *)&cmd_config_e_tag_port_id,
13208 (void *)&cmd_config_e_tag_vf,
13209 (void *)&cmd_config_e_tag_vf_id,
13214 /* E-tag stripping configuration */
13216 cmd_config_e_tag_stripping_parsed(
13217 void *parsed_result,
13218 __rte_unused struct cmdline *cl,
13219 __rte_unused void *data)
13221 struct cmd_config_e_tag_result *res =
13223 struct rte_eth_l2_tunnel_conf entry;
13225 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13228 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13230 if (!strcmp(res->on_off, "on"))
13231 rte_eth_dev_l2_tunnel_offload_set
13234 ETH_L2_TUNNEL_STRIPPING_MASK,
13237 rte_eth_dev_l2_tunnel_offload_set
13240 ETH_L2_TUNNEL_STRIPPING_MASK,
13244 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13245 .f = cmd_config_e_tag_stripping_parsed,
13247 .help_str = "E-tag ... : E-tag stripping enable/disable",
13249 (void *)&cmd_config_e_tag_e_tag,
13250 (void *)&cmd_config_e_tag_set,
13251 (void *)&cmd_config_e_tag_stripping,
13252 (void *)&cmd_config_e_tag_on_off,
13253 (void *)&cmd_config_e_tag_port,
13254 (void *)&cmd_config_e_tag_port_id,
13259 /* E-tag forwarding configuration */
13261 cmd_config_e_tag_forwarding_parsed(
13262 void *parsed_result,
13263 __rte_unused struct cmdline *cl,
13264 __rte_unused void *data)
13266 struct cmd_config_e_tag_result *res = parsed_result;
13267 struct rte_eth_l2_tunnel_conf entry;
13269 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13272 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13274 if (!strcmp(res->on_off, "on"))
13275 rte_eth_dev_l2_tunnel_offload_set
13278 ETH_L2_TUNNEL_FORWARDING_MASK,
13281 rte_eth_dev_l2_tunnel_offload_set
13284 ETH_L2_TUNNEL_FORWARDING_MASK,
13288 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13289 .f = cmd_config_e_tag_forwarding_parsed,
13291 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13293 (void *)&cmd_config_e_tag_e_tag,
13294 (void *)&cmd_config_e_tag_set,
13295 (void *)&cmd_config_e_tag_forwarding,
13296 (void *)&cmd_config_e_tag_on_off,
13297 (void *)&cmd_config_e_tag_port,
13298 (void *)&cmd_config_e_tag_port_id,
13303 /* E-tag filter configuration */
13305 cmd_config_e_tag_filter_add_parsed(
13306 void *parsed_result,
13307 __rte_unused struct cmdline *cl,
13308 __rte_unused void *data)
13310 struct cmd_config_e_tag_result *res = parsed_result;
13311 struct rte_eth_l2_tunnel_conf entry;
13314 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13317 if (res->e_tag_id_val > 0x3fff) {
13318 printf("e-tag-id must be equal or less than 0x3fff.\n");
13322 ret = rte_eth_dev_filter_supported(res->port_id,
13323 RTE_ETH_FILTER_L2_TUNNEL);
13325 printf("E-tag filter is not supported on port %u.\n",
13330 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13331 entry.tunnel_id = res->e_tag_id_val;
13332 entry.pool = res->dst_pool_val;
13334 ret = rte_eth_dev_filter_ctrl(res->port_id,
13335 RTE_ETH_FILTER_L2_TUNNEL,
13336 RTE_ETH_FILTER_ADD,
13339 printf("E-tag filter programming error: (%s)\n",
13343 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13344 .f = cmd_config_e_tag_filter_add_parsed,
13346 .help_str = "E-tag ... : E-tag filter add",
13348 (void *)&cmd_config_e_tag_e_tag,
13349 (void *)&cmd_config_e_tag_set,
13350 (void *)&cmd_config_e_tag_filter,
13351 (void *)&cmd_config_e_tag_add,
13352 (void *)&cmd_config_e_tag_e_tag_id,
13353 (void *)&cmd_config_e_tag_e_tag_id_val,
13354 (void *)&cmd_config_e_tag_dst_pool,
13355 (void *)&cmd_config_e_tag_dst_pool_val,
13356 (void *)&cmd_config_e_tag_port,
13357 (void *)&cmd_config_e_tag_port_id,
13363 cmd_config_e_tag_filter_del_parsed(
13364 void *parsed_result,
13365 __rte_unused struct cmdline *cl,
13366 __rte_unused void *data)
13368 struct cmd_config_e_tag_result *res = parsed_result;
13369 struct rte_eth_l2_tunnel_conf entry;
13372 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13375 if (res->e_tag_id_val > 0x3fff) {
13376 printf("e-tag-id must be less than 0x3fff.\n");
13380 ret = rte_eth_dev_filter_supported(res->port_id,
13381 RTE_ETH_FILTER_L2_TUNNEL);
13383 printf("E-tag filter is not supported on port %u.\n",
13388 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13389 entry.tunnel_id = res->e_tag_id_val;
13391 ret = rte_eth_dev_filter_ctrl(res->port_id,
13392 RTE_ETH_FILTER_L2_TUNNEL,
13393 RTE_ETH_FILTER_DELETE,
13396 printf("E-tag filter programming error: (%s)\n",
13400 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13401 .f = cmd_config_e_tag_filter_del_parsed,
13403 .help_str = "E-tag ... : E-tag filter delete",
13405 (void *)&cmd_config_e_tag_e_tag,
13406 (void *)&cmd_config_e_tag_set,
13407 (void *)&cmd_config_e_tag_filter,
13408 (void *)&cmd_config_e_tag_del,
13409 (void *)&cmd_config_e_tag_e_tag_id,
13410 (void *)&cmd_config_e_tag_e_tag_id_val,
13411 (void *)&cmd_config_e_tag_port,
13412 (void *)&cmd_config_e_tag_port_id,
13417 /* vf vlan anti spoof configuration */
13419 /* Common result structure for vf vlan anti spoof */
13420 struct cmd_vf_vlan_anti_spoof_result {
13421 cmdline_fixed_string_t set;
13422 cmdline_fixed_string_t vf;
13423 cmdline_fixed_string_t vlan;
13424 cmdline_fixed_string_t antispoof;
13427 cmdline_fixed_string_t on_off;
13430 /* Common CLI fields for vf vlan anti spoof enable disable */
13431 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13432 TOKEN_STRING_INITIALIZER
13433 (struct cmd_vf_vlan_anti_spoof_result,
13435 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13436 TOKEN_STRING_INITIALIZER
13437 (struct cmd_vf_vlan_anti_spoof_result,
13439 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13440 TOKEN_STRING_INITIALIZER
13441 (struct cmd_vf_vlan_anti_spoof_result,
13443 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13444 TOKEN_STRING_INITIALIZER
13445 (struct cmd_vf_vlan_anti_spoof_result,
13446 antispoof, "antispoof");
13447 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13448 TOKEN_NUM_INITIALIZER
13449 (struct cmd_vf_vlan_anti_spoof_result,
13451 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13452 TOKEN_NUM_INITIALIZER
13453 (struct cmd_vf_vlan_anti_spoof_result,
13455 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13456 TOKEN_STRING_INITIALIZER
13457 (struct cmd_vf_vlan_anti_spoof_result,
13461 cmd_set_vf_vlan_anti_spoof_parsed(
13462 void *parsed_result,
13463 __rte_unused struct cmdline *cl,
13464 __rte_unused void *data)
13466 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13467 int ret = -ENOTSUP;
13469 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13471 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13474 #ifdef RTE_LIBRTE_IXGBE_PMD
13475 if (ret == -ENOTSUP)
13476 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13477 res->vf_id, is_on);
13479 #ifdef RTE_LIBRTE_I40E_PMD
13480 if (ret == -ENOTSUP)
13481 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13482 res->vf_id, is_on);
13484 #ifdef RTE_LIBRTE_BNXT_PMD
13485 if (ret == -ENOTSUP)
13486 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13487 res->vf_id, is_on);
13494 printf("invalid vf_id %d\n", res->vf_id);
13497 printf("invalid port_id %d\n", res->port_id);
13500 printf("function not implemented\n");
13503 printf("programming error: (%s)\n", strerror(-ret));
13507 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13508 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13510 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13512 (void *)&cmd_vf_vlan_anti_spoof_set,
13513 (void *)&cmd_vf_vlan_anti_spoof_vf,
13514 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13515 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13516 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13517 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13518 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13523 /* vf mac anti spoof configuration */
13525 /* Common result structure for vf mac anti spoof */
13526 struct cmd_vf_mac_anti_spoof_result {
13527 cmdline_fixed_string_t set;
13528 cmdline_fixed_string_t vf;
13529 cmdline_fixed_string_t mac;
13530 cmdline_fixed_string_t antispoof;
13533 cmdline_fixed_string_t on_off;
13536 /* Common CLI fields for vf mac anti spoof enable disable */
13537 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13538 TOKEN_STRING_INITIALIZER
13539 (struct cmd_vf_mac_anti_spoof_result,
13541 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13542 TOKEN_STRING_INITIALIZER
13543 (struct cmd_vf_mac_anti_spoof_result,
13545 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13546 TOKEN_STRING_INITIALIZER
13547 (struct cmd_vf_mac_anti_spoof_result,
13549 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13550 TOKEN_STRING_INITIALIZER
13551 (struct cmd_vf_mac_anti_spoof_result,
13552 antispoof, "antispoof");
13553 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13554 TOKEN_NUM_INITIALIZER
13555 (struct cmd_vf_mac_anti_spoof_result,
13557 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13558 TOKEN_NUM_INITIALIZER
13559 (struct cmd_vf_mac_anti_spoof_result,
13561 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13562 TOKEN_STRING_INITIALIZER
13563 (struct cmd_vf_mac_anti_spoof_result,
13567 cmd_set_vf_mac_anti_spoof_parsed(
13568 void *parsed_result,
13569 __rte_unused struct cmdline *cl,
13570 __rte_unused void *data)
13572 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13573 int ret = -ENOTSUP;
13575 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13577 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13580 #ifdef RTE_LIBRTE_IXGBE_PMD
13581 if (ret == -ENOTSUP)
13582 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13583 res->vf_id, is_on);
13585 #ifdef RTE_LIBRTE_I40E_PMD
13586 if (ret == -ENOTSUP)
13587 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13588 res->vf_id, is_on);
13590 #ifdef RTE_LIBRTE_BNXT_PMD
13591 if (ret == -ENOTSUP)
13592 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13593 res->vf_id, is_on);
13600 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13603 printf("invalid port_id %d\n", res->port_id);
13606 printf("function not implemented\n");
13609 printf("programming error: (%s)\n", strerror(-ret));
13613 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13614 .f = cmd_set_vf_mac_anti_spoof_parsed,
13616 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13618 (void *)&cmd_vf_mac_anti_spoof_set,
13619 (void *)&cmd_vf_mac_anti_spoof_vf,
13620 (void *)&cmd_vf_mac_anti_spoof_mac,
13621 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13622 (void *)&cmd_vf_mac_anti_spoof_port_id,
13623 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13624 (void *)&cmd_vf_mac_anti_spoof_on_off,
13629 /* vf vlan strip queue configuration */
13631 /* Common result structure for vf mac anti spoof */
13632 struct cmd_vf_vlan_stripq_result {
13633 cmdline_fixed_string_t set;
13634 cmdline_fixed_string_t vf;
13635 cmdline_fixed_string_t vlan;
13636 cmdline_fixed_string_t stripq;
13639 cmdline_fixed_string_t on_off;
13642 /* Common CLI fields for vf vlan strip enable disable */
13643 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13644 TOKEN_STRING_INITIALIZER
13645 (struct cmd_vf_vlan_stripq_result,
13647 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13648 TOKEN_STRING_INITIALIZER
13649 (struct cmd_vf_vlan_stripq_result,
13651 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13652 TOKEN_STRING_INITIALIZER
13653 (struct cmd_vf_vlan_stripq_result,
13655 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13656 TOKEN_STRING_INITIALIZER
13657 (struct cmd_vf_vlan_stripq_result,
13659 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13660 TOKEN_NUM_INITIALIZER
13661 (struct cmd_vf_vlan_stripq_result,
13663 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13664 TOKEN_NUM_INITIALIZER
13665 (struct cmd_vf_vlan_stripq_result,
13667 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13668 TOKEN_STRING_INITIALIZER
13669 (struct cmd_vf_vlan_stripq_result,
13673 cmd_set_vf_vlan_stripq_parsed(
13674 void *parsed_result,
13675 __rte_unused struct cmdline *cl,
13676 __rte_unused void *data)
13678 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13679 int ret = -ENOTSUP;
13681 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13683 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13686 #ifdef RTE_LIBRTE_IXGBE_PMD
13687 if (ret == -ENOTSUP)
13688 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13689 res->vf_id, is_on);
13691 #ifdef RTE_LIBRTE_I40E_PMD
13692 if (ret == -ENOTSUP)
13693 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13694 res->vf_id, is_on);
13696 #ifdef RTE_LIBRTE_BNXT_PMD
13697 if (ret == -ENOTSUP)
13698 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13699 res->vf_id, is_on);
13706 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13709 printf("invalid port_id %d\n", res->port_id);
13712 printf("function not implemented\n");
13715 printf("programming error: (%s)\n", strerror(-ret));
13719 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13720 .f = cmd_set_vf_vlan_stripq_parsed,
13722 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13724 (void *)&cmd_vf_vlan_stripq_set,
13725 (void *)&cmd_vf_vlan_stripq_vf,
13726 (void *)&cmd_vf_vlan_stripq_vlan,
13727 (void *)&cmd_vf_vlan_stripq_stripq,
13728 (void *)&cmd_vf_vlan_stripq_port_id,
13729 (void *)&cmd_vf_vlan_stripq_vf_id,
13730 (void *)&cmd_vf_vlan_stripq_on_off,
13735 /* vf vlan insert configuration */
13737 /* Common result structure for vf vlan insert */
13738 struct cmd_vf_vlan_insert_result {
13739 cmdline_fixed_string_t set;
13740 cmdline_fixed_string_t vf;
13741 cmdline_fixed_string_t vlan;
13742 cmdline_fixed_string_t insert;
13748 /* Common CLI fields for vf vlan insert enable disable */
13749 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13750 TOKEN_STRING_INITIALIZER
13751 (struct cmd_vf_vlan_insert_result,
13753 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13754 TOKEN_STRING_INITIALIZER
13755 (struct cmd_vf_vlan_insert_result,
13757 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13758 TOKEN_STRING_INITIALIZER
13759 (struct cmd_vf_vlan_insert_result,
13761 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13762 TOKEN_STRING_INITIALIZER
13763 (struct cmd_vf_vlan_insert_result,
13765 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13766 TOKEN_NUM_INITIALIZER
13767 (struct cmd_vf_vlan_insert_result,
13769 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13770 TOKEN_NUM_INITIALIZER
13771 (struct cmd_vf_vlan_insert_result,
13773 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13774 TOKEN_NUM_INITIALIZER
13775 (struct cmd_vf_vlan_insert_result,
13779 cmd_set_vf_vlan_insert_parsed(
13780 void *parsed_result,
13781 __rte_unused struct cmdline *cl,
13782 __rte_unused void *data)
13784 struct cmd_vf_vlan_insert_result *res = parsed_result;
13785 int ret = -ENOTSUP;
13787 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13790 #ifdef RTE_LIBRTE_IXGBE_PMD
13791 if (ret == -ENOTSUP)
13792 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13795 #ifdef RTE_LIBRTE_I40E_PMD
13796 if (ret == -ENOTSUP)
13797 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13800 #ifdef RTE_LIBRTE_BNXT_PMD
13801 if (ret == -ENOTSUP)
13802 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13810 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13813 printf("invalid port_id %d\n", res->port_id);
13816 printf("function not implemented\n");
13819 printf("programming error: (%s)\n", strerror(-ret));
13823 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13824 .f = cmd_set_vf_vlan_insert_parsed,
13826 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13828 (void *)&cmd_vf_vlan_insert_set,
13829 (void *)&cmd_vf_vlan_insert_vf,
13830 (void *)&cmd_vf_vlan_insert_vlan,
13831 (void *)&cmd_vf_vlan_insert_insert,
13832 (void *)&cmd_vf_vlan_insert_port_id,
13833 (void *)&cmd_vf_vlan_insert_vf_id,
13834 (void *)&cmd_vf_vlan_insert_vlan_id,
13839 /* tx loopback configuration */
13841 /* Common result structure for tx loopback */
13842 struct cmd_tx_loopback_result {
13843 cmdline_fixed_string_t set;
13844 cmdline_fixed_string_t tx;
13845 cmdline_fixed_string_t loopback;
13847 cmdline_fixed_string_t on_off;
13850 /* Common CLI fields for tx loopback enable disable */
13851 cmdline_parse_token_string_t cmd_tx_loopback_set =
13852 TOKEN_STRING_INITIALIZER
13853 (struct cmd_tx_loopback_result,
13855 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13856 TOKEN_STRING_INITIALIZER
13857 (struct cmd_tx_loopback_result,
13859 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13860 TOKEN_STRING_INITIALIZER
13861 (struct cmd_tx_loopback_result,
13862 loopback, "loopback");
13863 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13864 TOKEN_NUM_INITIALIZER
13865 (struct cmd_tx_loopback_result,
13867 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13868 TOKEN_STRING_INITIALIZER
13869 (struct cmd_tx_loopback_result,
13873 cmd_set_tx_loopback_parsed(
13874 void *parsed_result,
13875 __rte_unused struct cmdline *cl,
13876 __rte_unused void *data)
13878 struct cmd_tx_loopback_result *res = parsed_result;
13879 int ret = -ENOTSUP;
13881 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13883 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13886 #ifdef RTE_LIBRTE_IXGBE_PMD
13887 if (ret == -ENOTSUP)
13888 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13890 #ifdef RTE_LIBRTE_I40E_PMD
13891 if (ret == -ENOTSUP)
13892 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13894 #ifdef RTE_LIBRTE_BNXT_PMD
13895 if (ret == -ENOTSUP)
13896 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13898 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13899 if (ret == -ENOTSUP)
13900 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13907 printf("invalid is_on %d\n", is_on);
13910 printf("invalid port_id %d\n", res->port_id);
13913 printf("function not implemented\n");
13916 printf("programming error: (%s)\n", strerror(-ret));
13920 cmdline_parse_inst_t cmd_set_tx_loopback = {
13921 .f = cmd_set_tx_loopback_parsed,
13923 .help_str = "set tx loopback <port_id> on|off",
13925 (void *)&cmd_tx_loopback_set,
13926 (void *)&cmd_tx_loopback_tx,
13927 (void *)&cmd_tx_loopback_loopback,
13928 (void *)&cmd_tx_loopback_port_id,
13929 (void *)&cmd_tx_loopback_on_off,
13934 /* all queues drop enable configuration */
13936 /* Common result structure for all queues drop enable */
13937 struct cmd_all_queues_drop_en_result {
13938 cmdline_fixed_string_t set;
13939 cmdline_fixed_string_t all;
13940 cmdline_fixed_string_t queues;
13941 cmdline_fixed_string_t drop;
13943 cmdline_fixed_string_t on_off;
13946 /* Common CLI fields for tx loopback enable disable */
13947 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13948 TOKEN_STRING_INITIALIZER
13949 (struct cmd_all_queues_drop_en_result,
13951 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13952 TOKEN_STRING_INITIALIZER
13953 (struct cmd_all_queues_drop_en_result,
13955 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13956 TOKEN_STRING_INITIALIZER
13957 (struct cmd_all_queues_drop_en_result,
13959 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13960 TOKEN_STRING_INITIALIZER
13961 (struct cmd_all_queues_drop_en_result,
13963 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13964 TOKEN_NUM_INITIALIZER
13965 (struct cmd_all_queues_drop_en_result,
13967 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13968 TOKEN_STRING_INITIALIZER
13969 (struct cmd_all_queues_drop_en_result,
13973 cmd_set_all_queues_drop_en_parsed(
13974 void *parsed_result,
13975 __rte_unused struct cmdline *cl,
13976 __rte_unused void *data)
13978 struct cmd_all_queues_drop_en_result *res = parsed_result;
13979 int ret = -ENOTSUP;
13980 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13982 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13985 #ifdef RTE_LIBRTE_IXGBE_PMD
13986 if (ret == -ENOTSUP)
13987 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13989 #ifdef RTE_LIBRTE_BNXT_PMD
13990 if (ret == -ENOTSUP)
13991 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13997 printf("invalid is_on %d\n", is_on);
14000 printf("invalid port_id %d\n", res->port_id);
14003 printf("function not implemented\n");
14006 printf("programming error: (%s)\n", strerror(-ret));
14010 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14011 .f = cmd_set_all_queues_drop_en_parsed,
14013 .help_str = "set all queues drop <port_id> on|off",
14015 (void *)&cmd_all_queues_drop_en_set,
14016 (void *)&cmd_all_queues_drop_en_all,
14017 (void *)&cmd_all_queues_drop_en_queues,
14018 (void *)&cmd_all_queues_drop_en_drop,
14019 (void *)&cmd_all_queues_drop_en_port_id,
14020 (void *)&cmd_all_queues_drop_en_on_off,
14025 /* vf split drop enable configuration */
14027 /* Common result structure for vf split drop enable */
14028 struct cmd_vf_split_drop_en_result {
14029 cmdline_fixed_string_t set;
14030 cmdline_fixed_string_t vf;
14031 cmdline_fixed_string_t split;
14032 cmdline_fixed_string_t drop;
14035 cmdline_fixed_string_t on_off;
14038 /* Common CLI fields for vf split drop enable disable */
14039 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14040 TOKEN_STRING_INITIALIZER
14041 (struct cmd_vf_split_drop_en_result,
14043 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14044 TOKEN_STRING_INITIALIZER
14045 (struct cmd_vf_split_drop_en_result,
14047 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14048 TOKEN_STRING_INITIALIZER
14049 (struct cmd_vf_split_drop_en_result,
14051 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14052 TOKEN_STRING_INITIALIZER
14053 (struct cmd_vf_split_drop_en_result,
14055 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14056 TOKEN_NUM_INITIALIZER
14057 (struct cmd_vf_split_drop_en_result,
14059 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14060 TOKEN_NUM_INITIALIZER
14061 (struct cmd_vf_split_drop_en_result,
14063 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14064 TOKEN_STRING_INITIALIZER
14065 (struct cmd_vf_split_drop_en_result,
14069 cmd_set_vf_split_drop_en_parsed(
14070 void *parsed_result,
14071 __rte_unused struct cmdline *cl,
14072 __rte_unused void *data)
14074 struct cmd_vf_split_drop_en_result *res = parsed_result;
14075 int ret = -ENOTSUP;
14076 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14078 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14081 #ifdef RTE_LIBRTE_IXGBE_PMD
14082 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14089 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14092 printf("invalid port_id %d\n", res->port_id);
14095 printf("not supported on port %d\n", res->port_id);
14098 printf("programming error: (%s)\n", strerror(-ret));
14102 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14103 .f = cmd_set_vf_split_drop_en_parsed,
14105 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14107 (void *)&cmd_vf_split_drop_en_set,
14108 (void *)&cmd_vf_split_drop_en_vf,
14109 (void *)&cmd_vf_split_drop_en_split,
14110 (void *)&cmd_vf_split_drop_en_drop,
14111 (void *)&cmd_vf_split_drop_en_port_id,
14112 (void *)&cmd_vf_split_drop_en_vf_id,
14113 (void *)&cmd_vf_split_drop_en_on_off,
14118 /* vf mac address configuration */
14120 /* Common result structure for vf mac address */
14121 struct cmd_set_vf_mac_addr_result {
14122 cmdline_fixed_string_t set;
14123 cmdline_fixed_string_t vf;
14124 cmdline_fixed_string_t mac;
14125 cmdline_fixed_string_t addr;
14128 struct rte_ether_addr mac_addr;
14132 /* Common CLI fields for vf split drop enable disable */
14133 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14134 TOKEN_STRING_INITIALIZER
14135 (struct cmd_set_vf_mac_addr_result,
14137 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14138 TOKEN_STRING_INITIALIZER
14139 (struct cmd_set_vf_mac_addr_result,
14141 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14142 TOKEN_STRING_INITIALIZER
14143 (struct cmd_set_vf_mac_addr_result,
14145 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14146 TOKEN_STRING_INITIALIZER
14147 (struct cmd_set_vf_mac_addr_result,
14149 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14150 TOKEN_NUM_INITIALIZER
14151 (struct cmd_set_vf_mac_addr_result,
14153 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14154 TOKEN_NUM_INITIALIZER
14155 (struct cmd_set_vf_mac_addr_result,
14157 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14158 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14162 cmd_set_vf_mac_addr_parsed(
14163 void *parsed_result,
14164 __rte_unused struct cmdline *cl,
14165 __rte_unused void *data)
14167 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14168 int ret = -ENOTSUP;
14170 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14173 #ifdef RTE_LIBRTE_IXGBE_PMD
14174 if (ret == -ENOTSUP)
14175 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14178 #ifdef RTE_LIBRTE_I40E_PMD
14179 if (ret == -ENOTSUP)
14180 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14183 #ifdef RTE_LIBRTE_BNXT_PMD
14184 if (ret == -ENOTSUP)
14185 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14193 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14196 printf("invalid port_id %d\n", res->port_id);
14199 printf("function not implemented\n");
14202 printf("programming error: (%s)\n", strerror(-ret));
14206 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14207 .f = cmd_set_vf_mac_addr_parsed,
14209 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14211 (void *)&cmd_set_vf_mac_addr_set,
14212 (void *)&cmd_set_vf_mac_addr_vf,
14213 (void *)&cmd_set_vf_mac_addr_mac,
14214 (void *)&cmd_set_vf_mac_addr_addr,
14215 (void *)&cmd_set_vf_mac_addr_port_id,
14216 (void *)&cmd_set_vf_mac_addr_vf_id,
14217 (void *)&cmd_set_vf_mac_addr_mac_addr,
14222 /* MACsec configuration */
14224 /* Common result structure for MACsec offload enable */
14225 struct cmd_macsec_offload_on_result {
14226 cmdline_fixed_string_t set;
14227 cmdline_fixed_string_t macsec;
14228 cmdline_fixed_string_t offload;
14230 cmdline_fixed_string_t on;
14231 cmdline_fixed_string_t encrypt;
14232 cmdline_fixed_string_t en_on_off;
14233 cmdline_fixed_string_t replay_protect;
14234 cmdline_fixed_string_t rp_on_off;
14237 /* Common CLI fields for MACsec offload disable */
14238 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14239 TOKEN_STRING_INITIALIZER
14240 (struct cmd_macsec_offload_on_result,
14242 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14243 TOKEN_STRING_INITIALIZER
14244 (struct cmd_macsec_offload_on_result,
14246 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14247 TOKEN_STRING_INITIALIZER
14248 (struct cmd_macsec_offload_on_result,
14249 offload, "offload");
14250 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14251 TOKEN_NUM_INITIALIZER
14252 (struct cmd_macsec_offload_on_result,
14254 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14255 TOKEN_STRING_INITIALIZER
14256 (struct cmd_macsec_offload_on_result,
14258 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14259 TOKEN_STRING_INITIALIZER
14260 (struct cmd_macsec_offload_on_result,
14261 encrypt, "encrypt");
14262 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14263 TOKEN_STRING_INITIALIZER
14264 (struct cmd_macsec_offload_on_result,
14265 en_on_off, "on#off");
14266 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14267 TOKEN_STRING_INITIALIZER
14268 (struct cmd_macsec_offload_on_result,
14269 replay_protect, "replay-protect");
14270 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14271 TOKEN_STRING_INITIALIZER
14272 (struct cmd_macsec_offload_on_result,
14273 rp_on_off, "on#off");
14276 cmd_set_macsec_offload_on_parsed(
14277 void *parsed_result,
14278 __rte_unused struct cmdline *cl,
14279 __rte_unused void *data)
14281 struct cmd_macsec_offload_on_result *res = parsed_result;
14282 int ret = -ENOTSUP;
14283 portid_t port_id = res->port_id;
14284 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14285 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14286 struct rte_eth_dev_info dev_info;
14288 if (port_id_is_invalid(port_id, ENABLED_WARN))
14290 if (!port_is_stopped(port_id)) {
14291 printf("Please stop port %d first\n", port_id);
14295 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14299 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14300 #ifdef RTE_LIBRTE_IXGBE_PMD
14301 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14309 ports[port_id].dev_conf.txmode.offloads |=
14310 DEV_TX_OFFLOAD_MACSEC_INSERT;
14311 cmd_reconfig_device_queue(port_id, 1, 1);
14314 printf("invalid port_id %d\n", port_id);
14317 printf("not supported on port %d\n", port_id);
14320 printf("programming error: (%s)\n", strerror(-ret));
14324 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14325 .f = cmd_set_macsec_offload_on_parsed,
14327 .help_str = "set macsec offload <port_id> on "
14328 "encrypt on|off replay-protect on|off",
14330 (void *)&cmd_macsec_offload_on_set,
14331 (void *)&cmd_macsec_offload_on_macsec,
14332 (void *)&cmd_macsec_offload_on_offload,
14333 (void *)&cmd_macsec_offload_on_port_id,
14334 (void *)&cmd_macsec_offload_on_on,
14335 (void *)&cmd_macsec_offload_on_encrypt,
14336 (void *)&cmd_macsec_offload_on_en_on_off,
14337 (void *)&cmd_macsec_offload_on_replay_protect,
14338 (void *)&cmd_macsec_offload_on_rp_on_off,
14343 /* Common result structure for MACsec offload disable */
14344 struct cmd_macsec_offload_off_result {
14345 cmdline_fixed_string_t set;
14346 cmdline_fixed_string_t macsec;
14347 cmdline_fixed_string_t offload;
14349 cmdline_fixed_string_t off;
14352 /* Common CLI fields for MACsec offload disable */
14353 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14354 TOKEN_STRING_INITIALIZER
14355 (struct cmd_macsec_offload_off_result,
14357 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14358 TOKEN_STRING_INITIALIZER
14359 (struct cmd_macsec_offload_off_result,
14361 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14362 TOKEN_STRING_INITIALIZER
14363 (struct cmd_macsec_offload_off_result,
14364 offload, "offload");
14365 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14366 TOKEN_NUM_INITIALIZER
14367 (struct cmd_macsec_offload_off_result,
14369 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14370 TOKEN_STRING_INITIALIZER
14371 (struct cmd_macsec_offload_off_result,
14375 cmd_set_macsec_offload_off_parsed(
14376 void *parsed_result,
14377 __rte_unused struct cmdline *cl,
14378 __rte_unused void *data)
14380 struct cmd_macsec_offload_off_result *res = parsed_result;
14381 int ret = -ENOTSUP;
14382 struct rte_eth_dev_info dev_info;
14383 portid_t port_id = res->port_id;
14385 if (port_id_is_invalid(port_id, ENABLED_WARN))
14387 if (!port_is_stopped(port_id)) {
14388 printf("Please stop port %d first\n", port_id);
14392 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14396 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14397 #ifdef RTE_LIBRTE_IXGBE_PMD
14398 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14403 ports[port_id].dev_conf.txmode.offloads &=
14404 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14405 cmd_reconfig_device_queue(port_id, 1, 1);
14408 printf("invalid port_id %d\n", port_id);
14411 printf("not supported on port %d\n", port_id);
14414 printf("programming error: (%s)\n", strerror(-ret));
14418 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14419 .f = cmd_set_macsec_offload_off_parsed,
14421 .help_str = "set macsec offload <port_id> off",
14423 (void *)&cmd_macsec_offload_off_set,
14424 (void *)&cmd_macsec_offload_off_macsec,
14425 (void *)&cmd_macsec_offload_off_offload,
14426 (void *)&cmd_macsec_offload_off_port_id,
14427 (void *)&cmd_macsec_offload_off_off,
14432 /* Common result structure for MACsec secure connection configure */
14433 struct cmd_macsec_sc_result {
14434 cmdline_fixed_string_t set;
14435 cmdline_fixed_string_t macsec;
14436 cmdline_fixed_string_t sc;
14437 cmdline_fixed_string_t tx_rx;
14439 struct rte_ether_addr mac;
14443 /* Common CLI fields for MACsec secure connection configure */
14444 cmdline_parse_token_string_t cmd_macsec_sc_set =
14445 TOKEN_STRING_INITIALIZER
14446 (struct cmd_macsec_sc_result,
14448 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14449 TOKEN_STRING_INITIALIZER
14450 (struct cmd_macsec_sc_result,
14452 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14453 TOKEN_STRING_INITIALIZER
14454 (struct cmd_macsec_sc_result,
14456 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14457 TOKEN_STRING_INITIALIZER
14458 (struct cmd_macsec_sc_result,
14460 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14461 TOKEN_NUM_INITIALIZER
14462 (struct cmd_macsec_sc_result,
14464 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14465 TOKEN_ETHERADDR_INITIALIZER
14466 (struct cmd_macsec_sc_result,
14468 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14469 TOKEN_NUM_INITIALIZER
14470 (struct cmd_macsec_sc_result,
14474 cmd_set_macsec_sc_parsed(
14475 void *parsed_result,
14476 __rte_unused struct cmdline *cl,
14477 __rte_unused void *data)
14479 struct cmd_macsec_sc_result *res = parsed_result;
14480 int ret = -ENOTSUP;
14481 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14483 #ifdef RTE_LIBRTE_IXGBE_PMD
14485 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14486 res->mac.addr_bytes) :
14487 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14488 res->mac.addr_bytes, res->pi);
14490 RTE_SET_USED(is_tx);
14496 printf("invalid port_id %d\n", res->port_id);
14499 printf("not supported on port %d\n", res->port_id);
14502 printf("programming error: (%s)\n", strerror(-ret));
14506 cmdline_parse_inst_t cmd_set_macsec_sc = {
14507 .f = cmd_set_macsec_sc_parsed,
14509 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14511 (void *)&cmd_macsec_sc_set,
14512 (void *)&cmd_macsec_sc_macsec,
14513 (void *)&cmd_macsec_sc_sc,
14514 (void *)&cmd_macsec_sc_tx_rx,
14515 (void *)&cmd_macsec_sc_port_id,
14516 (void *)&cmd_macsec_sc_mac,
14517 (void *)&cmd_macsec_sc_pi,
14522 /* Common result structure for MACsec secure connection configure */
14523 struct cmd_macsec_sa_result {
14524 cmdline_fixed_string_t set;
14525 cmdline_fixed_string_t macsec;
14526 cmdline_fixed_string_t sa;
14527 cmdline_fixed_string_t tx_rx;
14532 cmdline_fixed_string_t key;
14535 /* Common CLI fields for MACsec secure connection configure */
14536 cmdline_parse_token_string_t cmd_macsec_sa_set =
14537 TOKEN_STRING_INITIALIZER
14538 (struct cmd_macsec_sa_result,
14540 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14541 TOKEN_STRING_INITIALIZER
14542 (struct cmd_macsec_sa_result,
14544 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14545 TOKEN_STRING_INITIALIZER
14546 (struct cmd_macsec_sa_result,
14548 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14549 TOKEN_STRING_INITIALIZER
14550 (struct cmd_macsec_sa_result,
14552 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14553 TOKEN_NUM_INITIALIZER
14554 (struct cmd_macsec_sa_result,
14556 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14557 TOKEN_NUM_INITIALIZER
14558 (struct cmd_macsec_sa_result,
14560 cmdline_parse_token_num_t cmd_macsec_sa_an =
14561 TOKEN_NUM_INITIALIZER
14562 (struct cmd_macsec_sa_result,
14564 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14565 TOKEN_NUM_INITIALIZER
14566 (struct cmd_macsec_sa_result,
14568 cmdline_parse_token_string_t cmd_macsec_sa_key =
14569 TOKEN_STRING_INITIALIZER
14570 (struct cmd_macsec_sa_result,
14574 cmd_set_macsec_sa_parsed(
14575 void *parsed_result,
14576 __rte_unused struct cmdline *cl,
14577 __rte_unused void *data)
14579 struct cmd_macsec_sa_result *res = parsed_result;
14580 int ret = -ENOTSUP;
14581 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14582 uint8_t key[16] = { 0 };
14588 key_len = strlen(res->key) / 2;
14592 for (i = 0; i < key_len; i++) {
14593 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14596 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14599 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14602 #ifdef RTE_LIBRTE_IXGBE_PMD
14604 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14605 res->idx, res->an, res->pn, key) :
14606 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14607 res->idx, res->an, res->pn, key);
14609 RTE_SET_USED(is_tx);
14616 printf("invalid idx %d or an %d\n", res->idx, res->an);
14619 printf("invalid port_id %d\n", res->port_id);
14622 printf("not supported on port %d\n", res->port_id);
14625 printf("programming error: (%s)\n", strerror(-ret));
14629 cmdline_parse_inst_t cmd_set_macsec_sa = {
14630 .f = cmd_set_macsec_sa_parsed,
14632 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14634 (void *)&cmd_macsec_sa_set,
14635 (void *)&cmd_macsec_sa_macsec,
14636 (void *)&cmd_macsec_sa_sa,
14637 (void *)&cmd_macsec_sa_tx_rx,
14638 (void *)&cmd_macsec_sa_port_id,
14639 (void *)&cmd_macsec_sa_idx,
14640 (void *)&cmd_macsec_sa_an,
14641 (void *)&cmd_macsec_sa_pn,
14642 (void *)&cmd_macsec_sa_key,
14647 /* VF unicast promiscuous mode configuration */
14649 /* Common result structure for VF unicast promiscuous mode */
14650 struct cmd_vf_promisc_result {
14651 cmdline_fixed_string_t set;
14652 cmdline_fixed_string_t vf;
14653 cmdline_fixed_string_t promisc;
14656 cmdline_fixed_string_t on_off;
14659 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14660 cmdline_parse_token_string_t cmd_vf_promisc_set =
14661 TOKEN_STRING_INITIALIZER
14662 (struct cmd_vf_promisc_result,
14664 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14665 TOKEN_STRING_INITIALIZER
14666 (struct cmd_vf_promisc_result,
14668 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14669 TOKEN_STRING_INITIALIZER
14670 (struct cmd_vf_promisc_result,
14671 promisc, "promisc");
14672 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14673 TOKEN_NUM_INITIALIZER
14674 (struct cmd_vf_promisc_result,
14676 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14677 TOKEN_NUM_INITIALIZER
14678 (struct cmd_vf_promisc_result,
14680 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14681 TOKEN_STRING_INITIALIZER
14682 (struct cmd_vf_promisc_result,
14686 cmd_set_vf_promisc_parsed(
14687 void *parsed_result,
14688 __rte_unused struct cmdline *cl,
14689 __rte_unused void *data)
14691 struct cmd_vf_promisc_result *res = parsed_result;
14692 int ret = -ENOTSUP;
14694 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14696 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14699 #ifdef RTE_LIBRTE_I40E_PMD
14700 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14701 res->vf_id, is_on);
14708 printf("invalid vf_id %d\n", res->vf_id);
14711 printf("invalid port_id %d\n", res->port_id);
14714 printf("function not implemented\n");
14717 printf("programming error: (%s)\n", strerror(-ret));
14721 cmdline_parse_inst_t cmd_set_vf_promisc = {
14722 .f = cmd_set_vf_promisc_parsed,
14724 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14725 "Set unicast promiscuous mode for a VF from the PF",
14727 (void *)&cmd_vf_promisc_set,
14728 (void *)&cmd_vf_promisc_vf,
14729 (void *)&cmd_vf_promisc_promisc,
14730 (void *)&cmd_vf_promisc_port_id,
14731 (void *)&cmd_vf_promisc_vf_id,
14732 (void *)&cmd_vf_promisc_on_off,
14737 /* VF multicast promiscuous mode configuration */
14739 /* Common result structure for VF multicast promiscuous mode */
14740 struct cmd_vf_allmulti_result {
14741 cmdline_fixed_string_t set;
14742 cmdline_fixed_string_t vf;
14743 cmdline_fixed_string_t allmulti;
14746 cmdline_fixed_string_t on_off;
14749 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14750 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14751 TOKEN_STRING_INITIALIZER
14752 (struct cmd_vf_allmulti_result,
14754 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14755 TOKEN_STRING_INITIALIZER
14756 (struct cmd_vf_allmulti_result,
14758 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14759 TOKEN_STRING_INITIALIZER
14760 (struct cmd_vf_allmulti_result,
14761 allmulti, "allmulti");
14762 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14763 TOKEN_NUM_INITIALIZER
14764 (struct cmd_vf_allmulti_result,
14766 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14767 TOKEN_NUM_INITIALIZER
14768 (struct cmd_vf_allmulti_result,
14770 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14771 TOKEN_STRING_INITIALIZER
14772 (struct cmd_vf_allmulti_result,
14776 cmd_set_vf_allmulti_parsed(
14777 void *parsed_result,
14778 __rte_unused struct cmdline *cl,
14779 __rte_unused void *data)
14781 struct cmd_vf_allmulti_result *res = parsed_result;
14782 int ret = -ENOTSUP;
14784 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14789 #ifdef RTE_LIBRTE_I40E_PMD
14790 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14791 res->vf_id, is_on);
14798 printf("invalid vf_id %d\n", res->vf_id);
14801 printf("invalid port_id %d\n", res->port_id);
14804 printf("function not implemented\n");
14807 printf("programming error: (%s)\n", strerror(-ret));
14811 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14812 .f = cmd_set_vf_allmulti_parsed,
14814 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14815 "Set multicast promiscuous mode for a VF from the PF",
14817 (void *)&cmd_vf_allmulti_set,
14818 (void *)&cmd_vf_allmulti_vf,
14819 (void *)&cmd_vf_allmulti_allmulti,
14820 (void *)&cmd_vf_allmulti_port_id,
14821 (void *)&cmd_vf_allmulti_vf_id,
14822 (void *)&cmd_vf_allmulti_on_off,
14827 /* vf broadcast mode configuration */
14829 /* Common result structure for vf broadcast */
14830 struct cmd_set_vf_broadcast_result {
14831 cmdline_fixed_string_t set;
14832 cmdline_fixed_string_t vf;
14833 cmdline_fixed_string_t broadcast;
14836 cmdline_fixed_string_t on_off;
14839 /* Common CLI fields for vf broadcast enable disable */
14840 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14841 TOKEN_STRING_INITIALIZER
14842 (struct cmd_set_vf_broadcast_result,
14844 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14845 TOKEN_STRING_INITIALIZER
14846 (struct cmd_set_vf_broadcast_result,
14848 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14849 TOKEN_STRING_INITIALIZER
14850 (struct cmd_set_vf_broadcast_result,
14851 broadcast, "broadcast");
14852 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14853 TOKEN_NUM_INITIALIZER
14854 (struct cmd_set_vf_broadcast_result,
14856 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14857 TOKEN_NUM_INITIALIZER
14858 (struct cmd_set_vf_broadcast_result,
14860 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14861 TOKEN_STRING_INITIALIZER
14862 (struct cmd_set_vf_broadcast_result,
14866 cmd_set_vf_broadcast_parsed(
14867 void *parsed_result,
14868 __rte_unused struct cmdline *cl,
14869 __rte_unused void *data)
14871 struct cmd_set_vf_broadcast_result *res = parsed_result;
14872 int ret = -ENOTSUP;
14874 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14876 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14879 #ifdef RTE_LIBRTE_I40E_PMD
14880 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14881 res->vf_id, is_on);
14888 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14891 printf("invalid port_id %d\n", res->port_id);
14894 printf("function not implemented\n");
14897 printf("programming error: (%s)\n", strerror(-ret));
14901 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14902 .f = cmd_set_vf_broadcast_parsed,
14904 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14906 (void *)&cmd_set_vf_broadcast_set,
14907 (void *)&cmd_set_vf_broadcast_vf,
14908 (void *)&cmd_set_vf_broadcast_broadcast,
14909 (void *)&cmd_set_vf_broadcast_port_id,
14910 (void *)&cmd_set_vf_broadcast_vf_id,
14911 (void *)&cmd_set_vf_broadcast_on_off,
14916 /* vf vlan tag configuration */
14918 /* Common result structure for vf vlan tag */
14919 struct cmd_set_vf_vlan_tag_result {
14920 cmdline_fixed_string_t set;
14921 cmdline_fixed_string_t vf;
14922 cmdline_fixed_string_t vlan;
14923 cmdline_fixed_string_t tag;
14926 cmdline_fixed_string_t on_off;
14929 /* Common CLI fields for vf vlan tag enable disable */
14930 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14931 TOKEN_STRING_INITIALIZER
14932 (struct cmd_set_vf_vlan_tag_result,
14934 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14935 TOKEN_STRING_INITIALIZER
14936 (struct cmd_set_vf_vlan_tag_result,
14938 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14939 TOKEN_STRING_INITIALIZER
14940 (struct cmd_set_vf_vlan_tag_result,
14942 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14943 TOKEN_STRING_INITIALIZER
14944 (struct cmd_set_vf_vlan_tag_result,
14946 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14947 TOKEN_NUM_INITIALIZER
14948 (struct cmd_set_vf_vlan_tag_result,
14950 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14951 TOKEN_NUM_INITIALIZER
14952 (struct cmd_set_vf_vlan_tag_result,
14954 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14955 TOKEN_STRING_INITIALIZER
14956 (struct cmd_set_vf_vlan_tag_result,
14960 cmd_set_vf_vlan_tag_parsed(
14961 void *parsed_result,
14962 __rte_unused struct cmdline *cl,
14963 __rte_unused void *data)
14965 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14966 int ret = -ENOTSUP;
14968 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14970 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14973 #ifdef RTE_LIBRTE_I40E_PMD
14974 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14975 res->vf_id, is_on);
14982 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14985 printf("invalid port_id %d\n", res->port_id);
14988 printf("function not implemented\n");
14991 printf("programming error: (%s)\n", strerror(-ret));
14995 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14996 .f = cmd_set_vf_vlan_tag_parsed,
14998 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15000 (void *)&cmd_set_vf_vlan_tag_set,
15001 (void *)&cmd_set_vf_vlan_tag_vf,
15002 (void *)&cmd_set_vf_vlan_tag_vlan,
15003 (void *)&cmd_set_vf_vlan_tag_tag,
15004 (void *)&cmd_set_vf_vlan_tag_port_id,
15005 (void *)&cmd_set_vf_vlan_tag_vf_id,
15006 (void *)&cmd_set_vf_vlan_tag_on_off,
15011 /* Common definition of VF and TC TX bandwidth configuration */
15012 struct cmd_vf_tc_bw_result {
15013 cmdline_fixed_string_t set;
15014 cmdline_fixed_string_t vf;
15015 cmdline_fixed_string_t tc;
15016 cmdline_fixed_string_t tx;
15017 cmdline_fixed_string_t min_bw;
15018 cmdline_fixed_string_t max_bw;
15019 cmdline_fixed_string_t strict_link_prio;
15024 cmdline_fixed_string_t bw_list;
15028 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15029 TOKEN_STRING_INITIALIZER
15030 (struct cmd_vf_tc_bw_result,
15032 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15033 TOKEN_STRING_INITIALIZER
15034 (struct cmd_vf_tc_bw_result,
15036 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15037 TOKEN_STRING_INITIALIZER
15038 (struct cmd_vf_tc_bw_result,
15040 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15041 TOKEN_STRING_INITIALIZER
15042 (struct cmd_vf_tc_bw_result,
15044 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15045 TOKEN_STRING_INITIALIZER
15046 (struct cmd_vf_tc_bw_result,
15047 strict_link_prio, "strict-link-priority");
15048 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15049 TOKEN_STRING_INITIALIZER
15050 (struct cmd_vf_tc_bw_result,
15051 min_bw, "min-bandwidth");
15052 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15053 TOKEN_STRING_INITIALIZER
15054 (struct cmd_vf_tc_bw_result,
15055 max_bw, "max-bandwidth");
15056 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15057 TOKEN_NUM_INITIALIZER
15058 (struct cmd_vf_tc_bw_result,
15060 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15061 TOKEN_NUM_INITIALIZER
15062 (struct cmd_vf_tc_bw_result,
15064 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15065 TOKEN_NUM_INITIALIZER
15066 (struct cmd_vf_tc_bw_result,
15068 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15069 TOKEN_NUM_INITIALIZER
15070 (struct cmd_vf_tc_bw_result,
15072 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15073 TOKEN_STRING_INITIALIZER
15074 (struct cmd_vf_tc_bw_result,
15076 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15077 TOKEN_NUM_INITIALIZER
15078 (struct cmd_vf_tc_bw_result,
15081 /* VF max bandwidth setting */
15083 cmd_vf_max_bw_parsed(
15084 void *parsed_result,
15085 __rte_unused struct cmdline *cl,
15086 __rte_unused void *data)
15088 struct cmd_vf_tc_bw_result *res = parsed_result;
15089 int ret = -ENOTSUP;
15091 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15094 #ifdef RTE_LIBRTE_I40E_PMD
15095 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15096 res->vf_id, res->bw);
15103 printf("invalid vf_id %d or bandwidth %d\n",
15104 res->vf_id, res->bw);
15107 printf("invalid port_id %d\n", res->port_id);
15110 printf("function not implemented\n");
15113 printf("programming error: (%s)\n", strerror(-ret));
15117 cmdline_parse_inst_t cmd_vf_max_bw = {
15118 .f = cmd_vf_max_bw_parsed,
15120 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15122 (void *)&cmd_vf_tc_bw_set,
15123 (void *)&cmd_vf_tc_bw_vf,
15124 (void *)&cmd_vf_tc_bw_tx,
15125 (void *)&cmd_vf_tc_bw_max_bw,
15126 (void *)&cmd_vf_tc_bw_port_id,
15127 (void *)&cmd_vf_tc_bw_vf_id,
15128 (void *)&cmd_vf_tc_bw_bw,
15134 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15139 const char *p, *p0 = str;
15146 p = strchr(p0, '(');
15148 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15152 p0 = strchr(p, ')');
15154 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15158 if (size >= sizeof(s)) {
15159 printf("The string size exceeds the internal buffer size\n");
15162 snprintf(s, sizeof(s), "%.*s", size, p);
15163 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15165 printf("Failed to get the bandwidth list. ");
15169 for (i = 0; i < ret; i++)
15170 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15175 /* TC min bandwidth setting */
15177 cmd_vf_tc_min_bw_parsed(
15178 void *parsed_result,
15179 __rte_unused struct cmdline *cl,
15180 __rte_unused void *data)
15182 struct cmd_vf_tc_bw_result *res = parsed_result;
15185 int ret = -ENOTSUP;
15187 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15190 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15194 #ifdef RTE_LIBRTE_I40E_PMD
15195 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15203 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15206 printf("invalid port_id %d\n", res->port_id);
15209 printf("function not implemented\n");
15212 printf("programming error: (%s)\n", strerror(-ret));
15216 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15217 .f = cmd_vf_tc_min_bw_parsed,
15219 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15220 " <bw1, bw2, ...>",
15222 (void *)&cmd_vf_tc_bw_set,
15223 (void *)&cmd_vf_tc_bw_vf,
15224 (void *)&cmd_vf_tc_bw_tc,
15225 (void *)&cmd_vf_tc_bw_tx,
15226 (void *)&cmd_vf_tc_bw_min_bw,
15227 (void *)&cmd_vf_tc_bw_port_id,
15228 (void *)&cmd_vf_tc_bw_vf_id,
15229 (void *)&cmd_vf_tc_bw_bw_list,
15235 cmd_tc_min_bw_parsed(
15236 void *parsed_result,
15237 __rte_unused struct cmdline *cl,
15238 __rte_unused void *data)
15240 struct cmd_vf_tc_bw_result *res = parsed_result;
15241 struct rte_port *port;
15244 int ret = -ENOTSUP;
15246 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15249 port = &ports[res->port_id];
15250 /** Check if the port is not started **/
15251 if (port->port_status != RTE_PORT_STOPPED) {
15252 printf("Please stop port %d first\n", res->port_id);
15256 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15260 #ifdef RTE_LIBRTE_IXGBE_PMD
15261 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15268 printf("invalid bandwidth\n");
15271 printf("invalid port_id %d\n", res->port_id);
15274 printf("function not implemented\n");
15277 printf("programming error: (%s)\n", strerror(-ret));
15281 cmdline_parse_inst_t cmd_tc_min_bw = {
15282 .f = cmd_tc_min_bw_parsed,
15284 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15286 (void *)&cmd_vf_tc_bw_set,
15287 (void *)&cmd_vf_tc_bw_tc,
15288 (void *)&cmd_vf_tc_bw_tx,
15289 (void *)&cmd_vf_tc_bw_min_bw,
15290 (void *)&cmd_vf_tc_bw_port_id,
15291 (void *)&cmd_vf_tc_bw_bw_list,
15296 /* TC max bandwidth setting */
15298 cmd_vf_tc_max_bw_parsed(
15299 void *parsed_result,
15300 __rte_unused struct cmdline *cl,
15301 __rte_unused void *data)
15303 struct cmd_vf_tc_bw_result *res = parsed_result;
15304 int ret = -ENOTSUP;
15306 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15309 #ifdef RTE_LIBRTE_I40E_PMD
15310 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15311 res->tc_no, res->bw);
15318 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15319 res->vf_id, res->tc_no, res->bw);
15322 printf("invalid port_id %d\n", res->port_id);
15325 printf("function not implemented\n");
15328 printf("programming error: (%s)\n", strerror(-ret));
15332 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15333 .f = cmd_vf_tc_max_bw_parsed,
15335 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15338 (void *)&cmd_vf_tc_bw_set,
15339 (void *)&cmd_vf_tc_bw_vf,
15340 (void *)&cmd_vf_tc_bw_tc,
15341 (void *)&cmd_vf_tc_bw_tx,
15342 (void *)&cmd_vf_tc_bw_max_bw,
15343 (void *)&cmd_vf_tc_bw_port_id,
15344 (void *)&cmd_vf_tc_bw_vf_id,
15345 (void *)&cmd_vf_tc_bw_tc_no,
15346 (void *)&cmd_vf_tc_bw_bw,
15352 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15354 /* *** Set Port default Traffic Management Hierarchy *** */
15355 struct cmd_set_port_tm_hierarchy_default_result {
15356 cmdline_fixed_string_t set;
15357 cmdline_fixed_string_t port;
15358 cmdline_fixed_string_t tm;
15359 cmdline_fixed_string_t hierarchy;
15360 cmdline_fixed_string_t def;
15364 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15365 TOKEN_STRING_INITIALIZER(
15366 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15367 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15368 TOKEN_STRING_INITIALIZER(
15369 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15370 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15371 TOKEN_STRING_INITIALIZER(
15372 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15373 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15374 TOKEN_STRING_INITIALIZER(
15375 struct cmd_set_port_tm_hierarchy_default_result,
15376 hierarchy, "hierarchy");
15377 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15378 TOKEN_STRING_INITIALIZER(
15379 struct cmd_set_port_tm_hierarchy_default_result,
15381 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15382 TOKEN_NUM_INITIALIZER(
15383 struct cmd_set_port_tm_hierarchy_default_result,
15386 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15387 __rte_unused struct cmdline *cl,
15388 __rte_unused void *data)
15390 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15391 struct rte_port *p;
15392 portid_t port_id = res->port_id;
15394 if (port_id_is_invalid(port_id, ENABLED_WARN))
15397 p = &ports[port_id];
15399 /* Forward mode: tm */
15400 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15401 printf(" softnicfwd mode not enabled(error)\n");
15405 /* Set the default tm hierarchy */
15406 p->softport.default_tm_hierarchy_enable = 1;
15409 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15410 .f = cmd_set_port_tm_hierarchy_default_parsed,
15412 .help_str = "set port tm hierarchy default <port_id>",
15414 (void *)&cmd_set_port_tm_hierarchy_default_set,
15415 (void *)&cmd_set_port_tm_hierarchy_default_port,
15416 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15417 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15418 (void *)&cmd_set_port_tm_hierarchy_default_default,
15419 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15425 /** Set VXLAN encapsulation details */
15426 struct cmd_set_vxlan_result {
15427 cmdline_fixed_string_t set;
15428 cmdline_fixed_string_t vxlan;
15429 cmdline_fixed_string_t pos_token;
15430 cmdline_fixed_string_t ip_version;
15431 uint32_t vlan_present:1;
15435 cmdline_ipaddr_t ip_src;
15436 cmdline_ipaddr_t ip_dst;
15440 struct rte_ether_addr eth_src;
15441 struct rte_ether_addr eth_dst;
15444 cmdline_parse_token_string_t cmd_set_vxlan_set =
15445 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15446 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15447 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15448 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15449 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15451 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15452 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15453 "vxlan-with-vlan");
15454 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15455 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15457 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15458 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15460 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15461 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15463 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15464 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15465 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15466 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15468 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15469 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15470 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15471 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15473 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15474 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15475 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15476 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15478 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15479 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15480 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15481 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15483 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15484 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15485 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15486 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15488 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15489 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15490 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15491 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15493 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15494 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15495 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15496 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15498 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15499 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15500 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15501 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15503 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15504 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15505 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15506 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15508 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15509 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15511 static void cmd_set_vxlan_parsed(void *parsed_result,
15512 __rte_unused struct cmdline *cl,
15513 __rte_unused void *data)
15515 struct cmd_set_vxlan_result *res = parsed_result;
15520 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15523 vxlan_encap_conf.select_tos_ttl = 0;
15524 if (strcmp(res->vxlan, "vxlan") == 0)
15525 vxlan_encap_conf.select_vlan = 0;
15526 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15527 vxlan_encap_conf.select_vlan = 1;
15528 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15529 vxlan_encap_conf.select_vlan = 0;
15530 vxlan_encap_conf.select_tos_ttl = 1;
15532 if (strcmp(res->ip_version, "ipv4") == 0)
15533 vxlan_encap_conf.select_ipv4 = 1;
15534 else if (strcmp(res->ip_version, "ipv6") == 0)
15535 vxlan_encap_conf.select_ipv4 = 0;
15538 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15539 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15540 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15541 vxlan_encap_conf.ip_tos = res->tos;
15542 vxlan_encap_conf.ip_ttl = res->ttl;
15543 if (vxlan_encap_conf.select_ipv4) {
15544 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15545 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15547 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15548 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15550 if (vxlan_encap_conf.select_vlan)
15551 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15552 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15553 RTE_ETHER_ADDR_LEN);
15554 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15555 RTE_ETHER_ADDR_LEN);
15558 cmdline_parse_inst_t cmd_set_vxlan = {
15559 .f = cmd_set_vxlan_parsed,
15561 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15562 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15563 " eth-src <eth-src> eth-dst <eth-dst>",
15565 (void *)&cmd_set_vxlan_set,
15566 (void *)&cmd_set_vxlan_vxlan,
15567 (void *)&cmd_set_vxlan_ip_version,
15568 (void *)&cmd_set_vxlan_ip_version_value,
15569 (void *)&cmd_set_vxlan_vni,
15570 (void *)&cmd_set_vxlan_vni_value,
15571 (void *)&cmd_set_vxlan_udp_src,
15572 (void *)&cmd_set_vxlan_udp_src_value,
15573 (void *)&cmd_set_vxlan_udp_dst,
15574 (void *)&cmd_set_vxlan_udp_dst_value,
15575 (void *)&cmd_set_vxlan_ip_src,
15576 (void *)&cmd_set_vxlan_ip_src_value,
15577 (void *)&cmd_set_vxlan_ip_dst,
15578 (void *)&cmd_set_vxlan_ip_dst_value,
15579 (void *)&cmd_set_vxlan_eth_src,
15580 (void *)&cmd_set_vxlan_eth_src_value,
15581 (void *)&cmd_set_vxlan_eth_dst,
15582 (void *)&cmd_set_vxlan_eth_dst_value,
15587 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15588 .f = cmd_set_vxlan_parsed,
15590 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15591 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15592 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15593 " eth-dst <eth-dst>",
15595 (void *)&cmd_set_vxlan_set,
15596 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15597 (void *)&cmd_set_vxlan_ip_version,
15598 (void *)&cmd_set_vxlan_ip_version_value,
15599 (void *)&cmd_set_vxlan_vni,
15600 (void *)&cmd_set_vxlan_vni_value,
15601 (void *)&cmd_set_vxlan_udp_src,
15602 (void *)&cmd_set_vxlan_udp_src_value,
15603 (void *)&cmd_set_vxlan_udp_dst,
15604 (void *)&cmd_set_vxlan_udp_dst_value,
15605 (void *)&cmd_set_vxlan_ip_tos,
15606 (void *)&cmd_set_vxlan_ip_tos_value,
15607 (void *)&cmd_set_vxlan_ip_ttl,
15608 (void *)&cmd_set_vxlan_ip_ttl_value,
15609 (void *)&cmd_set_vxlan_ip_src,
15610 (void *)&cmd_set_vxlan_ip_src_value,
15611 (void *)&cmd_set_vxlan_ip_dst,
15612 (void *)&cmd_set_vxlan_ip_dst_value,
15613 (void *)&cmd_set_vxlan_eth_src,
15614 (void *)&cmd_set_vxlan_eth_src_value,
15615 (void *)&cmd_set_vxlan_eth_dst,
15616 (void *)&cmd_set_vxlan_eth_dst_value,
15621 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15622 .f = cmd_set_vxlan_parsed,
15624 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15625 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15626 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15629 (void *)&cmd_set_vxlan_set,
15630 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15631 (void *)&cmd_set_vxlan_ip_version,
15632 (void *)&cmd_set_vxlan_ip_version_value,
15633 (void *)&cmd_set_vxlan_vni,
15634 (void *)&cmd_set_vxlan_vni_value,
15635 (void *)&cmd_set_vxlan_udp_src,
15636 (void *)&cmd_set_vxlan_udp_src_value,
15637 (void *)&cmd_set_vxlan_udp_dst,
15638 (void *)&cmd_set_vxlan_udp_dst_value,
15639 (void *)&cmd_set_vxlan_ip_src,
15640 (void *)&cmd_set_vxlan_ip_src_value,
15641 (void *)&cmd_set_vxlan_ip_dst,
15642 (void *)&cmd_set_vxlan_ip_dst_value,
15643 (void *)&cmd_set_vxlan_vlan,
15644 (void *)&cmd_set_vxlan_vlan_value,
15645 (void *)&cmd_set_vxlan_eth_src,
15646 (void *)&cmd_set_vxlan_eth_src_value,
15647 (void *)&cmd_set_vxlan_eth_dst,
15648 (void *)&cmd_set_vxlan_eth_dst_value,
15653 /** Set NVGRE encapsulation details */
15654 struct cmd_set_nvgre_result {
15655 cmdline_fixed_string_t set;
15656 cmdline_fixed_string_t nvgre;
15657 cmdline_fixed_string_t pos_token;
15658 cmdline_fixed_string_t ip_version;
15660 cmdline_ipaddr_t ip_src;
15661 cmdline_ipaddr_t ip_dst;
15663 struct rte_ether_addr eth_src;
15664 struct rte_ether_addr eth_dst;
15667 cmdline_parse_token_string_t cmd_set_nvgre_set =
15668 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15669 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15670 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15671 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15672 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15673 "nvgre-with-vlan");
15674 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15675 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15677 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15678 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15680 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15681 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15683 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15684 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15685 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15686 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15688 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15689 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15690 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15691 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15693 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15694 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15695 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15696 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15698 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15699 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15700 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15701 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15703 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15704 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15705 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15706 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15708 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15709 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15711 static void cmd_set_nvgre_parsed(void *parsed_result,
15712 __rte_unused struct cmdline *cl,
15713 __rte_unused void *data)
15715 struct cmd_set_nvgre_result *res = parsed_result;
15717 uint32_t nvgre_tni;
15720 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15723 if (strcmp(res->nvgre, "nvgre") == 0)
15724 nvgre_encap_conf.select_vlan = 0;
15725 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15726 nvgre_encap_conf.select_vlan = 1;
15727 if (strcmp(res->ip_version, "ipv4") == 0)
15728 nvgre_encap_conf.select_ipv4 = 1;
15729 else if (strcmp(res->ip_version, "ipv6") == 0)
15730 nvgre_encap_conf.select_ipv4 = 0;
15733 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15734 if (nvgre_encap_conf.select_ipv4) {
15735 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15736 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15738 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15739 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15741 if (nvgre_encap_conf.select_vlan)
15742 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15743 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15744 RTE_ETHER_ADDR_LEN);
15745 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15746 RTE_ETHER_ADDR_LEN);
15749 cmdline_parse_inst_t cmd_set_nvgre = {
15750 .f = cmd_set_nvgre_parsed,
15752 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15753 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15754 " eth-dst <eth-dst>",
15756 (void *)&cmd_set_nvgre_set,
15757 (void *)&cmd_set_nvgre_nvgre,
15758 (void *)&cmd_set_nvgre_ip_version,
15759 (void *)&cmd_set_nvgre_ip_version_value,
15760 (void *)&cmd_set_nvgre_tni,
15761 (void *)&cmd_set_nvgre_tni_value,
15762 (void *)&cmd_set_nvgre_ip_src,
15763 (void *)&cmd_set_nvgre_ip_src_value,
15764 (void *)&cmd_set_nvgre_ip_dst,
15765 (void *)&cmd_set_nvgre_ip_dst_value,
15766 (void *)&cmd_set_nvgre_eth_src,
15767 (void *)&cmd_set_nvgre_eth_src_value,
15768 (void *)&cmd_set_nvgre_eth_dst,
15769 (void *)&cmd_set_nvgre_eth_dst_value,
15774 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15775 .f = cmd_set_nvgre_parsed,
15777 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15778 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15779 " eth-src <eth-src> eth-dst <eth-dst>",
15781 (void *)&cmd_set_nvgre_set,
15782 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15783 (void *)&cmd_set_nvgre_ip_version,
15784 (void *)&cmd_set_nvgre_ip_version_value,
15785 (void *)&cmd_set_nvgre_tni,
15786 (void *)&cmd_set_nvgre_tni_value,
15787 (void *)&cmd_set_nvgre_ip_src,
15788 (void *)&cmd_set_nvgre_ip_src_value,
15789 (void *)&cmd_set_nvgre_ip_dst,
15790 (void *)&cmd_set_nvgre_ip_dst_value,
15791 (void *)&cmd_set_nvgre_vlan,
15792 (void *)&cmd_set_nvgre_vlan_value,
15793 (void *)&cmd_set_nvgre_eth_src,
15794 (void *)&cmd_set_nvgre_eth_src_value,
15795 (void *)&cmd_set_nvgre_eth_dst,
15796 (void *)&cmd_set_nvgre_eth_dst_value,
15801 /** Set L2 encapsulation details */
15802 struct cmd_set_l2_encap_result {
15803 cmdline_fixed_string_t set;
15804 cmdline_fixed_string_t l2_encap;
15805 cmdline_fixed_string_t pos_token;
15806 cmdline_fixed_string_t ip_version;
15807 uint32_t vlan_present:1;
15809 struct rte_ether_addr eth_src;
15810 struct rte_ether_addr eth_dst;
15813 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15814 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15815 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15816 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15817 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15818 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15819 "l2_encap-with-vlan");
15820 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15821 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15823 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15824 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15826 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15827 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15829 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15830 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15831 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15832 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15834 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15835 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15836 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15837 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15839 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15840 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15842 static void cmd_set_l2_encap_parsed(void *parsed_result,
15843 __rte_unused struct cmdline *cl,
15844 __rte_unused void *data)
15846 struct cmd_set_l2_encap_result *res = parsed_result;
15848 if (strcmp(res->l2_encap, "l2_encap") == 0)
15849 l2_encap_conf.select_vlan = 0;
15850 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15851 l2_encap_conf.select_vlan = 1;
15852 if (strcmp(res->ip_version, "ipv4") == 0)
15853 l2_encap_conf.select_ipv4 = 1;
15854 else if (strcmp(res->ip_version, "ipv6") == 0)
15855 l2_encap_conf.select_ipv4 = 0;
15858 if (l2_encap_conf.select_vlan)
15859 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15860 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15861 RTE_ETHER_ADDR_LEN);
15862 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15863 RTE_ETHER_ADDR_LEN);
15866 cmdline_parse_inst_t cmd_set_l2_encap = {
15867 .f = cmd_set_l2_encap_parsed,
15869 .help_str = "set l2_encap ip-version ipv4|ipv6"
15870 " eth-src <eth-src> eth-dst <eth-dst>",
15872 (void *)&cmd_set_l2_encap_set,
15873 (void *)&cmd_set_l2_encap_l2_encap,
15874 (void *)&cmd_set_l2_encap_ip_version,
15875 (void *)&cmd_set_l2_encap_ip_version_value,
15876 (void *)&cmd_set_l2_encap_eth_src,
15877 (void *)&cmd_set_l2_encap_eth_src_value,
15878 (void *)&cmd_set_l2_encap_eth_dst,
15879 (void *)&cmd_set_l2_encap_eth_dst_value,
15884 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15885 .f = cmd_set_l2_encap_parsed,
15887 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15888 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15890 (void *)&cmd_set_l2_encap_set,
15891 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15892 (void *)&cmd_set_l2_encap_ip_version,
15893 (void *)&cmd_set_l2_encap_ip_version_value,
15894 (void *)&cmd_set_l2_encap_vlan,
15895 (void *)&cmd_set_l2_encap_vlan_value,
15896 (void *)&cmd_set_l2_encap_eth_src,
15897 (void *)&cmd_set_l2_encap_eth_src_value,
15898 (void *)&cmd_set_l2_encap_eth_dst,
15899 (void *)&cmd_set_l2_encap_eth_dst_value,
15904 /** Set L2 decapsulation details */
15905 struct cmd_set_l2_decap_result {
15906 cmdline_fixed_string_t set;
15907 cmdline_fixed_string_t l2_decap;
15908 cmdline_fixed_string_t pos_token;
15909 uint32_t vlan_present:1;
15912 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15913 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15914 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15915 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15917 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15918 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15919 "l2_decap-with-vlan");
15921 static void cmd_set_l2_decap_parsed(void *parsed_result,
15922 __rte_unused struct cmdline *cl,
15923 __rte_unused void *data)
15925 struct cmd_set_l2_decap_result *res = parsed_result;
15927 if (strcmp(res->l2_decap, "l2_decap") == 0)
15928 l2_decap_conf.select_vlan = 0;
15929 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15930 l2_decap_conf.select_vlan = 1;
15933 cmdline_parse_inst_t cmd_set_l2_decap = {
15934 .f = cmd_set_l2_decap_parsed,
15936 .help_str = "set l2_decap",
15938 (void *)&cmd_set_l2_decap_set,
15939 (void *)&cmd_set_l2_decap_l2_decap,
15944 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15945 .f = cmd_set_l2_decap_parsed,
15947 .help_str = "set l2_decap-with-vlan",
15949 (void *)&cmd_set_l2_decap_set,
15950 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15955 /** Set MPLSoGRE encapsulation details */
15956 struct cmd_set_mplsogre_encap_result {
15957 cmdline_fixed_string_t set;
15958 cmdline_fixed_string_t mplsogre;
15959 cmdline_fixed_string_t pos_token;
15960 cmdline_fixed_string_t ip_version;
15961 uint32_t vlan_present:1;
15963 cmdline_ipaddr_t ip_src;
15964 cmdline_ipaddr_t ip_dst;
15966 struct rte_ether_addr eth_src;
15967 struct rte_ether_addr eth_dst;
15970 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15971 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15973 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15974 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15976 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15977 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15978 mplsogre, "mplsogre_encap-with-vlan");
15979 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15980 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15981 pos_token, "ip-version");
15982 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15983 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15984 ip_version, "ipv4#ipv6");
15985 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15986 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15987 pos_token, "label");
15988 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15989 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15991 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15992 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15993 pos_token, "ip-src");
15994 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15995 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15996 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15997 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15998 pos_token, "ip-dst");
15999 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16000 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16001 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16002 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16003 pos_token, "vlan-tci");
16004 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16005 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16007 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16008 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16009 pos_token, "eth-src");
16010 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16011 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16013 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16014 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16015 pos_token, "eth-dst");
16016 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16017 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16020 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16021 __rte_unused struct cmdline *cl,
16022 __rte_unused void *data)
16024 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16026 uint32_t mplsogre_label;
16029 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16032 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16033 mplsogre_encap_conf.select_vlan = 0;
16034 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16035 mplsogre_encap_conf.select_vlan = 1;
16036 if (strcmp(res->ip_version, "ipv4") == 0)
16037 mplsogre_encap_conf.select_ipv4 = 1;
16038 else if (strcmp(res->ip_version, "ipv6") == 0)
16039 mplsogre_encap_conf.select_ipv4 = 0;
16042 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16043 if (mplsogre_encap_conf.select_ipv4) {
16044 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16045 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16047 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16048 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16050 if (mplsogre_encap_conf.select_vlan)
16051 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16052 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16053 RTE_ETHER_ADDR_LEN);
16054 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16055 RTE_ETHER_ADDR_LEN);
16058 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16059 .f = cmd_set_mplsogre_encap_parsed,
16061 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16062 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16063 " eth-dst <eth-dst>",
16065 (void *)&cmd_set_mplsogre_encap_set,
16066 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16067 (void *)&cmd_set_mplsogre_encap_ip_version,
16068 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16069 (void *)&cmd_set_mplsogre_encap_label,
16070 (void *)&cmd_set_mplsogre_encap_label_value,
16071 (void *)&cmd_set_mplsogre_encap_ip_src,
16072 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16073 (void *)&cmd_set_mplsogre_encap_ip_dst,
16074 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16075 (void *)&cmd_set_mplsogre_encap_eth_src,
16076 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16077 (void *)&cmd_set_mplsogre_encap_eth_dst,
16078 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16083 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16084 .f = cmd_set_mplsogre_encap_parsed,
16086 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16087 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16088 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16090 (void *)&cmd_set_mplsogre_encap_set,
16091 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16092 (void *)&cmd_set_mplsogre_encap_ip_version,
16093 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16094 (void *)&cmd_set_mplsogre_encap_label,
16095 (void *)&cmd_set_mplsogre_encap_label_value,
16096 (void *)&cmd_set_mplsogre_encap_ip_src,
16097 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16098 (void *)&cmd_set_mplsogre_encap_ip_dst,
16099 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16100 (void *)&cmd_set_mplsogre_encap_vlan,
16101 (void *)&cmd_set_mplsogre_encap_vlan_value,
16102 (void *)&cmd_set_mplsogre_encap_eth_src,
16103 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16104 (void *)&cmd_set_mplsogre_encap_eth_dst,
16105 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16110 /** Set MPLSoGRE decapsulation details */
16111 struct cmd_set_mplsogre_decap_result {
16112 cmdline_fixed_string_t set;
16113 cmdline_fixed_string_t mplsogre;
16114 cmdline_fixed_string_t pos_token;
16115 cmdline_fixed_string_t ip_version;
16116 uint32_t vlan_present:1;
16119 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16120 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16122 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16123 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16125 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16126 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16127 mplsogre, "mplsogre_decap-with-vlan");
16128 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16129 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16130 pos_token, "ip-version");
16131 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16132 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16133 ip_version, "ipv4#ipv6");
16135 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16136 __rte_unused struct cmdline *cl,
16137 __rte_unused void *data)
16139 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16141 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16142 mplsogre_decap_conf.select_vlan = 0;
16143 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16144 mplsogre_decap_conf.select_vlan = 1;
16145 if (strcmp(res->ip_version, "ipv4") == 0)
16146 mplsogre_decap_conf.select_ipv4 = 1;
16147 else if (strcmp(res->ip_version, "ipv6") == 0)
16148 mplsogre_decap_conf.select_ipv4 = 0;
16151 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16152 .f = cmd_set_mplsogre_decap_parsed,
16154 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16156 (void *)&cmd_set_mplsogre_decap_set,
16157 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16158 (void *)&cmd_set_mplsogre_decap_ip_version,
16159 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16164 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16165 .f = cmd_set_mplsogre_decap_parsed,
16167 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16169 (void *)&cmd_set_mplsogre_decap_set,
16170 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16171 (void *)&cmd_set_mplsogre_decap_ip_version,
16172 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16177 /** Set MPLSoUDP encapsulation details */
16178 struct cmd_set_mplsoudp_encap_result {
16179 cmdline_fixed_string_t set;
16180 cmdline_fixed_string_t mplsoudp;
16181 cmdline_fixed_string_t pos_token;
16182 cmdline_fixed_string_t ip_version;
16183 uint32_t vlan_present:1;
16187 cmdline_ipaddr_t ip_src;
16188 cmdline_ipaddr_t ip_dst;
16190 struct rte_ether_addr eth_src;
16191 struct rte_ether_addr eth_dst;
16194 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16195 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16197 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16198 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16200 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16201 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16202 mplsoudp, "mplsoudp_encap-with-vlan");
16203 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16204 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16205 pos_token, "ip-version");
16206 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16207 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16208 ip_version, "ipv4#ipv6");
16209 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16210 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16211 pos_token, "label");
16212 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16213 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16215 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16216 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16217 pos_token, "udp-src");
16218 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16219 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16221 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16222 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16223 pos_token, "udp-dst");
16224 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16225 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16227 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16228 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16229 pos_token, "ip-src");
16230 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16231 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16232 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16233 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16234 pos_token, "ip-dst");
16235 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16236 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16237 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16238 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16239 pos_token, "vlan-tci");
16240 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16241 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16243 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16244 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16245 pos_token, "eth-src");
16246 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16247 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16249 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16250 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16251 pos_token, "eth-dst");
16252 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16253 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16256 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16257 __rte_unused struct cmdline *cl,
16258 __rte_unused void *data)
16260 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16262 uint32_t mplsoudp_label;
16265 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16268 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16269 mplsoudp_encap_conf.select_vlan = 0;
16270 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16271 mplsoudp_encap_conf.select_vlan = 1;
16272 if (strcmp(res->ip_version, "ipv4") == 0)
16273 mplsoudp_encap_conf.select_ipv4 = 1;
16274 else if (strcmp(res->ip_version, "ipv6") == 0)
16275 mplsoudp_encap_conf.select_ipv4 = 0;
16278 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16279 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16280 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16281 if (mplsoudp_encap_conf.select_ipv4) {
16282 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16283 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16285 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16286 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16288 if (mplsoudp_encap_conf.select_vlan)
16289 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16290 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16291 RTE_ETHER_ADDR_LEN);
16292 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16293 RTE_ETHER_ADDR_LEN);
16296 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16297 .f = cmd_set_mplsoudp_encap_parsed,
16299 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16300 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16301 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16303 (void *)&cmd_set_mplsoudp_encap_set,
16304 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16305 (void *)&cmd_set_mplsoudp_encap_ip_version,
16306 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16307 (void *)&cmd_set_mplsoudp_encap_label,
16308 (void *)&cmd_set_mplsoudp_encap_label_value,
16309 (void *)&cmd_set_mplsoudp_encap_udp_src,
16310 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16311 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16312 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16313 (void *)&cmd_set_mplsoudp_encap_ip_src,
16314 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16315 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16316 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16317 (void *)&cmd_set_mplsoudp_encap_eth_src,
16318 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16319 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16320 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16325 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16326 .f = cmd_set_mplsoudp_encap_parsed,
16328 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16329 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16330 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16331 " eth-src <eth-src> eth-dst <eth-dst>",
16333 (void *)&cmd_set_mplsoudp_encap_set,
16334 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16335 (void *)&cmd_set_mplsoudp_encap_ip_version,
16336 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16337 (void *)&cmd_set_mplsoudp_encap_label,
16338 (void *)&cmd_set_mplsoudp_encap_label_value,
16339 (void *)&cmd_set_mplsoudp_encap_udp_src,
16340 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16341 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16342 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16343 (void *)&cmd_set_mplsoudp_encap_ip_src,
16344 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16345 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16346 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16347 (void *)&cmd_set_mplsoudp_encap_vlan,
16348 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16349 (void *)&cmd_set_mplsoudp_encap_eth_src,
16350 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16351 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16352 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16357 /** Set MPLSoUDP decapsulation details */
16358 struct cmd_set_mplsoudp_decap_result {
16359 cmdline_fixed_string_t set;
16360 cmdline_fixed_string_t mplsoudp;
16361 cmdline_fixed_string_t pos_token;
16362 cmdline_fixed_string_t ip_version;
16363 uint32_t vlan_present:1;
16366 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16367 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16369 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16370 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16372 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16373 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16374 mplsoudp, "mplsoudp_decap-with-vlan");
16375 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16376 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16377 pos_token, "ip-version");
16378 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16379 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16380 ip_version, "ipv4#ipv6");
16382 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16383 __rte_unused struct cmdline *cl,
16384 __rte_unused void *data)
16386 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16388 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16389 mplsoudp_decap_conf.select_vlan = 0;
16390 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16391 mplsoudp_decap_conf.select_vlan = 1;
16392 if (strcmp(res->ip_version, "ipv4") == 0)
16393 mplsoudp_decap_conf.select_ipv4 = 1;
16394 else if (strcmp(res->ip_version, "ipv6") == 0)
16395 mplsoudp_decap_conf.select_ipv4 = 0;
16398 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16399 .f = cmd_set_mplsoudp_decap_parsed,
16401 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16403 (void *)&cmd_set_mplsoudp_decap_set,
16404 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16405 (void *)&cmd_set_mplsoudp_decap_ip_version,
16406 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16411 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16412 .f = cmd_set_mplsoudp_decap_parsed,
16414 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16416 (void *)&cmd_set_mplsoudp_decap_set,
16417 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16418 (void *)&cmd_set_mplsoudp_decap_ip_version,
16419 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16424 /* Strict link priority scheduling mode setting */
16426 cmd_strict_link_prio_parsed(
16427 void *parsed_result,
16428 __rte_unused struct cmdline *cl,
16429 __rte_unused void *data)
16431 struct cmd_vf_tc_bw_result *res = parsed_result;
16432 int ret = -ENOTSUP;
16434 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16437 #ifdef RTE_LIBRTE_I40E_PMD
16438 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16445 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16448 printf("invalid port_id %d\n", res->port_id);
16451 printf("function not implemented\n");
16454 printf("programming error: (%s)\n", strerror(-ret));
16458 cmdline_parse_inst_t cmd_strict_link_prio = {
16459 .f = cmd_strict_link_prio_parsed,
16461 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16463 (void *)&cmd_vf_tc_bw_set,
16464 (void *)&cmd_vf_tc_bw_tx,
16465 (void *)&cmd_vf_tc_bw_strict_link_prio,
16466 (void *)&cmd_vf_tc_bw_port_id,
16467 (void *)&cmd_vf_tc_bw_tc_map,
16472 /* Load dynamic device personalization*/
16473 struct cmd_ddp_add_result {
16474 cmdline_fixed_string_t ddp;
16475 cmdline_fixed_string_t add;
16480 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16481 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16482 cmdline_parse_token_string_t cmd_ddp_add_add =
16483 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16484 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16485 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16486 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16487 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16490 cmd_ddp_add_parsed(
16491 void *parsed_result,
16492 __rte_unused struct cmdline *cl,
16493 __rte_unused void *data)
16495 struct cmd_ddp_add_result *res = parsed_result;
16501 int ret = -ENOTSUP;
16503 if (!all_ports_stopped()) {
16504 printf("Please stop all ports first\n");
16508 filepath = strdup(res->filepath);
16509 if (filepath == NULL) {
16510 printf("Failed to allocate memory\n");
16513 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16515 buff = open_file(file_fld[0], &size);
16517 free((void *)filepath);
16521 #ifdef RTE_LIBRTE_I40E_PMD
16522 if (ret == -ENOTSUP)
16523 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16525 RTE_PMD_I40E_PKG_OP_WR_ADD);
16528 if (ret == -EEXIST)
16529 printf("Profile has already existed.\n");
16531 printf("Failed to load profile.\n");
16532 else if (file_num == 2)
16533 save_file(file_fld[1], buff, size);
16536 free((void *)filepath);
16539 cmdline_parse_inst_t cmd_ddp_add = {
16540 .f = cmd_ddp_add_parsed,
16542 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16544 (void *)&cmd_ddp_add_ddp,
16545 (void *)&cmd_ddp_add_add,
16546 (void *)&cmd_ddp_add_port_id,
16547 (void *)&cmd_ddp_add_filepath,
16552 /* Delete dynamic device personalization*/
16553 struct cmd_ddp_del_result {
16554 cmdline_fixed_string_t ddp;
16555 cmdline_fixed_string_t del;
16560 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16561 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16562 cmdline_parse_token_string_t cmd_ddp_del_del =
16563 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16564 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16565 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16566 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16567 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16570 cmd_ddp_del_parsed(
16571 void *parsed_result,
16572 __rte_unused struct cmdline *cl,
16573 __rte_unused void *data)
16575 struct cmd_ddp_del_result *res = parsed_result;
16578 int ret = -ENOTSUP;
16580 if (!all_ports_stopped()) {
16581 printf("Please stop all ports first\n");
16585 buff = open_file(res->filepath, &size);
16589 #ifdef RTE_LIBRTE_I40E_PMD
16590 if (ret == -ENOTSUP)
16591 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16593 RTE_PMD_I40E_PKG_OP_WR_DEL);
16596 if (ret == -EACCES)
16597 printf("Profile does not exist.\n");
16599 printf("Failed to delete profile.\n");
16604 cmdline_parse_inst_t cmd_ddp_del = {
16605 .f = cmd_ddp_del_parsed,
16607 .help_str = "ddp del <port_id> <backup_profile_path>",
16609 (void *)&cmd_ddp_del_ddp,
16610 (void *)&cmd_ddp_del_del,
16611 (void *)&cmd_ddp_del_port_id,
16612 (void *)&cmd_ddp_del_filepath,
16617 /* Get dynamic device personalization profile info */
16618 struct cmd_ddp_info_result {
16619 cmdline_fixed_string_t ddp;
16620 cmdline_fixed_string_t get;
16621 cmdline_fixed_string_t info;
16625 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16626 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16627 cmdline_parse_token_string_t cmd_ddp_info_get =
16628 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16629 cmdline_parse_token_string_t cmd_ddp_info_info =
16630 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16631 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16632 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16635 cmd_ddp_info_parsed(
16636 void *parsed_result,
16637 __rte_unused struct cmdline *cl,
16638 __rte_unused void *data)
16640 struct cmd_ddp_info_result *res = parsed_result;
16643 int ret = -ENOTSUP;
16644 #ifdef RTE_LIBRTE_I40E_PMD
16647 uint32_t buff_size = 0;
16648 struct rte_pmd_i40e_profile_info info;
16649 uint32_t dev_num = 0;
16650 struct rte_pmd_i40e_ddp_device_id *devs;
16651 uint32_t proto_num = 0;
16652 struct rte_pmd_i40e_proto_info *proto = NULL;
16653 uint32_t pctype_num = 0;
16654 struct rte_pmd_i40e_ptype_info *pctype;
16655 uint32_t ptype_num = 0;
16656 struct rte_pmd_i40e_ptype_info *ptype;
16661 pkg = open_file(res->filepath, &pkg_size);
16665 #ifdef RTE_LIBRTE_I40E_PMD
16666 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16667 (uint8_t *)&info, sizeof(info),
16668 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16670 printf("Global Track id: 0x%x\n", info.track_id);
16671 printf("Global Version: %d.%d.%d.%d\n",
16672 info.version.major,
16673 info.version.minor,
16674 info.version.update,
16675 info.version.draft);
16676 printf("Global Package name: %s\n\n", info.name);
16679 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16680 (uint8_t *)&info, sizeof(info),
16681 RTE_PMD_I40E_PKG_INFO_HEADER);
16683 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16684 printf("i40e Profile Version: %d.%d.%d.%d\n",
16685 info.version.major,
16686 info.version.minor,
16687 info.version.update,
16688 info.version.draft);
16689 printf("i40e Profile name: %s\n\n", info.name);
16692 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16693 (uint8_t *)&buff_size, sizeof(buff_size),
16694 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16695 if (!ret && buff_size) {
16696 buff = (uint8_t *)malloc(buff_size);
16698 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16700 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16702 printf("Package Notes:\n%s\n\n", buff);
16707 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16708 (uint8_t *)&dev_num, sizeof(dev_num),
16709 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16710 if (!ret && dev_num) {
16711 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16712 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16714 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16715 (uint8_t *)devs, buff_size,
16716 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16718 printf("List of supported devices:\n");
16719 for (i = 0; i < dev_num; i++) {
16720 printf(" %04X:%04X %04X:%04X\n",
16721 devs[i].vendor_dev_id >> 16,
16722 devs[i].vendor_dev_id & 0xFFFF,
16723 devs[i].sub_vendor_dev_id >> 16,
16724 devs[i].sub_vendor_dev_id & 0xFFFF);
16732 /* get information about protocols and packet types */
16733 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16734 (uint8_t *)&proto_num, sizeof(proto_num),
16735 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16736 if (ret || !proto_num)
16737 goto no_print_return;
16739 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16740 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16742 goto no_print_return;
16744 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16746 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16748 printf("List of used protocols:\n");
16749 for (i = 0; i < proto_num; i++)
16750 printf(" %2u: %s\n", proto[i].proto_id,
16754 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16755 (uint8_t *)&pctype_num, sizeof(pctype_num),
16756 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16757 if (ret || !pctype_num)
16758 goto no_print_pctypes;
16760 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16761 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16763 goto no_print_pctypes;
16765 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16767 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16770 goto no_print_pctypes;
16773 printf("List of defined packet classification types:\n");
16774 for (i = 0; i < pctype_num; i++) {
16775 printf(" %2u:", pctype[i].ptype_id);
16776 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16777 proto_id = pctype[i].protocols[j];
16778 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16779 for (n = 0; n < proto_num; n++) {
16780 if (proto[n].proto_id == proto_id) {
16781 printf(" %s", proto[n].name);
16794 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16796 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16797 if (ret || !ptype_num)
16798 goto no_print_return;
16800 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16801 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16803 goto no_print_return;
16805 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16807 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16810 goto no_print_return;
16812 printf("List of defined packet types:\n");
16813 for (i = 0; i < ptype_num; i++) {
16814 printf(" %2u:", ptype[i].ptype_id);
16815 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16816 proto_id = ptype[i].protocols[j];
16817 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16818 for (n = 0; n < proto_num; n++) {
16819 if (proto[n].proto_id == proto_id) {
16820 printf(" %s", proto[n].name);
16836 if (ret == -ENOTSUP)
16837 printf("Function not supported in PMD driver\n");
16841 cmdline_parse_inst_t cmd_ddp_get_info = {
16842 .f = cmd_ddp_info_parsed,
16844 .help_str = "ddp get info <profile_path>",
16846 (void *)&cmd_ddp_info_ddp,
16847 (void *)&cmd_ddp_info_get,
16848 (void *)&cmd_ddp_info_info,
16849 (void *)&cmd_ddp_info_filepath,
16854 /* Get dynamic device personalization profile info list*/
16855 #define PROFILE_INFO_SIZE 48
16856 #define MAX_PROFILE_NUM 16
16858 struct cmd_ddp_get_list_result {
16859 cmdline_fixed_string_t ddp;
16860 cmdline_fixed_string_t get;
16861 cmdline_fixed_string_t list;
16865 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16866 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16867 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16868 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16869 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16870 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16871 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16872 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16875 cmd_ddp_get_list_parsed(
16876 __rte_unused void *parsed_result,
16877 __rte_unused struct cmdline *cl,
16878 __rte_unused void *data)
16880 #ifdef RTE_LIBRTE_I40E_PMD
16881 struct cmd_ddp_get_list_result *res = parsed_result;
16882 struct rte_pmd_i40e_profile_list *p_list;
16883 struct rte_pmd_i40e_profile_info *p_info;
16888 int ret = -ENOTSUP;
16890 #ifdef RTE_LIBRTE_I40E_PMD
16891 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16892 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16894 printf("%s: Failed to malloc buffer\n", __func__);
16896 if (ret == -ENOTSUP)
16897 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16898 (uint8_t *)p_list, size);
16901 p_num = p_list->p_count;
16902 printf("Profile number is: %d\n\n", p_num);
16904 for (i = 0; i < p_num; i++) {
16905 p_info = &p_list->p_info[i];
16906 printf("Profile %d:\n", i);
16907 printf("Track id: 0x%x\n", p_info->track_id);
16908 printf("Version: %d.%d.%d.%d\n",
16909 p_info->version.major,
16910 p_info->version.minor,
16911 p_info->version.update,
16912 p_info->version.draft);
16913 printf("Profile name: %s\n\n", p_info->name);
16921 printf("Failed to get ddp list\n");
16924 cmdline_parse_inst_t cmd_ddp_get_list = {
16925 .f = cmd_ddp_get_list_parsed,
16927 .help_str = "ddp get list <port_id>",
16929 (void *)&cmd_ddp_get_list_ddp,
16930 (void *)&cmd_ddp_get_list_get,
16931 (void *)&cmd_ddp_get_list_list,
16932 (void *)&cmd_ddp_get_list_port_id,
16937 /* Configure input set */
16938 struct cmd_cfg_input_set_result {
16939 cmdline_fixed_string_t port;
16940 cmdline_fixed_string_t cfg;
16942 cmdline_fixed_string_t pctype;
16944 cmdline_fixed_string_t inset_type;
16945 cmdline_fixed_string_t opt;
16946 cmdline_fixed_string_t field;
16951 cmd_cfg_input_set_parsed(
16952 __rte_unused void *parsed_result,
16953 __rte_unused struct cmdline *cl,
16954 __rte_unused void *data)
16956 #ifdef RTE_LIBRTE_I40E_PMD
16957 struct cmd_cfg_input_set_result *res = parsed_result;
16958 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16959 struct rte_pmd_i40e_inset inset;
16961 int ret = -ENOTSUP;
16963 if (!all_ports_stopped()) {
16964 printf("Please stop all ports first\n");
16968 #ifdef RTE_LIBRTE_I40E_PMD
16969 if (!strcmp(res->inset_type, "hash_inset"))
16970 inset_type = INSET_HASH;
16971 else if (!strcmp(res->inset_type, "fdir_inset"))
16972 inset_type = INSET_FDIR;
16973 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16974 inset_type = INSET_FDIR_FLX;
16975 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16976 &inset, inset_type);
16978 printf("Failed to get input set.\n");
16982 if (!strcmp(res->opt, "get")) {
16983 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16986 printf("Field index %d is enabled.\n", res->field_idx);
16988 printf("Field index %d is disabled.\n", res->field_idx);
16990 } else if (!strcmp(res->opt, "set"))
16991 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16993 else if (!strcmp(res->opt, "clear"))
16994 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16997 printf("Failed to configure input set field.\n");
17001 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17002 &inset, inset_type);
17004 printf("Failed to set input set.\n");
17009 if (ret == -ENOTSUP)
17010 printf("Function not supported\n");
17013 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17014 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17016 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17017 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17019 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17020 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17022 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17023 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17025 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17026 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17028 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17029 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17031 "hash_inset#fdir_inset#fdir_flx_inset");
17032 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17033 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17034 opt, "get#set#clear");
17035 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17036 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17038 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17039 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17042 cmdline_parse_inst_t cmd_cfg_input_set = {
17043 .f = cmd_cfg_input_set_parsed,
17045 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17046 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17048 (void *)&cmd_cfg_input_set_port,
17049 (void *)&cmd_cfg_input_set_cfg,
17050 (void *)&cmd_cfg_input_set_port_id,
17051 (void *)&cmd_cfg_input_set_pctype,
17052 (void *)&cmd_cfg_input_set_pctype_id,
17053 (void *)&cmd_cfg_input_set_inset_type,
17054 (void *)&cmd_cfg_input_set_opt,
17055 (void *)&cmd_cfg_input_set_field,
17056 (void *)&cmd_cfg_input_set_field_idx,
17061 /* Clear input set */
17062 struct cmd_clear_input_set_result {
17063 cmdline_fixed_string_t port;
17064 cmdline_fixed_string_t cfg;
17066 cmdline_fixed_string_t pctype;
17068 cmdline_fixed_string_t inset_type;
17069 cmdline_fixed_string_t clear;
17070 cmdline_fixed_string_t all;
17074 cmd_clear_input_set_parsed(
17075 __rte_unused void *parsed_result,
17076 __rte_unused struct cmdline *cl,
17077 __rte_unused void *data)
17079 #ifdef RTE_LIBRTE_I40E_PMD
17080 struct cmd_clear_input_set_result *res = parsed_result;
17081 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17082 struct rte_pmd_i40e_inset inset;
17084 int ret = -ENOTSUP;
17086 if (!all_ports_stopped()) {
17087 printf("Please stop all ports first\n");
17091 #ifdef RTE_LIBRTE_I40E_PMD
17092 if (!strcmp(res->inset_type, "hash_inset"))
17093 inset_type = INSET_HASH;
17094 else if (!strcmp(res->inset_type, "fdir_inset"))
17095 inset_type = INSET_FDIR;
17096 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17097 inset_type = INSET_FDIR_FLX;
17099 memset(&inset, 0, sizeof(inset));
17101 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17102 &inset, inset_type);
17104 printf("Failed to clear input set.\n");
17110 if (ret == -ENOTSUP)
17111 printf("Function not supported\n");
17114 cmdline_parse_token_string_t cmd_clear_input_set_port =
17115 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17117 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17118 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17120 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17121 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17123 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17124 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17126 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17127 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17129 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17130 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17132 "hash_inset#fdir_inset#fdir_flx_inset");
17133 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17134 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17136 cmdline_parse_token_string_t cmd_clear_input_set_all =
17137 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17140 cmdline_parse_inst_t cmd_clear_input_set = {
17141 .f = cmd_clear_input_set_parsed,
17143 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17144 "fdir_inset|fdir_flx_inset clear all",
17146 (void *)&cmd_clear_input_set_port,
17147 (void *)&cmd_clear_input_set_cfg,
17148 (void *)&cmd_clear_input_set_port_id,
17149 (void *)&cmd_clear_input_set_pctype,
17150 (void *)&cmd_clear_input_set_pctype_id,
17151 (void *)&cmd_clear_input_set_inset_type,
17152 (void *)&cmd_clear_input_set_clear,
17153 (void *)&cmd_clear_input_set_all,
17158 /* show vf stats */
17160 /* Common result structure for show vf stats */
17161 struct cmd_show_vf_stats_result {
17162 cmdline_fixed_string_t show;
17163 cmdline_fixed_string_t vf;
17164 cmdline_fixed_string_t stats;
17169 /* Common CLI fields show vf stats*/
17170 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17171 TOKEN_STRING_INITIALIZER
17172 (struct cmd_show_vf_stats_result,
17174 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17175 TOKEN_STRING_INITIALIZER
17176 (struct cmd_show_vf_stats_result,
17178 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17179 TOKEN_STRING_INITIALIZER
17180 (struct cmd_show_vf_stats_result,
17182 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17183 TOKEN_NUM_INITIALIZER
17184 (struct cmd_show_vf_stats_result,
17186 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17187 TOKEN_NUM_INITIALIZER
17188 (struct cmd_show_vf_stats_result,
17192 cmd_show_vf_stats_parsed(
17193 void *parsed_result,
17194 __rte_unused struct cmdline *cl,
17195 __rte_unused void *data)
17197 struct cmd_show_vf_stats_result *res = parsed_result;
17198 struct rte_eth_stats stats;
17199 int ret = -ENOTSUP;
17200 static const char *nic_stats_border = "########################";
17202 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17205 memset(&stats, 0, sizeof(stats));
17207 #ifdef RTE_LIBRTE_I40E_PMD
17208 if (ret == -ENOTSUP)
17209 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17213 #ifdef RTE_LIBRTE_BNXT_PMD
17214 if (ret == -ENOTSUP)
17215 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17224 printf("invalid vf_id %d\n", res->vf_id);
17227 printf("invalid port_id %d\n", res->port_id);
17230 printf("function not implemented\n");
17233 printf("programming error: (%s)\n", strerror(-ret));
17236 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17237 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17239 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17241 stats.ipackets, stats.imissed, stats.ibytes);
17242 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17243 printf(" RX-nombuf: %-10"PRIu64"\n",
17245 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17247 stats.opackets, stats.oerrors, stats.obytes);
17249 printf(" %s############################%s\n",
17250 nic_stats_border, nic_stats_border);
17253 cmdline_parse_inst_t cmd_show_vf_stats = {
17254 .f = cmd_show_vf_stats_parsed,
17256 .help_str = "show vf stats <port_id> <vf_id>",
17258 (void *)&cmd_show_vf_stats_show,
17259 (void *)&cmd_show_vf_stats_vf,
17260 (void *)&cmd_show_vf_stats_stats,
17261 (void *)&cmd_show_vf_stats_port_id,
17262 (void *)&cmd_show_vf_stats_vf_id,
17267 /* clear vf stats */
17269 /* Common result structure for clear vf stats */
17270 struct cmd_clear_vf_stats_result {
17271 cmdline_fixed_string_t clear;
17272 cmdline_fixed_string_t vf;
17273 cmdline_fixed_string_t stats;
17278 /* Common CLI fields clear vf stats*/
17279 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17280 TOKEN_STRING_INITIALIZER
17281 (struct cmd_clear_vf_stats_result,
17283 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17284 TOKEN_STRING_INITIALIZER
17285 (struct cmd_clear_vf_stats_result,
17287 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17288 TOKEN_STRING_INITIALIZER
17289 (struct cmd_clear_vf_stats_result,
17291 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17292 TOKEN_NUM_INITIALIZER
17293 (struct cmd_clear_vf_stats_result,
17295 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17296 TOKEN_NUM_INITIALIZER
17297 (struct cmd_clear_vf_stats_result,
17301 cmd_clear_vf_stats_parsed(
17302 void *parsed_result,
17303 __rte_unused struct cmdline *cl,
17304 __rte_unused void *data)
17306 struct cmd_clear_vf_stats_result *res = parsed_result;
17307 int ret = -ENOTSUP;
17309 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17312 #ifdef RTE_LIBRTE_I40E_PMD
17313 if (ret == -ENOTSUP)
17314 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17317 #ifdef RTE_LIBRTE_BNXT_PMD
17318 if (ret == -ENOTSUP)
17319 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17327 printf("invalid vf_id %d\n", res->vf_id);
17330 printf("invalid port_id %d\n", res->port_id);
17333 printf("function not implemented\n");
17336 printf("programming error: (%s)\n", strerror(-ret));
17340 cmdline_parse_inst_t cmd_clear_vf_stats = {
17341 .f = cmd_clear_vf_stats_parsed,
17343 .help_str = "clear vf stats <port_id> <vf_id>",
17345 (void *)&cmd_clear_vf_stats_clear,
17346 (void *)&cmd_clear_vf_stats_vf,
17347 (void *)&cmd_clear_vf_stats_stats,
17348 (void *)&cmd_clear_vf_stats_port_id,
17349 (void *)&cmd_clear_vf_stats_vf_id,
17354 /* port config pctype mapping reset */
17356 /* Common result structure for port config pctype mapping reset */
17357 struct cmd_pctype_mapping_reset_result {
17358 cmdline_fixed_string_t port;
17359 cmdline_fixed_string_t config;
17361 cmdline_fixed_string_t pctype;
17362 cmdline_fixed_string_t mapping;
17363 cmdline_fixed_string_t reset;
17366 /* Common CLI fields for port config pctype mapping reset*/
17367 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17368 TOKEN_STRING_INITIALIZER
17369 (struct cmd_pctype_mapping_reset_result,
17371 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17372 TOKEN_STRING_INITIALIZER
17373 (struct cmd_pctype_mapping_reset_result,
17375 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17376 TOKEN_NUM_INITIALIZER
17377 (struct cmd_pctype_mapping_reset_result,
17379 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17380 TOKEN_STRING_INITIALIZER
17381 (struct cmd_pctype_mapping_reset_result,
17383 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17384 TOKEN_STRING_INITIALIZER
17385 (struct cmd_pctype_mapping_reset_result,
17386 mapping, "mapping");
17387 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17388 TOKEN_STRING_INITIALIZER
17389 (struct cmd_pctype_mapping_reset_result,
17393 cmd_pctype_mapping_reset_parsed(
17394 void *parsed_result,
17395 __rte_unused struct cmdline *cl,
17396 __rte_unused void *data)
17398 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17399 int ret = -ENOTSUP;
17401 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17404 #ifdef RTE_LIBRTE_I40E_PMD
17405 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17412 printf("invalid port_id %d\n", res->port_id);
17415 printf("function not implemented\n");
17418 printf("programming error: (%s)\n", strerror(-ret));
17422 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17423 .f = cmd_pctype_mapping_reset_parsed,
17425 .help_str = "port config <port_id> pctype mapping reset",
17427 (void *)&cmd_pctype_mapping_reset_port,
17428 (void *)&cmd_pctype_mapping_reset_config,
17429 (void *)&cmd_pctype_mapping_reset_port_id,
17430 (void *)&cmd_pctype_mapping_reset_pctype,
17431 (void *)&cmd_pctype_mapping_reset_mapping,
17432 (void *)&cmd_pctype_mapping_reset_reset,
17437 /* show port pctype mapping */
17439 /* Common result structure for show port pctype mapping */
17440 struct cmd_pctype_mapping_get_result {
17441 cmdline_fixed_string_t show;
17442 cmdline_fixed_string_t port;
17444 cmdline_fixed_string_t pctype;
17445 cmdline_fixed_string_t mapping;
17448 /* Common CLI fields for pctype mapping get */
17449 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17450 TOKEN_STRING_INITIALIZER
17451 (struct cmd_pctype_mapping_get_result,
17453 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17454 TOKEN_STRING_INITIALIZER
17455 (struct cmd_pctype_mapping_get_result,
17457 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17458 TOKEN_NUM_INITIALIZER
17459 (struct cmd_pctype_mapping_get_result,
17461 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17462 TOKEN_STRING_INITIALIZER
17463 (struct cmd_pctype_mapping_get_result,
17465 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17466 TOKEN_STRING_INITIALIZER
17467 (struct cmd_pctype_mapping_get_result,
17468 mapping, "mapping");
17471 cmd_pctype_mapping_get_parsed(
17472 void *parsed_result,
17473 __rte_unused struct cmdline *cl,
17474 __rte_unused void *data)
17476 struct cmd_pctype_mapping_get_result *res = parsed_result;
17477 int ret = -ENOTSUP;
17478 #ifdef RTE_LIBRTE_I40E_PMD
17479 struct rte_pmd_i40e_flow_type_mapping
17480 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17481 int i, j, first_pctype;
17484 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17487 #ifdef RTE_LIBRTE_I40E_PMD
17488 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17495 printf("invalid port_id %d\n", res->port_id);
17498 printf("function not implemented\n");
17501 printf("programming error: (%s)\n", strerror(-ret));
17505 #ifdef RTE_LIBRTE_I40E_PMD
17506 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17507 if (mapping[i].pctype != 0ULL) {
17510 printf("pctype: ");
17511 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17512 if (mapping[i].pctype & (1ULL << j)) {
17513 printf(first_pctype ?
17514 "%02d" : ",%02d", j);
17518 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17524 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17525 .f = cmd_pctype_mapping_get_parsed,
17527 .help_str = "show port <port_id> pctype mapping",
17529 (void *)&cmd_pctype_mapping_get_show,
17530 (void *)&cmd_pctype_mapping_get_port,
17531 (void *)&cmd_pctype_mapping_get_port_id,
17532 (void *)&cmd_pctype_mapping_get_pctype,
17533 (void *)&cmd_pctype_mapping_get_mapping,
17538 /* port config pctype mapping update */
17540 /* Common result structure for port config pctype mapping update */
17541 struct cmd_pctype_mapping_update_result {
17542 cmdline_fixed_string_t port;
17543 cmdline_fixed_string_t config;
17545 cmdline_fixed_string_t pctype;
17546 cmdline_fixed_string_t mapping;
17547 cmdline_fixed_string_t update;
17548 cmdline_fixed_string_t pctype_list;
17549 uint16_t flow_type;
17552 /* Common CLI fields for pctype mapping update*/
17553 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17554 TOKEN_STRING_INITIALIZER
17555 (struct cmd_pctype_mapping_update_result,
17557 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17558 TOKEN_STRING_INITIALIZER
17559 (struct cmd_pctype_mapping_update_result,
17561 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17562 TOKEN_NUM_INITIALIZER
17563 (struct cmd_pctype_mapping_update_result,
17565 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17566 TOKEN_STRING_INITIALIZER
17567 (struct cmd_pctype_mapping_update_result,
17569 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17570 TOKEN_STRING_INITIALIZER
17571 (struct cmd_pctype_mapping_update_result,
17572 mapping, "mapping");
17573 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17574 TOKEN_STRING_INITIALIZER
17575 (struct cmd_pctype_mapping_update_result,
17577 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17578 TOKEN_STRING_INITIALIZER
17579 (struct cmd_pctype_mapping_update_result,
17580 pctype_list, NULL);
17581 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17582 TOKEN_NUM_INITIALIZER
17583 (struct cmd_pctype_mapping_update_result,
17584 flow_type, UINT16);
17587 cmd_pctype_mapping_update_parsed(
17588 void *parsed_result,
17589 __rte_unused struct cmdline *cl,
17590 __rte_unused void *data)
17592 struct cmd_pctype_mapping_update_result *res = parsed_result;
17593 int ret = -ENOTSUP;
17594 #ifdef RTE_LIBRTE_I40E_PMD
17595 struct rte_pmd_i40e_flow_type_mapping mapping;
17597 unsigned int nb_item;
17598 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17601 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17604 #ifdef RTE_LIBRTE_I40E_PMD
17605 nb_item = parse_item_list(res->pctype_list, "pctypes",
17606 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17607 mapping.flow_type = res->flow_type;
17608 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17609 mapping.pctype |= (1ULL << pctype_list[i]);
17610 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17620 printf("invalid pctype or flow type\n");
17623 printf("invalid port_id %d\n", res->port_id);
17626 printf("function not implemented\n");
17629 printf("programming error: (%s)\n", strerror(-ret));
17633 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17634 .f = cmd_pctype_mapping_update_parsed,
17636 .help_str = "port config <port_id> pctype mapping update"
17637 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17639 (void *)&cmd_pctype_mapping_update_port,
17640 (void *)&cmd_pctype_mapping_update_config,
17641 (void *)&cmd_pctype_mapping_update_port_id,
17642 (void *)&cmd_pctype_mapping_update_pctype,
17643 (void *)&cmd_pctype_mapping_update_mapping,
17644 (void *)&cmd_pctype_mapping_update_update,
17645 (void *)&cmd_pctype_mapping_update_pc_type,
17646 (void *)&cmd_pctype_mapping_update_flow_type,
17651 /* ptype mapping get */
17653 /* Common result structure for ptype mapping get */
17654 struct cmd_ptype_mapping_get_result {
17655 cmdline_fixed_string_t ptype;
17656 cmdline_fixed_string_t mapping;
17657 cmdline_fixed_string_t get;
17659 uint8_t valid_only;
17662 /* Common CLI fields for ptype mapping get */
17663 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17664 TOKEN_STRING_INITIALIZER
17665 (struct cmd_ptype_mapping_get_result,
17667 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17668 TOKEN_STRING_INITIALIZER
17669 (struct cmd_ptype_mapping_get_result,
17670 mapping, "mapping");
17671 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17672 TOKEN_STRING_INITIALIZER
17673 (struct cmd_ptype_mapping_get_result,
17675 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17676 TOKEN_NUM_INITIALIZER
17677 (struct cmd_ptype_mapping_get_result,
17679 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17680 TOKEN_NUM_INITIALIZER
17681 (struct cmd_ptype_mapping_get_result,
17682 valid_only, UINT8);
17685 cmd_ptype_mapping_get_parsed(
17686 void *parsed_result,
17687 __rte_unused struct cmdline *cl,
17688 __rte_unused void *data)
17690 struct cmd_ptype_mapping_get_result *res = parsed_result;
17691 int ret = -ENOTSUP;
17692 #ifdef RTE_LIBRTE_I40E_PMD
17693 int max_ptype_num = 256;
17694 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17702 #ifdef RTE_LIBRTE_I40E_PMD
17703 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17714 printf("invalid port_id %d\n", res->port_id);
17717 printf("function not implemented\n");
17720 printf("programming error: (%s)\n", strerror(-ret));
17723 #ifdef RTE_LIBRTE_I40E_PMD
17725 for (i = 0; i < count; i++)
17726 printf("%3d\t0x%08x\n",
17727 mapping[i].hw_ptype, mapping[i].sw_ptype);
17732 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17733 .f = cmd_ptype_mapping_get_parsed,
17735 .help_str = "ptype mapping get <port_id> <valid_only>",
17737 (void *)&cmd_ptype_mapping_get_ptype,
17738 (void *)&cmd_ptype_mapping_get_mapping,
17739 (void *)&cmd_ptype_mapping_get_get,
17740 (void *)&cmd_ptype_mapping_get_port_id,
17741 (void *)&cmd_ptype_mapping_get_valid_only,
17746 /* ptype mapping replace */
17748 /* Common result structure for ptype mapping replace */
17749 struct cmd_ptype_mapping_replace_result {
17750 cmdline_fixed_string_t ptype;
17751 cmdline_fixed_string_t mapping;
17752 cmdline_fixed_string_t replace;
17759 /* Common CLI fields for ptype mapping replace */
17760 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17761 TOKEN_STRING_INITIALIZER
17762 (struct cmd_ptype_mapping_replace_result,
17764 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17765 TOKEN_STRING_INITIALIZER
17766 (struct cmd_ptype_mapping_replace_result,
17767 mapping, "mapping");
17768 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17769 TOKEN_STRING_INITIALIZER
17770 (struct cmd_ptype_mapping_replace_result,
17771 replace, "replace");
17772 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17773 TOKEN_NUM_INITIALIZER
17774 (struct cmd_ptype_mapping_replace_result,
17776 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17777 TOKEN_NUM_INITIALIZER
17778 (struct cmd_ptype_mapping_replace_result,
17780 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17781 TOKEN_NUM_INITIALIZER
17782 (struct cmd_ptype_mapping_replace_result,
17784 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17785 TOKEN_NUM_INITIALIZER
17786 (struct cmd_ptype_mapping_replace_result,
17790 cmd_ptype_mapping_replace_parsed(
17791 void *parsed_result,
17792 __rte_unused struct cmdline *cl,
17793 __rte_unused void *data)
17795 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17796 int ret = -ENOTSUP;
17798 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17801 #ifdef RTE_LIBRTE_I40E_PMD
17802 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17812 printf("invalid ptype 0x%8x or 0x%8x\n",
17813 res->target, res->pkt_type);
17816 printf("invalid port_id %d\n", res->port_id);
17819 printf("function not implemented\n");
17822 printf("programming error: (%s)\n", strerror(-ret));
17826 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17827 .f = cmd_ptype_mapping_replace_parsed,
17830 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17832 (void *)&cmd_ptype_mapping_replace_ptype,
17833 (void *)&cmd_ptype_mapping_replace_mapping,
17834 (void *)&cmd_ptype_mapping_replace_replace,
17835 (void *)&cmd_ptype_mapping_replace_port_id,
17836 (void *)&cmd_ptype_mapping_replace_target,
17837 (void *)&cmd_ptype_mapping_replace_mask,
17838 (void *)&cmd_ptype_mapping_replace_pkt_type,
17843 /* ptype mapping reset */
17845 /* Common result structure for ptype mapping reset */
17846 struct cmd_ptype_mapping_reset_result {
17847 cmdline_fixed_string_t ptype;
17848 cmdline_fixed_string_t mapping;
17849 cmdline_fixed_string_t reset;
17853 /* Common CLI fields for ptype mapping reset*/
17854 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17855 TOKEN_STRING_INITIALIZER
17856 (struct cmd_ptype_mapping_reset_result,
17858 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17859 TOKEN_STRING_INITIALIZER
17860 (struct cmd_ptype_mapping_reset_result,
17861 mapping, "mapping");
17862 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17863 TOKEN_STRING_INITIALIZER
17864 (struct cmd_ptype_mapping_reset_result,
17866 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17867 TOKEN_NUM_INITIALIZER
17868 (struct cmd_ptype_mapping_reset_result,
17872 cmd_ptype_mapping_reset_parsed(
17873 void *parsed_result,
17874 __rte_unused struct cmdline *cl,
17875 __rte_unused void *data)
17877 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17878 int ret = -ENOTSUP;
17880 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17883 #ifdef RTE_LIBRTE_I40E_PMD
17884 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17891 printf("invalid port_id %d\n", res->port_id);
17894 printf("function not implemented\n");
17897 printf("programming error: (%s)\n", strerror(-ret));
17901 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17902 .f = cmd_ptype_mapping_reset_parsed,
17904 .help_str = "ptype mapping reset <port_id>",
17906 (void *)&cmd_ptype_mapping_reset_ptype,
17907 (void *)&cmd_ptype_mapping_reset_mapping,
17908 (void *)&cmd_ptype_mapping_reset_reset,
17909 (void *)&cmd_ptype_mapping_reset_port_id,
17914 /* ptype mapping update */
17916 /* Common result structure for ptype mapping update */
17917 struct cmd_ptype_mapping_update_result {
17918 cmdline_fixed_string_t ptype;
17919 cmdline_fixed_string_t mapping;
17920 cmdline_fixed_string_t reset;
17926 /* Common CLI fields for ptype mapping update*/
17927 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17928 TOKEN_STRING_INITIALIZER
17929 (struct cmd_ptype_mapping_update_result,
17931 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17932 TOKEN_STRING_INITIALIZER
17933 (struct cmd_ptype_mapping_update_result,
17934 mapping, "mapping");
17935 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17936 TOKEN_STRING_INITIALIZER
17937 (struct cmd_ptype_mapping_update_result,
17939 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17940 TOKEN_NUM_INITIALIZER
17941 (struct cmd_ptype_mapping_update_result,
17943 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17944 TOKEN_NUM_INITIALIZER
17945 (struct cmd_ptype_mapping_update_result,
17947 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17948 TOKEN_NUM_INITIALIZER
17949 (struct cmd_ptype_mapping_update_result,
17953 cmd_ptype_mapping_update_parsed(
17954 void *parsed_result,
17955 __rte_unused struct cmdline *cl,
17956 __rte_unused void *data)
17958 struct cmd_ptype_mapping_update_result *res = parsed_result;
17959 int ret = -ENOTSUP;
17960 #ifdef RTE_LIBRTE_I40E_PMD
17961 struct rte_pmd_i40e_ptype_mapping mapping;
17963 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17966 #ifdef RTE_LIBRTE_I40E_PMD
17967 mapping.hw_ptype = res->hw_ptype;
17968 mapping.sw_ptype = res->sw_ptype;
17969 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17979 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17982 printf("invalid port_id %d\n", res->port_id);
17985 printf("function not implemented\n");
17988 printf("programming error: (%s)\n", strerror(-ret));
17992 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17993 .f = cmd_ptype_mapping_update_parsed,
17995 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17997 (void *)&cmd_ptype_mapping_update_ptype,
17998 (void *)&cmd_ptype_mapping_update_mapping,
17999 (void *)&cmd_ptype_mapping_update_update,
18000 (void *)&cmd_ptype_mapping_update_port_id,
18001 (void *)&cmd_ptype_mapping_update_hw_ptype,
18002 (void *)&cmd_ptype_mapping_update_sw_ptype,
18007 /* Common result structure for file commands */
18008 struct cmd_cmdfile_result {
18009 cmdline_fixed_string_t load;
18010 cmdline_fixed_string_t filename;
18013 /* Common CLI fields for file commands */
18014 cmdline_parse_token_string_t cmd_load_cmdfile =
18015 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18016 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18017 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18020 cmd_load_from_file_parsed(
18021 void *parsed_result,
18022 __rte_unused struct cmdline *cl,
18023 __rte_unused void *data)
18025 struct cmd_cmdfile_result *res = parsed_result;
18027 cmdline_read_from_file(res->filename);
18030 cmdline_parse_inst_t cmd_load_from_file = {
18031 .f = cmd_load_from_file_parsed,
18033 .help_str = "load <filename>",
18035 (void *)&cmd_load_cmdfile,
18036 (void *)&cmd_load_cmdfile_filename,
18041 /* Get Rx offloads capabilities */
18042 struct cmd_rx_offload_get_capa_result {
18043 cmdline_fixed_string_t show;
18044 cmdline_fixed_string_t port;
18046 cmdline_fixed_string_t rx_offload;
18047 cmdline_fixed_string_t capabilities;
18050 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18051 TOKEN_STRING_INITIALIZER
18052 (struct cmd_rx_offload_get_capa_result,
18054 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18055 TOKEN_STRING_INITIALIZER
18056 (struct cmd_rx_offload_get_capa_result,
18058 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18059 TOKEN_NUM_INITIALIZER
18060 (struct cmd_rx_offload_get_capa_result,
18062 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18063 TOKEN_STRING_INITIALIZER
18064 (struct cmd_rx_offload_get_capa_result,
18065 rx_offload, "rx_offload");
18066 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18067 TOKEN_STRING_INITIALIZER
18068 (struct cmd_rx_offload_get_capa_result,
18069 capabilities, "capabilities");
18072 print_rx_offloads(uint64_t offloads)
18074 uint64_t single_offload;
18082 begin = __builtin_ctzll(offloads);
18083 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18085 single_offload = 1ULL << begin;
18086 for (bit = begin; bit < end; bit++) {
18087 if (offloads & single_offload)
18089 rte_eth_dev_rx_offload_name(single_offload));
18090 single_offload <<= 1;
18095 cmd_rx_offload_get_capa_parsed(
18096 void *parsed_result,
18097 __rte_unused struct cmdline *cl,
18098 __rte_unused void *data)
18100 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18101 struct rte_eth_dev_info dev_info;
18102 portid_t port_id = res->port_id;
18103 uint64_t queue_offloads;
18104 uint64_t port_offloads;
18107 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18111 queue_offloads = dev_info.rx_queue_offload_capa;
18112 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18114 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18115 printf(" Per Queue :");
18116 print_rx_offloads(queue_offloads);
18119 printf(" Per Port :");
18120 print_rx_offloads(port_offloads);
18124 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18125 .f = cmd_rx_offload_get_capa_parsed,
18127 .help_str = "show port <port_id> rx_offload capabilities",
18129 (void *)&cmd_rx_offload_get_capa_show,
18130 (void *)&cmd_rx_offload_get_capa_port,
18131 (void *)&cmd_rx_offload_get_capa_port_id,
18132 (void *)&cmd_rx_offload_get_capa_rx_offload,
18133 (void *)&cmd_rx_offload_get_capa_capabilities,
18138 /* Get Rx offloads configuration */
18139 struct cmd_rx_offload_get_configuration_result {
18140 cmdline_fixed_string_t show;
18141 cmdline_fixed_string_t port;
18143 cmdline_fixed_string_t rx_offload;
18144 cmdline_fixed_string_t configuration;
18147 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18148 TOKEN_STRING_INITIALIZER
18149 (struct cmd_rx_offload_get_configuration_result,
18151 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18152 TOKEN_STRING_INITIALIZER
18153 (struct cmd_rx_offload_get_configuration_result,
18155 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18156 TOKEN_NUM_INITIALIZER
18157 (struct cmd_rx_offload_get_configuration_result,
18159 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18160 TOKEN_STRING_INITIALIZER
18161 (struct cmd_rx_offload_get_configuration_result,
18162 rx_offload, "rx_offload");
18163 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18164 TOKEN_STRING_INITIALIZER
18165 (struct cmd_rx_offload_get_configuration_result,
18166 configuration, "configuration");
18169 cmd_rx_offload_get_configuration_parsed(
18170 void *parsed_result,
18171 __rte_unused struct cmdline *cl,
18172 __rte_unused void *data)
18174 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18175 struct rte_eth_dev_info dev_info;
18176 portid_t port_id = res->port_id;
18177 struct rte_port *port = &ports[port_id];
18178 uint64_t port_offloads;
18179 uint64_t queue_offloads;
18180 uint16_t nb_rx_queues;
18184 printf("Rx Offloading Configuration of port %d :\n", port_id);
18186 port_offloads = port->dev_conf.rxmode.offloads;
18188 print_rx_offloads(port_offloads);
18191 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18195 nb_rx_queues = dev_info.nb_rx_queues;
18196 for (q = 0; q < nb_rx_queues; q++) {
18197 queue_offloads = port->rx_conf[q].offloads;
18198 printf(" Queue[%2d] :", q);
18199 print_rx_offloads(queue_offloads);
18205 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18206 .f = cmd_rx_offload_get_configuration_parsed,
18208 .help_str = "show port <port_id> rx_offload configuration",
18210 (void *)&cmd_rx_offload_get_configuration_show,
18211 (void *)&cmd_rx_offload_get_configuration_port,
18212 (void *)&cmd_rx_offload_get_configuration_port_id,
18213 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18214 (void *)&cmd_rx_offload_get_configuration_configuration,
18219 /* Enable/Disable a per port offloading */
18220 struct cmd_config_per_port_rx_offload_result {
18221 cmdline_fixed_string_t port;
18222 cmdline_fixed_string_t config;
18224 cmdline_fixed_string_t rx_offload;
18225 cmdline_fixed_string_t offload;
18226 cmdline_fixed_string_t on_off;
18229 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18230 TOKEN_STRING_INITIALIZER
18231 (struct cmd_config_per_port_rx_offload_result,
18233 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18234 TOKEN_STRING_INITIALIZER
18235 (struct cmd_config_per_port_rx_offload_result,
18237 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18238 TOKEN_NUM_INITIALIZER
18239 (struct cmd_config_per_port_rx_offload_result,
18241 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18242 TOKEN_STRING_INITIALIZER
18243 (struct cmd_config_per_port_rx_offload_result,
18244 rx_offload, "rx_offload");
18245 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18246 TOKEN_STRING_INITIALIZER
18247 (struct cmd_config_per_port_rx_offload_result,
18248 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18249 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18250 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18251 "scatter#timestamp#security#keep_crc#rss_hash");
18252 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18253 TOKEN_STRING_INITIALIZER
18254 (struct cmd_config_per_port_rx_offload_result,
18258 search_rx_offload(const char *name)
18260 uint64_t single_offload;
18261 const char *single_name;
18265 single_offload = 1;
18266 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18267 single_name = rte_eth_dev_rx_offload_name(single_offload);
18268 if (!strcasecmp(single_name, name)) {
18272 single_offload <<= 1;
18276 return single_offload;
18282 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18283 __rte_unused struct cmdline *cl,
18284 __rte_unused void *data)
18286 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18287 portid_t port_id = res->port_id;
18288 struct rte_eth_dev_info dev_info;
18289 struct rte_port *port = &ports[port_id];
18290 uint64_t single_offload;
18291 uint16_t nb_rx_queues;
18295 if (port->port_status != RTE_PORT_STOPPED) {
18296 printf("Error: Can't config offload when Port %d "
18297 "is not stopped\n", port_id);
18301 single_offload = search_rx_offload(res->offload);
18302 if (single_offload == 0) {
18303 printf("Unknown offload name: %s\n", res->offload);
18307 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18311 nb_rx_queues = dev_info.nb_rx_queues;
18312 if (!strcmp(res->on_off, "on")) {
18313 port->dev_conf.rxmode.offloads |= single_offload;
18314 for (q = 0; q < nb_rx_queues; q++)
18315 port->rx_conf[q].offloads |= single_offload;
18317 port->dev_conf.rxmode.offloads &= ~single_offload;
18318 for (q = 0; q < nb_rx_queues; q++)
18319 port->rx_conf[q].offloads &= ~single_offload;
18322 cmd_reconfig_device_queue(port_id, 1, 1);
18325 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18326 .f = cmd_config_per_port_rx_offload_parsed,
18328 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18329 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18330 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18331 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18334 (void *)&cmd_config_per_port_rx_offload_result_port,
18335 (void *)&cmd_config_per_port_rx_offload_result_config,
18336 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18337 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18338 (void *)&cmd_config_per_port_rx_offload_result_offload,
18339 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18344 /* Enable/Disable a per queue offloading */
18345 struct cmd_config_per_queue_rx_offload_result {
18346 cmdline_fixed_string_t port;
18348 cmdline_fixed_string_t rxq;
18350 cmdline_fixed_string_t rx_offload;
18351 cmdline_fixed_string_t offload;
18352 cmdline_fixed_string_t on_off;
18355 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18356 TOKEN_STRING_INITIALIZER
18357 (struct cmd_config_per_queue_rx_offload_result,
18359 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18360 TOKEN_NUM_INITIALIZER
18361 (struct cmd_config_per_queue_rx_offload_result,
18363 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18364 TOKEN_STRING_INITIALIZER
18365 (struct cmd_config_per_queue_rx_offload_result,
18367 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18368 TOKEN_NUM_INITIALIZER
18369 (struct cmd_config_per_queue_rx_offload_result,
18371 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18372 TOKEN_STRING_INITIALIZER
18373 (struct cmd_config_per_queue_rx_offload_result,
18374 rx_offload, "rx_offload");
18375 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18376 TOKEN_STRING_INITIALIZER
18377 (struct cmd_config_per_queue_rx_offload_result,
18378 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18379 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18380 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18381 "scatter#timestamp#security#keep_crc");
18382 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18383 TOKEN_STRING_INITIALIZER
18384 (struct cmd_config_per_queue_rx_offload_result,
18388 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18389 __rte_unused struct cmdline *cl,
18390 __rte_unused void *data)
18392 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18393 struct rte_eth_dev_info dev_info;
18394 portid_t port_id = res->port_id;
18395 uint16_t queue_id = res->queue_id;
18396 struct rte_port *port = &ports[port_id];
18397 uint64_t single_offload;
18400 if (port->port_status != RTE_PORT_STOPPED) {
18401 printf("Error: Can't config offload when Port %d "
18402 "is not stopped\n", port_id);
18406 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18410 if (queue_id >= dev_info.nb_rx_queues) {
18411 printf("Error: input queue_id should be 0 ... "
18412 "%d\n", dev_info.nb_rx_queues - 1);
18416 single_offload = search_rx_offload(res->offload);
18417 if (single_offload == 0) {
18418 printf("Unknown offload name: %s\n", res->offload);
18422 if (!strcmp(res->on_off, "on"))
18423 port->rx_conf[queue_id].offloads |= single_offload;
18425 port->rx_conf[queue_id].offloads &= ~single_offload;
18427 cmd_reconfig_device_queue(port_id, 1, 1);
18430 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18431 .f = cmd_config_per_queue_rx_offload_parsed,
18433 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18434 "vlan_strip|ipv4_cksum|"
18435 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18436 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18437 "jumbo_frame|scatter|timestamp|security|keep_crc "
18440 (void *)&cmd_config_per_queue_rx_offload_result_port,
18441 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18442 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18443 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18444 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18445 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18446 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18451 /* Get Tx offloads capabilities */
18452 struct cmd_tx_offload_get_capa_result {
18453 cmdline_fixed_string_t show;
18454 cmdline_fixed_string_t port;
18456 cmdline_fixed_string_t tx_offload;
18457 cmdline_fixed_string_t capabilities;
18460 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18461 TOKEN_STRING_INITIALIZER
18462 (struct cmd_tx_offload_get_capa_result,
18464 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18465 TOKEN_STRING_INITIALIZER
18466 (struct cmd_tx_offload_get_capa_result,
18468 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18469 TOKEN_NUM_INITIALIZER
18470 (struct cmd_tx_offload_get_capa_result,
18472 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18473 TOKEN_STRING_INITIALIZER
18474 (struct cmd_tx_offload_get_capa_result,
18475 tx_offload, "tx_offload");
18476 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18477 TOKEN_STRING_INITIALIZER
18478 (struct cmd_tx_offload_get_capa_result,
18479 capabilities, "capabilities");
18482 print_tx_offloads(uint64_t offloads)
18484 uint64_t single_offload;
18492 begin = __builtin_ctzll(offloads);
18493 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18495 single_offload = 1ULL << begin;
18496 for (bit = begin; bit < end; bit++) {
18497 if (offloads & single_offload)
18499 rte_eth_dev_tx_offload_name(single_offload));
18500 single_offload <<= 1;
18505 cmd_tx_offload_get_capa_parsed(
18506 void *parsed_result,
18507 __rte_unused struct cmdline *cl,
18508 __rte_unused void *data)
18510 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18511 struct rte_eth_dev_info dev_info;
18512 portid_t port_id = res->port_id;
18513 uint64_t queue_offloads;
18514 uint64_t port_offloads;
18517 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18521 queue_offloads = dev_info.tx_queue_offload_capa;
18522 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18524 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18525 printf(" Per Queue :");
18526 print_tx_offloads(queue_offloads);
18529 printf(" Per Port :");
18530 print_tx_offloads(port_offloads);
18534 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18535 .f = cmd_tx_offload_get_capa_parsed,
18537 .help_str = "show port <port_id> tx_offload capabilities",
18539 (void *)&cmd_tx_offload_get_capa_show,
18540 (void *)&cmd_tx_offload_get_capa_port,
18541 (void *)&cmd_tx_offload_get_capa_port_id,
18542 (void *)&cmd_tx_offload_get_capa_tx_offload,
18543 (void *)&cmd_tx_offload_get_capa_capabilities,
18548 /* Get Tx offloads configuration */
18549 struct cmd_tx_offload_get_configuration_result {
18550 cmdline_fixed_string_t show;
18551 cmdline_fixed_string_t port;
18553 cmdline_fixed_string_t tx_offload;
18554 cmdline_fixed_string_t configuration;
18557 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18558 TOKEN_STRING_INITIALIZER
18559 (struct cmd_tx_offload_get_configuration_result,
18561 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18562 TOKEN_STRING_INITIALIZER
18563 (struct cmd_tx_offload_get_configuration_result,
18565 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18566 TOKEN_NUM_INITIALIZER
18567 (struct cmd_tx_offload_get_configuration_result,
18569 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18570 TOKEN_STRING_INITIALIZER
18571 (struct cmd_tx_offload_get_configuration_result,
18572 tx_offload, "tx_offload");
18573 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18574 TOKEN_STRING_INITIALIZER
18575 (struct cmd_tx_offload_get_configuration_result,
18576 configuration, "configuration");
18579 cmd_tx_offload_get_configuration_parsed(
18580 void *parsed_result,
18581 __rte_unused struct cmdline *cl,
18582 __rte_unused void *data)
18584 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18585 struct rte_eth_dev_info dev_info;
18586 portid_t port_id = res->port_id;
18587 struct rte_port *port = &ports[port_id];
18588 uint64_t port_offloads;
18589 uint64_t queue_offloads;
18590 uint16_t nb_tx_queues;
18594 printf("Tx Offloading Configuration of port %d :\n", port_id);
18596 port_offloads = port->dev_conf.txmode.offloads;
18598 print_tx_offloads(port_offloads);
18601 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18605 nb_tx_queues = dev_info.nb_tx_queues;
18606 for (q = 0; q < nb_tx_queues; q++) {
18607 queue_offloads = port->tx_conf[q].offloads;
18608 printf(" Queue[%2d] :", q);
18609 print_tx_offloads(queue_offloads);
18615 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18616 .f = cmd_tx_offload_get_configuration_parsed,
18618 .help_str = "show port <port_id> tx_offload configuration",
18620 (void *)&cmd_tx_offload_get_configuration_show,
18621 (void *)&cmd_tx_offload_get_configuration_port,
18622 (void *)&cmd_tx_offload_get_configuration_port_id,
18623 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18624 (void *)&cmd_tx_offload_get_configuration_configuration,
18629 /* Enable/Disable a per port offloading */
18630 struct cmd_config_per_port_tx_offload_result {
18631 cmdline_fixed_string_t port;
18632 cmdline_fixed_string_t config;
18634 cmdline_fixed_string_t tx_offload;
18635 cmdline_fixed_string_t offload;
18636 cmdline_fixed_string_t on_off;
18639 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18640 TOKEN_STRING_INITIALIZER
18641 (struct cmd_config_per_port_tx_offload_result,
18643 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18644 TOKEN_STRING_INITIALIZER
18645 (struct cmd_config_per_port_tx_offload_result,
18647 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18648 TOKEN_NUM_INITIALIZER
18649 (struct cmd_config_per_port_tx_offload_result,
18651 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18652 TOKEN_STRING_INITIALIZER
18653 (struct cmd_config_per_port_tx_offload_result,
18654 tx_offload, "tx_offload");
18655 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18656 TOKEN_STRING_INITIALIZER
18657 (struct cmd_config_per_port_tx_offload_result,
18658 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18659 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18660 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18661 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18662 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18663 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18664 TOKEN_STRING_INITIALIZER
18665 (struct cmd_config_per_port_tx_offload_result,
18669 search_tx_offload(const char *name)
18671 uint64_t single_offload;
18672 const char *single_name;
18676 single_offload = 1;
18677 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18678 single_name = rte_eth_dev_tx_offload_name(single_offload);
18679 if (single_name == NULL)
18681 if (!strcasecmp(single_name, name)) {
18684 } else if (!strcasecmp(single_name, "UNKNOWN"))
18686 single_offload <<= 1;
18690 return single_offload;
18696 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18697 __rte_unused struct cmdline *cl,
18698 __rte_unused void *data)
18700 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18701 portid_t port_id = res->port_id;
18702 struct rte_eth_dev_info dev_info;
18703 struct rte_port *port = &ports[port_id];
18704 uint64_t single_offload;
18705 uint16_t nb_tx_queues;
18709 if (port->port_status != RTE_PORT_STOPPED) {
18710 printf("Error: Can't config offload when Port %d "
18711 "is not stopped\n", port_id);
18715 single_offload = search_tx_offload(res->offload);
18716 if (single_offload == 0) {
18717 printf("Unknown offload name: %s\n", res->offload);
18721 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18725 nb_tx_queues = dev_info.nb_tx_queues;
18726 if (!strcmp(res->on_off, "on")) {
18727 port->dev_conf.txmode.offloads |= single_offload;
18728 for (q = 0; q < nb_tx_queues; q++)
18729 port->tx_conf[q].offloads |= single_offload;
18731 port->dev_conf.txmode.offloads &= ~single_offload;
18732 for (q = 0; q < nb_tx_queues; q++)
18733 port->tx_conf[q].offloads &= ~single_offload;
18736 cmd_reconfig_device_queue(port_id, 1, 1);
18739 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18740 .f = cmd_config_per_port_tx_offload_parsed,
18742 .help_str = "port config <port_id> tx_offload "
18743 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18744 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18745 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18746 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18747 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18749 (void *)&cmd_config_per_port_tx_offload_result_port,
18750 (void *)&cmd_config_per_port_tx_offload_result_config,
18751 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18752 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18753 (void *)&cmd_config_per_port_tx_offload_result_offload,
18754 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18759 /* Enable/Disable a per queue offloading */
18760 struct cmd_config_per_queue_tx_offload_result {
18761 cmdline_fixed_string_t port;
18763 cmdline_fixed_string_t txq;
18765 cmdline_fixed_string_t tx_offload;
18766 cmdline_fixed_string_t offload;
18767 cmdline_fixed_string_t on_off;
18770 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18771 TOKEN_STRING_INITIALIZER
18772 (struct cmd_config_per_queue_tx_offload_result,
18774 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18775 TOKEN_NUM_INITIALIZER
18776 (struct cmd_config_per_queue_tx_offload_result,
18778 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18779 TOKEN_STRING_INITIALIZER
18780 (struct cmd_config_per_queue_tx_offload_result,
18782 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18783 TOKEN_NUM_INITIALIZER
18784 (struct cmd_config_per_queue_tx_offload_result,
18786 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18787 TOKEN_STRING_INITIALIZER
18788 (struct cmd_config_per_queue_tx_offload_result,
18789 tx_offload, "tx_offload");
18790 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18791 TOKEN_STRING_INITIALIZER
18792 (struct cmd_config_per_queue_tx_offload_result,
18793 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18794 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18795 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18796 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18797 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18798 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18799 TOKEN_STRING_INITIALIZER
18800 (struct cmd_config_per_queue_tx_offload_result,
18804 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18805 __rte_unused struct cmdline *cl,
18806 __rte_unused void *data)
18808 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18809 struct rte_eth_dev_info dev_info;
18810 portid_t port_id = res->port_id;
18811 uint16_t queue_id = res->queue_id;
18812 struct rte_port *port = &ports[port_id];
18813 uint64_t single_offload;
18816 if (port->port_status != RTE_PORT_STOPPED) {
18817 printf("Error: Can't config offload when Port %d "
18818 "is not stopped\n", port_id);
18822 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18826 if (queue_id >= dev_info.nb_tx_queues) {
18827 printf("Error: input queue_id should be 0 ... "
18828 "%d\n", dev_info.nb_tx_queues - 1);
18832 single_offload = search_tx_offload(res->offload);
18833 if (single_offload == 0) {
18834 printf("Unknown offload name: %s\n", res->offload);
18838 if (!strcmp(res->on_off, "on"))
18839 port->tx_conf[queue_id].offloads |= single_offload;
18841 port->tx_conf[queue_id].offloads &= ~single_offload;
18843 cmd_reconfig_device_queue(port_id, 1, 1);
18846 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18847 .f = cmd_config_per_queue_tx_offload_parsed,
18849 .help_str = "port <port_id> txq <queue_id> tx_offload "
18850 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18851 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18852 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18853 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18854 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18857 (void *)&cmd_config_per_queue_tx_offload_result_port,
18858 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18859 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18860 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18861 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18862 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18863 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18868 /* *** configure tx_metadata for specific port *** */
18869 struct cmd_config_tx_metadata_specific_result {
18870 cmdline_fixed_string_t port;
18871 cmdline_fixed_string_t keyword;
18873 cmdline_fixed_string_t item;
18878 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18879 __rte_unused struct cmdline *cl,
18880 __rte_unused void *data)
18882 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18884 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18886 ports[res->port_id].tx_metadata = res->value;
18887 /* Add/remove callback to insert valid metadata in every Tx packet. */
18888 if (ports[res->port_id].tx_metadata)
18889 add_tx_md_callback(res->port_id);
18891 remove_tx_md_callback(res->port_id);
18892 rte_flow_dynf_metadata_register();
18895 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18896 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18898 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18899 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18900 keyword, "config");
18901 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18902 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18904 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18905 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18906 item, "tx_metadata");
18907 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18908 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18911 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18912 .f = cmd_config_tx_metadata_specific_parsed,
18914 .help_str = "port config <port_id> tx_metadata <value>",
18916 (void *)&cmd_config_tx_metadata_specific_port,
18917 (void *)&cmd_config_tx_metadata_specific_keyword,
18918 (void *)&cmd_config_tx_metadata_specific_id,
18919 (void *)&cmd_config_tx_metadata_specific_item,
18920 (void *)&cmd_config_tx_metadata_specific_value,
18925 /* *** set dynf *** */
18926 struct cmd_config_tx_dynf_specific_result {
18927 cmdline_fixed_string_t port;
18928 cmdline_fixed_string_t keyword;
18930 cmdline_fixed_string_t item;
18931 cmdline_fixed_string_t name;
18932 cmdline_fixed_string_t value;
18936 cmd_config_dynf_specific_parsed(void *parsed_result,
18937 __rte_unused struct cmdline *cl,
18938 __rte_unused void *data)
18940 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18941 struct rte_mbuf_dynflag desc_flag;
18943 uint64_t old_port_flags;
18945 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18947 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18949 if (strlcpy(desc_flag.name, res->name,
18950 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18951 printf("Flag name too long\n");
18954 desc_flag.flags = 0;
18955 flag = rte_mbuf_dynflag_register(&desc_flag);
18957 printf("Can't register flag\n");
18960 strcpy(dynf_names[flag], desc_flag.name);
18962 old_port_flags = ports[res->port_id].mbuf_dynf;
18963 if (!strcmp(res->value, "set")) {
18964 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18965 if (old_port_flags == 0)
18966 add_tx_dynf_callback(res->port_id);
18968 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18969 if (ports[res->port_id].mbuf_dynf == 0)
18970 remove_tx_dynf_callback(res->port_id);
18974 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18975 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18977 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18978 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18979 keyword, "config");
18980 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18981 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18983 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18984 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18986 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18987 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18989 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18990 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18991 value, "set#clear");
18993 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18994 .f = cmd_config_dynf_specific_parsed,
18996 .help_str = "port config <port id> dynf <name> set|clear",
18998 (void *)&cmd_config_tx_dynf_specific_port,
18999 (void *)&cmd_config_tx_dynf_specific_keyword,
19000 (void *)&cmd_config_tx_dynf_specific_port_id,
19001 (void *)&cmd_config_tx_dynf_specific_item,
19002 (void *)&cmd_config_tx_dynf_specific_name,
19003 (void *)&cmd_config_tx_dynf_specific_value,
19008 /* *** display tx_metadata per port configuration *** */
19009 struct cmd_show_tx_metadata_result {
19010 cmdline_fixed_string_t cmd_show;
19011 cmdline_fixed_string_t cmd_port;
19012 cmdline_fixed_string_t cmd_keyword;
19017 cmd_show_tx_metadata_parsed(void *parsed_result,
19018 __rte_unused struct cmdline *cl,
19019 __rte_unused void *data)
19021 struct cmd_show_tx_metadata_result *res = parsed_result;
19023 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19024 printf("invalid port id %u\n", res->cmd_pid);
19027 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19028 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19029 ports[res->cmd_pid].tx_metadata);
19033 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19034 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19036 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19037 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19039 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19040 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19042 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19043 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19044 cmd_keyword, "tx_metadata");
19046 cmdline_parse_inst_t cmd_show_tx_metadata = {
19047 .f = cmd_show_tx_metadata_parsed,
19049 .help_str = "show port <port_id> tx_metadata",
19051 (void *)&cmd_show_tx_metadata_show,
19052 (void *)&cmd_show_tx_metadata_port,
19053 (void *)&cmd_show_tx_metadata_pid,
19054 (void *)&cmd_show_tx_metadata_keyword,
19059 /* show port supported ptypes */
19061 /* Common result structure for show port ptypes */
19062 struct cmd_show_port_supported_ptypes_result {
19063 cmdline_fixed_string_t show;
19064 cmdline_fixed_string_t port;
19066 cmdline_fixed_string_t ptypes;
19069 /* Common CLI fields for show port ptypes */
19070 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19071 TOKEN_STRING_INITIALIZER
19072 (struct cmd_show_port_supported_ptypes_result,
19074 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19075 TOKEN_STRING_INITIALIZER
19076 (struct cmd_show_port_supported_ptypes_result,
19078 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19079 TOKEN_NUM_INITIALIZER
19080 (struct cmd_show_port_supported_ptypes_result,
19082 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19083 TOKEN_STRING_INITIALIZER
19084 (struct cmd_show_port_supported_ptypes_result,
19088 cmd_show_port_supported_ptypes_parsed(
19089 void *parsed_result,
19090 __rte_unused struct cmdline *cl,
19091 __rte_unused void *data)
19093 #define RSVD_PTYPE_MASK 0xf0000000
19094 #define MAX_PTYPES_PER_LAYER 16
19095 #define LTYPE_NAMESIZE 32
19096 #define PTYPE_NAMESIZE 256
19097 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19098 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19099 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19100 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19101 uint16_t port_id = res->port_id;
19104 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19108 while (ptype_mask != RSVD_PTYPE_MASK) {
19110 switch (ptype_mask) {
19111 case RTE_PTYPE_L2_MASK:
19112 strlcpy(ltype, "L2", sizeof(ltype));
19114 case RTE_PTYPE_L3_MASK:
19115 strlcpy(ltype, "L3", sizeof(ltype));
19117 case RTE_PTYPE_L4_MASK:
19118 strlcpy(ltype, "L4", sizeof(ltype));
19120 case RTE_PTYPE_TUNNEL_MASK:
19121 strlcpy(ltype, "Tunnel", sizeof(ltype));
19123 case RTE_PTYPE_INNER_L2_MASK:
19124 strlcpy(ltype, "Inner L2", sizeof(ltype));
19126 case RTE_PTYPE_INNER_L3_MASK:
19127 strlcpy(ltype, "Inner L3", sizeof(ltype));
19129 case RTE_PTYPE_INNER_L4_MASK:
19130 strlcpy(ltype, "Inner L4", sizeof(ltype));
19136 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19137 ptype_mask, ptypes,
19138 MAX_PTYPES_PER_LAYER);
19141 printf("Supported %s ptypes:\n", ltype);
19143 printf("%s ptypes unsupported\n", ltype);
19145 for (i = 0; i < ret; ++i) {
19146 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19147 printf("%s\n", buf);
19154 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19155 .f = cmd_show_port_supported_ptypes_parsed,
19157 .help_str = "show port <port_id> ptypes",
19159 (void *)&cmd_show_port_supported_ptypes_show,
19160 (void *)&cmd_show_port_supported_ptypes_port,
19161 (void *)&cmd_show_port_supported_ptypes_port_id,
19162 (void *)&cmd_show_port_supported_ptypes_ptypes,
19167 /* *** display rx/tx descriptor status *** */
19168 struct cmd_show_rx_tx_desc_status_result {
19169 cmdline_fixed_string_t cmd_show;
19170 cmdline_fixed_string_t cmd_port;
19171 cmdline_fixed_string_t cmd_keyword;
19172 cmdline_fixed_string_t cmd_desc;
19173 cmdline_fixed_string_t cmd_status;
19180 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19181 __rte_unused struct cmdline *cl,
19182 __rte_unused void *data)
19184 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19187 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19188 printf("invalid port id %u\n", res->cmd_pid);
19192 if (!strcmp(res->cmd_keyword, "rxq")) {
19193 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19196 printf("Invalid queueid = %d\n", res->cmd_qid);
19199 if (rc == RTE_ETH_RX_DESC_AVAIL)
19200 printf("Desc status = AVAILABLE\n");
19201 else if (rc == RTE_ETH_RX_DESC_DONE)
19202 printf("Desc status = DONE\n");
19204 printf("Desc status = UNAVAILABLE\n");
19205 } else if (!strcmp(res->cmd_keyword, "txq")) {
19206 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19209 printf("Invalid queueid = %d\n", res->cmd_qid);
19212 if (rc == RTE_ETH_TX_DESC_FULL)
19213 printf("Desc status = FULL\n");
19214 else if (rc == RTE_ETH_TX_DESC_DONE)
19215 printf("Desc status = DONE\n");
19217 printf("Desc status = UNAVAILABLE\n");
19221 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19222 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19224 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19225 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19227 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19228 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19230 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19231 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19232 cmd_keyword, "rxq#txq");
19233 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19234 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19236 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19237 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19239 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19240 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19242 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19243 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19244 cmd_status, "status");
19245 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19246 .f = cmd_show_rx_tx_desc_status_parsed,
19248 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19251 (void *)&cmd_show_rx_tx_desc_status_show,
19252 (void *)&cmd_show_rx_tx_desc_status_port,
19253 (void *)&cmd_show_rx_tx_desc_status_pid,
19254 (void *)&cmd_show_rx_tx_desc_status_keyword,
19255 (void *)&cmd_show_rx_tx_desc_status_qid,
19256 (void *)&cmd_show_rx_tx_desc_status_desc,
19257 (void *)&cmd_show_rx_tx_desc_status_did,
19258 (void *)&cmd_show_rx_tx_desc_status_status,
19263 /* Common result structure for set port ptypes */
19264 struct cmd_set_port_ptypes_result {
19265 cmdline_fixed_string_t set;
19266 cmdline_fixed_string_t port;
19268 cmdline_fixed_string_t ptype_mask;
19272 /* Common CLI fields for set port ptypes */
19273 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19274 TOKEN_STRING_INITIALIZER
19275 (struct cmd_set_port_ptypes_result,
19277 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19278 TOKEN_STRING_INITIALIZER
19279 (struct cmd_set_port_ptypes_result,
19281 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19282 TOKEN_NUM_INITIALIZER
19283 (struct cmd_set_port_ptypes_result,
19285 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19286 TOKEN_STRING_INITIALIZER
19287 (struct cmd_set_port_ptypes_result,
19288 ptype_mask, "ptype_mask");
19289 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19290 TOKEN_NUM_INITIALIZER
19291 (struct cmd_set_port_ptypes_result,
19295 cmd_set_port_ptypes_parsed(
19296 void *parsed_result,
19297 __rte_unused struct cmdline *cl,
19298 __rte_unused void *data)
19300 struct cmd_set_port_ptypes_result *res = parsed_result;
19301 #define PTYPE_NAMESIZE 256
19302 char ptype_name[PTYPE_NAMESIZE];
19303 uint16_t port_id = res->port_id;
19304 uint32_t ptype_mask = res->mask;
19307 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19310 printf("Port %d doesn't support any ptypes.\n", port_id);
19314 uint32_t ptypes[ret];
19316 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19318 printf("Unable to set requested ptypes for Port %d\n", port_id);
19322 printf("Successfully set following ptypes for Port %d\n", port_id);
19323 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19324 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19325 printf("%s\n", ptype_name);
19328 clear_ptypes = false;
19331 cmdline_parse_inst_t cmd_set_port_ptypes = {
19332 .f = cmd_set_port_ptypes_parsed,
19334 .help_str = "set port <port_id> ptype_mask <mask>",
19336 (void *)&cmd_set_port_ptypes_set,
19337 (void *)&cmd_set_port_ptypes_port,
19338 (void *)&cmd_set_port_ptypes_port_id,
19339 (void *)&cmd_set_port_ptypes_mask_str,
19340 (void *)&cmd_set_port_ptypes_mask_u32,
19345 /* *** display mac addresses added to a port *** */
19346 struct cmd_showport_macs_result {
19347 cmdline_fixed_string_t cmd_show;
19348 cmdline_fixed_string_t cmd_port;
19349 cmdline_fixed_string_t cmd_keyword;
19354 cmd_showport_macs_parsed(void *parsed_result,
19355 __rte_unused struct cmdline *cl,
19356 __rte_unused void *data)
19358 struct cmd_showport_macs_result *res = parsed_result;
19360 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19363 if (!strcmp(res->cmd_keyword, "macs"))
19364 show_macs(res->cmd_pid);
19365 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19366 show_mcast_macs(res->cmd_pid);
19369 cmdline_parse_token_string_t cmd_showport_macs_show =
19370 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19372 cmdline_parse_token_string_t cmd_showport_macs_port =
19373 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19375 cmdline_parse_token_num_t cmd_showport_macs_pid =
19376 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19378 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19379 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19380 cmd_keyword, "macs#mcast_macs");
19382 cmdline_parse_inst_t cmd_showport_macs = {
19383 .f = cmd_showport_macs_parsed,
19385 .help_str = "show port <port_id> macs|mcast_macs",
19387 (void *)&cmd_showport_macs_show,
19388 (void *)&cmd_showport_macs_port,
19389 (void *)&cmd_showport_macs_pid,
19390 (void *)&cmd_showport_macs_keyword,
19395 /* ******************************************************************************** */
19397 /* list of instructions */
19398 cmdline_parse_ctx_t main_ctx[] = {
19399 (cmdline_parse_inst_t *)&cmd_help_brief,
19400 (cmdline_parse_inst_t *)&cmd_help_long,
19401 (cmdline_parse_inst_t *)&cmd_quit,
19402 (cmdline_parse_inst_t *)&cmd_load_from_file,
19403 (cmdline_parse_inst_t *)&cmd_showport,
19404 (cmdline_parse_inst_t *)&cmd_showqueue,
19405 (cmdline_parse_inst_t *)&cmd_showportall,
19406 (cmdline_parse_inst_t *)&cmd_showdevice,
19407 (cmdline_parse_inst_t *)&cmd_showcfg,
19408 (cmdline_parse_inst_t *)&cmd_showfwdall,
19409 (cmdline_parse_inst_t *)&cmd_start,
19410 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19411 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19412 (cmdline_parse_inst_t *)&cmd_set_link_up,
19413 (cmdline_parse_inst_t *)&cmd_set_link_down,
19414 (cmdline_parse_inst_t *)&cmd_reset,
19415 (cmdline_parse_inst_t *)&cmd_set_numbers,
19416 (cmdline_parse_inst_t *)&cmd_set_log,
19417 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19418 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19419 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19420 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19421 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19422 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19423 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19424 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19425 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19426 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19427 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19428 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19429 (cmdline_parse_inst_t *)&cmd_set_link_check,
19430 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19431 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19432 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19433 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19434 #ifdef RTE_LIBRTE_PMD_BOND
19435 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19436 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19437 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19438 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19439 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19440 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19441 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19442 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19443 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19444 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19445 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19447 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19448 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19449 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19450 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19451 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19452 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19453 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19454 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19455 (cmdline_parse_inst_t *)&cmd_csum_set,
19456 (cmdline_parse_inst_t *)&cmd_csum_show,
19457 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19458 (cmdline_parse_inst_t *)&cmd_tso_set,
19459 (cmdline_parse_inst_t *)&cmd_tso_show,
19460 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19461 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19462 (cmdline_parse_inst_t *)&cmd_gro_enable,
19463 (cmdline_parse_inst_t *)&cmd_gro_flush,
19464 (cmdline_parse_inst_t *)&cmd_gro_show,
19465 (cmdline_parse_inst_t *)&cmd_gso_enable,
19466 (cmdline_parse_inst_t *)&cmd_gso_size,
19467 (cmdline_parse_inst_t *)&cmd_gso_show,
19468 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19469 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19470 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19471 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19472 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19473 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19474 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19475 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19476 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19477 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19478 (cmdline_parse_inst_t *)&cmd_config_dcb,
19479 (cmdline_parse_inst_t *)&cmd_read_reg,
19480 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19481 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19482 (cmdline_parse_inst_t *)&cmd_write_reg,
19483 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19484 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19485 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19486 (cmdline_parse_inst_t *)&cmd_stop,
19487 (cmdline_parse_inst_t *)&cmd_mac_addr,
19488 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19489 (cmdline_parse_inst_t *)&cmd_set_qmap,
19490 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19491 (cmdline_parse_inst_t *)&cmd_operate_port,
19492 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19493 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19494 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19495 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19496 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19497 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19498 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19499 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19500 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19501 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19502 (cmdline_parse_inst_t *)&cmd_config_mtu,
19503 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19504 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19505 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19506 (cmdline_parse_inst_t *)&cmd_config_rss,
19507 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19508 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19509 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19510 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19511 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19512 (cmdline_parse_inst_t *)&cmd_showport_reta,
19513 (cmdline_parse_inst_t *)&cmd_showport_macs,
19514 (cmdline_parse_inst_t *)&cmd_config_burst,
19515 (cmdline_parse_inst_t *)&cmd_config_thresh,
19516 (cmdline_parse_inst_t *)&cmd_config_threshold,
19517 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19518 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19519 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19520 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19521 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19522 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19523 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19524 (cmdline_parse_inst_t *)&cmd_global_config,
19525 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19526 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19527 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19528 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19529 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19530 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19531 (cmdline_parse_inst_t *)&cmd_dump,
19532 (cmdline_parse_inst_t *)&cmd_dump_one,
19533 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19534 (cmdline_parse_inst_t *)&cmd_syn_filter,
19535 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19536 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19537 (cmdline_parse_inst_t *)&cmd_flex_filter,
19538 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19539 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19540 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19541 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19542 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19543 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19544 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19545 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19546 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19547 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19548 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19549 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19550 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19551 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19552 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19553 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19554 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19555 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19556 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19557 (cmdline_parse_inst_t *)&cmd_flow,
19558 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19559 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19560 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19561 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19562 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19563 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19564 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19565 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19566 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19567 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19568 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19569 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19570 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19571 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19572 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19573 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19574 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19575 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19576 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19577 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19578 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19579 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19580 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19581 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19582 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19583 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19584 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19585 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19586 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19587 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19588 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19589 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19590 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19591 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19592 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19593 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19594 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19595 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19596 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19597 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19598 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19599 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19600 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19601 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19602 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19603 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19604 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19605 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19606 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19607 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19608 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19610 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19611 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19612 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19613 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19614 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19615 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19616 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19617 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19618 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19619 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19620 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19621 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19622 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19623 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19624 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19625 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19626 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19627 (cmdline_parse_inst_t *)&cmd_ddp_add,
19628 (cmdline_parse_inst_t *)&cmd_ddp_del,
19629 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19630 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19631 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19632 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19633 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19634 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19635 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19636 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19637 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19638 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19639 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19640 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19642 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19643 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19644 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19645 (cmdline_parse_inst_t *)&cmd_queue_region,
19646 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19647 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19648 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19649 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19650 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19651 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19652 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19653 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19654 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19655 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19656 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19657 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19658 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19659 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19660 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19661 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19662 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19663 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19664 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19665 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19666 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19667 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19668 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19669 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19670 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19671 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19672 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19673 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19674 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19675 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19676 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19677 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19678 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19679 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19680 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19681 #ifdef RTE_LIBRTE_BPF
19682 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19683 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19685 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19686 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19687 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19688 (cmdline_parse_inst_t *)&cmd_set_raw,
19689 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19690 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19691 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19695 /* read cmdline commands from file */
19697 cmdline_read_from_file(const char *filename)
19699 struct cmdline *cl;
19701 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19703 printf("Failed to create file based cmdline context: %s\n",
19708 cmdline_interact(cl);
19713 printf("Read CLI commands from %s\n", filename);
19716 /* prompt function, called from main on MASTER lcore */
19720 /* initialize non-constant commands */
19721 cmd_set_fwd_mode_init();
19722 cmd_set_fwd_retry_mode_init();
19724 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19725 if (testpmd_cl == NULL)
19727 cmdline_interact(testpmd_cl);
19728 cmdline_stdin_exit(testpmd_cl);
19734 if (testpmd_cl != NULL)
19735 cmdline_quit(testpmd_cl);
19739 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19741 if (id == (portid_t)RTE_PORT_ALL) {
19744 RTE_ETH_FOREACH_DEV(pid) {
19745 /* check if need_reconfig has been set to 1 */
19746 if (ports[pid].need_reconfig == 0)
19747 ports[pid].need_reconfig = dev;
19748 /* check if need_reconfig_queues has been set to 1 */
19749 if (ports[pid].need_reconfig_queues == 0)
19750 ports[pid].need_reconfig_queues = queue;
19752 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19753 /* check if need_reconfig has been set to 1 */
19754 if (ports[id].need_reconfig == 0)
19755 ports[id].need_reconfig = dev;
19756 /* check if need_reconfig_queues has been set to 1 */
19757 if (ports[id].need_reconfig_queues == 0)
19758 ports[id].need_reconfig_queues = queue;