1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
53 #ifdef RTE_LIBRTE_PMD_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
58 #include <rte_pmd_dpaa.h>
60 #ifdef RTE_LIBRTE_IXGBE_PMD
61 #include <rte_pmd_ixgbe.h>
63 #ifdef RTE_LIBRTE_I40E_PMD
64 #include <rte_pmd_i40e.h>
66 #ifdef RTE_LIBRTE_BNXT_PMD
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
85 __rte_unused void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port X rss reta (size) (mask0,mask1,...)\n"
170 " Display the rss redirection table entry indicated"
171 " by masks on port X. size is used to indicate the"
172 " hardware supported reta size\n\n"
174 "show port (port_id) rss-hash [key]\n"
175 " Display the RSS hash functions and RSS hash key of port\n\n"
177 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
178 " Clear information for port_id, or all.\n\n"
180 "show (rxq|txq) info (port_id) (queue_id)\n"
181 " Display information for configured RX/TX queue.\n\n"
183 "show config (rxtx|cores|fwd|txpkts)\n"
184 " Display the given configuration.\n\n"
186 "read rxd (port_id) (queue_id) (rxd_id)\n"
187 " Display an RX descriptor of a port RX queue.\n\n"
189 "read txd (port_id) (queue_id) (txd_id)\n"
190 " Display a TX descriptor of a port TX queue.\n\n"
192 "ddp get list (port_id)\n"
193 " Get ddp profile info list\n\n"
195 "ddp get info (profile_path)\n"
196 " Get ddp profile information.\n\n"
198 "show vf stats (port_id) (vf_id)\n"
199 " Display a VF's statistics.\n\n"
201 "clear vf stats (port_id) (vf_id)\n"
202 " Reset a VF's statistics.\n\n"
204 "show port (port_id) pctype mapping\n"
205 " Get flow ptype to pctype mapping on a port\n\n"
207 "show port meter stats (port_id) (meter_id) (clear)\n"
208 " Get meter stats on a port\n\n"
210 "show fwd stats all\n"
211 " Display statistics for all fwd engines.\n\n"
213 "clear fwd stats all\n"
214 " Clear statistics for all fwd engines.\n\n"
216 "show port (port_id) rx_offload capabilities\n"
217 " List all per queue and per port Rx offloading"
218 " capabilities of a port\n\n"
220 "show port (port_id) rx_offload configuration\n"
221 " List port level and all queue level"
222 " Rx offloading configuration\n\n"
224 "show port (port_id) tx_offload capabilities\n"
225 " List all per queue and per port"
226 " Tx offloading capabilities of a port\n\n"
228 "show port (port_id) tx_offload configuration\n"
229 " List port level and all queue level"
230 " Tx offloading configuration\n\n"
232 "show port (port_id) tx_metadata\n"
233 " Show Tx metadata value set"
234 " for a specific port\n\n"
236 "show port (port_id) ptypes\n"
237 " Show port supported ptypes"
238 " for a specific port\n\n"
240 "show device info (<identifier>|all)"
241 " Show general information about devices probed.\n\n"
243 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
244 " Show status of rx|tx descriptor.\n\n"
246 "show port (port_id) macs|mcast_macs"
247 " Display list of mac addresses added to port.\n\n"
251 if (show_all || !strcmp(res->section, "config")) {
257 "Configuration changes only become active when"
258 " forwarding is started/restarted.\n\n"
261 " Reset forwarding to the default configuration.\n\n"
263 "set verbose (level)\n"
264 " Set the debug verbosity level X.\n\n"
266 "set log global|(type) (level)\n"
267 " Set the log level.\n\n"
270 " Set number of ports.\n\n"
273 " Set number of cores.\n\n"
275 "set coremask (mask)\n"
276 " Set the forwarding cores hexadecimal mask.\n\n"
278 "set portmask (mask)\n"
279 " Set the forwarding ports hexadecimal mask.\n\n"
282 " Set number of packets per burst.\n\n"
284 "set burst tx delay (microseconds) retry (num)\n"
285 " Set the transmit delay time and number of retries,"
286 " effective when retry is enabled.\n\n"
288 "set txpkts (x[,y]*)\n"
289 " Set the length of each segment of TXONLY"
290 " and optionally CSUM packets.\n\n"
292 "set txsplit (off|on|rand)\n"
293 " Set the split policy for the TX packets."
294 " Right now only applicable for CSUM and TXONLY"
297 "set corelist (x[,y]*)\n"
298 " Set the list of forwarding cores.\n\n"
300 "set portlist (x[,y]*)\n"
301 " Set the list of forwarding ports.\n\n"
303 "set port setup on (iterator|event)\n"
304 " Select how attached port is retrieved for setup.\n\n"
306 "set tx loopback (port_id) (on|off)\n"
307 " Enable or disable tx loopback.\n\n"
309 "set all queues drop (port_id) (on|off)\n"
310 " Set drop enable bit for all queues.\n\n"
312 "set vf split drop (port_id) (vf_id) (on|off)\n"
313 " Set split drop enable bit for a VF from the PF.\n\n"
315 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
316 " Set MAC antispoof for a VF from the PF.\n\n"
318 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
319 " Enable MACsec offload.\n\n"
321 "set macsec offload (port_id) off\n"
322 " Disable MACsec offload.\n\n"
324 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
325 " Configure MACsec secure connection (SC).\n\n"
327 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
328 " Configure MACsec secure association (SA).\n\n"
330 "set vf broadcast (port_id) (vf_id) (on|off)\n"
331 " Set VF broadcast for a VF from the PF.\n\n"
333 "vlan set stripq (on|off) (port_id,queue_id)\n"
334 " Set the VLAN strip for a queue on a port.\n\n"
336 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
337 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
339 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
340 " Set VLAN insert for a VF from the PF.\n\n"
342 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
343 " Set VLAN antispoof for a VF from the PF.\n\n"
345 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
346 " Set VLAN tag for a VF from the PF.\n\n"
348 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
349 " Set a VF's max bandwidth(Mbps).\n\n"
351 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
352 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
354 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
355 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
357 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
358 " Set some TCs' strict link priority mode on a physical port.\n\n"
360 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
361 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
363 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
364 " Set the VLAN strip or filter or qinq strip or extend\n\n"
366 "vlan set (inner|outer) tpid (value) (port_id)\n"
367 " Set the VLAN TPID for Packet Filtering on"
370 "rx_vlan add (vlan_id|all) (port_id)\n"
371 " Add a vlan_id, or all identifiers, to the set"
372 " of VLAN identifiers filtered by port_id.\n\n"
374 "rx_vlan rm (vlan_id|all) (port_id)\n"
375 " Remove a vlan_id, or all identifiers, from the set"
376 " of VLAN identifiers filtered by port_id.\n\n"
378 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
379 " Add a vlan_id, to the set of VLAN identifiers"
380 "filtered for VF(s) from port_id.\n\n"
382 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
383 " Remove a vlan_id, to the set of VLAN identifiers"
384 "filtered for VF(s) from port_id.\n\n"
386 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
387 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
388 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
389 " add a tunnel filter of a port.\n\n"
391 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
392 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
393 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
394 " remove a tunnel filter of a port.\n\n"
396 "rx_vxlan_port add (udp_port) (port_id)\n"
397 " Add an UDP port for VXLAN packet filter on a port\n\n"
399 "rx_vxlan_port rm (udp_port) (port_id)\n"
400 " Remove an UDP port for VXLAN packet filter on a port\n\n"
402 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
403 " Set hardware insertion of VLAN IDs (single or double VLAN "
404 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
406 "tx_vlan set pvid port_id vlan_id (on|off)\n"
407 " Set port based TX VLAN insertion.\n\n"
409 "tx_vlan reset (port_id)\n"
410 " Disable hardware insertion of a VLAN header in"
411 " packets sent on a port.\n\n"
413 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
414 " Select hardware or software calculation of the"
415 " checksum when transmitting a packet using the"
416 " csum forward engine.\n"
417 " ip|udp|tcp|sctp always concern the inner layer.\n"
418 " outer-ip concerns the outer IP layer in"
419 " outer-udp concerns the outer UDP layer in"
420 " case the packet is recognized as a tunnel packet by"
421 " the forward engine (vxlan, gre and ipip are supported)\n"
422 " Please check the NIC datasheet for HW limits.\n\n"
424 "csum parse-tunnel (on|off) (tx_port_id)\n"
425 " If disabled, treat tunnel packets as non-tunneled"
426 " packets (treat inner headers as payload). The port\n"
427 " argument is the port used for TX in csum forward"
430 "csum show (port_id)\n"
431 " Display tx checksum offload configuration\n\n"
433 "tso set (segsize) (portid)\n"
434 " Enable TCP Segmentation Offload in csum forward"
436 " Please check the NIC datasheet for HW limits.\n\n"
439 " Display the status of TCP Segmentation Offload.\n\n"
441 "set port (port_id) gro on|off\n"
442 " Enable or disable Generic Receive Offload in"
443 " csum forwarding engine.\n\n"
445 "show port (port_id) gro\n"
446 " Display GRO configuration.\n\n"
448 "set gro flush (cycles)\n"
449 " Set the cycle to flush GROed packets from"
450 " reassembly tables.\n\n"
452 "set port (port_id) gso (on|off)"
453 " Enable or disable Generic Segmentation Offload in"
454 " csum forwarding engine.\n\n"
456 "set gso segsz (length)\n"
457 " Set max packet length for output GSO segments,"
458 " including packet header and payload.\n\n"
460 "show port (port_id) gso\n"
461 " Show GSO configuration.\n\n"
464 " Set packet forwarding mode.\n\n"
466 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
467 " Add a MAC address on port_id.\n\n"
469 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
470 " Remove a MAC address from port_id.\n\n"
472 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
473 " Set the default MAC address for port_id.\n\n"
475 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
476 " Add a MAC address for a VF on the port.\n\n"
478 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
479 " Set the MAC address for a VF from the PF.\n\n"
481 "set eth-peer (port_id) (peer_addr)\n"
482 " set the peer address for certain port.\n\n"
484 "set port (port_id) uta (mac_address|all) (on|off)\n"
485 " Add/Remove a or all unicast hash filter(s)"
488 "set promisc (port_id|all) (on|off)\n"
489 " Set the promiscuous mode on port_id, or all.\n\n"
491 "set allmulti (port_id|all) (on|off)\n"
492 " Set the allmulti mode on port_id, or all.\n\n"
494 "set vf promisc (port_id) (vf_id) (on|off)\n"
495 " Set unicast promiscuous mode for a VF from the PF.\n\n"
497 "set vf allmulti (port_id) (vf_id) (on|off)\n"
498 " Set multicast promiscuous mode for a VF from the PF.\n\n"
500 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
501 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
502 " (on|off) autoneg (on|off) (port_id)\n"
503 "set flow_ctrl rx (on|off) (portid)\n"
504 "set flow_ctrl tx (on|off) (portid)\n"
505 "set flow_ctrl high_water (high_water) (portid)\n"
506 "set flow_ctrl low_water (low_water) (portid)\n"
507 "set flow_ctrl pause_time (pause_time) (portid)\n"
508 "set flow_ctrl send_xon (send_xon) (portid)\n"
509 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
510 "set flow_ctrl autoneg (on|off) (port_id)\n"
511 " Set the link flow control parameter on a port.\n\n"
513 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
514 " (low_water) (pause_time) (priority) (port_id)\n"
515 " Set the priority flow control parameter on a"
518 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
519 " Set statistics mapping (qmapping 0..15) for RX/TX"
521 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
522 " on port 0 to mapping 5.\n\n"
524 "set xstats-hide-zero on|off\n"
525 " Set the option to hide the zero values"
526 " for xstats display.\n"
528 "set port (port_id) vf (vf_id) rx|tx on|off\n"
529 " Enable/Disable a VF receive/tranmit from a port\n\n"
531 "set port (port_id) vf (vf_id) (mac_addr)"
532 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
533 " Add/Remove unicast or multicast MAC addr filter"
536 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
538 " AUPE:accepts untagged VLAN;"
539 "ROPE:accept unicast hash\n\n"
540 " BAM:accepts broadcast packets;"
541 "MPE:accepts all multicast packets\n\n"
542 " Enable/Disable a VF receive mode of a port\n\n"
544 "set port (port_id) queue (queue_id) rate (rate_num)\n"
545 " Set rate limit for a queue of a port\n\n"
547 "set port (port_id) vf (vf_id) rate (rate_num) "
548 "queue_mask (queue_mask_value)\n"
549 " Set rate limit for queues in VF of a port\n\n"
551 "set port (port_id) mirror-rule (rule_id)"
552 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
553 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
554 " Set pool or vlan type mirror rule on a port.\n"
555 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
556 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
559 "set port (port_id) mirror-rule (rule_id)"
560 " (uplink-mirror|downlink-mirror) dst-pool"
561 " (pool_id) (on|off)\n"
562 " Set uplink or downlink type mirror rule on a port.\n"
563 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
564 " 0 on' enable mirror income traffic to pool 0.\n\n"
566 "reset port (port_id) mirror-rule (rule_id)\n"
567 " Reset a mirror rule.\n\n"
569 "set flush_rx (on|off)\n"
570 " Flush (default) or don't flush RX streams before"
571 " forwarding. Mainly used with PCAP drivers.\n\n"
573 "set bypass mode (normal|bypass|isolate) (port_id)\n"
574 " Set the bypass mode for the lowest port on bypass enabled"
577 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
578 "mode (normal|bypass|isolate) (port_id)\n"
579 " Set the event required to initiate specified bypass mode for"
580 " the lowest port on a bypass enabled NIC where:\n"
581 " timeout = enable bypass after watchdog timeout.\n"
582 " os_on = enable bypass when OS/board is powered on.\n"
583 " os_off = enable bypass when OS/board is powered off.\n"
584 " power_on = enable bypass when power supply is turned on.\n"
585 " power_off = enable bypass when power supply is turned off."
588 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
589 " Set the bypass watchdog timeout to 'n' seconds"
590 " where 0 = instant.\n\n"
592 "show bypass config (port_id)\n"
593 " Show the bypass configuration for a bypass enabled NIC"
594 " using the lowest port on the NIC.\n\n"
596 #ifdef RTE_LIBRTE_PMD_BOND
597 "create bonded device (mode) (socket)\n"
598 " Create a new bonded device with specific bonding mode and socket.\n\n"
600 "add bonding slave (slave_id) (port_id)\n"
601 " Add a slave device to a bonded device.\n\n"
603 "remove bonding slave (slave_id) (port_id)\n"
604 " Remove a slave device from a bonded device.\n\n"
606 "set bonding mode (value) (port_id)\n"
607 " Set the bonding mode on a bonded device.\n\n"
609 "set bonding primary (slave_id) (port_id)\n"
610 " Set the primary slave for a bonded device.\n\n"
612 "show bonding config (port_id)\n"
613 " Show the bonding config for port_id.\n\n"
615 "set bonding mac_addr (port_id) (address)\n"
616 " Set the MAC address of a bonded device.\n\n"
618 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
619 " Set Aggregation mode for IEEE802.3AD (mode 4)"
621 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
622 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
624 "set bonding mon_period (port_id) (value)\n"
625 " Set the bonding link status monitoring polling period in ms.\n\n"
627 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
628 " Enable/disable dedicated queues for LACP control traffic.\n\n"
631 "set link-up port (port_id)\n"
632 " Set link up for a port.\n\n"
634 "set link-down port (port_id)\n"
635 " Set link down for a port.\n\n"
637 "E-tag set insertion on port-tag-id (value)"
638 " port (port_id) vf (vf_id)\n"
639 " Enable E-tag insertion for a VF on a port\n\n"
641 "E-tag set insertion off port (port_id) vf (vf_id)\n"
642 " Disable E-tag insertion for a VF on a port\n\n"
644 "E-tag set stripping (on|off) port (port_id)\n"
645 " Enable/disable E-tag stripping on a port\n\n"
647 "E-tag set forwarding (on|off) port (port_id)\n"
648 " Enable/disable E-tag based forwarding"
651 "E-tag set filter add e-tag-id (value) dst-pool"
652 " (pool_id) port (port_id)\n"
653 " Add an E-tag forwarding filter on a port\n\n"
655 "E-tag set filter del e-tag-id (value) port (port_id)\n"
656 " Delete an E-tag forwarding filter on a port\n\n"
658 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
659 " Load a profile package on a port\n\n"
661 "ddp del (port_id) (backup_profile_path)\n"
662 " Delete a profile package from a port\n\n"
664 "ptype mapping get (port_id) (valid_only)\n"
665 " Get ptype mapping on a port\n\n"
667 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
668 " Replace target with the pkt_type in ptype mapping\n\n"
670 "ptype mapping reset (port_id)\n"
671 " Reset ptype mapping on a port\n\n"
673 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
674 " Update a ptype mapping item on a port\n\n"
676 "set port (port_id) ptype_mask (ptype_mask)\n"
677 " set packet types classification for a specific port\n\n"
679 "set port (port_id) queue-region region_id (value) "
680 "queue_start_index (value) queue_num (value)\n"
681 " Set a queue region on a port\n\n"
683 "set port (port_id) queue-region region_id (value) "
685 " Set a flowtype region index on a port\n\n"
687 "set port (port_id) queue-region UP (value) region_id (value)\n"
688 " Set the mapping of User Priority to "
689 "queue region on a port\n\n"
691 "set port (port_id) queue-region flush (on|off)\n"
692 " flush all queue region related configuration\n\n"
694 "show port meter cap (port_id)\n"
695 " Show port meter capability information\n\n"
697 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
698 " meter profile add - srtcm rfc 2697\n\n"
700 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
701 " meter profile add - trtcm rfc 2698\n\n"
703 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
704 " meter profile add - trtcm rfc 4115\n\n"
706 "del port meter profile (port_id) (profile_id)\n"
707 " meter profile delete\n\n"
709 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
710 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
711 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
712 "(dscp_tbl_entry63)]\n"
715 "enable port meter (port_id) (mtr_id)\n"
718 "disable port meter (port_id) (mtr_id)\n"
721 "del port meter (port_id) (mtr_id)\n"
724 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
725 " meter update meter profile\n\n"
727 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
728 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
729 " update meter dscp table entries\n\n"
731 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
732 "(action0) [(action1) (action2)]\n"
733 " meter update policer action\n\n"
735 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
736 " meter update stats\n\n"
738 "show port (port_id) queue-region\n"
739 " show all queue region related configuration info\n\n"
741 , list_pkt_forwarding_modes()
745 if (show_all || !strcmp(res->section, "ports")) {
751 "----------------\n\n"
753 "port start (port_id|all)\n"
754 " Start all ports or port_id.\n\n"
756 "port stop (port_id|all)\n"
757 " Stop all ports or port_id.\n\n"
759 "port close (port_id|all)\n"
760 " Close all ports or port_id.\n\n"
762 "port reset (port_id|all)\n"
763 " Reset all ports or port_id.\n\n"
765 "port attach (ident)\n"
766 " Attach physical or virtual dev by pci address or virtual device name\n\n"
768 "port detach (port_id)\n"
769 " Detach physical or virtual dev by port_id\n\n"
771 "port config (port_id|all)"
772 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
773 " duplex (half|full|auto)\n"
774 " Set speed and duplex for all ports or port_id\n\n"
776 "port config (port_id|all) loopback (mode)\n"
777 " Set loopback mode for all ports or port_id\n\n"
779 "port config all (rxq|txq|rxd|txd) (value)\n"
780 " Set number for rxq/txq/rxd/txd.\n\n"
782 "port config all max-pkt-len (value)\n"
783 " Set the max packet length.\n\n"
785 "port config all max-lro-pkt-size (value)\n"
786 " Set the max LRO aggregated packet size.\n\n"
788 "port config all drop-en (on|off)\n"
789 " Enable or disable packet drop on all RX queues of all ports when no "
790 "receive buffers available.\n\n"
792 "port config all rss (all|default|ip|tcp|udp|sctp|"
793 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
794 " Set the RSS mode.\n\n"
796 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
797 " Set the RSS redirection table.\n\n"
799 "port config (port_id) dcb vt (on|off) (traffic_class)"
801 " Set the DCB mode.\n\n"
803 "port config all burst (value)\n"
804 " Set the number of packets per burst.\n\n"
806 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
808 " Set the ring prefetch/host/writeback threshold"
809 " for tx/rx queue.\n\n"
811 "port config all (txfreet|txrst|rxfreet) (value)\n"
812 " Set free threshold for rx/tx, or set"
813 " tx rs bit threshold.\n\n"
814 "port config mtu X value\n"
815 " Set the MTU of port X to a given value\n\n"
817 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
818 " Set a rx/tx queue's ring size configuration, the new"
819 " value will take effect after command that (re-)start the port"
820 " or command that setup the specific queue\n\n"
822 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
823 " Start/stop a rx/tx queue of port X. Only take effect"
824 " when port X is started\n\n"
826 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
827 " Switch on/off a deferred start of port X rx/tx queue. Only"
828 " take effect when port X is stopped.\n\n"
830 "port (port_id) (rxq|txq) (queue_id) setup\n"
831 " Setup a rx/tx queue of port X.\n\n"
833 "port config (port_id|all) l2-tunnel E-tag ether-type"
835 " Set the value of E-tag ether-type.\n\n"
837 "port config (port_id|all) l2-tunnel E-tag"
838 " (enable|disable)\n"
839 " Enable/disable the E-tag support.\n\n"
841 "port config (port_id) pctype mapping reset\n"
842 " Reset flow type to pctype mapping on a port\n\n"
844 "port config (port_id) pctype mapping update"
845 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
846 " Update a flow type to pctype mapping item on a port\n\n"
848 "port config (port_id) pctype (pctype_id) hash_inset|"
849 "fdir_inset|fdir_flx_inset get|set|clear field\n"
851 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
853 "port config (port_id) pctype (pctype_id) hash_inset|"
854 "fdir_inset|fdir_flx_inset clear all"
855 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
857 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
858 " Add/remove UDP tunnel port for tunneling offload\n\n"
860 "port config <port_id> rx_offload vlan_strip|"
861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 "outer_ipv4_cksum|macsec_strip|header_split|"
863 "vlan_filter|vlan_extend|jumbo_frame|"
864 "scatter|timestamp|security|keep_crc on|off\n"
865 " Enable or disable a per port Rx offloading"
866 " on all Rx queues of a port\n\n"
868 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
869 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 "outer_ipv4_cksum|macsec_strip|header_split|"
871 "vlan_filter|vlan_extend|jumbo_frame|"
872 "scatter|timestamp|security|keep_crc on|off\n"
873 " Enable or disable a per queue Rx offloading"
874 " only on a specific Rx queue\n\n"
876 "port config (port_id) tx_offload vlan_insert|"
877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
880 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
882 " Enable or disable a per port Tx offloading"
883 " on all Tx queues of a port\n\n"
885 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
886 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
889 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
891 " Enable or disable a per queue Tx offloading"
892 " only on a specific Tx queue\n\n"
894 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
895 " Load an eBPF program as a callback"
896 " for particular RX/TX queue\n\n"
898 "bpf-unload rx|tx (port) (queue)\n"
899 " Unload previously loaded eBPF program"
900 " for particular RX/TX queue\n\n"
902 "port config (port_id) tx_metadata (value)\n"
903 " Set Tx metadata value per port. Testpmd will add this value"
904 " to any Tx packet sent from this port\n\n"
906 "port config (port_id) dynf (name) set|clear\n"
907 " Register a dynf and Set/clear this flag on Tx. "
908 "Testpmd will set this value to any Tx packet "
909 "sent from this port\n\n"
913 if (show_all || !strcmp(res->section, "registers")) {
921 "read reg (port_id) (address)\n"
922 " Display value of a port register.\n\n"
924 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
925 " Display a port register bit field.\n\n"
927 "read regbit (port_id) (address) (bit_x)\n"
928 " Display a single port register bit.\n\n"
930 "write reg (port_id) (address) (value)\n"
931 " Set value of a port register.\n\n"
933 "write regfield (port_id) (address) (bit_x) (bit_y)"
935 " Set bit field of a port register.\n\n"
937 "write regbit (port_id) (address) (bit_x) (value)\n"
938 " Set single bit value of a port register.\n\n"
941 if (show_all || !strcmp(res->section, "filters")) {
949 "ethertype_filter (port_id) (add|del)"
950 " (mac_addr|mac_ignr) (mac_address) ethertype"
951 " (ether_type) (drop|fwd) queue (queue_id)\n"
952 " Add/Del an ethertype filter.\n\n"
954 "2tuple_filter (port_id) (add|del)"
955 " dst_port (dst_port_value) protocol (protocol_value)"
956 " mask (mask_value) tcp_flags (tcp_flags_value)"
957 " priority (prio_value) queue (queue_id)\n"
958 " Add/Del a 2tuple filter.\n\n"
960 "5tuple_filter (port_id) (add|del)"
961 " dst_ip (dst_address) src_ip (src_address)"
962 " dst_port (dst_port_value) src_port (src_port_value)"
963 " protocol (protocol_value)"
964 " mask (mask_value) tcp_flags (tcp_flags_value)"
965 " priority (prio_value) queue (queue_id)\n"
966 " Add/Del a 5tuple filter.\n\n"
968 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
969 " Add/Del syn filter.\n\n"
971 "flex_filter (port_id) (add|del) len (len_value)"
972 " bytes (bytes_value) mask (mask_value)"
973 " priority (prio_value) queue (queue_id)\n"
974 " Add/Del a flex filter.\n\n"
976 "flow_director_filter (port_id) mode IP (add|del|update)"
977 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
978 " src (src_ip_address) dst (dst_ip_address)"
979 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
980 " vlan (vlan_value) flexbytes (flexbytes_value)"
981 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
982 " fd_id (fd_id_value)\n"
983 " Add/Del an IP type flow director filter.\n\n"
985 "flow_director_filter (port_id) mode IP (add|del|update)"
986 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
987 " src (src_ip_address) (src_port)"
988 " dst (dst_ip_address) (dst_port)"
989 " tos (tos_value) ttl (ttl_value)"
990 " vlan (vlan_value) flexbytes (flexbytes_value)"
991 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
992 " fd_id (fd_id_value)\n"
993 " Add/Del an UDP/TCP type flow director filter.\n\n"
995 "flow_director_filter (port_id) mode IP (add|del|update)"
996 " flow (ipv4-sctp|ipv6-sctp)"
997 " src (src_ip_address) (src_port)"
998 " dst (dst_ip_address) (dst_port)"
999 " tag (verification_tag) "
1000 " tos (tos_value) ttl (ttl_value)"
1001 " vlan (vlan_value)"
1002 " flexbytes (flexbytes_value) (drop|fwd)"
1003 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1004 " Add/Del a SCTP type flow director filter.\n\n"
1006 "flow_director_filter (port_id) mode IP (add|del|update)"
1007 " flow l2_payload ether (ethertype)"
1008 " flexbytes (flexbytes_value) (drop|fwd)"
1009 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1010 " Add/Del a l2 payload type flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1013 " mac (mac_address) vlan (vlan_value)"
1014 " flexbytes (flexbytes_value) (drop|fwd)"
1015 " queue (queue_id) fd_id (fd_id_value)\n"
1016 " Add/Del a MAC-VLAN flow director filter.\n\n"
1018 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1019 " mac (mac_address) vlan (vlan_value)"
1020 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1021 " flexbytes (flexbytes_value) (drop|fwd)"
1022 " queue (queue_id) fd_id (fd_id_value)\n"
1023 " Add/Del a Tunnel flow director filter.\n\n"
1025 "flow_director_filter (port_id) mode raw (add|del|update)"
1026 " flow (flow_id) (drop|fwd) queue (queue_id)"
1027 " fd_id (fd_id_value) packet (packet file name)\n"
1028 " Add/Del a raw type flow director filter.\n\n"
1030 "flush_flow_director (port_id)\n"
1031 " Flush all flow director entries of a device.\n\n"
1033 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1034 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1035 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1036 " Set flow director IP mask.\n\n"
1038 "flow_director_mask (port_id) mode MAC-VLAN"
1039 " vlan (vlan_value)\n"
1040 " Set flow director MAC-VLAN mask.\n\n"
1042 "flow_director_mask (port_id) mode Tunnel"
1043 " vlan (vlan_value) mac (mac_value)"
1044 " tunnel-type (tunnel_type_value)"
1045 " tunnel-id (tunnel_id_value)\n"
1046 " Set flow director Tunnel mask.\n\n"
1048 "flow_director_flex_mask (port_id)"
1049 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1050 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1052 " Configure mask of flex payload.\n\n"
1054 "flow_director_flex_payload (port_id)"
1055 " (raw|l2|l3|l4) (config)\n"
1056 " Configure flex payload selection.\n\n"
1058 "get_sym_hash_ena_per_port (port_id)\n"
1059 " get symmetric hash enable configuration per port.\n\n"
1061 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1062 " set symmetric hash enable configuration per port"
1063 " to enable or disable.\n\n"
1065 "get_hash_global_config (port_id)\n"
1066 " Get the global configurations of hash filters.\n\n"
1068 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1069 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1070 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1071 " (enable|disable)\n"
1072 " Set the global configurations of hash filters.\n\n"
1074 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1075 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1076 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1077 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1078 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1079 "ipv6-next-header|udp-src-port|udp-dst-port|"
1080 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1081 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1082 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1083 "fld-8th|none) (select|add)\n"
1084 " Set the input set for hash.\n\n"
1086 "set_fdir_input_set (port_id) "
1087 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1088 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1089 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1090 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1091 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1092 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1093 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1095 " Set the input set for FDir.\n\n"
1097 "flow validate {port_id}"
1098 " [group {group_id}] [priority {level}]"
1099 " [ingress] [egress]"
1100 " pattern {item} [/ {item} [...]] / end"
1101 " actions {action} [/ {action} [...]] / end\n"
1102 " Check whether a flow rule can be created.\n\n"
1104 "flow create {port_id}"
1105 " [group {group_id}] [priority {level}]"
1106 " [ingress] [egress]"
1107 " pattern {item} [/ {item} [...]] / end"
1108 " actions {action} [/ {action} [...]] / end\n"
1109 " Create a flow rule.\n\n"
1111 "flow destroy {port_id} rule {rule_id} [...]\n"
1112 " Destroy specific flow rules.\n\n"
1114 "flow flush {port_id}\n"
1115 " Destroy all flow rules.\n\n"
1117 "flow query {port_id} {rule_id} {action}\n"
1118 " Query an existing flow rule.\n\n"
1120 "flow list {port_id} [group {group_id}] [...]\n"
1121 " List existing flow rules sorted by priority,"
1122 " filtered by group identifiers.\n\n"
1124 "flow isolate {port_id} {boolean}\n"
1125 " Restrict ingress traffic to the defined"
1128 "flow aged {port_id} [destroy]\n"
1129 " List and destroy aged flows"
1132 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1133 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1134 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1135 " Configure the VXLAN encapsulation for flows.\n\n"
1137 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1138 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1139 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1140 " eth-dst (eth-dst)\n"
1141 " Configure the VXLAN encapsulation for flows.\n\n"
1143 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1144 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1145 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1146 " eth-dst (eth-dst)\n"
1147 " Configure the VXLAN encapsulation for flows.\n\n"
1149 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1150 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1152 " Configure the NVGRE encapsulation for flows.\n\n"
1154 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1155 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1156 " eth-src (eth-src) eth-dst (eth-dst)\n"
1157 " Configure the NVGRE encapsulation for flows.\n\n"
1159 "set raw_encap {flow items}\n"
1160 " Configure the encapsulation with raw data.\n\n"
1162 "set raw_decap {flow items}\n"
1163 " Configure the decapsulation with raw data.\n\n"
1168 if (show_all || !strcmp(res->section, "traffic_management")) {
1172 "Traffic Management:\n"
1174 "show port tm cap (port_id)\n"
1175 " Display the port TM capability.\n\n"
1177 "show port tm level cap (port_id) (level_id)\n"
1178 " Display the port TM hierarchical level capability.\n\n"
1180 "show port tm node cap (port_id) (node_id)\n"
1181 " Display the port TM node capability.\n\n"
1183 "show port tm node type (port_id) (node_id)\n"
1184 " Display the port TM node type.\n\n"
1186 "show port tm node stats (port_id) (node_id) (clear)\n"
1187 " Display the port TM node stats.\n\n"
1189 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1190 "set port tm hierarchy default (port_id)\n"
1191 " Set default traffic Management hierarchy on a port\n\n"
1194 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1195 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1196 " (packet_length_adjust)\n"
1197 " Add port tm node private shaper profile.\n\n"
1199 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1200 " Delete port tm node private shaper profile.\n\n"
1202 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1203 " (shaper_profile_id)\n"
1204 " Add/update port tm node shared shaper.\n\n"
1206 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1207 " Delete port tm node shared shaper.\n\n"
1209 "set port tm node shaper profile (port_id) (node_id)"
1210 " (shaper_profile_id)\n"
1211 " Set port tm node shaper profile.\n\n"
1213 "add port tm node wred profile (port_id) (wred_profile_id)"
1214 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1215 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1216 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1217 " Add port tm node wred profile.\n\n"
1219 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1220 " Delete port tm node wred profile.\n\n"
1222 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1223 " (priority) (weight) (level_id) (shaper_profile_id)"
1224 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1225 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1226 " Add port tm nonleaf node.\n\n"
1228 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1229 " (priority) (weight) (level_id) (shaper_profile_id)"
1230 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1231 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1232 " Add port tm leaf node.\n\n"
1234 "del port tm node (port_id) (node_id)\n"
1235 " Delete port tm node.\n\n"
1237 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1238 " (priority) (weight)\n"
1239 " Set port tm node parent.\n\n"
1241 "suspend port tm node (port_id) (node_id)"
1242 " Suspend tm node.\n\n"
1244 "resume port tm node (port_id) (node_id)"
1245 " Resume tm node.\n\n"
1247 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1248 " Commit tm hierarchy.\n\n"
1250 "set port tm mark ip_ecn (port) (green) (yellow)"
1252 " Enables/Disables the traffic management marking"
1253 " for IP ECN (Explicit Congestion Notification)"
1254 " packets on a given port\n\n"
1256 "set port tm mark ip_dscp (port) (green) (yellow)"
1258 " Enables/Disables the traffic management marking"
1259 " on the port for IP dscp packets\n\n"
1261 "set port tm mark vlan_dei (port) (green) (yellow)"
1263 " Enables/Disables the traffic management marking"
1264 " on the port for VLAN packets with DEI enabled\n\n"
1268 if (show_all || !strcmp(res->section, "devices")) {
1272 "Device Operations:\n"
1274 "device detach (identifier)\n"
1275 " Detach device by identifier.\n\n"
1281 cmdline_parse_token_string_t cmd_help_long_help =
1282 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1284 cmdline_parse_token_string_t cmd_help_long_section =
1285 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1286 "all#control#display#config#"
1287 "ports#registers#filters#traffic_management#devices");
1289 cmdline_parse_inst_t cmd_help_long = {
1290 .f = cmd_help_long_parsed,
1292 .help_str = "help all|control|display|config|ports|register|"
1293 "filters|traffic_management|devices: "
1296 (void *)&cmd_help_long_help,
1297 (void *)&cmd_help_long_section,
1303 /* *** start/stop/close all ports *** */
1304 struct cmd_operate_port_result {
1305 cmdline_fixed_string_t keyword;
1306 cmdline_fixed_string_t name;
1307 cmdline_fixed_string_t value;
1310 static void cmd_operate_port_parsed(void *parsed_result,
1311 __rte_unused struct cmdline *cl,
1312 __rte_unused void *data)
1314 struct cmd_operate_port_result *res = parsed_result;
1316 if (!strcmp(res->name, "start"))
1317 start_port(RTE_PORT_ALL);
1318 else if (!strcmp(res->name, "stop"))
1319 stop_port(RTE_PORT_ALL);
1320 else if (!strcmp(res->name, "close"))
1321 close_port(RTE_PORT_ALL);
1322 else if (!strcmp(res->name, "reset"))
1323 reset_port(RTE_PORT_ALL);
1325 printf("Unknown parameter\n");
1328 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1329 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1331 cmdline_parse_token_string_t cmd_operate_port_all_port =
1332 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1333 "start#stop#close#reset");
1334 cmdline_parse_token_string_t cmd_operate_port_all_all =
1335 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1337 cmdline_parse_inst_t cmd_operate_port = {
1338 .f = cmd_operate_port_parsed,
1340 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1342 (void *)&cmd_operate_port_all_cmd,
1343 (void *)&cmd_operate_port_all_port,
1344 (void *)&cmd_operate_port_all_all,
1349 /* *** start/stop/close specific port *** */
1350 struct cmd_operate_specific_port_result {
1351 cmdline_fixed_string_t keyword;
1352 cmdline_fixed_string_t name;
1356 static void cmd_operate_specific_port_parsed(void *parsed_result,
1357 __rte_unused struct cmdline *cl,
1358 __rte_unused void *data)
1360 struct cmd_operate_specific_port_result *res = parsed_result;
1362 if (!strcmp(res->name, "start"))
1363 start_port(res->value);
1364 else if (!strcmp(res->name, "stop"))
1365 stop_port(res->value);
1366 else if (!strcmp(res->name, "close"))
1367 close_port(res->value);
1368 else if (!strcmp(res->name, "reset"))
1369 reset_port(res->value);
1371 printf("Unknown parameter\n");
1374 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1375 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1377 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1378 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1379 name, "start#stop#close#reset");
1380 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1381 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1384 cmdline_parse_inst_t cmd_operate_specific_port = {
1385 .f = cmd_operate_specific_port_parsed,
1387 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1389 (void *)&cmd_operate_specific_port_cmd,
1390 (void *)&cmd_operate_specific_port_port,
1391 (void *)&cmd_operate_specific_port_id,
1396 /* *** enable port setup (after attach) via iterator or event *** */
1397 struct cmd_set_port_setup_on_result {
1398 cmdline_fixed_string_t set;
1399 cmdline_fixed_string_t port;
1400 cmdline_fixed_string_t setup;
1401 cmdline_fixed_string_t on;
1402 cmdline_fixed_string_t mode;
1405 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1406 __rte_unused struct cmdline *cl,
1407 __rte_unused void *data)
1409 struct cmd_set_port_setup_on_result *res = parsed_result;
1411 if (strcmp(res->mode, "event") == 0)
1412 setup_on_probe_event = true;
1413 else if (strcmp(res->mode, "iterator") == 0)
1414 setup_on_probe_event = false;
1416 printf("Unknown mode\n");
1419 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1420 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1422 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1423 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1425 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1426 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1428 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1429 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1431 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1432 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1433 mode, "iterator#event");
1435 cmdline_parse_inst_t cmd_set_port_setup_on = {
1436 .f = cmd_set_port_setup_on_parsed,
1438 .help_str = "set port setup on iterator|event",
1440 (void *)&cmd_set_port_setup_on_set,
1441 (void *)&cmd_set_port_setup_on_port,
1442 (void *)&cmd_set_port_setup_on_setup,
1443 (void *)&cmd_set_port_setup_on_on,
1444 (void *)&cmd_set_port_setup_on_mode,
1449 /* *** attach a specified port *** */
1450 struct cmd_operate_attach_port_result {
1451 cmdline_fixed_string_t port;
1452 cmdline_fixed_string_t keyword;
1453 cmdline_multi_string_t identifier;
1456 static void cmd_operate_attach_port_parsed(void *parsed_result,
1457 __rte_unused struct cmdline *cl,
1458 __rte_unused void *data)
1460 struct cmd_operate_attach_port_result *res = parsed_result;
1462 if (!strcmp(res->keyword, "attach"))
1463 attach_port(res->identifier);
1465 printf("Unknown parameter\n");
1468 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1469 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1471 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1472 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1474 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1475 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1476 identifier, TOKEN_STRING_MULTI);
1478 cmdline_parse_inst_t cmd_operate_attach_port = {
1479 .f = cmd_operate_attach_port_parsed,
1481 .help_str = "port attach <identifier>: "
1482 "(identifier: pci address or virtual dev name)",
1484 (void *)&cmd_operate_attach_port_port,
1485 (void *)&cmd_operate_attach_port_keyword,
1486 (void *)&cmd_operate_attach_port_identifier,
1491 /* *** detach a specified port *** */
1492 struct cmd_operate_detach_port_result {
1493 cmdline_fixed_string_t port;
1494 cmdline_fixed_string_t keyword;
1498 static void cmd_operate_detach_port_parsed(void *parsed_result,
1499 __rte_unused struct cmdline *cl,
1500 __rte_unused void *data)
1502 struct cmd_operate_detach_port_result *res = parsed_result;
1504 if (!strcmp(res->keyword, "detach")) {
1505 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1506 detach_port_device(res->port_id);
1508 printf("Unknown parameter\n");
1512 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1513 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1515 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1516 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1518 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1519 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1522 cmdline_parse_inst_t cmd_operate_detach_port = {
1523 .f = cmd_operate_detach_port_parsed,
1525 .help_str = "port detach <port_id>",
1527 (void *)&cmd_operate_detach_port_port,
1528 (void *)&cmd_operate_detach_port_keyword,
1529 (void *)&cmd_operate_detach_port_port_id,
1534 /* *** detach device by identifier *** */
1535 struct cmd_operate_detach_device_result {
1536 cmdline_fixed_string_t device;
1537 cmdline_fixed_string_t keyword;
1538 cmdline_fixed_string_t identifier;
1541 static void cmd_operate_detach_device_parsed(void *parsed_result,
1542 __rte_unused struct cmdline *cl,
1543 __rte_unused void *data)
1545 struct cmd_operate_detach_device_result *res = parsed_result;
1547 if (!strcmp(res->keyword, "detach"))
1548 detach_devargs(res->identifier);
1550 printf("Unknown parameter\n");
1553 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1554 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1556 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1557 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1559 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1560 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1563 cmdline_parse_inst_t cmd_operate_detach_device = {
1564 .f = cmd_operate_detach_device_parsed,
1566 .help_str = "device detach <identifier>:"
1567 "(identifier: pci address or virtual dev name)",
1569 (void *)&cmd_operate_detach_device_device,
1570 (void *)&cmd_operate_detach_device_keyword,
1571 (void *)&cmd_operate_detach_device_identifier,
1575 /* *** configure speed for all ports *** */
1576 struct cmd_config_speed_all {
1577 cmdline_fixed_string_t port;
1578 cmdline_fixed_string_t keyword;
1579 cmdline_fixed_string_t all;
1580 cmdline_fixed_string_t item1;
1581 cmdline_fixed_string_t item2;
1582 cmdline_fixed_string_t value1;
1583 cmdline_fixed_string_t value2;
1587 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1592 if (!strcmp(duplexstr, "half")) {
1593 duplex = ETH_LINK_HALF_DUPLEX;
1594 } else if (!strcmp(duplexstr, "full")) {
1595 duplex = ETH_LINK_FULL_DUPLEX;
1596 } else if (!strcmp(duplexstr, "auto")) {
1597 duplex = ETH_LINK_FULL_DUPLEX;
1599 printf("Unknown duplex parameter\n");
1603 if (!strcmp(speedstr, "10")) {
1604 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1605 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1606 } else if (!strcmp(speedstr, "100")) {
1607 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1608 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1610 if (duplex != ETH_LINK_FULL_DUPLEX) {
1611 printf("Invalid speed/duplex parameters\n");
1614 if (!strcmp(speedstr, "1000")) {
1615 *speed = ETH_LINK_SPEED_1G;
1616 } else if (!strcmp(speedstr, "10000")) {
1617 *speed = ETH_LINK_SPEED_10G;
1618 } else if (!strcmp(speedstr, "25000")) {
1619 *speed = ETH_LINK_SPEED_25G;
1620 } else if (!strcmp(speedstr, "40000")) {
1621 *speed = ETH_LINK_SPEED_40G;
1622 } else if (!strcmp(speedstr, "50000")) {
1623 *speed = ETH_LINK_SPEED_50G;
1624 } else if (!strcmp(speedstr, "100000")) {
1625 *speed = ETH_LINK_SPEED_100G;
1626 } else if (!strcmp(speedstr, "200000")) {
1627 *speed = ETH_LINK_SPEED_200G;
1628 } else if (!strcmp(speedstr, "auto")) {
1629 *speed = ETH_LINK_SPEED_AUTONEG;
1631 printf("Unknown speed parameter\n");
1640 cmd_config_speed_all_parsed(void *parsed_result,
1641 __rte_unused struct cmdline *cl,
1642 __rte_unused void *data)
1644 struct cmd_config_speed_all *res = parsed_result;
1645 uint32_t link_speed;
1648 if (!all_ports_stopped()) {
1649 printf("Please stop all ports first\n");
1653 if (parse_and_check_speed_duplex(res->value1, res->value2,
1657 RTE_ETH_FOREACH_DEV(pid) {
1658 ports[pid].dev_conf.link_speeds = link_speed;
1661 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1664 cmdline_parse_token_string_t cmd_config_speed_all_port =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1666 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1667 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1669 cmdline_parse_token_string_t cmd_config_speed_all_all =
1670 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1671 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1673 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1675 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1676 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1678 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1682 cmdline_parse_inst_t cmd_config_speed_all = {
1683 .f = cmd_config_speed_all_parsed,
1685 .help_str = "port config all speed "
1686 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1689 (void *)&cmd_config_speed_all_port,
1690 (void *)&cmd_config_speed_all_keyword,
1691 (void *)&cmd_config_speed_all_all,
1692 (void *)&cmd_config_speed_all_item1,
1693 (void *)&cmd_config_speed_all_value1,
1694 (void *)&cmd_config_speed_all_item2,
1695 (void *)&cmd_config_speed_all_value2,
1700 /* *** configure speed for specific port *** */
1701 struct cmd_config_speed_specific {
1702 cmdline_fixed_string_t port;
1703 cmdline_fixed_string_t keyword;
1705 cmdline_fixed_string_t item1;
1706 cmdline_fixed_string_t item2;
1707 cmdline_fixed_string_t value1;
1708 cmdline_fixed_string_t value2;
1712 cmd_config_speed_specific_parsed(void *parsed_result,
1713 __rte_unused struct cmdline *cl,
1714 __rte_unused void *data)
1716 struct cmd_config_speed_specific *res = parsed_result;
1717 uint32_t link_speed;
1719 if (!all_ports_stopped()) {
1720 printf("Please stop all ports first\n");
1724 if (port_id_is_invalid(res->id, ENABLED_WARN))
1727 if (parse_and_check_speed_duplex(res->value1, res->value2,
1731 ports[res->id].dev_conf.link_speeds = link_speed;
1733 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1737 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1738 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1740 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1741 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1743 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1744 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1745 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1746 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1748 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1749 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1750 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1751 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1752 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1754 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1755 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1758 cmdline_parse_inst_t cmd_config_speed_specific = {
1759 .f = cmd_config_speed_specific_parsed,
1761 .help_str = "port config <port_id> speed "
1762 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1765 (void *)&cmd_config_speed_specific_port,
1766 (void *)&cmd_config_speed_specific_keyword,
1767 (void *)&cmd_config_speed_specific_id,
1768 (void *)&cmd_config_speed_specific_item1,
1769 (void *)&cmd_config_speed_specific_value1,
1770 (void *)&cmd_config_speed_specific_item2,
1771 (void *)&cmd_config_speed_specific_value2,
1776 /* *** configure loopback for all ports *** */
1777 struct cmd_config_loopback_all {
1778 cmdline_fixed_string_t port;
1779 cmdline_fixed_string_t keyword;
1780 cmdline_fixed_string_t all;
1781 cmdline_fixed_string_t item;
1786 cmd_config_loopback_all_parsed(void *parsed_result,
1787 __rte_unused struct cmdline *cl,
1788 __rte_unused void *data)
1790 struct cmd_config_loopback_all *res = parsed_result;
1793 if (!all_ports_stopped()) {
1794 printf("Please stop all ports first\n");
1798 RTE_ETH_FOREACH_DEV(pid) {
1799 ports[pid].dev_conf.lpbk_mode = res->mode;
1802 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1805 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1806 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1807 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1808 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1810 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1811 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1812 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1813 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1815 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1816 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1818 cmdline_parse_inst_t cmd_config_loopback_all = {
1819 .f = cmd_config_loopback_all_parsed,
1821 .help_str = "port config all loopback <mode>",
1823 (void *)&cmd_config_loopback_all_port,
1824 (void *)&cmd_config_loopback_all_keyword,
1825 (void *)&cmd_config_loopback_all_all,
1826 (void *)&cmd_config_loopback_all_item,
1827 (void *)&cmd_config_loopback_all_mode,
1832 /* *** configure loopback for specific port *** */
1833 struct cmd_config_loopback_specific {
1834 cmdline_fixed_string_t port;
1835 cmdline_fixed_string_t keyword;
1837 cmdline_fixed_string_t item;
1842 cmd_config_loopback_specific_parsed(void *parsed_result,
1843 __rte_unused struct cmdline *cl,
1844 __rte_unused void *data)
1846 struct cmd_config_loopback_specific *res = parsed_result;
1848 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1851 if (!port_is_stopped(res->port_id)) {
1852 printf("Please stop port %u first\n", res->port_id);
1856 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1858 cmd_reconfig_device_queue(res->port_id, 1, 1);
1862 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1863 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1865 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1868 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1869 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1871 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1872 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1874 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1875 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1878 cmdline_parse_inst_t cmd_config_loopback_specific = {
1879 .f = cmd_config_loopback_specific_parsed,
1881 .help_str = "port config <port_id> loopback <mode>",
1883 (void *)&cmd_config_loopback_specific_port,
1884 (void *)&cmd_config_loopback_specific_keyword,
1885 (void *)&cmd_config_loopback_specific_id,
1886 (void *)&cmd_config_loopback_specific_item,
1887 (void *)&cmd_config_loopback_specific_mode,
1892 /* *** configure txq/rxq, txd/rxd *** */
1893 struct cmd_config_rx_tx {
1894 cmdline_fixed_string_t port;
1895 cmdline_fixed_string_t keyword;
1896 cmdline_fixed_string_t all;
1897 cmdline_fixed_string_t name;
1902 cmd_config_rx_tx_parsed(void *parsed_result,
1903 __rte_unused struct cmdline *cl,
1904 __rte_unused void *data)
1906 struct cmd_config_rx_tx *res = parsed_result;
1908 if (!all_ports_stopped()) {
1909 printf("Please stop all ports first\n");
1912 if (!strcmp(res->name, "rxq")) {
1913 if (!res->value && !nb_txq) {
1914 printf("Warning: Either rx or tx queues should be non zero\n");
1917 if (check_nb_rxq(res->value) != 0)
1919 nb_rxq = res->value;
1921 else if (!strcmp(res->name, "txq")) {
1922 if (!res->value && !nb_rxq) {
1923 printf("Warning: Either rx or tx queues should be non zero\n");
1926 if (check_nb_txq(res->value) != 0)
1928 nb_txq = res->value;
1930 else if (!strcmp(res->name, "rxd")) {
1931 if (check_nb_rxd(res->value) != 0)
1933 nb_rxd = res->value;
1934 } else if (!strcmp(res->name, "txd")) {
1935 if (check_nb_txd(res->value) != 0)
1938 nb_txd = res->value;
1940 printf("Unknown parameter\n");
1948 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1951 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1952 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1953 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1954 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1955 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1956 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1957 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1960 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1961 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1963 cmdline_parse_inst_t cmd_config_rx_tx = {
1964 .f = cmd_config_rx_tx_parsed,
1966 .help_str = "port config all rxq|txq|rxd|txd <value>",
1968 (void *)&cmd_config_rx_tx_port,
1969 (void *)&cmd_config_rx_tx_keyword,
1970 (void *)&cmd_config_rx_tx_all,
1971 (void *)&cmd_config_rx_tx_name,
1972 (void *)&cmd_config_rx_tx_value,
1977 /* *** config max packet length *** */
1978 struct cmd_config_max_pkt_len_result {
1979 cmdline_fixed_string_t port;
1980 cmdline_fixed_string_t keyword;
1981 cmdline_fixed_string_t all;
1982 cmdline_fixed_string_t name;
1987 cmd_config_max_pkt_len_parsed(void *parsed_result,
1988 __rte_unused struct cmdline *cl,
1989 __rte_unused void *data)
1991 struct cmd_config_max_pkt_len_result *res = parsed_result;
1994 if (!all_ports_stopped()) {
1995 printf("Please stop all ports first\n");
1999 RTE_ETH_FOREACH_DEV(pid) {
2000 struct rte_port *port = &ports[pid];
2001 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2003 if (!strcmp(res->name, "max-pkt-len")) {
2004 if (res->value < RTE_ETHER_MIN_LEN) {
2005 printf("max-pkt-len can not be less than %d\n",
2009 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2012 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2013 if (res->value > RTE_ETHER_MAX_LEN)
2014 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2016 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2017 port->dev_conf.rxmode.offloads = rx_offloads;
2019 printf("Unknown parameter\n");
2026 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2029 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2030 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2032 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2035 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2036 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2038 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2039 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2041 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2042 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2045 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2046 .f = cmd_config_max_pkt_len_parsed,
2048 .help_str = "port config all max-pkt-len <value>",
2050 (void *)&cmd_config_max_pkt_len_port,
2051 (void *)&cmd_config_max_pkt_len_keyword,
2052 (void *)&cmd_config_max_pkt_len_all,
2053 (void *)&cmd_config_max_pkt_len_name,
2054 (void *)&cmd_config_max_pkt_len_value,
2059 /* *** config max LRO aggregated packet size *** */
2060 struct cmd_config_max_lro_pkt_size_result {
2061 cmdline_fixed_string_t port;
2062 cmdline_fixed_string_t keyword;
2063 cmdline_fixed_string_t all;
2064 cmdline_fixed_string_t name;
2069 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2070 __rte_unused struct cmdline *cl,
2071 __rte_unused void *data)
2073 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2076 if (!all_ports_stopped()) {
2077 printf("Please stop all ports first\n");
2081 RTE_ETH_FOREACH_DEV(pid) {
2082 struct rte_port *port = &ports[pid];
2084 if (!strcmp(res->name, "max-lro-pkt-size")) {
2086 port->dev_conf.rxmode.max_lro_pkt_size)
2089 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2091 printf("Unknown parameter\n");
2098 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2101 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2102 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2104 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2105 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2107 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2108 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2110 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2111 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2112 name, "max-lro-pkt-size");
2113 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2114 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2117 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2118 .f = cmd_config_max_lro_pkt_size_parsed,
2120 .help_str = "port config all max-lro-pkt-size <value>",
2122 (void *)&cmd_config_max_lro_pkt_size_port,
2123 (void *)&cmd_config_max_lro_pkt_size_keyword,
2124 (void *)&cmd_config_max_lro_pkt_size_all,
2125 (void *)&cmd_config_max_lro_pkt_size_name,
2126 (void *)&cmd_config_max_lro_pkt_size_value,
2131 /* *** configure port MTU *** */
2132 struct cmd_config_mtu_result {
2133 cmdline_fixed_string_t port;
2134 cmdline_fixed_string_t keyword;
2135 cmdline_fixed_string_t mtu;
2141 cmd_config_mtu_parsed(void *parsed_result,
2142 __rte_unused struct cmdline *cl,
2143 __rte_unused void *data)
2145 struct cmd_config_mtu_result *res = parsed_result;
2147 if (res->value < RTE_ETHER_MIN_LEN) {
2148 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2151 port_mtu_set(res->port_id, res->value);
2154 cmdline_parse_token_string_t cmd_config_mtu_port =
2155 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2157 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2158 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2160 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2161 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2163 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2164 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2165 cmdline_parse_token_num_t cmd_config_mtu_value =
2166 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2168 cmdline_parse_inst_t cmd_config_mtu = {
2169 .f = cmd_config_mtu_parsed,
2171 .help_str = "port config mtu <port_id> <value>",
2173 (void *)&cmd_config_mtu_port,
2174 (void *)&cmd_config_mtu_keyword,
2175 (void *)&cmd_config_mtu_mtu,
2176 (void *)&cmd_config_mtu_port_id,
2177 (void *)&cmd_config_mtu_value,
2182 /* *** configure rx mode *** */
2183 struct cmd_config_rx_mode_flag {
2184 cmdline_fixed_string_t port;
2185 cmdline_fixed_string_t keyword;
2186 cmdline_fixed_string_t all;
2187 cmdline_fixed_string_t name;
2188 cmdline_fixed_string_t value;
2192 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2193 __rte_unused struct cmdline *cl,
2194 __rte_unused void *data)
2196 struct cmd_config_rx_mode_flag *res = parsed_result;
2198 if (!all_ports_stopped()) {
2199 printf("Please stop all ports first\n");
2203 if (!strcmp(res->name, "drop-en")) {
2204 if (!strcmp(res->value, "on"))
2206 else if (!strcmp(res->value, "off"))
2209 printf("Unknown parameter\n");
2213 printf("Unknown parameter\n");
2219 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2222 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2223 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2224 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2225 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2227 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2228 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2229 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2230 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2232 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2233 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2236 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2237 .f = cmd_config_rx_mode_flag_parsed,
2239 .help_str = "port config all drop-en on|off",
2241 (void *)&cmd_config_rx_mode_flag_port,
2242 (void *)&cmd_config_rx_mode_flag_keyword,
2243 (void *)&cmd_config_rx_mode_flag_all,
2244 (void *)&cmd_config_rx_mode_flag_name,
2245 (void *)&cmd_config_rx_mode_flag_value,
2250 /* *** configure rss *** */
2251 struct cmd_config_rss {
2252 cmdline_fixed_string_t port;
2253 cmdline_fixed_string_t keyword;
2254 cmdline_fixed_string_t all;
2255 cmdline_fixed_string_t name;
2256 cmdline_fixed_string_t value;
2260 cmd_config_rss_parsed(void *parsed_result,
2261 __rte_unused struct cmdline *cl,
2262 __rte_unused void *data)
2264 struct cmd_config_rss *res = parsed_result;
2265 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2266 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2267 int use_default = 0;
2268 int all_updated = 1;
2273 if (!strcmp(res->value, "all"))
2274 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2275 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2276 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2277 ETH_RSS_AH | ETH_RSS_PFCP;
2278 else if (!strcmp(res->value, "eth"))
2279 rss_conf.rss_hf = ETH_RSS_ETH;
2280 else if (!strcmp(res->value, "vlan"))
2281 rss_conf.rss_hf = ETH_RSS_VLAN;
2282 else if (!strcmp(res->value, "ip"))
2283 rss_conf.rss_hf = ETH_RSS_IP;
2284 else if (!strcmp(res->value, "udp"))
2285 rss_conf.rss_hf = ETH_RSS_UDP;
2286 else if (!strcmp(res->value, "tcp"))
2287 rss_conf.rss_hf = ETH_RSS_TCP;
2288 else if (!strcmp(res->value, "sctp"))
2289 rss_conf.rss_hf = ETH_RSS_SCTP;
2290 else if (!strcmp(res->value, "ether"))
2291 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2292 else if (!strcmp(res->value, "port"))
2293 rss_conf.rss_hf = ETH_RSS_PORT;
2294 else if (!strcmp(res->value, "vxlan"))
2295 rss_conf.rss_hf = ETH_RSS_VXLAN;
2296 else if (!strcmp(res->value, "geneve"))
2297 rss_conf.rss_hf = ETH_RSS_GENEVE;
2298 else if (!strcmp(res->value, "nvgre"))
2299 rss_conf.rss_hf = ETH_RSS_NVGRE;
2300 else if (!strcmp(res->value, "l3-src-only"))
2301 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2302 else if (!strcmp(res->value, "l3-dst-only"))
2303 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2304 else if (!strcmp(res->value, "l4-src-only"))
2305 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2306 else if (!strcmp(res->value, "l4-dst-only"))
2307 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2308 else if (!strcmp(res->value, "l2-src-only"))
2309 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2310 else if (!strcmp(res->value, "l2-dst-only"))
2311 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2312 else if (!strcmp(res->value, "l2tpv3"))
2313 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2314 else if (!strcmp(res->value, "esp"))
2315 rss_conf.rss_hf = ETH_RSS_ESP;
2316 else if (!strcmp(res->value, "ah"))
2317 rss_conf.rss_hf = ETH_RSS_AH;
2318 else if (!strcmp(res->value, "pfcp"))
2319 rss_conf.rss_hf = ETH_RSS_PFCP;
2320 else if (!strcmp(res->value, "pppoe"))
2321 rss_conf.rss_hf = ETH_RSS_PPPOE;
2322 else if (!strcmp(res->value, "none"))
2323 rss_conf.rss_hf = 0;
2324 else if (!strcmp(res->value, "default"))
2326 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2327 atoi(res->value) < 64)
2328 rss_conf.rss_hf = 1ULL << atoi(res->value);
2330 printf("Unknown parameter\n");
2333 rss_conf.rss_key = NULL;
2334 /* Update global configuration for RSS types. */
2335 RTE_ETH_FOREACH_DEV(i) {
2336 struct rte_eth_rss_conf local_rss_conf;
2338 ret = eth_dev_info_get_print_err(i, &dev_info);
2343 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2345 local_rss_conf = rss_conf;
2346 local_rss_conf.rss_hf = rss_conf.rss_hf &
2347 dev_info.flow_type_rss_offloads;
2348 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2349 printf("Port %u modified RSS hash function based on hardware support,"
2350 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2351 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2353 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2356 printf("Configuration of RSS hash at ethernet port %d "
2357 "failed with error (%d): %s.\n",
2358 i, -diag, strerror(-diag));
2361 if (all_updated && !use_default) {
2362 rss_hf = rss_conf.rss_hf;
2363 printf("rss_hf %#"PRIx64"\n", rss_hf);
2367 cmdline_parse_token_string_t cmd_config_rss_port =
2368 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2369 cmdline_parse_token_string_t cmd_config_rss_keyword =
2370 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2371 cmdline_parse_token_string_t cmd_config_rss_all =
2372 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2373 cmdline_parse_token_string_t cmd_config_rss_name =
2374 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2375 cmdline_parse_token_string_t cmd_config_rss_value =
2376 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2378 cmdline_parse_inst_t cmd_config_rss = {
2379 .f = cmd_config_rss_parsed,
2381 .help_str = "port config all rss "
2382 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2383 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|<flowtype_id>",
2385 (void *)&cmd_config_rss_port,
2386 (void *)&cmd_config_rss_keyword,
2387 (void *)&cmd_config_rss_all,
2388 (void *)&cmd_config_rss_name,
2389 (void *)&cmd_config_rss_value,
2394 /* *** configure rss hash key *** */
2395 struct cmd_config_rss_hash_key {
2396 cmdline_fixed_string_t port;
2397 cmdline_fixed_string_t config;
2399 cmdline_fixed_string_t rss_hash_key;
2400 cmdline_fixed_string_t rss_type;
2401 cmdline_fixed_string_t key;
2405 hexa_digit_to_value(char hexa_digit)
2407 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2408 return (uint8_t) (hexa_digit - '0');
2409 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2410 return (uint8_t) ((hexa_digit - 'a') + 10);
2411 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2412 return (uint8_t) ((hexa_digit - 'A') + 10);
2413 /* Invalid hexa digit */
2418 parse_and_check_key_hexa_digit(char *key, int idx)
2422 hexa_v = hexa_digit_to_value(key[idx]);
2424 printf("invalid key: character %c at position %d is not a "
2425 "valid hexa digit\n", key[idx], idx);
2430 cmd_config_rss_hash_key_parsed(void *parsed_result,
2431 __rte_unused struct cmdline *cl,
2432 __rte_unused void *data)
2434 struct cmd_config_rss_hash_key *res = parsed_result;
2435 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2439 struct rte_eth_dev_info dev_info;
2440 uint8_t hash_key_size;
2444 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2448 if (dev_info.hash_key_size > 0 &&
2449 dev_info.hash_key_size <= sizeof(hash_key))
2450 hash_key_size = dev_info.hash_key_size;
2452 printf("dev_info did not provide a valid hash key size\n");
2455 /* Check the length of the RSS hash key */
2456 key_len = strlen(res->key);
2457 if (key_len != (hash_key_size * 2)) {
2458 printf("key length: %d invalid - key must be a string of %d"
2459 " hexa-decimal numbers\n",
2460 (int) key_len, hash_key_size * 2);
2463 /* Translate RSS hash key into binary representation */
2464 for (i = 0; i < hash_key_size; i++) {
2465 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2468 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2471 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2473 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2477 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2478 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2479 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2480 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2482 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2483 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2484 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2485 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2486 rss_hash_key, "rss-hash-key");
2487 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2488 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2489 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2490 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2491 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2492 "ipv6-tcp-ex#ipv6-udp-ex#"
2493 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2494 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2495 "l2tpv3#esp#ah#pfcp#pppoe");
2496 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2497 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2499 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2500 .f = cmd_config_rss_hash_key_parsed,
2502 .help_str = "port config <port_id> rss-hash-key "
2503 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2504 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2505 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2506 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2507 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2508 "l2tpv3|esp|ah|pfcp|pppoe "
2509 "<string of hex digits (variable length, NIC dependent)>",
2511 (void *)&cmd_config_rss_hash_key_port,
2512 (void *)&cmd_config_rss_hash_key_config,
2513 (void *)&cmd_config_rss_hash_key_port_id,
2514 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2515 (void *)&cmd_config_rss_hash_key_rss_type,
2516 (void *)&cmd_config_rss_hash_key_value,
2521 /* *** configure port rxq/txq ring size *** */
2522 struct cmd_config_rxtx_ring_size {
2523 cmdline_fixed_string_t port;
2524 cmdline_fixed_string_t config;
2526 cmdline_fixed_string_t rxtxq;
2528 cmdline_fixed_string_t rsize;
2533 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2534 __rte_unused struct cmdline *cl,
2535 __rte_unused void *data)
2537 struct cmd_config_rxtx_ring_size *res = parsed_result;
2538 struct rte_port *port;
2541 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2544 if (res->portid == (portid_t)RTE_PORT_ALL) {
2545 printf("Invalid port id\n");
2549 port = &ports[res->portid];
2551 if (!strcmp(res->rxtxq, "rxq"))
2553 else if (!strcmp(res->rxtxq, "txq"))
2556 printf("Unknown parameter\n");
2560 if (isrx && rx_queue_id_is_invalid(res->qid))
2562 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2565 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2566 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2572 port->nb_rx_desc[res->qid] = res->size;
2574 port->nb_tx_desc[res->qid] = res->size;
2576 cmd_reconfig_device_queue(res->portid, 0, 1);
2579 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2580 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2582 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2583 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2585 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2586 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2588 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2589 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2591 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2592 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2594 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2595 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2596 rsize, "ring_size");
2597 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2598 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2601 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2602 .f = cmd_config_rxtx_ring_size_parsed,
2604 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2606 (void *)&cmd_config_rxtx_ring_size_port,
2607 (void *)&cmd_config_rxtx_ring_size_config,
2608 (void *)&cmd_config_rxtx_ring_size_portid,
2609 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2610 (void *)&cmd_config_rxtx_ring_size_qid,
2611 (void *)&cmd_config_rxtx_ring_size_rsize,
2612 (void *)&cmd_config_rxtx_ring_size_size,
2617 /* *** configure port rxq/txq start/stop *** */
2618 struct cmd_config_rxtx_queue {
2619 cmdline_fixed_string_t port;
2621 cmdline_fixed_string_t rxtxq;
2623 cmdline_fixed_string_t opname;
2627 cmd_config_rxtx_queue_parsed(void *parsed_result,
2628 __rte_unused struct cmdline *cl,
2629 __rte_unused void *data)
2631 struct cmd_config_rxtx_queue *res = parsed_result;
2636 if (test_done == 0) {
2637 printf("Please stop forwarding first\n");
2641 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2644 if (port_is_started(res->portid) != 1) {
2645 printf("Please start port %u first\n", res->portid);
2649 if (!strcmp(res->rxtxq, "rxq"))
2651 else if (!strcmp(res->rxtxq, "txq"))
2654 printf("Unknown parameter\n");
2658 if (isrx && rx_queue_id_is_invalid(res->qid))
2660 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2663 if (!strcmp(res->opname, "start"))
2665 else if (!strcmp(res->opname, "stop"))
2668 printf("Unknown parameter\n");
2672 if (isstart && isrx)
2673 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2674 else if (!isstart && isrx)
2675 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2676 else if (isstart && !isrx)
2677 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2679 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2681 if (ret == -ENOTSUP)
2682 printf("Function not supported in PMD driver\n");
2685 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2686 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2687 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2688 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2689 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2690 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2691 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2692 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2693 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2694 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2697 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2698 .f = cmd_config_rxtx_queue_parsed,
2700 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2702 (void *)&cmd_config_rxtx_queue_port,
2703 (void *)&cmd_config_rxtx_queue_portid,
2704 (void *)&cmd_config_rxtx_queue_rxtxq,
2705 (void *)&cmd_config_rxtx_queue_qid,
2706 (void *)&cmd_config_rxtx_queue_opname,
2711 /* *** configure port rxq/txq deferred start on/off *** */
2712 struct cmd_config_deferred_start_rxtx_queue {
2713 cmdline_fixed_string_t port;
2715 cmdline_fixed_string_t rxtxq;
2717 cmdline_fixed_string_t opname;
2718 cmdline_fixed_string_t state;
2722 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2723 __rte_unused struct cmdline *cl,
2724 __rte_unused void *data)
2726 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2727 struct rte_port *port;
2730 uint8_t needreconfig = 0;
2732 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2735 if (port_is_started(res->port_id) != 0) {
2736 printf("Please stop port %u first\n", res->port_id);
2740 port = &ports[res->port_id];
2742 isrx = !strcmp(res->rxtxq, "rxq");
2744 if (isrx && rx_queue_id_is_invalid(res->qid))
2746 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2749 ison = !strcmp(res->state, "on");
2751 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2752 port->rx_conf[res->qid].rx_deferred_start = ison;
2754 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2755 port->tx_conf[res->qid].tx_deferred_start = ison;
2760 cmd_reconfig_device_queue(res->port_id, 0, 1);
2763 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2764 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2766 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2767 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2769 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2770 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2772 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2773 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2775 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2776 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2777 opname, "deferred_start");
2778 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2779 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2782 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2783 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2785 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2787 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2788 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2789 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2790 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2791 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2792 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2797 /* *** configure port rxq/txq setup *** */
2798 struct cmd_setup_rxtx_queue {
2799 cmdline_fixed_string_t port;
2801 cmdline_fixed_string_t rxtxq;
2803 cmdline_fixed_string_t setup;
2806 /* Common CLI fields for queue setup */
2807 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2808 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2809 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2810 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2811 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2812 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2813 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2814 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2815 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2816 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2819 cmd_setup_rxtx_queue_parsed(
2820 void *parsed_result,
2821 __rte_unused struct cmdline *cl,
2822 __rte_unused void *data)
2824 struct cmd_setup_rxtx_queue *res = parsed_result;
2825 struct rte_port *port;
2826 struct rte_mempool *mp;
2827 unsigned int socket_id;
2831 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2834 if (res->portid == (portid_t)RTE_PORT_ALL) {
2835 printf("Invalid port id\n");
2839 if (!strcmp(res->rxtxq, "rxq"))
2841 else if (!strcmp(res->rxtxq, "txq"))
2844 printf("Unknown parameter\n");
2848 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2849 printf("Invalid rx queue\n");
2851 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2852 printf("Invalid tx queue\n");
2856 port = &ports[res->portid];
2858 socket_id = rxring_numa[res->portid];
2859 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2860 socket_id = port->socket_id;
2862 mp = mbuf_pool_find(socket_id);
2864 printf("Failed to setup RX queue: "
2865 "No mempool allocation"
2866 " on the socket %d\n",
2867 rxring_numa[res->portid]);
2870 ret = rte_eth_rx_queue_setup(res->portid,
2872 port->nb_rx_desc[res->qid],
2874 &port->rx_conf[res->qid],
2877 printf("Failed to setup RX queue\n");
2879 socket_id = txring_numa[res->portid];
2880 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2881 socket_id = port->socket_id;
2883 ret = rte_eth_tx_queue_setup(res->portid,
2885 port->nb_tx_desc[res->qid],
2887 &port->tx_conf[res->qid]);
2889 printf("Failed to setup TX queue\n");
2893 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2894 .f = cmd_setup_rxtx_queue_parsed,
2896 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2898 (void *)&cmd_setup_rxtx_queue_port,
2899 (void *)&cmd_setup_rxtx_queue_portid,
2900 (void *)&cmd_setup_rxtx_queue_rxtxq,
2901 (void *)&cmd_setup_rxtx_queue_qid,
2902 (void *)&cmd_setup_rxtx_queue_setup,
2908 /* *** Configure RSS RETA *** */
2909 struct cmd_config_rss_reta {
2910 cmdline_fixed_string_t port;
2911 cmdline_fixed_string_t keyword;
2913 cmdline_fixed_string_t name;
2914 cmdline_fixed_string_t list_name;
2915 cmdline_fixed_string_t list_of_items;
2919 parse_reta_config(const char *str,
2920 struct rte_eth_rss_reta_entry64 *reta_conf,
2921 uint16_t nb_entries)
2925 uint16_t hash_index, idx, shift;
2928 const char *p, *p0 = str;
2935 unsigned long int_fld[_NUM_FLD];
2936 char *str_fld[_NUM_FLD];
2938 while ((p = strchr(p0,'(')) != NULL) {
2940 if((p0 = strchr(p,')')) == NULL)
2944 if(size >= sizeof(s))
2947 snprintf(s, sizeof(s), "%.*s", size, p);
2948 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2950 for (i = 0; i < _NUM_FLD; i++) {
2952 int_fld[i] = strtoul(str_fld[i], &end, 0);
2953 if (errno != 0 || end == str_fld[i] ||
2958 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2959 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2961 if (hash_index >= nb_entries) {
2962 printf("Invalid RETA hash index=%d\n", hash_index);
2966 idx = hash_index / RTE_RETA_GROUP_SIZE;
2967 shift = hash_index % RTE_RETA_GROUP_SIZE;
2968 reta_conf[idx].mask |= (1ULL << shift);
2969 reta_conf[idx].reta[shift] = nb_queue;
2976 cmd_set_rss_reta_parsed(void *parsed_result,
2977 __rte_unused struct cmdline *cl,
2978 __rte_unused void *data)
2981 struct rte_eth_dev_info dev_info;
2982 struct rte_eth_rss_reta_entry64 reta_conf[8];
2983 struct cmd_config_rss_reta *res = parsed_result;
2985 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2989 if (dev_info.reta_size == 0) {
2990 printf("Redirection table size is 0 which is "
2991 "invalid for RSS\n");
2994 printf("The reta size of port %d is %u\n",
2995 res->port_id, dev_info.reta_size);
2996 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2997 printf("Currently do not support more than %u entries of "
2998 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3002 memset(reta_conf, 0, sizeof(reta_conf));
3003 if (!strcmp(res->list_name, "reta")) {
3004 if (parse_reta_config(res->list_of_items, reta_conf,
3005 dev_info.reta_size)) {
3006 printf("Invalid RSS Redirection Table "
3007 "config entered\n");
3010 ret = rte_eth_dev_rss_reta_update(res->port_id,
3011 reta_conf, dev_info.reta_size);
3013 printf("Bad redirection table parameter, "
3014 "return code = %d \n", ret);
3018 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3019 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3020 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3021 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3022 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3023 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3024 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3025 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3026 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3027 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3028 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3029 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3031 cmdline_parse_inst_t cmd_config_rss_reta = {
3032 .f = cmd_set_rss_reta_parsed,
3034 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3036 (void *)&cmd_config_rss_reta_port,
3037 (void *)&cmd_config_rss_reta_keyword,
3038 (void *)&cmd_config_rss_reta_port_id,
3039 (void *)&cmd_config_rss_reta_name,
3040 (void *)&cmd_config_rss_reta_list_name,
3041 (void *)&cmd_config_rss_reta_list_of_items,
3046 /* *** SHOW PORT RETA INFO *** */
3047 struct cmd_showport_reta {
3048 cmdline_fixed_string_t show;
3049 cmdline_fixed_string_t port;
3051 cmdline_fixed_string_t rss;
3052 cmdline_fixed_string_t reta;
3054 cmdline_fixed_string_t list_of_items;
3058 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3059 uint16_t nb_entries,
3063 const char *p, *p0 = str;
3068 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3069 RTE_RETA_GROUP_SIZE;
3072 p = strchr(p0, '(');
3076 p0 = strchr(p, ')');
3080 if (size >= sizeof(s)) {
3081 printf("The string size exceeds the internal buffer size\n");
3084 snprintf(s, sizeof(s), "%.*s", size, p);
3085 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3086 if (ret <= 0 || ret != num) {
3087 printf("The bits of masks do not match the number of "
3088 "reta entries: %u\n", num);
3091 for (i = 0; i < ret; i++)
3092 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3098 cmd_showport_reta_parsed(void *parsed_result,
3099 __rte_unused struct cmdline *cl,
3100 __rte_unused void *data)
3102 struct cmd_showport_reta *res = parsed_result;
3103 struct rte_eth_rss_reta_entry64 reta_conf[8];
3104 struct rte_eth_dev_info dev_info;
3105 uint16_t max_reta_size;
3108 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3112 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3113 if (res->size == 0 || res->size > max_reta_size) {
3114 printf("Invalid redirection table size: %u (1-%u)\n",
3115 res->size, max_reta_size);
3119 memset(reta_conf, 0, sizeof(reta_conf));
3120 if (showport_parse_reta_config(reta_conf, res->size,
3121 res->list_of_items) < 0) {
3122 printf("Invalid string: %s for reta masks\n",
3123 res->list_of_items);
3126 port_rss_reta_info(res->port_id, reta_conf, res->size);
3129 cmdline_parse_token_string_t cmd_showport_reta_show =
3130 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3131 cmdline_parse_token_string_t cmd_showport_reta_port =
3132 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3133 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3134 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3135 cmdline_parse_token_string_t cmd_showport_reta_rss =
3136 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3137 cmdline_parse_token_string_t cmd_showport_reta_reta =
3138 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3139 cmdline_parse_token_num_t cmd_showport_reta_size =
3140 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3141 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3142 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3143 list_of_items, NULL);
3145 cmdline_parse_inst_t cmd_showport_reta = {
3146 .f = cmd_showport_reta_parsed,
3148 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3150 (void *)&cmd_showport_reta_show,
3151 (void *)&cmd_showport_reta_port,
3152 (void *)&cmd_showport_reta_port_id,
3153 (void *)&cmd_showport_reta_rss,
3154 (void *)&cmd_showport_reta_reta,
3155 (void *)&cmd_showport_reta_size,
3156 (void *)&cmd_showport_reta_list_of_items,
3161 /* *** Show RSS hash configuration *** */
3162 struct cmd_showport_rss_hash {
3163 cmdline_fixed_string_t show;
3164 cmdline_fixed_string_t port;
3166 cmdline_fixed_string_t rss_hash;
3167 cmdline_fixed_string_t rss_type;
3168 cmdline_fixed_string_t key; /* optional argument */
3171 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3172 __rte_unused struct cmdline *cl,
3175 struct cmd_showport_rss_hash *res = parsed_result;
3177 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3180 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3181 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3182 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3183 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3184 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3185 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3186 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3187 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3189 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3190 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3192 cmdline_parse_inst_t cmd_showport_rss_hash = {
3193 .f = cmd_showport_rss_hash_parsed,
3195 .help_str = "show port <port_id> rss-hash",
3197 (void *)&cmd_showport_rss_hash_show,
3198 (void *)&cmd_showport_rss_hash_port,
3199 (void *)&cmd_showport_rss_hash_port_id,
3200 (void *)&cmd_showport_rss_hash_rss_hash,
3205 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3206 .f = cmd_showport_rss_hash_parsed,
3208 .help_str = "show port <port_id> rss-hash key",
3210 (void *)&cmd_showport_rss_hash_show,
3211 (void *)&cmd_showport_rss_hash_port,
3212 (void *)&cmd_showport_rss_hash_port_id,
3213 (void *)&cmd_showport_rss_hash_rss_hash,
3214 (void *)&cmd_showport_rss_hash_rss_key,
3219 /* *** Configure DCB *** */
3220 struct cmd_config_dcb {
3221 cmdline_fixed_string_t port;
3222 cmdline_fixed_string_t config;
3224 cmdline_fixed_string_t dcb;
3225 cmdline_fixed_string_t vt;
3226 cmdline_fixed_string_t vt_en;
3228 cmdline_fixed_string_t pfc;
3229 cmdline_fixed_string_t pfc_en;
3233 cmd_config_dcb_parsed(void *parsed_result,
3234 __rte_unused struct cmdline *cl,
3235 __rte_unused void *data)
3237 struct cmd_config_dcb *res = parsed_result;
3238 portid_t port_id = res->port_id;
3239 struct rte_port *port;
3243 port = &ports[port_id];
3244 /** Check if the port is not started **/
3245 if (port->port_status != RTE_PORT_STOPPED) {
3246 printf("Please stop port %d first\n", port_id);
3250 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3251 printf("The invalid number of traffic class,"
3252 " only 4 or 8 allowed.\n");
3256 if (nb_fwd_lcores < res->num_tcs) {
3257 printf("nb_cores shouldn't be less than number of TCs.\n");
3260 if (!strncmp(res->pfc_en, "on", 2))
3265 /* DCB in VT mode */
3266 if (!strncmp(res->vt_en, "on", 2))
3267 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3268 (enum rte_eth_nb_tcs)res->num_tcs,
3271 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3272 (enum rte_eth_nb_tcs)res->num_tcs,
3277 printf("Cannot initialize network ports.\n");
3281 cmd_reconfig_device_queue(port_id, 1, 1);
3284 cmdline_parse_token_string_t cmd_config_dcb_port =
3285 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3286 cmdline_parse_token_string_t cmd_config_dcb_config =
3287 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3288 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3289 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3290 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3291 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3292 cmdline_parse_token_string_t cmd_config_dcb_vt =
3293 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3294 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3295 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3296 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3297 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3298 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3299 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3300 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3301 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3303 cmdline_parse_inst_t cmd_config_dcb = {
3304 .f = cmd_config_dcb_parsed,
3306 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3308 (void *)&cmd_config_dcb_port,
3309 (void *)&cmd_config_dcb_config,
3310 (void *)&cmd_config_dcb_port_id,
3311 (void *)&cmd_config_dcb_dcb,
3312 (void *)&cmd_config_dcb_vt,
3313 (void *)&cmd_config_dcb_vt_en,
3314 (void *)&cmd_config_dcb_num_tcs,
3315 (void *)&cmd_config_dcb_pfc,
3316 (void *)&cmd_config_dcb_pfc_en,
3321 /* *** configure number of packets per burst *** */
3322 struct cmd_config_burst {
3323 cmdline_fixed_string_t port;
3324 cmdline_fixed_string_t keyword;
3325 cmdline_fixed_string_t all;
3326 cmdline_fixed_string_t name;
3331 cmd_config_burst_parsed(void *parsed_result,
3332 __rte_unused struct cmdline *cl,
3333 __rte_unused void *data)
3335 struct cmd_config_burst *res = parsed_result;
3336 struct rte_eth_dev_info dev_info;
3337 uint16_t rec_nb_pkts;
3340 if (!all_ports_stopped()) {
3341 printf("Please stop all ports first\n");
3345 if (!strcmp(res->name, "burst")) {
3346 if (res->value == 0) {
3347 /* If user gives a value of zero, query the PMD for
3348 * its recommended Rx burst size. Testpmd uses a single
3349 * size for all ports, so assume all ports are the same
3350 * NIC model and use the values from Port 0.
3352 ret = eth_dev_info_get_print_err(0, &dev_info);
3356 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3358 if (rec_nb_pkts == 0) {
3359 printf("PMD does not recommend a burst size.\n"
3360 "User provided value must be between"
3361 " 1 and %d\n", MAX_PKT_BURST);
3363 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3364 printf("PMD recommended burst size of %d"
3365 " exceeds maximum value of %d\n",
3366 rec_nb_pkts, MAX_PKT_BURST);
3369 printf("Using PMD-provided burst value of %d\n",
3371 nb_pkt_per_burst = rec_nb_pkts;
3372 } else if (res->value > MAX_PKT_BURST) {
3373 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3376 nb_pkt_per_burst = res->value;
3378 printf("Unknown parameter\n");
3384 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3387 cmdline_parse_token_string_t cmd_config_burst_port =
3388 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3389 cmdline_parse_token_string_t cmd_config_burst_keyword =
3390 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3391 cmdline_parse_token_string_t cmd_config_burst_all =
3392 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3393 cmdline_parse_token_string_t cmd_config_burst_name =
3394 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3395 cmdline_parse_token_num_t cmd_config_burst_value =
3396 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3398 cmdline_parse_inst_t cmd_config_burst = {
3399 .f = cmd_config_burst_parsed,
3401 .help_str = "port config all burst <value>",
3403 (void *)&cmd_config_burst_port,
3404 (void *)&cmd_config_burst_keyword,
3405 (void *)&cmd_config_burst_all,
3406 (void *)&cmd_config_burst_name,
3407 (void *)&cmd_config_burst_value,
3412 /* *** configure rx/tx queues *** */
3413 struct cmd_config_thresh {
3414 cmdline_fixed_string_t port;
3415 cmdline_fixed_string_t keyword;
3416 cmdline_fixed_string_t all;
3417 cmdline_fixed_string_t name;
3422 cmd_config_thresh_parsed(void *parsed_result,
3423 __rte_unused struct cmdline *cl,
3424 __rte_unused void *data)
3426 struct cmd_config_thresh *res = parsed_result;
3428 if (!all_ports_stopped()) {
3429 printf("Please stop all ports first\n");
3433 if (!strcmp(res->name, "txpt"))
3434 tx_pthresh = res->value;
3435 else if(!strcmp(res->name, "txht"))
3436 tx_hthresh = res->value;
3437 else if(!strcmp(res->name, "txwt"))
3438 tx_wthresh = res->value;
3439 else if(!strcmp(res->name, "rxpt"))
3440 rx_pthresh = res->value;
3441 else if(!strcmp(res->name, "rxht"))
3442 rx_hthresh = res->value;
3443 else if(!strcmp(res->name, "rxwt"))
3444 rx_wthresh = res->value;
3446 printf("Unknown parameter\n");
3452 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3455 cmdline_parse_token_string_t cmd_config_thresh_port =
3456 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3457 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3458 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3459 cmdline_parse_token_string_t cmd_config_thresh_all =
3460 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3461 cmdline_parse_token_string_t cmd_config_thresh_name =
3462 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3463 "txpt#txht#txwt#rxpt#rxht#rxwt");
3464 cmdline_parse_token_num_t cmd_config_thresh_value =
3465 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3467 cmdline_parse_inst_t cmd_config_thresh = {
3468 .f = cmd_config_thresh_parsed,
3470 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3472 (void *)&cmd_config_thresh_port,
3473 (void *)&cmd_config_thresh_keyword,
3474 (void *)&cmd_config_thresh_all,
3475 (void *)&cmd_config_thresh_name,
3476 (void *)&cmd_config_thresh_value,
3481 /* *** configure free/rs threshold *** */
3482 struct cmd_config_threshold {
3483 cmdline_fixed_string_t port;
3484 cmdline_fixed_string_t keyword;
3485 cmdline_fixed_string_t all;
3486 cmdline_fixed_string_t name;
3491 cmd_config_threshold_parsed(void *parsed_result,
3492 __rte_unused struct cmdline *cl,
3493 __rte_unused void *data)
3495 struct cmd_config_threshold *res = parsed_result;
3497 if (!all_ports_stopped()) {
3498 printf("Please stop all ports first\n");
3502 if (!strcmp(res->name, "txfreet"))
3503 tx_free_thresh = res->value;
3504 else if (!strcmp(res->name, "txrst"))
3505 tx_rs_thresh = res->value;
3506 else if (!strcmp(res->name, "rxfreet"))
3507 rx_free_thresh = res->value;
3509 printf("Unknown parameter\n");
3515 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3518 cmdline_parse_token_string_t cmd_config_threshold_port =
3519 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3520 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3521 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3523 cmdline_parse_token_string_t cmd_config_threshold_all =
3524 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3525 cmdline_parse_token_string_t cmd_config_threshold_name =
3526 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3527 "txfreet#txrst#rxfreet");
3528 cmdline_parse_token_num_t cmd_config_threshold_value =
3529 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3531 cmdline_parse_inst_t cmd_config_threshold = {
3532 .f = cmd_config_threshold_parsed,
3534 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3536 (void *)&cmd_config_threshold_port,
3537 (void *)&cmd_config_threshold_keyword,
3538 (void *)&cmd_config_threshold_all,
3539 (void *)&cmd_config_threshold_name,
3540 (void *)&cmd_config_threshold_value,
3546 struct cmd_stop_result {
3547 cmdline_fixed_string_t stop;
3550 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3551 __rte_unused struct cmdline *cl,
3552 __rte_unused void *data)
3554 stop_packet_forwarding();
3557 cmdline_parse_token_string_t cmd_stop_stop =
3558 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3560 cmdline_parse_inst_t cmd_stop = {
3561 .f = cmd_stop_parsed,
3563 .help_str = "stop: Stop packet forwarding",
3565 (void *)&cmd_stop_stop,
3570 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3573 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3574 unsigned int *parsed_items, int check_unique_values)
3576 unsigned int nb_item;
3584 * First parse all items in the list and store their value.
3589 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3591 if ((c >= '0') && (c <= '9')) {
3592 value = (unsigned int) (value * 10 + (c - '0'));
3597 printf("character %c is not a decimal digit\n", c);
3601 printf("No valid value before comma\n");
3604 if (nb_item < max_items) {
3605 parsed_items[nb_item] = value;
3611 if (nb_item >= max_items) {
3612 printf("Number of %s = %u > %u (maximum items)\n",
3613 item_name, nb_item + 1, max_items);
3616 parsed_items[nb_item++] = value;
3617 if (! check_unique_values)
3621 * Then, check that all values in the list are differents.
3622 * No optimization here...
3624 for (i = 0; i < nb_item; i++) {
3625 for (j = i + 1; j < nb_item; j++) {
3626 if (parsed_items[j] == parsed_items[i]) {
3627 printf("duplicated %s %u at index %u and %u\n",
3628 item_name, parsed_items[i], i, j);
3636 struct cmd_set_list_result {
3637 cmdline_fixed_string_t cmd_keyword;
3638 cmdline_fixed_string_t list_name;
3639 cmdline_fixed_string_t list_of_items;
3642 static void cmd_set_list_parsed(void *parsed_result,
3643 __rte_unused struct cmdline *cl,
3644 __rte_unused void *data)
3646 struct cmd_set_list_result *res;
3648 unsigned int lcorelist[RTE_MAX_LCORE];
3649 unsigned int portlist[RTE_MAX_ETHPORTS];
3651 unsigned int nb_item;
3653 if (test_done == 0) {
3654 printf("Please stop forwarding first\n");
3658 res = parsed_result;
3659 if (!strcmp(res->list_name, "corelist")) {
3660 nb_item = parse_item_list(res->list_of_items, "core",
3662 parsed_items.lcorelist, 1);
3664 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3669 if (!strcmp(res->list_name, "portlist")) {
3670 nb_item = parse_item_list(res->list_of_items, "port",
3672 parsed_items.portlist, 1);
3674 set_fwd_ports_list(parsed_items.portlist, nb_item);
3680 cmdline_parse_token_string_t cmd_set_list_keyword =
3681 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3683 cmdline_parse_token_string_t cmd_set_list_name =
3684 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3685 "corelist#portlist");
3686 cmdline_parse_token_string_t cmd_set_list_of_items =
3687 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3690 cmdline_parse_inst_t cmd_set_fwd_list = {
3691 .f = cmd_set_list_parsed,
3693 .help_str = "set corelist|portlist <list0[,list1]*>",
3695 (void *)&cmd_set_list_keyword,
3696 (void *)&cmd_set_list_name,
3697 (void *)&cmd_set_list_of_items,
3702 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3704 struct cmd_setmask_result {
3705 cmdline_fixed_string_t set;
3706 cmdline_fixed_string_t mask;
3710 static void cmd_set_mask_parsed(void *parsed_result,
3711 __rte_unused struct cmdline *cl,
3712 __rte_unused void *data)
3714 struct cmd_setmask_result *res = parsed_result;
3716 if (test_done == 0) {
3717 printf("Please stop forwarding first\n");
3720 if (!strcmp(res->mask, "coremask")) {
3721 set_fwd_lcores_mask(res->hexavalue);
3723 } else if (!strcmp(res->mask, "portmask")) {
3724 set_fwd_ports_mask(res->hexavalue);
3729 cmdline_parse_token_string_t cmd_setmask_set =
3730 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3731 cmdline_parse_token_string_t cmd_setmask_mask =
3732 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3733 "coremask#portmask");
3734 cmdline_parse_token_num_t cmd_setmask_value =
3735 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3737 cmdline_parse_inst_t cmd_set_fwd_mask = {
3738 .f = cmd_set_mask_parsed,
3740 .help_str = "set coremask|portmask <hexadecimal value>",
3742 (void *)&cmd_setmask_set,
3743 (void *)&cmd_setmask_mask,
3744 (void *)&cmd_setmask_value,
3750 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3752 struct cmd_set_result {
3753 cmdline_fixed_string_t set;
3754 cmdline_fixed_string_t what;
3758 static void cmd_set_parsed(void *parsed_result,
3759 __rte_unused struct cmdline *cl,
3760 __rte_unused void *data)
3762 struct cmd_set_result *res = parsed_result;
3763 if (!strcmp(res->what, "nbport")) {
3764 set_fwd_ports_number(res->value);
3766 } else if (!strcmp(res->what, "nbcore")) {
3767 set_fwd_lcores_number(res->value);
3769 } else if (!strcmp(res->what, "burst"))
3770 set_nb_pkt_per_burst(res->value);
3771 else if (!strcmp(res->what, "verbose"))
3772 set_verbose_level(res->value);
3775 cmdline_parse_token_string_t cmd_set_set =
3776 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3777 cmdline_parse_token_string_t cmd_set_what =
3778 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3779 "nbport#nbcore#burst#verbose");
3780 cmdline_parse_token_num_t cmd_set_value =
3781 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3783 cmdline_parse_inst_t cmd_set_numbers = {
3784 .f = cmd_set_parsed,
3786 .help_str = "set nbport|nbcore|burst|verbose <value>",
3788 (void *)&cmd_set_set,
3789 (void *)&cmd_set_what,
3790 (void *)&cmd_set_value,
3795 /* *** SET LOG LEVEL CONFIGURATION *** */
3797 struct cmd_set_log_result {
3798 cmdline_fixed_string_t set;
3799 cmdline_fixed_string_t log;
3800 cmdline_fixed_string_t type;
3805 cmd_set_log_parsed(void *parsed_result,
3806 __rte_unused struct cmdline *cl,
3807 __rte_unused void *data)
3809 struct cmd_set_log_result *res;
3812 res = parsed_result;
3813 if (!strcmp(res->type, "global"))
3814 rte_log_set_global_level(res->level);
3816 ret = rte_log_set_level_regexp(res->type, res->level);
3818 printf("Unable to set log level\n");
3822 cmdline_parse_token_string_t cmd_set_log_set =
3823 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3824 cmdline_parse_token_string_t cmd_set_log_log =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3826 cmdline_parse_token_string_t cmd_set_log_type =
3827 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3828 cmdline_parse_token_num_t cmd_set_log_level =
3829 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3831 cmdline_parse_inst_t cmd_set_log = {
3832 .f = cmd_set_log_parsed,
3834 .help_str = "set log global|<type> <level>",
3836 (void *)&cmd_set_log_set,
3837 (void *)&cmd_set_log_log,
3838 (void *)&cmd_set_log_type,
3839 (void *)&cmd_set_log_level,
3844 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3846 struct cmd_set_txpkts_result {
3847 cmdline_fixed_string_t cmd_keyword;
3848 cmdline_fixed_string_t txpkts;
3849 cmdline_fixed_string_t seg_lengths;
3853 cmd_set_txpkts_parsed(void *parsed_result,
3854 __rte_unused struct cmdline *cl,
3855 __rte_unused void *data)
3857 struct cmd_set_txpkts_result *res;
3858 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3859 unsigned int nb_segs;
3861 res = parsed_result;
3862 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3863 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3865 set_tx_pkt_segments(seg_lengths, nb_segs);
3868 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3869 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3870 cmd_keyword, "set");
3871 cmdline_parse_token_string_t cmd_set_txpkts_name =
3872 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3874 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3875 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3878 cmdline_parse_inst_t cmd_set_txpkts = {
3879 .f = cmd_set_txpkts_parsed,
3881 .help_str = "set txpkts <len0[,len1]*>",
3883 (void *)&cmd_set_txpkts_keyword,
3884 (void *)&cmd_set_txpkts_name,
3885 (void *)&cmd_set_txpkts_lengths,
3890 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3892 struct cmd_set_txsplit_result {
3893 cmdline_fixed_string_t cmd_keyword;
3894 cmdline_fixed_string_t txsplit;
3895 cmdline_fixed_string_t mode;
3899 cmd_set_txsplit_parsed(void *parsed_result,
3900 __rte_unused struct cmdline *cl,
3901 __rte_unused void *data)
3903 struct cmd_set_txsplit_result *res;
3905 res = parsed_result;
3906 set_tx_pkt_split(res->mode);
3909 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3910 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3911 cmd_keyword, "set");
3912 cmdline_parse_token_string_t cmd_set_txsplit_name =
3913 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3914 txsplit, "txsplit");
3915 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3916 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3919 cmdline_parse_inst_t cmd_set_txsplit = {
3920 .f = cmd_set_txsplit_parsed,
3922 .help_str = "set txsplit on|off|rand",
3924 (void *)&cmd_set_txsplit_keyword,
3925 (void *)&cmd_set_txsplit_name,
3926 (void *)&cmd_set_txsplit_mode,
3931 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3932 struct cmd_rx_vlan_filter_all_result {
3933 cmdline_fixed_string_t rx_vlan;
3934 cmdline_fixed_string_t what;
3935 cmdline_fixed_string_t all;
3940 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3941 __rte_unused struct cmdline *cl,
3942 __rte_unused void *data)
3944 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3946 if (!strcmp(res->what, "add"))
3947 rx_vlan_all_filter_set(res->port_id, 1);
3949 rx_vlan_all_filter_set(res->port_id, 0);
3952 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3953 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3954 rx_vlan, "rx_vlan");
3955 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3956 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3958 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3959 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3961 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3962 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3965 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3966 .f = cmd_rx_vlan_filter_all_parsed,
3968 .help_str = "rx_vlan add|rm all <port_id>: "
3969 "Add/Remove all identifiers to/from the set of VLAN "
3970 "identifiers filtered by a port",
3972 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3973 (void *)&cmd_rx_vlan_filter_all_what,
3974 (void *)&cmd_rx_vlan_filter_all_all,
3975 (void *)&cmd_rx_vlan_filter_all_portid,
3980 /* *** VLAN OFFLOAD SET ON A PORT *** */
3981 struct cmd_vlan_offload_result {
3982 cmdline_fixed_string_t vlan;
3983 cmdline_fixed_string_t set;
3984 cmdline_fixed_string_t vlan_type;
3985 cmdline_fixed_string_t what;
3986 cmdline_fixed_string_t on;
3987 cmdline_fixed_string_t port_id;
3991 cmd_vlan_offload_parsed(void *parsed_result,
3992 __rte_unused struct cmdline *cl,
3993 __rte_unused void *data)
3996 struct cmd_vlan_offload_result *res = parsed_result;
3999 portid_t port_id = 0;
4003 len = strnlen(str, STR_TOKEN_SIZE);
4005 /* Get port_id first */
4013 tmp = strtoul(str, NULL, 0);
4014 /* If port_id greater that what portid_t can represent, return */
4015 if(tmp >= RTE_MAX_ETHPORTS)
4017 port_id = (portid_t)tmp;
4019 if (!strcmp(res->on, "on"))
4024 if (!strcmp(res->what, "strip"))
4025 rx_vlan_strip_set(port_id, on);
4026 else if(!strcmp(res->what, "stripq")){
4027 uint16_t queue_id = 0;
4029 /* No queue_id, return */
4031 printf("must specify (port,queue_id)\n");
4034 tmp = strtoul(str + i + 1, NULL, 0);
4035 /* If queue_id greater that what 16-bits can represent, return */
4039 queue_id = (uint16_t)tmp;
4040 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4042 else if (!strcmp(res->what, "filter"))
4043 rx_vlan_filter_set(port_id, on);
4044 else if (!strcmp(res->what, "qinq_strip"))
4045 rx_vlan_qinq_strip_set(port_id, on);
4047 vlan_extend_set(port_id, on);
4052 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4053 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4055 cmdline_parse_token_string_t cmd_vlan_offload_set =
4056 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4058 cmdline_parse_token_string_t cmd_vlan_offload_what =
4059 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4060 what, "strip#filter#qinq_strip#extend#stripq");
4061 cmdline_parse_token_string_t cmd_vlan_offload_on =
4062 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4064 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4065 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4068 cmdline_parse_inst_t cmd_vlan_offload = {
4069 .f = cmd_vlan_offload_parsed,
4071 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4072 "<port_id[,queue_id]>: "
4073 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4075 (void *)&cmd_vlan_offload_vlan,
4076 (void *)&cmd_vlan_offload_set,
4077 (void *)&cmd_vlan_offload_what,
4078 (void *)&cmd_vlan_offload_on,
4079 (void *)&cmd_vlan_offload_portid,
4084 /* *** VLAN TPID SET ON A PORT *** */
4085 struct cmd_vlan_tpid_result {
4086 cmdline_fixed_string_t vlan;
4087 cmdline_fixed_string_t set;
4088 cmdline_fixed_string_t vlan_type;
4089 cmdline_fixed_string_t what;
4095 cmd_vlan_tpid_parsed(void *parsed_result,
4096 __rte_unused struct cmdline *cl,
4097 __rte_unused void *data)
4099 struct cmd_vlan_tpid_result *res = parsed_result;
4100 enum rte_vlan_type vlan_type;
4102 if (!strcmp(res->vlan_type, "inner"))
4103 vlan_type = ETH_VLAN_TYPE_INNER;
4104 else if (!strcmp(res->vlan_type, "outer"))
4105 vlan_type = ETH_VLAN_TYPE_OUTER;
4107 printf("Unknown vlan type\n");
4110 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4113 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4114 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4116 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4117 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4119 cmdline_parse_token_string_t cmd_vlan_type =
4120 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4121 vlan_type, "inner#outer");
4122 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4123 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4125 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4126 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4128 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4129 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4132 cmdline_parse_inst_t cmd_vlan_tpid = {
4133 .f = cmd_vlan_tpid_parsed,
4135 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4136 "Set the VLAN Ether type",
4138 (void *)&cmd_vlan_tpid_vlan,
4139 (void *)&cmd_vlan_tpid_set,
4140 (void *)&cmd_vlan_type,
4141 (void *)&cmd_vlan_tpid_what,
4142 (void *)&cmd_vlan_tpid_tpid,
4143 (void *)&cmd_vlan_tpid_portid,
4148 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4149 struct cmd_rx_vlan_filter_result {
4150 cmdline_fixed_string_t rx_vlan;
4151 cmdline_fixed_string_t what;
4157 cmd_rx_vlan_filter_parsed(void *parsed_result,
4158 __rte_unused struct cmdline *cl,
4159 __rte_unused void *data)
4161 struct cmd_rx_vlan_filter_result *res = parsed_result;
4163 if (!strcmp(res->what, "add"))
4164 rx_vft_set(res->port_id, res->vlan_id, 1);
4166 rx_vft_set(res->port_id, res->vlan_id, 0);
4169 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4170 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4171 rx_vlan, "rx_vlan");
4172 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4173 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4175 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4176 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4178 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4179 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4182 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4183 .f = cmd_rx_vlan_filter_parsed,
4185 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4186 "Add/Remove a VLAN identifier to/from the set of VLAN "
4187 "identifiers filtered by a port",
4189 (void *)&cmd_rx_vlan_filter_rx_vlan,
4190 (void *)&cmd_rx_vlan_filter_what,
4191 (void *)&cmd_rx_vlan_filter_vlanid,
4192 (void *)&cmd_rx_vlan_filter_portid,
4197 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4198 struct cmd_tx_vlan_set_result {
4199 cmdline_fixed_string_t tx_vlan;
4200 cmdline_fixed_string_t set;
4206 cmd_tx_vlan_set_parsed(void *parsed_result,
4207 __rte_unused struct cmdline *cl,
4208 __rte_unused void *data)
4210 struct cmd_tx_vlan_set_result *res = parsed_result;
4212 if (!port_is_stopped(res->port_id)) {
4213 printf("Please stop port %d first\n", res->port_id);
4217 tx_vlan_set(res->port_id, res->vlan_id);
4219 cmd_reconfig_device_queue(res->port_id, 1, 1);
4222 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4223 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4224 tx_vlan, "tx_vlan");
4225 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4226 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4228 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4229 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4231 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4232 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4235 cmdline_parse_inst_t cmd_tx_vlan_set = {
4236 .f = cmd_tx_vlan_set_parsed,
4238 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4239 "Enable hardware insertion of a single VLAN header "
4240 "with a given TAG Identifier in packets sent on a port",
4242 (void *)&cmd_tx_vlan_set_tx_vlan,
4243 (void *)&cmd_tx_vlan_set_set,
4244 (void *)&cmd_tx_vlan_set_portid,
4245 (void *)&cmd_tx_vlan_set_vlanid,
4250 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4251 struct cmd_tx_vlan_set_qinq_result {
4252 cmdline_fixed_string_t tx_vlan;
4253 cmdline_fixed_string_t set;
4256 uint16_t vlan_id_outer;
4260 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4261 __rte_unused struct cmdline *cl,
4262 __rte_unused void *data)
4264 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4266 if (!port_is_stopped(res->port_id)) {
4267 printf("Please stop port %d first\n", res->port_id);
4271 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4273 cmd_reconfig_device_queue(res->port_id, 1, 1);
4276 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4277 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4278 tx_vlan, "tx_vlan");
4279 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4280 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4282 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4283 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4285 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4286 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4288 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4289 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4290 vlan_id_outer, UINT16);
4292 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4293 .f = cmd_tx_vlan_set_qinq_parsed,
4295 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4296 "Enable hardware insertion of double VLAN header "
4297 "with given TAG Identifiers in packets sent on a port",
4299 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4300 (void *)&cmd_tx_vlan_set_qinq_set,
4301 (void *)&cmd_tx_vlan_set_qinq_portid,
4302 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4303 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4308 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4309 struct cmd_tx_vlan_set_pvid_result {
4310 cmdline_fixed_string_t tx_vlan;
4311 cmdline_fixed_string_t set;
4312 cmdline_fixed_string_t pvid;
4315 cmdline_fixed_string_t mode;
4319 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4320 __rte_unused struct cmdline *cl,
4321 __rte_unused void *data)
4323 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4325 if (strcmp(res->mode, "on") == 0)
4326 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4328 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4331 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4332 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4333 tx_vlan, "tx_vlan");
4334 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4335 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4337 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4338 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4340 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4341 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4343 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4344 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4346 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4347 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4350 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4351 .f = cmd_tx_vlan_set_pvid_parsed,
4353 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4355 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4356 (void *)&cmd_tx_vlan_set_pvid_set,
4357 (void *)&cmd_tx_vlan_set_pvid_pvid,
4358 (void *)&cmd_tx_vlan_set_pvid_port_id,
4359 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4360 (void *)&cmd_tx_vlan_set_pvid_mode,
4365 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4366 struct cmd_tx_vlan_reset_result {
4367 cmdline_fixed_string_t tx_vlan;
4368 cmdline_fixed_string_t reset;
4373 cmd_tx_vlan_reset_parsed(void *parsed_result,
4374 __rte_unused struct cmdline *cl,
4375 __rte_unused void *data)
4377 struct cmd_tx_vlan_reset_result *res = parsed_result;
4379 if (!port_is_stopped(res->port_id)) {
4380 printf("Please stop port %d first\n", res->port_id);
4384 tx_vlan_reset(res->port_id);
4386 cmd_reconfig_device_queue(res->port_id, 1, 1);
4389 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4390 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4391 tx_vlan, "tx_vlan");
4392 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4393 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4395 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4396 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4399 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4400 .f = cmd_tx_vlan_reset_parsed,
4402 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4403 "VLAN header in packets sent on a port",
4405 (void *)&cmd_tx_vlan_reset_tx_vlan,
4406 (void *)&cmd_tx_vlan_reset_reset,
4407 (void *)&cmd_tx_vlan_reset_portid,
4413 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4414 struct cmd_csum_result {
4415 cmdline_fixed_string_t csum;
4416 cmdline_fixed_string_t mode;
4417 cmdline_fixed_string_t proto;
4418 cmdline_fixed_string_t hwsw;
4423 csum_show(int port_id)
4425 struct rte_eth_dev_info dev_info;
4426 uint64_t tx_offloads;
4429 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4430 printf("Parse tunnel is %s\n",
4431 (ports[port_id].parse_tunnel) ? "on" : "off");
4432 printf("IP checksum offload is %s\n",
4433 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4434 printf("UDP checksum offload is %s\n",
4435 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4436 printf("TCP checksum offload is %s\n",
4437 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4438 printf("SCTP checksum offload is %s\n",
4439 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4440 printf("Outer-Ip checksum offload is %s\n",
4441 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4442 printf("Outer-Udp checksum offload is %s\n",
4443 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4445 /* display warnings if configuration is not supported by the NIC */
4446 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4450 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4451 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4452 printf("Warning: hardware IP checksum enabled but not "
4453 "supported by port %d\n", port_id);
4455 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4456 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4457 printf("Warning: hardware UDP checksum enabled but not "
4458 "supported by port %d\n", port_id);
4460 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4461 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4462 printf("Warning: hardware TCP checksum enabled but not "
4463 "supported by port %d\n", port_id);
4465 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4466 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4467 printf("Warning: hardware SCTP checksum enabled but not "
4468 "supported by port %d\n", port_id);
4470 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4471 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4472 printf("Warning: hardware outer IP checksum enabled but not "
4473 "supported by port %d\n", port_id);
4475 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4476 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4478 printf("Warning: hardware outer UDP checksum enabled but not "
4479 "supported by port %d\n", port_id);
4484 cmd_config_queue_tx_offloads(struct rte_port *port)
4488 /* Apply queue tx offloads configuration */
4489 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4490 port->tx_conf[k].offloads =
4491 port->dev_conf.txmode.offloads;
4495 cmd_csum_parsed(void *parsed_result,
4496 __rte_unused struct cmdline *cl,
4497 __rte_unused void *data)
4499 struct cmd_csum_result *res = parsed_result;
4501 uint64_t csum_offloads = 0;
4502 struct rte_eth_dev_info dev_info;
4505 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4506 printf("invalid port %d\n", res->port_id);
4509 if (!port_is_stopped(res->port_id)) {
4510 printf("Please stop port %d first\n", res->port_id);
4514 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4518 if (!strcmp(res->mode, "set")) {
4520 if (!strcmp(res->hwsw, "hw"))
4523 if (!strcmp(res->proto, "ip")) {
4524 if (hw == 0 || (dev_info.tx_offload_capa &
4525 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4526 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4528 printf("IP checksum offload is not supported "
4529 "by port %u\n", res->port_id);
4531 } else if (!strcmp(res->proto, "udp")) {
4532 if (hw == 0 || (dev_info.tx_offload_capa &
4533 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4534 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4536 printf("UDP checksum offload is not supported "
4537 "by port %u\n", res->port_id);
4539 } else if (!strcmp(res->proto, "tcp")) {
4540 if (hw == 0 || (dev_info.tx_offload_capa &
4541 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4542 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4544 printf("TCP checksum offload is not supported "
4545 "by port %u\n", res->port_id);
4547 } else if (!strcmp(res->proto, "sctp")) {
4548 if (hw == 0 || (dev_info.tx_offload_capa &
4549 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4550 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4552 printf("SCTP checksum offload is not supported "
4553 "by port %u\n", res->port_id);
4555 } else if (!strcmp(res->proto, "outer-ip")) {
4556 if (hw == 0 || (dev_info.tx_offload_capa &
4557 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4559 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4561 printf("Outer IP checksum offload is not "
4562 "supported by port %u\n", res->port_id);
4564 } else if (!strcmp(res->proto, "outer-udp")) {
4565 if (hw == 0 || (dev_info.tx_offload_capa &
4566 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4568 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4570 printf("Outer UDP checksum offload is not "
4571 "supported by port %u\n", res->port_id);
4576 ports[res->port_id].dev_conf.txmode.offloads |=
4579 ports[res->port_id].dev_conf.txmode.offloads &=
4582 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4584 csum_show(res->port_id);
4586 cmd_reconfig_device_queue(res->port_id, 1, 1);
4589 cmdline_parse_token_string_t cmd_csum_csum =
4590 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4592 cmdline_parse_token_string_t cmd_csum_mode =
4593 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4595 cmdline_parse_token_string_t cmd_csum_proto =
4596 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4597 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4598 cmdline_parse_token_string_t cmd_csum_hwsw =
4599 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4601 cmdline_parse_token_num_t cmd_csum_portid =
4602 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4605 cmdline_parse_inst_t cmd_csum_set = {
4606 .f = cmd_csum_parsed,
4608 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4609 "Enable/Disable hardware calculation of L3/L4 checksum when "
4610 "using csum forward engine",
4612 (void *)&cmd_csum_csum,
4613 (void *)&cmd_csum_mode,
4614 (void *)&cmd_csum_proto,
4615 (void *)&cmd_csum_hwsw,
4616 (void *)&cmd_csum_portid,
4621 cmdline_parse_token_string_t cmd_csum_mode_show =
4622 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4625 cmdline_parse_inst_t cmd_csum_show = {
4626 .f = cmd_csum_parsed,
4628 .help_str = "csum show <port_id>: Show checksum offload configuration",
4630 (void *)&cmd_csum_csum,
4631 (void *)&cmd_csum_mode_show,
4632 (void *)&cmd_csum_portid,
4637 /* Enable/disable tunnel parsing */
4638 struct cmd_csum_tunnel_result {
4639 cmdline_fixed_string_t csum;
4640 cmdline_fixed_string_t parse;
4641 cmdline_fixed_string_t onoff;
4646 cmd_csum_tunnel_parsed(void *parsed_result,
4647 __rte_unused struct cmdline *cl,
4648 __rte_unused void *data)
4650 struct cmd_csum_tunnel_result *res = parsed_result;
4652 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4655 if (!strcmp(res->onoff, "on"))
4656 ports[res->port_id].parse_tunnel = 1;
4658 ports[res->port_id].parse_tunnel = 0;
4660 csum_show(res->port_id);
4663 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4664 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4666 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4667 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4668 parse, "parse-tunnel");
4669 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4670 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4672 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4673 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4676 cmdline_parse_inst_t cmd_csum_tunnel = {
4677 .f = cmd_csum_tunnel_parsed,
4679 .help_str = "csum parse-tunnel on|off <port_id>: "
4680 "Enable/Disable parsing of tunnels for csum engine",
4682 (void *)&cmd_csum_tunnel_csum,
4683 (void *)&cmd_csum_tunnel_parse,
4684 (void *)&cmd_csum_tunnel_onoff,
4685 (void *)&cmd_csum_tunnel_portid,
4690 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4691 struct cmd_tso_set_result {
4692 cmdline_fixed_string_t tso;
4693 cmdline_fixed_string_t mode;
4699 cmd_tso_set_parsed(void *parsed_result,
4700 __rte_unused struct cmdline *cl,
4701 __rte_unused void *data)
4703 struct cmd_tso_set_result *res = parsed_result;
4704 struct rte_eth_dev_info dev_info;
4707 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4709 if (!port_is_stopped(res->port_id)) {
4710 printf("Please stop port %d first\n", res->port_id);
4714 if (!strcmp(res->mode, "set"))
4715 ports[res->port_id].tso_segsz = res->tso_segsz;
4717 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4721 if ((ports[res->port_id].tso_segsz != 0) &&
4722 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4723 printf("Error: TSO is not supported by port %d\n",
4728 if (ports[res->port_id].tso_segsz == 0) {
4729 ports[res->port_id].dev_conf.txmode.offloads &=
4730 ~DEV_TX_OFFLOAD_TCP_TSO;
4731 printf("TSO for non-tunneled packets is disabled\n");
4733 ports[res->port_id].dev_conf.txmode.offloads |=
4734 DEV_TX_OFFLOAD_TCP_TSO;
4735 printf("TSO segment size for non-tunneled packets is %d\n",
4736 ports[res->port_id].tso_segsz);
4738 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4740 /* display warnings if configuration is not supported by the NIC */
4741 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4745 if ((ports[res->port_id].tso_segsz != 0) &&
4746 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4747 printf("Warning: TSO enabled but not "
4748 "supported by port %d\n", res->port_id);
4751 cmd_reconfig_device_queue(res->port_id, 1, 1);
4754 cmdline_parse_token_string_t cmd_tso_set_tso =
4755 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4757 cmdline_parse_token_string_t cmd_tso_set_mode =
4758 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4760 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4761 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4763 cmdline_parse_token_num_t cmd_tso_set_portid =
4764 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4767 cmdline_parse_inst_t cmd_tso_set = {
4768 .f = cmd_tso_set_parsed,
4770 .help_str = "tso set <tso_segsz> <port_id>: "
4771 "Set TSO segment size of non-tunneled packets for csum engine "
4774 (void *)&cmd_tso_set_tso,
4775 (void *)&cmd_tso_set_mode,
4776 (void *)&cmd_tso_set_tso_segsz,
4777 (void *)&cmd_tso_set_portid,
4782 cmdline_parse_token_string_t cmd_tso_show_mode =
4783 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4787 cmdline_parse_inst_t cmd_tso_show = {
4788 .f = cmd_tso_set_parsed,
4790 .help_str = "tso show <port_id>: "
4791 "Show TSO segment size of non-tunneled packets for csum engine",
4793 (void *)&cmd_tso_set_tso,
4794 (void *)&cmd_tso_show_mode,
4795 (void *)&cmd_tso_set_portid,
4800 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4801 struct cmd_tunnel_tso_set_result {
4802 cmdline_fixed_string_t tso;
4803 cmdline_fixed_string_t mode;
4808 static struct rte_eth_dev_info
4809 check_tunnel_tso_nic_support(portid_t port_id)
4811 struct rte_eth_dev_info dev_info;
4813 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4816 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4817 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4818 "not enabled for port %d\n", port_id);
4819 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4820 printf("Warning: GRE TUNNEL TSO not supported therefore "
4821 "not enabled for port %d\n", port_id);
4822 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4823 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4824 "not enabled for port %d\n", port_id);
4825 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4826 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4827 "not enabled for port %d\n", port_id);
4828 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4829 printf("Warning: IP TUNNEL TSO not supported therefore "
4830 "not enabled for port %d\n", port_id);
4831 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4832 printf("Warning: UDP TUNNEL TSO not supported therefore "
4833 "not enabled for port %d\n", port_id);
4838 cmd_tunnel_tso_set_parsed(void *parsed_result,
4839 __rte_unused struct cmdline *cl,
4840 __rte_unused void *data)
4842 struct cmd_tunnel_tso_set_result *res = parsed_result;
4843 struct rte_eth_dev_info dev_info;
4845 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4847 if (!port_is_stopped(res->port_id)) {
4848 printf("Please stop port %d first\n", res->port_id);
4852 if (!strcmp(res->mode, "set"))
4853 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4855 dev_info = check_tunnel_tso_nic_support(res->port_id);
4856 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4857 ports[res->port_id].dev_conf.txmode.offloads &=
4858 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4859 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4860 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4861 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4862 DEV_TX_OFFLOAD_IP_TNL_TSO |
4863 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4864 printf("TSO for tunneled packets is disabled\n");
4866 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4867 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4868 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4869 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4870 DEV_TX_OFFLOAD_IP_TNL_TSO |
4871 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4873 ports[res->port_id].dev_conf.txmode.offloads |=
4874 (tso_offloads & dev_info.tx_offload_capa);
4875 printf("TSO segment size for tunneled packets is %d\n",
4876 ports[res->port_id].tunnel_tso_segsz);
4878 /* Below conditions are needed to make it work:
4879 * (1) tunnel TSO is supported by the NIC;
4880 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4882 * (3) for tunneled pkts with outer L3 of IPv4,
4883 * "csum set outer-ip" must be set to hw, because after tso,
4884 * total_len of outer IP header is changed, and the checksum
4885 * of outer IP header calculated by sw should be wrong; that
4886 * is not necessary for IPv6 tunneled pkts because there's no
4887 * checksum in IP header anymore.
4890 if (!ports[res->port_id].parse_tunnel)
4891 printf("Warning: csum parse_tunnel must be set "
4892 "so that tunneled packets are recognized\n");
4893 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4894 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4895 printf("Warning: csum set outer-ip must be set to hw "
4896 "if outer L3 is IPv4; not necessary for IPv6\n");
4899 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4900 cmd_reconfig_device_queue(res->port_id, 1, 1);
4903 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4904 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4906 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4907 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4909 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4910 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4912 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4913 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4916 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4917 .f = cmd_tunnel_tso_set_parsed,
4919 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4920 "Set TSO segment size of tunneled packets for csum engine "
4923 (void *)&cmd_tunnel_tso_set_tso,
4924 (void *)&cmd_tunnel_tso_set_mode,
4925 (void *)&cmd_tunnel_tso_set_tso_segsz,
4926 (void *)&cmd_tunnel_tso_set_portid,
4931 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4932 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4936 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4937 .f = cmd_tunnel_tso_set_parsed,
4939 .help_str = "tunnel_tso show <port_id> "
4940 "Show TSO segment size of tunneled packets for csum engine",
4942 (void *)&cmd_tunnel_tso_set_tso,
4943 (void *)&cmd_tunnel_tso_show_mode,
4944 (void *)&cmd_tunnel_tso_set_portid,
4949 /* *** SET GRO FOR A PORT *** */
4950 struct cmd_gro_enable_result {
4951 cmdline_fixed_string_t cmd_set;
4952 cmdline_fixed_string_t cmd_port;
4953 cmdline_fixed_string_t cmd_keyword;
4954 cmdline_fixed_string_t cmd_onoff;
4959 cmd_gro_enable_parsed(void *parsed_result,
4960 __rte_unused struct cmdline *cl,
4961 __rte_unused void *data)
4963 struct cmd_gro_enable_result *res;
4965 res = parsed_result;
4966 if (!strcmp(res->cmd_keyword, "gro"))
4967 setup_gro(res->cmd_onoff, res->cmd_pid);
4970 cmdline_parse_token_string_t cmd_gro_enable_set =
4971 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4973 cmdline_parse_token_string_t cmd_gro_enable_port =
4974 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4975 cmd_keyword, "port");
4976 cmdline_parse_token_num_t cmd_gro_enable_pid =
4977 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4979 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4980 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4981 cmd_keyword, "gro");
4982 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4983 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4984 cmd_onoff, "on#off");
4986 cmdline_parse_inst_t cmd_gro_enable = {
4987 .f = cmd_gro_enable_parsed,
4989 .help_str = "set port <port_id> gro on|off",
4991 (void *)&cmd_gro_enable_set,
4992 (void *)&cmd_gro_enable_port,
4993 (void *)&cmd_gro_enable_pid,
4994 (void *)&cmd_gro_enable_keyword,
4995 (void *)&cmd_gro_enable_onoff,
5000 /* *** DISPLAY GRO CONFIGURATION *** */
5001 struct cmd_gro_show_result {
5002 cmdline_fixed_string_t cmd_show;
5003 cmdline_fixed_string_t cmd_port;
5004 cmdline_fixed_string_t cmd_keyword;
5009 cmd_gro_show_parsed(void *parsed_result,
5010 __rte_unused struct cmdline *cl,
5011 __rte_unused void *data)
5013 struct cmd_gro_show_result *res;
5015 res = parsed_result;
5016 if (!strcmp(res->cmd_keyword, "gro"))
5017 show_gro(res->cmd_pid);
5020 cmdline_parse_token_string_t cmd_gro_show_show =
5021 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5023 cmdline_parse_token_string_t cmd_gro_show_port =
5024 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5026 cmdline_parse_token_num_t cmd_gro_show_pid =
5027 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5029 cmdline_parse_token_string_t cmd_gro_show_keyword =
5030 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5031 cmd_keyword, "gro");
5033 cmdline_parse_inst_t cmd_gro_show = {
5034 .f = cmd_gro_show_parsed,
5036 .help_str = "show port <port_id> gro",
5038 (void *)&cmd_gro_show_show,
5039 (void *)&cmd_gro_show_port,
5040 (void *)&cmd_gro_show_pid,
5041 (void *)&cmd_gro_show_keyword,
5046 /* *** SET FLUSH CYCLES FOR GRO *** */
5047 struct cmd_gro_flush_result {
5048 cmdline_fixed_string_t cmd_set;
5049 cmdline_fixed_string_t cmd_keyword;
5050 cmdline_fixed_string_t cmd_flush;
5055 cmd_gro_flush_parsed(void *parsed_result,
5056 __rte_unused struct cmdline *cl,
5057 __rte_unused void *data)
5059 struct cmd_gro_flush_result *res;
5061 res = parsed_result;
5062 if ((!strcmp(res->cmd_keyword, "gro")) &&
5063 (!strcmp(res->cmd_flush, "flush")))
5064 setup_gro_flush_cycles(res->cmd_cycles);
5067 cmdline_parse_token_string_t cmd_gro_flush_set =
5068 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5070 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5071 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5072 cmd_keyword, "gro");
5073 cmdline_parse_token_string_t cmd_gro_flush_flush =
5074 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5075 cmd_flush, "flush");
5076 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5077 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5080 cmdline_parse_inst_t cmd_gro_flush = {
5081 .f = cmd_gro_flush_parsed,
5083 .help_str = "set gro flush <cycles>",
5085 (void *)&cmd_gro_flush_set,
5086 (void *)&cmd_gro_flush_keyword,
5087 (void *)&cmd_gro_flush_flush,
5088 (void *)&cmd_gro_flush_cycles,
5093 /* *** ENABLE/DISABLE GSO *** */
5094 struct cmd_gso_enable_result {
5095 cmdline_fixed_string_t cmd_set;
5096 cmdline_fixed_string_t cmd_port;
5097 cmdline_fixed_string_t cmd_keyword;
5098 cmdline_fixed_string_t cmd_mode;
5103 cmd_gso_enable_parsed(void *parsed_result,
5104 __rte_unused struct cmdline *cl,
5105 __rte_unused void *data)
5107 struct cmd_gso_enable_result *res;
5109 res = parsed_result;
5110 if (!strcmp(res->cmd_keyword, "gso"))
5111 setup_gso(res->cmd_mode, res->cmd_pid);
5114 cmdline_parse_token_string_t cmd_gso_enable_set =
5115 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5117 cmdline_parse_token_string_t cmd_gso_enable_port =
5118 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5120 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5121 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5122 cmd_keyword, "gso");
5123 cmdline_parse_token_string_t cmd_gso_enable_mode =
5124 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5125 cmd_mode, "on#off");
5126 cmdline_parse_token_num_t cmd_gso_enable_pid =
5127 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5130 cmdline_parse_inst_t cmd_gso_enable = {
5131 .f = cmd_gso_enable_parsed,
5133 .help_str = "set port <port_id> gso on|off",
5135 (void *)&cmd_gso_enable_set,
5136 (void *)&cmd_gso_enable_port,
5137 (void *)&cmd_gso_enable_pid,
5138 (void *)&cmd_gso_enable_keyword,
5139 (void *)&cmd_gso_enable_mode,
5144 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5145 struct cmd_gso_size_result {
5146 cmdline_fixed_string_t cmd_set;
5147 cmdline_fixed_string_t cmd_keyword;
5148 cmdline_fixed_string_t cmd_segsz;
5153 cmd_gso_size_parsed(void *parsed_result,
5154 __rte_unused struct cmdline *cl,
5155 __rte_unused void *data)
5157 struct cmd_gso_size_result *res = parsed_result;
5159 if (test_done == 0) {
5160 printf("Before setting GSO segsz, please first"
5161 " stop forwarding\n");
5165 if (!strcmp(res->cmd_keyword, "gso") &&
5166 !strcmp(res->cmd_segsz, "segsz")) {
5167 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5168 printf("gso_size should be larger than %zu."
5169 " Please input a legal value\n",
5170 RTE_GSO_SEG_SIZE_MIN);
5172 gso_max_segment_size = res->cmd_size;
5176 cmdline_parse_token_string_t cmd_gso_size_set =
5177 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5179 cmdline_parse_token_string_t cmd_gso_size_keyword =
5180 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5181 cmd_keyword, "gso");
5182 cmdline_parse_token_string_t cmd_gso_size_segsz =
5183 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5184 cmd_segsz, "segsz");
5185 cmdline_parse_token_num_t cmd_gso_size_size =
5186 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5189 cmdline_parse_inst_t cmd_gso_size = {
5190 .f = cmd_gso_size_parsed,
5192 .help_str = "set gso segsz <length>",
5194 (void *)&cmd_gso_size_set,
5195 (void *)&cmd_gso_size_keyword,
5196 (void *)&cmd_gso_size_segsz,
5197 (void *)&cmd_gso_size_size,
5202 /* *** SHOW GSO CONFIGURATION *** */
5203 struct cmd_gso_show_result {
5204 cmdline_fixed_string_t cmd_show;
5205 cmdline_fixed_string_t cmd_port;
5206 cmdline_fixed_string_t cmd_keyword;
5211 cmd_gso_show_parsed(void *parsed_result,
5212 __rte_unused struct cmdline *cl,
5213 __rte_unused void *data)
5215 struct cmd_gso_show_result *res = parsed_result;
5217 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5218 printf("invalid port id %u\n", res->cmd_pid);
5221 if (!strcmp(res->cmd_keyword, "gso")) {
5222 if (gso_ports[res->cmd_pid].enable) {
5223 printf("Max GSO'd packet size: %uB\n"
5224 "Supported GSO types: TCP/IPv4, "
5225 "UDP/IPv4, VxLAN with inner "
5226 "TCP/IPv4 packet, GRE with inner "
5227 "TCP/IPv4 packet\n",
5228 gso_max_segment_size);
5230 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5234 cmdline_parse_token_string_t cmd_gso_show_show =
5235 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5237 cmdline_parse_token_string_t cmd_gso_show_port =
5238 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5240 cmdline_parse_token_string_t cmd_gso_show_keyword =
5241 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5242 cmd_keyword, "gso");
5243 cmdline_parse_token_num_t cmd_gso_show_pid =
5244 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5247 cmdline_parse_inst_t cmd_gso_show = {
5248 .f = cmd_gso_show_parsed,
5250 .help_str = "show port <port_id> gso",
5252 (void *)&cmd_gso_show_show,
5253 (void *)&cmd_gso_show_port,
5254 (void *)&cmd_gso_show_pid,
5255 (void *)&cmd_gso_show_keyword,
5260 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5261 struct cmd_set_flush_rx {
5262 cmdline_fixed_string_t set;
5263 cmdline_fixed_string_t flush_rx;
5264 cmdline_fixed_string_t mode;
5268 cmd_set_flush_rx_parsed(void *parsed_result,
5269 __rte_unused struct cmdline *cl,
5270 __rte_unused void *data)
5272 struct cmd_set_flush_rx *res = parsed_result;
5273 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5276 cmdline_parse_token_string_t cmd_setflushrx_set =
5277 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5279 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5280 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5281 flush_rx, "flush_rx");
5282 cmdline_parse_token_string_t cmd_setflushrx_mode =
5283 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5287 cmdline_parse_inst_t cmd_set_flush_rx = {
5288 .f = cmd_set_flush_rx_parsed,
5289 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5292 (void *)&cmd_setflushrx_set,
5293 (void *)&cmd_setflushrx_flush_rx,
5294 (void *)&cmd_setflushrx_mode,
5299 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5300 struct cmd_set_link_check {
5301 cmdline_fixed_string_t set;
5302 cmdline_fixed_string_t link_check;
5303 cmdline_fixed_string_t mode;
5307 cmd_set_link_check_parsed(void *parsed_result,
5308 __rte_unused struct cmdline *cl,
5309 __rte_unused void *data)
5311 struct cmd_set_link_check *res = parsed_result;
5312 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5315 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5316 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5318 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5319 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5320 link_check, "link_check");
5321 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5322 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5326 cmdline_parse_inst_t cmd_set_link_check = {
5327 .f = cmd_set_link_check_parsed,
5328 .help_str = "set link_check on|off: Enable/Disable link status check "
5329 "when starting/stopping a port",
5332 (void *)&cmd_setlinkcheck_set,
5333 (void *)&cmd_setlinkcheck_link_check,
5334 (void *)&cmd_setlinkcheck_mode,
5339 /* *** SET NIC BYPASS MODE *** */
5340 struct cmd_set_bypass_mode_result {
5341 cmdline_fixed_string_t set;
5342 cmdline_fixed_string_t bypass;
5343 cmdline_fixed_string_t mode;
5344 cmdline_fixed_string_t value;
5349 cmd_set_bypass_mode_parsed(void *parsed_result,
5350 __rte_unused struct cmdline *cl,
5351 __rte_unused void *data)
5353 struct cmd_set_bypass_mode_result *res = parsed_result;
5354 portid_t port_id = res->port_id;
5355 int32_t rc = -EINVAL;
5357 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5358 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5360 if (!strcmp(res->value, "bypass"))
5361 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5362 else if (!strcmp(res->value, "isolate"))
5363 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5365 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5367 /* Set the bypass mode for the relevant port. */
5368 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5371 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5374 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5375 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5377 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5378 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5380 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5381 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5383 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5384 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5385 value, "normal#bypass#isolate");
5386 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5387 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5390 cmdline_parse_inst_t cmd_set_bypass_mode = {
5391 .f = cmd_set_bypass_mode_parsed,
5392 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5393 "Set the NIC bypass mode for port_id",
5396 (void *)&cmd_setbypass_mode_set,
5397 (void *)&cmd_setbypass_mode_bypass,
5398 (void *)&cmd_setbypass_mode_mode,
5399 (void *)&cmd_setbypass_mode_value,
5400 (void *)&cmd_setbypass_mode_port,
5405 /* *** SET NIC BYPASS EVENT *** */
5406 struct cmd_set_bypass_event_result {
5407 cmdline_fixed_string_t set;
5408 cmdline_fixed_string_t bypass;
5409 cmdline_fixed_string_t event;
5410 cmdline_fixed_string_t event_value;
5411 cmdline_fixed_string_t mode;
5412 cmdline_fixed_string_t mode_value;
5417 cmd_set_bypass_event_parsed(void *parsed_result,
5418 __rte_unused struct cmdline *cl,
5419 __rte_unused void *data)
5421 int32_t rc = -EINVAL;
5422 struct cmd_set_bypass_event_result *res = parsed_result;
5423 portid_t port_id = res->port_id;
5425 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5426 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5427 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5429 if (!strcmp(res->event_value, "timeout"))
5430 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5431 else if (!strcmp(res->event_value, "os_on"))
5432 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5433 else if (!strcmp(res->event_value, "os_off"))
5434 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5435 else if (!strcmp(res->event_value, "power_on"))
5436 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5437 else if (!strcmp(res->event_value, "power_off"))
5438 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5440 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5442 if (!strcmp(res->mode_value, "bypass"))
5443 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5444 else if (!strcmp(res->mode_value, "isolate"))
5445 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5447 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5449 /* Set the watchdog timeout. */
5450 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5453 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5454 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5458 printf("Failed to set timeout value %u "
5459 "for port %d, errto code: %d.\n",
5460 bypass_timeout, port_id, rc);
5464 /* Set the bypass event to transition to bypass mode. */
5465 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5470 printf("\t Failed to set bypass event for port = %d.\n",
5474 cmdline_parse_token_string_t cmd_setbypass_event_set =
5475 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5477 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5478 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5480 cmdline_parse_token_string_t cmd_setbypass_event_event =
5481 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5483 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5484 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5485 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5486 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5487 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5489 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5490 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5491 mode_value, "normal#bypass#isolate");
5492 cmdline_parse_token_num_t cmd_setbypass_event_port =
5493 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5496 cmdline_parse_inst_t cmd_set_bypass_event = {
5497 .f = cmd_set_bypass_event_parsed,
5498 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5499 "power_off mode normal|bypass|isolate <port_id>: "
5500 "Set the NIC bypass event mode for port_id",
5503 (void *)&cmd_setbypass_event_set,
5504 (void *)&cmd_setbypass_event_bypass,
5505 (void *)&cmd_setbypass_event_event,
5506 (void *)&cmd_setbypass_event_event_value,
5507 (void *)&cmd_setbypass_event_mode,
5508 (void *)&cmd_setbypass_event_mode_value,
5509 (void *)&cmd_setbypass_event_port,
5515 /* *** SET NIC BYPASS TIMEOUT *** */
5516 struct cmd_set_bypass_timeout_result {
5517 cmdline_fixed_string_t set;
5518 cmdline_fixed_string_t bypass;
5519 cmdline_fixed_string_t timeout;
5520 cmdline_fixed_string_t value;
5524 cmd_set_bypass_timeout_parsed(void *parsed_result,
5525 __rte_unused struct cmdline *cl,
5526 __rte_unused void *data)
5528 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5530 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5531 if (!strcmp(res->value, "1.5"))
5532 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5533 else if (!strcmp(res->value, "2"))
5534 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5535 else if (!strcmp(res->value, "3"))
5536 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5537 else if (!strcmp(res->value, "4"))
5538 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5539 else if (!strcmp(res->value, "8"))
5540 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5541 else if (!strcmp(res->value, "16"))
5542 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5543 else if (!strcmp(res->value, "32"))
5544 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5546 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5550 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5551 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5553 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5554 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5556 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5557 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5558 timeout, "timeout");
5559 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5560 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5561 value, "0#1.5#2#3#4#8#16#32");
5563 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5564 .f = cmd_set_bypass_timeout_parsed,
5565 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5566 "Set the NIC bypass watchdog timeout in seconds",
5569 (void *)&cmd_setbypass_timeout_set,
5570 (void *)&cmd_setbypass_timeout_bypass,
5571 (void *)&cmd_setbypass_timeout_timeout,
5572 (void *)&cmd_setbypass_timeout_value,
5577 /* *** SHOW NIC BYPASS MODE *** */
5578 struct cmd_show_bypass_config_result {
5579 cmdline_fixed_string_t show;
5580 cmdline_fixed_string_t bypass;
5581 cmdline_fixed_string_t config;
5586 cmd_show_bypass_config_parsed(void *parsed_result,
5587 __rte_unused struct cmdline *cl,
5588 __rte_unused void *data)
5590 struct cmd_show_bypass_config_result *res = parsed_result;
5591 portid_t port_id = res->port_id;
5593 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5594 uint32_t event_mode;
5595 uint32_t bypass_mode;
5596 uint32_t timeout = bypass_timeout;
5599 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5600 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5601 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5602 {"UNKNOWN", "normal", "bypass", "isolate"};
5603 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5611 /* Display the bypass mode.*/
5612 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5613 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5617 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5618 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5620 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5623 /* Display the bypass timeout.*/
5624 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5625 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5627 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5629 /* Display the bypass events and associated modes. */
5630 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5632 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5633 printf("\tFailed to get bypass mode for event = %s\n",
5636 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5637 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5639 printf("\tbypass event: %-16s = %s\n", events[i],
5645 printf("\tFailed to get bypass configuration for port = %d\n",
5649 cmdline_parse_token_string_t cmd_showbypass_config_show =
5650 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5652 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5653 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5655 cmdline_parse_token_string_t cmd_showbypass_config_config =
5656 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5658 cmdline_parse_token_num_t cmd_showbypass_config_port =
5659 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5662 cmdline_parse_inst_t cmd_show_bypass_config = {
5663 .f = cmd_show_bypass_config_parsed,
5664 .help_str = "show bypass config <port_id>: "
5665 "Show the NIC bypass config for port_id",
5668 (void *)&cmd_showbypass_config_show,
5669 (void *)&cmd_showbypass_config_bypass,
5670 (void *)&cmd_showbypass_config_config,
5671 (void *)&cmd_showbypass_config_port,
5676 #ifdef RTE_LIBRTE_PMD_BOND
5677 /* *** SET BONDING MODE *** */
5678 struct cmd_set_bonding_mode_result {
5679 cmdline_fixed_string_t set;
5680 cmdline_fixed_string_t bonding;
5681 cmdline_fixed_string_t mode;
5686 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5687 __rte_unused struct cmdline *cl,
5688 __rte_unused void *data)
5690 struct cmd_set_bonding_mode_result *res = parsed_result;
5691 portid_t port_id = res->port_id;
5693 /* Set the bonding mode for the relevant port. */
5694 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5695 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5698 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5701 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5703 bonding, "bonding");
5704 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5705 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5707 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5708 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5710 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5711 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5714 cmdline_parse_inst_t cmd_set_bonding_mode = {
5715 .f = cmd_set_bonding_mode_parsed,
5716 .help_str = "set bonding mode <mode_value> <port_id>: "
5717 "Set the bonding mode for port_id",
5720 (void *) &cmd_setbonding_mode_set,
5721 (void *) &cmd_setbonding_mode_bonding,
5722 (void *) &cmd_setbonding_mode_mode,
5723 (void *) &cmd_setbonding_mode_value,
5724 (void *) &cmd_setbonding_mode_port,
5729 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5730 struct cmd_set_bonding_lacp_dedicated_queues_result {
5731 cmdline_fixed_string_t set;
5732 cmdline_fixed_string_t bonding;
5733 cmdline_fixed_string_t lacp;
5734 cmdline_fixed_string_t dedicated_queues;
5736 cmdline_fixed_string_t mode;
5739 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5740 __rte_unused struct cmdline *cl,
5741 __rte_unused void *data)
5743 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5744 portid_t port_id = res->port_id;
5745 struct rte_port *port;
5747 port = &ports[port_id];
5749 /** Check if the port is not started **/
5750 if (port->port_status != RTE_PORT_STOPPED) {
5751 printf("Please stop port %d first\n", port_id);
5755 if (!strcmp(res->mode, "enable")) {
5756 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5757 printf("Dedicate queues for LACP control packets"
5760 printf("Enabling dedicate queues for LACP control "
5761 "packets on port %d failed\n", port_id);
5762 } else if (!strcmp(res->mode, "disable")) {
5763 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5764 printf("Dedicated queues for LACP control packets "
5767 printf("Disabling dedicated queues for LACP control "
5768 "traffic on port %d failed\n", port_id);
5772 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5773 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5775 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5776 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5777 bonding, "bonding");
5778 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5779 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5781 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5783 dedicated_queues, "dedicated_queues");
5784 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5785 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5787 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5788 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5789 mode, "enable#disable");
5791 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5792 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5793 .help_str = "set bonding lacp dedicated_queues <port_id> "
5795 "Enable/disable dedicated queues for LACP control traffic for port_id",
5798 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5799 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5800 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5801 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5802 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5803 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5808 /* *** SET BALANCE XMIT POLICY *** */
5809 struct cmd_set_bonding_balance_xmit_policy_result {
5810 cmdline_fixed_string_t set;
5811 cmdline_fixed_string_t bonding;
5812 cmdline_fixed_string_t balance_xmit_policy;
5814 cmdline_fixed_string_t policy;
5817 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5818 __rte_unused struct cmdline *cl,
5819 __rte_unused void *data)
5821 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5822 portid_t port_id = res->port_id;
5825 if (!strcmp(res->policy, "l2")) {
5826 policy = BALANCE_XMIT_POLICY_LAYER2;
5827 } else if (!strcmp(res->policy, "l23")) {
5828 policy = BALANCE_XMIT_POLICY_LAYER23;
5829 } else if (!strcmp(res->policy, "l34")) {
5830 policy = BALANCE_XMIT_POLICY_LAYER34;
5832 printf("\t Invalid xmit policy selection");
5836 /* Set the bonding mode for the relevant port. */
5837 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5838 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5843 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5846 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5848 bonding, "bonding");
5849 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5851 balance_xmit_policy, "balance_xmit_policy");
5852 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5853 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5855 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5856 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5857 policy, "l2#l23#l34");
5859 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5860 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5861 .help_str = "set bonding balance_xmit_policy <port_id> "
5863 "Set the bonding balance_xmit_policy for port_id",
5866 (void *)&cmd_setbonding_balance_xmit_policy_set,
5867 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5868 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5869 (void *)&cmd_setbonding_balance_xmit_policy_port,
5870 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5875 /* *** SHOW NIC BONDING CONFIGURATION *** */
5876 struct cmd_show_bonding_config_result {
5877 cmdline_fixed_string_t show;
5878 cmdline_fixed_string_t bonding;
5879 cmdline_fixed_string_t config;
5883 static void cmd_show_bonding_config_parsed(void *parsed_result,
5884 __rte_unused struct cmdline *cl,
5885 __rte_unused void *data)
5887 struct cmd_show_bonding_config_result *res = parsed_result;
5888 int bonding_mode, agg_mode;
5889 portid_t slaves[RTE_MAX_ETHPORTS];
5890 int num_slaves, num_active_slaves;
5893 portid_t port_id = res->port_id;
5895 /* Display the bonding mode.*/
5896 bonding_mode = rte_eth_bond_mode_get(port_id);
5897 if (bonding_mode < 0) {
5898 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5901 printf("\tBonding mode: %d\n", bonding_mode);
5903 if (bonding_mode == BONDING_MODE_BALANCE) {
5904 int balance_xmit_policy;
5906 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5907 if (balance_xmit_policy < 0) {
5908 printf("\tFailed to get balance xmit policy for port = %d\n",
5912 printf("\tBalance Xmit Policy: ");
5914 switch (balance_xmit_policy) {
5915 case BALANCE_XMIT_POLICY_LAYER2:
5916 printf("BALANCE_XMIT_POLICY_LAYER2");
5918 case BALANCE_XMIT_POLICY_LAYER23:
5919 printf("BALANCE_XMIT_POLICY_LAYER23");
5921 case BALANCE_XMIT_POLICY_LAYER34:
5922 printf("BALANCE_XMIT_POLICY_LAYER34");
5929 if (bonding_mode == BONDING_MODE_8023AD) {
5930 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5931 printf("\tIEEE802.3AD Aggregator Mode: ");
5934 printf("bandwidth");
5946 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5948 if (num_slaves < 0) {
5949 printf("\tFailed to get slave list for port = %d\n", port_id);
5952 if (num_slaves > 0) {
5953 printf("\tSlaves (%d): [", num_slaves);
5954 for (i = 0; i < num_slaves - 1; i++)
5955 printf("%d ", slaves[i]);
5957 printf("%d]\n", slaves[num_slaves - 1]);
5959 printf("\tSlaves: []\n");
5963 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5966 if (num_active_slaves < 0) {
5967 printf("\tFailed to get active slave list for port = %d\n", port_id);
5970 if (num_active_slaves > 0) {
5971 printf("\tActive Slaves (%d): [", num_active_slaves);
5972 for (i = 0; i < num_active_slaves - 1; i++)
5973 printf("%d ", slaves[i]);
5975 printf("%d]\n", slaves[num_active_slaves - 1]);
5978 printf("\tActive Slaves: []\n");
5982 primary_id = rte_eth_bond_primary_get(port_id);
5983 if (primary_id < 0) {
5984 printf("\tFailed to get primary slave for port = %d\n", port_id);
5987 printf("\tPrimary: [%d]\n", primary_id);
5991 cmdline_parse_token_string_t cmd_showbonding_config_show =
5992 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5994 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5995 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5996 bonding, "bonding");
5997 cmdline_parse_token_string_t cmd_showbonding_config_config =
5998 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6000 cmdline_parse_token_num_t cmd_showbonding_config_port =
6001 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6004 cmdline_parse_inst_t cmd_show_bonding_config = {
6005 .f = cmd_show_bonding_config_parsed,
6006 .help_str = "show bonding config <port_id>: "
6007 "Show the bonding config for port_id",
6010 (void *)&cmd_showbonding_config_show,
6011 (void *)&cmd_showbonding_config_bonding,
6012 (void *)&cmd_showbonding_config_config,
6013 (void *)&cmd_showbonding_config_port,
6018 /* *** SET BONDING PRIMARY *** */
6019 struct cmd_set_bonding_primary_result {
6020 cmdline_fixed_string_t set;
6021 cmdline_fixed_string_t bonding;
6022 cmdline_fixed_string_t primary;
6027 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6028 __rte_unused struct cmdline *cl,
6029 __rte_unused void *data)
6031 struct cmd_set_bonding_primary_result *res = parsed_result;
6032 portid_t master_port_id = res->port_id;
6033 portid_t slave_port_id = res->slave_id;
6035 /* Set the primary slave for a bonded device. */
6036 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6037 printf("\t Failed to set primary slave for port = %d.\n",
6044 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6045 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6047 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6048 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6049 bonding, "bonding");
6050 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6051 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6052 primary, "primary");
6053 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6054 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6056 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6057 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6060 cmdline_parse_inst_t cmd_set_bonding_primary = {
6061 .f = cmd_set_bonding_primary_parsed,
6062 .help_str = "set bonding primary <slave_id> <port_id>: "
6063 "Set the primary slave for port_id",
6066 (void *)&cmd_setbonding_primary_set,
6067 (void *)&cmd_setbonding_primary_bonding,
6068 (void *)&cmd_setbonding_primary_primary,
6069 (void *)&cmd_setbonding_primary_slave,
6070 (void *)&cmd_setbonding_primary_port,
6075 /* *** ADD SLAVE *** */
6076 struct cmd_add_bonding_slave_result {
6077 cmdline_fixed_string_t add;
6078 cmdline_fixed_string_t bonding;
6079 cmdline_fixed_string_t slave;
6084 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6085 __rte_unused struct cmdline *cl,
6086 __rte_unused void *data)
6088 struct cmd_add_bonding_slave_result *res = parsed_result;
6089 portid_t master_port_id = res->port_id;
6090 portid_t slave_port_id = res->slave_id;
6092 /* add the slave for a bonded device. */
6093 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6094 printf("\t Failed to add slave %d to master port = %d.\n",
6095 slave_port_id, master_port_id);
6099 set_port_slave_flag(slave_port_id);
6102 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6103 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6105 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6106 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6107 bonding, "bonding");
6108 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6109 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6111 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6112 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6114 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6115 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6118 cmdline_parse_inst_t cmd_add_bonding_slave = {
6119 .f = cmd_add_bonding_slave_parsed,
6120 .help_str = "add bonding slave <slave_id> <port_id>: "
6121 "Add a slave device to a bonded device",
6124 (void *)&cmd_addbonding_slave_add,
6125 (void *)&cmd_addbonding_slave_bonding,
6126 (void *)&cmd_addbonding_slave_slave,
6127 (void *)&cmd_addbonding_slave_slaveid,
6128 (void *)&cmd_addbonding_slave_port,
6133 /* *** REMOVE SLAVE *** */
6134 struct cmd_remove_bonding_slave_result {
6135 cmdline_fixed_string_t remove;
6136 cmdline_fixed_string_t bonding;
6137 cmdline_fixed_string_t slave;
6142 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6143 __rte_unused struct cmdline *cl,
6144 __rte_unused void *data)
6146 struct cmd_remove_bonding_slave_result *res = parsed_result;
6147 portid_t master_port_id = res->port_id;
6148 portid_t slave_port_id = res->slave_id;
6150 /* remove the slave from a bonded device. */
6151 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6152 printf("\t Failed to remove slave %d from master port = %d.\n",
6153 slave_port_id, master_port_id);
6157 clear_port_slave_flag(slave_port_id);
6160 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6161 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6163 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6164 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6165 bonding, "bonding");
6166 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6167 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6169 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6170 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6172 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6173 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6176 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6177 .f = cmd_remove_bonding_slave_parsed,
6178 .help_str = "remove bonding slave <slave_id> <port_id>: "
6179 "Remove a slave device from a bonded device",
6182 (void *)&cmd_removebonding_slave_remove,
6183 (void *)&cmd_removebonding_slave_bonding,
6184 (void *)&cmd_removebonding_slave_slave,
6185 (void *)&cmd_removebonding_slave_slaveid,
6186 (void *)&cmd_removebonding_slave_port,
6191 /* *** CREATE BONDED DEVICE *** */
6192 struct cmd_create_bonded_device_result {
6193 cmdline_fixed_string_t create;
6194 cmdline_fixed_string_t bonded;
6195 cmdline_fixed_string_t device;
6200 static int bond_dev_num = 0;
6202 static void cmd_create_bonded_device_parsed(void *parsed_result,
6203 __rte_unused struct cmdline *cl,
6204 __rte_unused void *data)
6206 struct cmd_create_bonded_device_result *res = parsed_result;
6207 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6211 if (test_done == 0) {
6212 printf("Please stop forwarding first\n");
6216 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6219 /* Create a new bonded device. */
6220 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6222 printf("\t Failed to create bonded device.\n");
6225 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6228 /* Update number of ports */
6229 nb_ports = rte_eth_dev_count_avail();
6230 reconfig(port_id, res->socket);
6231 ret = rte_eth_promiscuous_enable(port_id);
6233 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6234 port_id, rte_strerror(-ret));
6236 ports[port_id].need_setup = 0;
6237 ports[port_id].port_status = RTE_PORT_STOPPED;
6242 cmdline_parse_token_string_t cmd_createbonded_device_create =
6243 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6245 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6246 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6248 cmdline_parse_token_string_t cmd_createbonded_device_device =
6249 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6251 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6252 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6254 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6255 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6258 cmdline_parse_inst_t cmd_create_bonded_device = {
6259 .f = cmd_create_bonded_device_parsed,
6260 .help_str = "create bonded device <mode> <socket>: "
6261 "Create a new bonded device with specific bonding mode and socket",
6264 (void *)&cmd_createbonded_device_create,
6265 (void *)&cmd_createbonded_device_bonded,
6266 (void *)&cmd_createbonded_device_device,
6267 (void *)&cmd_createbonded_device_mode,
6268 (void *)&cmd_createbonded_device_socket,
6273 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6274 struct cmd_set_bond_mac_addr_result {
6275 cmdline_fixed_string_t set;
6276 cmdline_fixed_string_t bonding;
6277 cmdline_fixed_string_t mac_addr;
6279 struct rte_ether_addr address;
6282 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6283 __rte_unused struct cmdline *cl,
6284 __rte_unused void *data)
6286 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6289 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6292 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6294 /* check the return value and print it if is < 0 */
6296 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6299 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6300 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6301 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6302 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6304 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6305 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6307 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6308 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6310 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6311 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6313 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6314 .f = cmd_set_bond_mac_addr_parsed,
6316 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6318 (void *)&cmd_set_bond_mac_addr_set,
6319 (void *)&cmd_set_bond_mac_addr_bonding,
6320 (void *)&cmd_set_bond_mac_addr_mac,
6321 (void *)&cmd_set_bond_mac_addr_portnum,
6322 (void *)&cmd_set_bond_mac_addr_addr,
6328 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6329 struct cmd_set_bond_mon_period_result {
6330 cmdline_fixed_string_t set;
6331 cmdline_fixed_string_t bonding;
6332 cmdline_fixed_string_t mon_period;
6337 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6338 __rte_unused struct cmdline *cl,
6339 __rte_unused void *data)
6341 struct cmd_set_bond_mon_period_result *res = parsed_result;
6344 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6346 /* check the return value and print it if is < 0 */
6348 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6351 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6352 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6354 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6355 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6356 bonding, "bonding");
6357 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6358 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6359 mon_period, "mon_period");
6360 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6361 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6363 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6364 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6367 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6368 .f = cmd_set_bond_mon_period_parsed,
6370 .help_str = "set bonding mon_period <port_id> <period_ms>",
6372 (void *)&cmd_set_bond_mon_period_set,
6373 (void *)&cmd_set_bond_mon_period_bonding,
6374 (void *)&cmd_set_bond_mon_period_mon_period,
6375 (void *)&cmd_set_bond_mon_period_portnum,
6376 (void *)&cmd_set_bond_mon_period_period_ms,
6383 struct cmd_set_bonding_agg_mode_policy_result {
6384 cmdline_fixed_string_t set;
6385 cmdline_fixed_string_t bonding;
6386 cmdline_fixed_string_t agg_mode;
6388 cmdline_fixed_string_t policy;
6393 cmd_set_bonding_agg_mode(void *parsed_result,
6394 __rte_unused struct cmdline *cl,
6395 __rte_unused void *data)
6397 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6398 uint8_t policy = AGG_BANDWIDTH;
6400 if (!strcmp(res->policy, "bandwidth"))
6401 policy = AGG_BANDWIDTH;
6402 else if (!strcmp(res->policy, "stable"))
6403 policy = AGG_STABLE;
6404 else if (!strcmp(res->policy, "count"))
6407 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6411 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6412 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6414 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6415 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6416 bonding, "bonding");
6418 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6419 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6420 agg_mode, "agg_mode");
6422 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6423 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6426 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6427 TOKEN_STRING_INITIALIZER(
6428 struct cmd_set_bonding_balance_xmit_policy_result,
6429 policy, "stable#bandwidth#count");
6431 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6432 .f = cmd_set_bonding_agg_mode,
6434 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6436 (void *)&cmd_set_bonding_agg_mode_set,
6437 (void *)&cmd_set_bonding_agg_mode_bonding,
6438 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6439 (void *)&cmd_set_bonding_agg_mode_portnum,
6440 (void *)&cmd_set_bonding_agg_mode_policy_string,
6446 #endif /* RTE_LIBRTE_PMD_BOND */
6448 /* *** SET FORWARDING MODE *** */
6449 struct cmd_set_fwd_mode_result {
6450 cmdline_fixed_string_t set;
6451 cmdline_fixed_string_t fwd;
6452 cmdline_fixed_string_t mode;
6455 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6456 __rte_unused struct cmdline *cl,
6457 __rte_unused void *data)
6459 struct cmd_set_fwd_mode_result *res = parsed_result;
6462 set_pkt_forwarding_mode(res->mode);
6465 cmdline_parse_token_string_t cmd_setfwd_set =
6466 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6467 cmdline_parse_token_string_t cmd_setfwd_fwd =
6468 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6469 cmdline_parse_token_string_t cmd_setfwd_mode =
6470 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6471 "" /* defined at init */);
6473 cmdline_parse_inst_t cmd_set_fwd_mode = {
6474 .f = cmd_set_fwd_mode_parsed,
6476 .help_str = NULL, /* defined at init */
6478 (void *)&cmd_setfwd_set,
6479 (void *)&cmd_setfwd_fwd,
6480 (void *)&cmd_setfwd_mode,
6485 static void cmd_set_fwd_mode_init(void)
6488 static char token[128];
6489 static char help[256];
6490 cmdline_parse_token_string_t *token_struct;
6492 modes = list_pkt_forwarding_modes();
6493 snprintf(help, sizeof(help), "set fwd %s: "
6494 "Set packet forwarding mode", modes);
6495 cmd_set_fwd_mode.help_str = help;
6497 /* string token separator is # */
6498 for (c = token; *modes != '\0'; modes++)
6503 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6504 token_struct->string_data.str = token;
6507 /* *** SET RETRY FORWARDING MODE *** */
6508 struct cmd_set_fwd_retry_mode_result {
6509 cmdline_fixed_string_t set;
6510 cmdline_fixed_string_t fwd;
6511 cmdline_fixed_string_t mode;
6512 cmdline_fixed_string_t retry;
6515 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6516 __rte_unused struct cmdline *cl,
6517 __rte_unused void *data)
6519 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6522 set_pkt_forwarding_mode(res->mode);
6525 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6526 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6528 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6529 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6531 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6532 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6534 "" /* defined at init */);
6535 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6536 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6539 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6540 .f = cmd_set_fwd_retry_mode_parsed,
6542 .help_str = NULL, /* defined at init */
6544 (void *)&cmd_setfwd_retry_set,
6545 (void *)&cmd_setfwd_retry_fwd,
6546 (void *)&cmd_setfwd_retry_mode,
6547 (void *)&cmd_setfwd_retry_retry,
6552 static void cmd_set_fwd_retry_mode_init(void)
6555 static char token[128];
6556 static char help[256];
6557 cmdline_parse_token_string_t *token_struct;
6559 modes = list_pkt_forwarding_retry_modes();
6560 snprintf(help, sizeof(help), "set fwd %s retry: "
6561 "Set packet forwarding mode with retry", modes);
6562 cmd_set_fwd_retry_mode.help_str = help;
6564 /* string token separator is # */
6565 for (c = token; *modes != '\0'; modes++)
6570 token_struct = (cmdline_parse_token_string_t *)
6571 cmd_set_fwd_retry_mode.tokens[2];
6572 token_struct->string_data.str = token;
6575 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6576 struct cmd_set_burst_tx_retry_result {
6577 cmdline_fixed_string_t set;
6578 cmdline_fixed_string_t burst;
6579 cmdline_fixed_string_t tx;
6580 cmdline_fixed_string_t delay;
6582 cmdline_fixed_string_t retry;
6586 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6587 __rte_unused struct cmdline *cl,
6588 __rte_unused void *data)
6590 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6592 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6593 && !strcmp(res->tx, "tx")) {
6594 if (!strcmp(res->delay, "delay"))
6595 burst_tx_delay_time = res->time;
6596 if (!strcmp(res->retry, "retry"))
6597 burst_tx_retry_num = res->retry_num;
6602 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6603 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6604 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6605 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6607 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6608 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6609 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6610 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6611 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6612 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6613 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6614 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6615 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6616 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6618 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6619 .f = cmd_set_burst_tx_retry_parsed,
6620 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6622 (void *)&cmd_set_burst_tx_retry_set,
6623 (void *)&cmd_set_burst_tx_retry_burst,
6624 (void *)&cmd_set_burst_tx_retry_tx,
6625 (void *)&cmd_set_burst_tx_retry_delay,
6626 (void *)&cmd_set_burst_tx_retry_time,
6627 (void *)&cmd_set_burst_tx_retry_retry,
6628 (void *)&cmd_set_burst_tx_retry_retry_num,
6633 /* *** SET PROMISC MODE *** */
6634 struct cmd_set_promisc_mode_result {
6635 cmdline_fixed_string_t set;
6636 cmdline_fixed_string_t promisc;
6637 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6638 uint16_t port_num; /* valid if "allports" argument == 0 */
6639 cmdline_fixed_string_t mode;
6642 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6643 __rte_unused struct cmdline *cl,
6646 struct cmd_set_promisc_mode_result *res = parsed_result;
6650 if (!strcmp(res->mode, "on"))
6657 RTE_ETH_FOREACH_DEV(i)
6658 eth_set_promisc_mode(i, enable);
6660 eth_set_promisc_mode(res->port_num, enable);
6664 cmdline_parse_token_string_t cmd_setpromisc_set =
6665 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6666 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6669 cmdline_parse_token_string_t cmd_setpromisc_portall =
6670 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6672 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6673 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6675 cmdline_parse_token_string_t cmd_setpromisc_mode =
6676 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6679 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6680 .f = cmd_set_promisc_mode_parsed,
6682 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6684 (void *)&cmd_setpromisc_set,
6685 (void *)&cmd_setpromisc_promisc,
6686 (void *)&cmd_setpromisc_portall,
6687 (void *)&cmd_setpromisc_mode,
6692 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6693 .f = cmd_set_promisc_mode_parsed,
6695 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6697 (void *)&cmd_setpromisc_set,
6698 (void *)&cmd_setpromisc_promisc,
6699 (void *)&cmd_setpromisc_portnum,
6700 (void *)&cmd_setpromisc_mode,
6705 /* *** SET ALLMULTI MODE *** */
6706 struct cmd_set_allmulti_mode_result {
6707 cmdline_fixed_string_t set;
6708 cmdline_fixed_string_t allmulti;
6709 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6710 uint16_t port_num; /* valid if "allports" argument == 0 */
6711 cmdline_fixed_string_t mode;
6714 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6715 __rte_unused struct cmdline *cl,
6718 struct cmd_set_allmulti_mode_result *res = parsed_result;
6722 if (!strcmp(res->mode, "on"))
6729 RTE_ETH_FOREACH_DEV(i) {
6730 eth_set_allmulticast_mode(i, enable);
6734 eth_set_allmulticast_mode(res->port_num, enable);
6738 cmdline_parse_token_string_t cmd_setallmulti_set =
6739 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6740 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6743 cmdline_parse_token_string_t cmd_setallmulti_portall =
6744 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6746 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6747 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6749 cmdline_parse_token_string_t cmd_setallmulti_mode =
6750 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6753 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6754 .f = cmd_set_allmulti_mode_parsed,
6756 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6758 (void *)&cmd_setallmulti_set,
6759 (void *)&cmd_setallmulti_allmulti,
6760 (void *)&cmd_setallmulti_portall,
6761 (void *)&cmd_setallmulti_mode,
6766 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6767 .f = cmd_set_allmulti_mode_parsed,
6769 .help_str = "set allmulti <port_id> on|off: "
6770 "Set allmulti mode on port_id",
6772 (void *)&cmd_setallmulti_set,
6773 (void *)&cmd_setallmulti_allmulti,
6774 (void *)&cmd_setallmulti_portnum,
6775 (void *)&cmd_setallmulti_mode,
6780 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6781 struct cmd_link_flow_ctrl_set_result {
6782 cmdline_fixed_string_t set;
6783 cmdline_fixed_string_t flow_ctrl;
6784 cmdline_fixed_string_t rx;
6785 cmdline_fixed_string_t rx_lfc_mode;
6786 cmdline_fixed_string_t tx;
6787 cmdline_fixed_string_t tx_lfc_mode;
6788 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6789 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6790 cmdline_fixed_string_t autoneg_str;
6791 cmdline_fixed_string_t autoneg;
6792 cmdline_fixed_string_t hw_str;
6793 uint32_t high_water;
6794 cmdline_fixed_string_t lw_str;
6796 cmdline_fixed_string_t pt_str;
6797 uint16_t pause_time;
6798 cmdline_fixed_string_t xon_str;
6803 cmdline_parse_token_string_t cmd_lfc_set_set =
6804 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6806 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6807 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6808 flow_ctrl, "flow_ctrl");
6809 cmdline_parse_token_string_t cmd_lfc_set_rx =
6810 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6812 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6813 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6814 rx_lfc_mode, "on#off");
6815 cmdline_parse_token_string_t cmd_lfc_set_tx =
6816 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6818 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6819 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6820 tx_lfc_mode, "on#off");
6821 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6822 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6823 hw_str, "high_water");
6824 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6825 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6826 high_water, UINT32);
6827 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6828 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6829 lw_str, "low_water");
6830 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6831 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6833 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6834 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6835 pt_str, "pause_time");
6836 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6837 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6838 pause_time, UINT16);
6839 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6840 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6841 xon_str, "send_xon");
6842 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6843 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6845 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6846 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6847 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6848 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6849 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6850 mac_ctrl_frame_fwd_mode, "on#off");
6851 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6852 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6853 autoneg_str, "autoneg");
6854 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6855 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6857 cmdline_parse_token_num_t cmd_lfc_set_portid =
6858 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6861 /* forward declaration */
6863 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6866 cmdline_parse_inst_t cmd_link_flow_control_set = {
6867 .f = cmd_link_flow_ctrl_set_parsed,
6869 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6870 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6871 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6873 (void *)&cmd_lfc_set_set,
6874 (void *)&cmd_lfc_set_flow_ctrl,
6875 (void *)&cmd_lfc_set_rx,
6876 (void *)&cmd_lfc_set_rx_mode,
6877 (void *)&cmd_lfc_set_tx,
6878 (void *)&cmd_lfc_set_tx_mode,
6879 (void *)&cmd_lfc_set_high_water,
6880 (void *)&cmd_lfc_set_low_water,
6881 (void *)&cmd_lfc_set_pause_time,
6882 (void *)&cmd_lfc_set_send_xon,
6883 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6884 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6885 (void *)&cmd_lfc_set_autoneg_str,
6886 (void *)&cmd_lfc_set_autoneg,
6887 (void *)&cmd_lfc_set_portid,
6892 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6893 .f = cmd_link_flow_ctrl_set_parsed,
6894 .data = (void *)&cmd_link_flow_control_set_rx,
6895 .help_str = "set flow_ctrl rx on|off <port_id>: "
6896 "Change rx flow control parameter",
6898 (void *)&cmd_lfc_set_set,
6899 (void *)&cmd_lfc_set_flow_ctrl,
6900 (void *)&cmd_lfc_set_rx,
6901 (void *)&cmd_lfc_set_rx_mode,
6902 (void *)&cmd_lfc_set_portid,
6907 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6908 .f = cmd_link_flow_ctrl_set_parsed,
6909 .data = (void *)&cmd_link_flow_control_set_tx,
6910 .help_str = "set flow_ctrl tx on|off <port_id>: "
6911 "Change tx flow control parameter",
6913 (void *)&cmd_lfc_set_set,
6914 (void *)&cmd_lfc_set_flow_ctrl,
6915 (void *)&cmd_lfc_set_tx,
6916 (void *)&cmd_lfc_set_tx_mode,
6917 (void *)&cmd_lfc_set_portid,
6922 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6923 .f = cmd_link_flow_ctrl_set_parsed,
6924 .data = (void *)&cmd_link_flow_control_set_hw,
6925 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6926 "Change high water flow control parameter",
6928 (void *)&cmd_lfc_set_set,
6929 (void *)&cmd_lfc_set_flow_ctrl,
6930 (void *)&cmd_lfc_set_high_water_str,
6931 (void *)&cmd_lfc_set_high_water,
6932 (void *)&cmd_lfc_set_portid,
6937 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6938 .f = cmd_link_flow_ctrl_set_parsed,
6939 .data = (void *)&cmd_link_flow_control_set_lw,
6940 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6941 "Change low water flow control parameter",
6943 (void *)&cmd_lfc_set_set,
6944 (void *)&cmd_lfc_set_flow_ctrl,
6945 (void *)&cmd_lfc_set_low_water_str,
6946 (void *)&cmd_lfc_set_low_water,
6947 (void *)&cmd_lfc_set_portid,
6952 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6953 .f = cmd_link_flow_ctrl_set_parsed,
6954 .data = (void *)&cmd_link_flow_control_set_pt,
6955 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6956 "Change pause time flow control parameter",
6958 (void *)&cmd_lfc_set_set,
6959 (void *)&cmd_lfc_set_flow_ctrl,
6960 (void *)&cmd_lfc_set_pause_time_str,
6961 (void *)&cmd_lfc_set_pause_time,
6962 (void *)&cmd_lfc_set_portid,
6967 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6968 .f = cmd_link_flow_ctrl_set_parsed,
6969 .data = (void *)&cmd_link_flow_control_set_xon,
6970 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6971 "Change send_xon flow control parameter",
6973 (void *)&cmd_lfc_set_set,
6974 (void *)&cmd_lfc_set_flow_ctrl,
6975 (void *)&cmd_lfc_set_send_xon_str,
6976 (void *)&cmd_lfc_set_send_xon,
6977 (void *)&cmd_lfc_set_portid,
6982 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6983 .f = cmd_link_flow_ctrl_set_parsed,
6984 .data = (void *)&cmd_link_flow_control_set_macfwd,
6985 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6986 "Change mac ctrl fwd flow control parameter",
6988 (void *)&cmd_lfc_set_set,
6989 (void *)&cmd_lfc_set_flow_ctrl,
6990 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6991 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6992 (void *)&cmd_lfc_set_portid,
6997 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6998 .f = cmd_link_flow_ctrl_set_parsed,
6999 .data = (void *)&cmd_link_flow_control_set_autoneg,
7000 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7001 "Change autoneg flow control parameter",
7003 (void *)&cmd_lfc_set_set,
7004 (void *)&cmd_lfc_set_flow_ctrl,
7005 (void *)&cmd_lfc_set_autoneg_str,
7006 (void *)&cmd_lfc_set_autoneg,
7007 (void *)&cmd_lfc_set_portid,
7013 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7014 __rte_unused struct cmdline *cl,
7017 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7018 cmdline_parse_inst_t *cmd = data;
7019 struct rte_eth_fc_conf fc_conf;
7025 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7026 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7027 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7028 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7030 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7031 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7034 /* Partial command line, retrieve current configuration */
7036 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7038 printf("cannot get current flow ctrl parameters, return"
7039 "code = %d\n", ret);
7043 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7044 (fc_conf.mode == RTE_FC_FULL))
7046 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7047 (fc_conf.mode == RTE_FC_FULL))
7051 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7052 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7054 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7055 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7057 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7059 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7060 fc_conf.high_water = res->high_water;
7062 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7063 fc_conf.low_water = res->low_water;
7065 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7066 fc_conf.pause_time = res->pause_time;
7068 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7069 fc_conf.send_xon = res->send_xon;
7071 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7072 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7073 fc_conf.mac_ctrl_frame_fwd = 1;
7075 fc_conf.mac_ctrl_frame_fwd = 0;
7078 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7079 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7081 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7083 printf("bad flow contrl parameter, return code = %d \n", ret);
7086 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7087 struct cmd_priority_flow_ctrl_set_result {
7088 cmdline_fixed_string_t set;
7089 cmdline_fixed_string_t pfc_ctrl;
7090 cmdline_fixed_string_t rx;
7091 cmdline_fixed_string_t rx_pfc_mode;
7092 cmdline_fixed_string_t tx;
7093 cmdline_fixed_string_t tx_pfc_mode;
7094 uint32_t high_water;
7096 uint16_t pause_time;
7102 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7103 __rte_unused struct cmdline *cl,
7104 __rte_unused void *data)
7106 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7107 struct rte_eth_pfc_conf pfc_conf;
7108 int rx_fc_enable, tx_fc_enable;
7112 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7113 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7114 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7115 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7117 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7118 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7121 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7122 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7123 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7124 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7125 pfc_conf.fc.high_water = res->high_water;
7126 pfc_conf.fc.low_water = res->low_water;
7127 pfc_conf.fc.pause_time = res->pause_time;
7128 pfc_conf.priority = res->priority;
7130 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7132 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7135 cmdline_parse_token_string_t cmd_pfc_set_set =
7136 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7138 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7139 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7140 pfc_ctrl, "pfc_ctrl");
7141 cmdline_parse_token_string_t cmd_pfc_set_rx =
7142 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7144 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7145 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7146 rx_pfc_mode, "on#off");
7147 cmdline_parse_token_string_t cmd_pfc_set_tx =
7148 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7150 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7151 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7152 tx_pfc_mode, "on#off");
7153 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7154 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7155 high_water, UINT32);
7156 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7157 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7159 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7160 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7161 pause_time, UINT16);
7162 cmdline_parse_token_num_t cmd_pfc_set_priority =
7163 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7165 cmdline_parse_token_num_t cmd_pfc_set_portid =
7166 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7169 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7170 .f = cmd_priority_flow_ctrl_set_parsed,
7172 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7173 "<pause_time> <priority> <port_id>: "
7174 "Configure the Ethernet priority flow control",
7176 (void *)&cmd_pfc_set_set,
7177 (void *)&cmd_pfc_set_flow_ctrl,
7178 (void *)&cmd_pfc_set_rx,
7179 (void *)&cmd_pfc_set_rx_mode,
7180 (void *)&cmd_pfc_set_tx,
7181 (void *)&cmd_pfc_set_tx_mode,
7182 (void *)&cmd_pfc_set_high_water,
7183 (void *)&cmd_pfc_set_low_water,
7184 (void *)&cmd_pfc_set_pause_time,
7185 (void *)&cmd_pfc_set_priority,
7186 (void *)&cmd_pfc_set_portid,
7191 /* *** RESET CONFIGURATION *** */
7192 struct cmd_reset_result {
7193 cmdline_fixed_string_t reset;
7194 cmdline_fixed_string_t def;
7197 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7199 __rte_unused void *data)
7201 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7202 set_def_fwd_config();
7205 cmdline_parse_token_string_t cmd_reset_set =
7206 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7207 cmdline_parse_token_string_t cmd_reset_def =
7208 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7211 cmdline_parse_inst_t cmd_reset = {
7212 .f = cmd_reset_parsed,
7214 .help_str = "set default: Reset default forwarding configuration",
7216 (void *)&cmd_reset_set,
7217 (void *)&cmd_reset_def,
7222 /* *** START FORWARDING *** */
7223 struct cmd_start_result {
7224 cmdline_fixed_string_t start;
7227 cmdline_parse_token_string_t cmd_start_start =
7228 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7230 static void cmd_start_parsed(__rte_unused void *parsed_result,
7231 __rte_unused struct cmdline *cl,
7232 __rte_unused void *data)
7234 start_packet_forwarding(0);
7237 cmdline_parse_inst_t cmd_start = {
7238 .f = cmd_start_parsed,
7240 .help_str = "start: Start packet forwarding",
7242 (void *)&cmd_start_start,
7247 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7248 struct cmd_start_tx_first_result {
7249 cmdline_fixed_string_t start;
7250 cmdline_fixed_string_t tx_first;
7254 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7255 __rte_unused struct cmdline *cl,
7256 __rte_unused void *data)
7258 start_packet_forwarding(1);
7261 cmdline_parse_token_string_t cmd_start_tx_first_start =
7262 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7264 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7265 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7266 tx_first, "tx_first");
7268 cmdline_parse_inst_t cmd_start_tx_first = {
7269 .f = cmd_start_tx_first_parsed,
7271 .help_str = "start tx_first: Start packet forwarding, "
7272 "after sending 1 burst of packets",
7274 (void *)&cmd_start_tx_first_start,
7275 (void *)&cmd_start_tx_first_tx_first,
7280 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7281 struct cmd_start_tx_first_n_result {
7282 cmdline_fixed_string_t start;
7283 cmdline_fixed_string_t tx_first;
7288 cmd_start_tx_first_n_parsed(void *parsed_result,
7289 __rte_unused struct cmdline *cl,
7290 __rte_unused void *data)
7292 struct cmd_start_tx_first_n_result *res = parsed_result;
7294 start_packet_forwarding(res->tx_num);
7297 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7298 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7300 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7301 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7302 tx_first, "tx_first");
7303 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7304 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7307 cmdline_parse_inst_t cmd_start_tx_first_n = {
7308 .f = cmd_start_tx_first_n_parsed,
7310 .help_str = "start tx_first <num>: "
7311 "packet forwarding, after sending <num> bursts of packets",
7313 (void *)&cmd_start_tx_first_n_start,
7314 (void *)&cmd_start_tx_first_n_tx_first,
7315 (void *)&cmd_start_tx_first_n_tx_num,
7320 /* *** SET LINK UP *** */
7321 struct cmd_set_link_up_result {
7322 cmdline_fixed_string_t set;
7323 cmdline_fixed_string_t link_up;
7324 cmdline_fixed_string_t port;
7328 cmdline_parse_token_string_t cmd_set_link_up_set =
7329 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7330 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7331 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7333 cmdline_parse_token_string_t cmd_set_link_up_port =
7334 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7335 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7336 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7338 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7339 __rte_unused struct cmdline *cl,
7340 __rte_unused void *data)
7342 struct cmd_set_link_up_result *res = parsed_result;
7343 dev_set_link_up(res->port_id);
7346 cmdline_parse_inst_t cmd_set_link_up = {
7347 .f = cmd_set_link_up_parsed,
7349 .help_str = "set link-up port <port id>",
7351 (void *)&cmd_set_link_up_set,
7352 (void *)&cmd_set_link_up_link_up,
7353 (void *)&cmd_set_link_up_port,
7354 (void *)&cmd_set_link_up_port_id,
7359 /* *** SET LINK DOWN *** */
7360 struct cmd_set_link_down_result {
7361 cmdline_fixed_string_t set;
7362 cmdline_fixed_string_t link_down;
7363 cmdline_fixed_string_t port;
7367 cmdline_parse_token_string_t cmd_set_link_down_set =
7368 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7369 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7370 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7372 cmdline_parse_token_string_t cmd_set_link_down_port =
7373 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7374 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7375 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7377 static void cmd_set_link_down_parsed(
7378 __rte_unused void *parsed_result,
7379 __rte_unused struct cmdline *cl,
7380 __rte_unused void *data)
7382 struct cmd_set_link_down_result *res = parsed_result;
7383 dev_set_link_down(res->port_id);
7386 cmdline_parse_inst_t cmd_set_link_down = {
7387 .f = cmd_set_link_down_parsed,
7389 .help_str = "set link-down port <port id>",
7391 (void *)&cmd_set_link_down_set,
7392 (void *)&cmd_set_link_down_link_down,
7393 (void *)&cmd_set_link_down_port,
7394 (void *)&cmd_set_link_down_port_id,
7399 /* *** SHOW CFG *** */
7400 struct cmd_showcfg_result {
7401 cmdline_fixed_string_t show;
7402 cmdline_fixed_string_t cfg;
7403 cmdline_fixed_string_t what;
7406 static void cmd_showcfg_parsed(void *parsed_result,
7407 __rte_unused struct cmdline *cl,
7408 __rte_unused void *data)
7410 struct cmd_showcfg_result *res = parsed_result;
7411 if (!strcmp(res->what, "rxtx"))
7412 rxtx_config_display();
7413 else if (!strcmp(res->what, "cores"))
7414 fwd_lcores_config_display();
7415 else if (!strcmp(res->what, "fwd"))
7416 pkt_fwd_config_display(&cur_fwd_config);
7417 else if (!strcmp(res->what, "txpkts"))
7418 show_tx_pkt_segments();
7421 cmdline_parse_token_string_t cmd_showcfg_show =
7422 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7423 cmdline_parse_token_string_t cmd_showcfg_port =
7424 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7425 cmdline_parse_token_string_t cmd_showcfg_what =
7426 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7427 "rxtx#cores#fwd#txpkts");
7429 cmdline_parse_inst_t cmd_showcfg = {
7430 .f = cmd_showcfg_parsed,
7432 .help_str = "show config rxtx|cores|fwd|txpkts",
7434 (void *)&cmd_showcfg_show,
7435 (void *)&cmd_showcfg_port,
7436 (void *)&cmd_showcfg_what,
7441 /* *** SHOW ALL PORT INFO *** */
7442 struct cmd_showportall_result {
7443 cmdline_fixed_string_t show;
7444 cmdline_fixed_string_t port;
7445 cmdline_fixed_string_t what;
7446 cmdline_fixed_string_t all;
7449 static void cmd_showportall_parsed(void *parsed_result,
7450 __rte_unused struct cmdline *cl,
7451 __rte_unused void *data)
7455 struct cmd_showportall_result *res = parsed_result;
7456 if (!strcmp(res->show, "clear")) {
7457 if (!strcmp(res->what, "stats"))
7458 RTE_ETH_FOREACH_DEV(i)
7460 else if (!strcmp(res->what, "xstats"))
7461 RTE_ETH_FOREACH_DEV(i)
7462 nic_xstats_clear(i);
7463 } else if (!strcmp(res->what, "info"))
7464 RTE_ETH_FOREACH_DEV(i)
7465 port_infos_display(i);
7466 else if (!strcmp(res->what, "summary")) {
7467 port_summary_header_display();
7468 RTE_ETH_FOREACH_DEV(i)
7469 port_summary_display(i);
7471 else if (!strcmp(res->what, "stats"))
7472 RTE_ETH_FOREACH_DEV(i)
7473 nic_stats_display(i);
7474 else if (!strcmp(res->what, "xstats"))
7475 RTE_ETH_FOREACH_DEV(i)
7476 nic_xstats_display(i);
7477 else if (!strcmp(res->what, "fdir"))
7478 RTE_ETH_FOREACH_DEV(i)
7480 else if (!strcmp(res->what, "stat_qmap"))
7481 RTE_ETH_FOREACH_DEV(i)
7482 nic_stats_mapping_display(i);
7483 else if (!strcmp(res->what, "dcb_tc"))
7484 RTE_ETH_FOREACH_DEV(i)
7485 port_dcb_info_display(i);
7486 else if (!strcmp(res->what, "cap"))
7487 RTE_ETH_FOREACH_DEV(i)
7488 port_offload_cap_display(i);
7491 cmdline_parse_token_string_t cmd_showportall_show =
7492 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7494 cmdline_parse_token_string_t cmd_showportall_port =
7495 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7496 cmdline_parse_token_string_t cmd_showportall_what =
7497 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7498 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7499 cmdline_parse_token_string_t cmd_showportall_all =
7500 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7501 cmdline_parse_inst_t cmd_showportall = {
7502 .f = cmd_showportall_parsed,
7504 .help_str = "show|clear port "
7505 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7507 (void *)&cmd_showportall_show,
7508 (void *)&cmd_showportall_port,
7509 (void *)&cmd_showportall_what,
7510 (void *)&cmd_showportall_all,
7515 /* *** SHOW PORT INFO *** */
7516 struct cmd_showport_result {
7517 cmdline_fixed_string_t show;
7518 cmdline_fixed_string_t port;
7519 cmdline_fixed_string_t what;
7523 static void cmd_showport_parsed(void *parsed_result,
7524 __rte_unused struct cmdline *cl,
7525 __rte_unused void *data)
7527 struct cmd_showport_result *res = parsed_result;
7528 if (!strcmp(res->show, "clear")) {
7529 if (!strcmp(res->what, "stats"))
7530 nic_stats_clear(res->portnum);
7531 else if (!strcmp(res->what, "xstats"))
7532 nic_xstats_clear(res->portnum);
7533 } else if (!strcmp(res->what, "info"))
7534 port_infos_display(res->portnum);
7535 else if (!strcmp(res->what, "summary")) {
7536 port_summary_header_display();
7537 port_summary_display(res->portnum);
7539 else if (!strcmp(res->what, "stats"))
7540 nic_stats_display(res->portnum);
7541 else if (!strcmp(res->what, "xstats"))
7542 nic_xstats_display(res->portnum);
7543 else if (!strcmp(res->what, "fdir"))
7544 fdir_get_infos(res->portnum);
7545 else if (!strcmp(res->what, "stat_qmap"))
7546 nic_stats_mapping_display(res->portnum);
7547 else if (!strcmp(res->what, "dcb_tc"))
7548 port_dcb_info_display(res->portnum);
7549 else if (!strcmp(res->what, "cap"))
7550 port_offload_cap_display(res->portnum);
7553 cmdline_parse_token_string_t cmd_showport_show =
7554 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7556 cmdline_parse_token_string_t cmd_showport_port =
7557 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7558 cmdline_parse_token_string_t cmd_showport_what =
7559 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7560 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7561 cmdline_parse_token_num_t cmd_showport_portnum =
7562 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7564 cmdline_parse_inst_t cmd_showport = {
7565 .f = cmd_showport_parsed,
7567 .help_str = "show|clear port "
7568 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7571 (void *)&cmd_showport_show,
7572 (void *)&cmd_showport_port,
7573 (void *)&cmd_showport_what,
7574 (void *)&cmd_showport_portnum,
7579 /* *** SHOW DEVICE INFO *** */
7580 struct cmd_showdevice_result {
7581 cmdline_fixed_string_t show;
7582 cmdline_fixed_string_t device;
7583 cmdline_fixed_string_t what;
7584 cmdline_fixed_string_t identifier;
7587 static void cmd_showdevice_parsed(void *parsed_result,
7588 __rte_unused struct cmdline *cl,
7589 __rte_unused void *data)
7591 struct cmd_showdevice_result *res = parsed_result;
7592 if (!strcmp(res->what, "info")) {
7593 if (!strcmp(res->identifier, "all"))
7594 device_infos_display(NULL);
7596 device_infos_display(res->identifier);
7600 cmdline_parse_token_string_t cmd_showdevice_show =
7601 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7603 cmdline_parse_token_string_t cmd_showdevice_device =
7604 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7605 cmdline_parse_token_string_t cmd_showdevice_what =
7606 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7608 cmdline_parse_token_string_t cmd_showdevice_identifier =
7609 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7612 cmdline_parse_inst_t cmd_showdevice = {
7613 .f = cmd_showdevice_parsed,
7615 .help_str = "show device info <identifier>|all",
7617 (void *)&cmd_showdevice_show,
7618 (void *)&cmd_showdevice_device,
7619 (void *)&cmd_showdevice_what,
7620 (void *)&cmd_showdevice_identifier,
7624 /* *** SHOW QUEUE INFO *** */
7625 struct cmd_showqueue_result {
7626 cmdline_fixed_string_t show;
7627 cmdline_fixed_string_t type;
7628 cmdline_fixed_string_t what;
7634 cmd_showqueue_parsed(void *parsed_result,
7635 __rte_unused struct cmdline *cl,
7636 __rte_unused void *data)
7638 struct cmd_showqueue_result *res = parsed_result;
7640 if (!strcmp(res->type, "rxq"))
7641 rx_queue_infos_display(res->portnum, res->queuenum);
7642 else if (!strcmp(res->type, "txq"))
7643 tx_queue_infos_display(res->portnum, res->queuenum);
7646 cmdline_parse_token_string_t cmd_showqueue_show =
7647 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7648 cmdline_parse_token_string_t cmd_showqueue_type =
7649 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7650 cmdline_parse_token_string_t cmd_showqueue_what =
7651 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7652 cmdline_parse_token_num_t cmd_showqueue_portnum =
7653 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7654 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7655 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7657 cmdline_parse_inst_t cmd_showqueue = {
7658 .f = cmd_showqueue_parsed,
7660 .help_str = "show rxq|txq info <port_id> <queue_id>",
7662 (void *)&cmd_showqueue_show,
7663 (void *)&cmd_showqueue_type,
7664 (void *)&cmd_showqueue_what,
7665 (void *)&cmd_showqueue_portnum,
7666 (void *)&cmd_showqueue_queuenum,
7671 /* show/clear fwd engine statistics */
7673 cmdline_fixed_string_t action;
7674 cmdline_fixed_string_t fwd;
7675 cmdline_fixed_string_t stats;
7676 cmdline_fixed_string_t all;
7679 cmdline_parse_token_string_t cmd_fwd_action =
7680 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7681 cmdline_parse_token_string_t cmd_fwd_fwd =
7682 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7683 cmdline_parse_token_string_t cmd_fwd_stats =
7684 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7685 cmdline_parse_token_string_t cmd_fwd_all =
7686 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7689 cmd_showfwdall_parsed(void *parsed_result,
7690 __rte_unused struct cmdline *cl,
7691 __rte_unused void *data)
7693 struct fwd_result *res = parsed_result;
7695 if (!strcmp(res->action, "show"))
7696 fwd_stats_display();
7701 static cmdline_parse_inst_t cmd_showfwdall = {
7702 .f = cmd_showfwdall_parsed,
7704 .help_str = "show|clear fwd stats all",
7706 (void *)&cmd_fwd_action,
7707 (void *)&cmd_fwd_fwd,
7708 (void *)&cmd_fwd_stats,
7709 (void *)&cmd_fwd_all,
7714 /* *** READ PORT REGISTER *** */
7715 struct cmd_read_reg_result {
7716 cmdline_fixed_string_t read;
7717 cmdline_fixed_string_t reg;
7723 cmd_read_reg_parsed(void *parsed_result,
7724 __rte_unused struct cmdline *cl,
7725 __rte_unused void *data)
7727 struct cmd_read_reg_result *res = parsed_result;
7728 port_reg_display(res->port_id, res->reg_off);
7731 cmdline_parse_token_string_t cmd_read_reg_read =
7732 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7733 cmdline_parse_token_string_t cmd_read_reg_reg =
7734 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7735 cmdline_parse_token_num_t cmd_read_reg_port_id =
7736 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7737 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7738 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7740 cmdline_parse_inst_t cmd_read_reg = {
7741 .f = cmd_read_reg_parsed,
7743 .help_str = "read reg <port_id> <reg_off>",
7745 (void *)&cmd_read_reg_read,
7746 (void *)&cmd_read_reg_reg,
7747 (void *)&cmd_read_reg_port_id,
7748 (void *)&cmd_read_reg_reg_off,
7753 /* *** READ PORT REGISTER BIT FIELD *** */
7754 struct cmd_read_reg_bit_field_result {
7755 cmdline_fixed_string_t read;
7756 cmdline_fixed_string_t regfield;
7764 cmd_read_reg_bit_field_parsed(void *parsed_result,
7765 __rte_unused struct cmdline *cl,
7766 __rte_unused void *data)
7768 struct cmd_read_reg_bit_field_result *res = parsed_result;
7769 port_reg_bit_field_display(res->port_id, res->reg_off,
7770 res->bit1_pos, res->bit2_pos);
7773 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7774 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7776 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7777 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7778 regfield, "regfield");
7779 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7780 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7782 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7783 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7785 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7786 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7788 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7789 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7792 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7793 .f = cmd_read_reg_bit_field_parsed,
7795 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7796 "Read register bit field between bit_x and bit_y included",
7798 (void *)&cmd_read_reg_bit_field_read,
7799 (void *)&cmd_read_reg_bit_field_regfield,
7800 (void *)&cmd_read_reg_bit_field_port_id,
7801 (void *)&cmd_read_reg_bit_field_reg_off,
7802 (void *)&cmd_read_reg_bit_field_bit1_pos,
7803 (void *)&cmd_read_reg_bit_field_bit2_pos,
7808 /* *** READ PORT REGISTER BIT *** */
7809 struct cmd_read_reg_bit_result {
7810 cmdline_fixed_string_t read;
7811 cmdline_fixed_string_t regbit;
7818 cmd_read_reg_bit_parsed(void *parsed_result,
7819 __rte_unused struct cmdline *cl,
7820 __rte_unused void *data)
7822 struct cmd_read_reg_bit_result *res = parsed_result;
7823 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7826 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7827 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7828 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7829 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7831 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7832 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7833 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7834 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7835 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7836 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7838 cmdline_parse_inst_t cmd_read_reg_bit = {
7839 .f = cmd_read_reg_bit_parsed,
7841 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7843 (void *)&cmd_read_reg_bit_read,
7844 (void *)&cmd_read_reg_bit_regbit,
7845 (void *)&cmd_read_reg_bit_port_id,
7846 (void *)&cmd_read_reg_bit_reg_off,
7847 (void *)&cmd_read_reg_bit_bit_pos,
7852 /* *** WRITE PORT REGISTER *** */
7853 struct cmd_write_reg_result {
7854 cmdline_fixed_string_t write;
7855 cmdline_fixed_string_t reg;
7862 cmd_write_reg_parsed(void *parsed_result,
7863 __rte_unused struct cmdline *cl,
7864 __rte_unused void *data)
7866 struct cmd_write_reg_result *res = parsed_result;
7867 port_reg_set(res->port_id, res->reg_off, res->value);
7870 cmdline_parse_token_string_t cmd_write_reg_write =
7871 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7872 cmdline_parse_token_string_t cmd_write_reg_reg =
7873 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7874 cmdline_parse_token_num_t cmd_write_reg_port_id =
7875 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7876 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7877 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7878 cmdline_parse_token_num_t cmd_write_reg_value =
7879 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7881 cmdline_parse_inst_t cmd_write_reg = {
7882 .f = cmd_write_reg_parsed,
7884 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7886 (void *)&cmd_write_reg_write,
7887 (void *)&cmd_write_reg_reg,
7888 (void *)&cmd_write_reg_port_id,
7889 (void *)&cmd_write_reg_reg_off,
7890 (void *)&cmd_write_reg_value,
7895 /* *** WRITE PORT REGISTER BIT FIELD *** */
7896 struct cmd_write_reg_bit_field_result {
7897 cmdline_fixed_string_t write;
7898 cmdline_fixed_string_t regfield;
7907 cmd_write_reg_bit_field_parsed(void *parsed_result,
7908 __rte_unused struct cmdline *cl,
7909 __rte_unused void *data)
7911 struct cmd_write_reg_bit_field_result *res = parsed_result;
7912 port_reg_bit_field_set(res->port_id, res->reg_off,
7913 res->bit1_pos, res->bit2_pos, res->value);
7916 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7917 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7919 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7920 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7921 regfield, "regfield");
7922 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7923 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7925 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7926 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7928 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7929 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7931 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7932 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7934 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7935 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7938 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7939 .f = cmd_write_reg_bit_field_parsed,
7941 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7943 "Set register bit field between bit_x and bit_y included",
7945 (void *)&cmd_write_reg_bit_field_write,
7946 (void *)&cmd_write_reg_bit_field_regfield,
7947 (void *)&cmd_write_reg_bit_field_port_id,
7948 (void *)&cmd_write_reg_bit_field_reg_off,
7949 (void *)&cmd_write_reg_bit_field_bit1_pos,
7950 (void *)&cmd_write_reg_bit_field_bit2_pos,
7951 (void *)&cmd_write_reg_bit_field_value,
7956 /* *** WRITE PORT REGISTER BIT *** */
7957 struct cmd_write_reg_bit_result {
7958 cmdline_fixed_string_t write;
7959 cmdline_fixed_string_t regbit;
7967 cmd_write_reg_bit_parsed(void *parsed_result,
7968 __rte_unused struct cmdline *cl,
7969 __rte_unused void *data)
7971 struct cmd_write_reg_bit_result *res = parsed_result;
7972 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7975 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7976 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7978 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7979 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7981 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7982 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7983 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7984 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7985 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7986 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7987 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7988 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7990 cmdline_parse_inst_t cmd_write_reg_bit = {
7991 .f = cmd_write_reg_bit_parsed,
7993 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7996 (void *)&cmd_write_reg_bit_write,
7997 (void *)&cmd_write_reg_bit_regbit,
7998 (void *)&cmd_write_reg_bit_port_id,
7999 (void *)&cmd_write_reg_bit_reg_off,
8000 (void *)&cmd_write_reg_bit_bit_pos,
8001 (void *)&cmd_write_reg_bit_value,
8006 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8007 struct cmd_read_rxd_txd_result {
8008 cmdline_fixed_string_t read;
8009 cmdline_fixed_string_t rxd_txd;
8016 cmd_read_rxd_txd_parsed(void *parsed_result,
8017 __rte_unused struct cmdline *cl,
8018 __rte_unused void *data)
8020 struct cmd_read_rxd_txd_result *res = parsed_result;
8022 if (!strcmp(res->rxd_txd, "rxd"))
8023 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8024 else if (!strcmp(res->rxd_txd, "txd"))
8025 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8028 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8029 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8030 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8031 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8033 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8034 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8035 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8036 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8037 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8038 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8040 cmdline_parse_inst_t cmd_read_rxd_txd = {
8041 .f = cmd_read_rxd_txd_parsed,
8043 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8045 (void *)&cmd_read_rxd_txd_read,
8046 (void *)&cmd_read_rxd_txd_rxd_txd,
8047 (void *)&cmd_read_rxd_txd_port_id,
8048 (void *)&cmd_read_rxd_txd_queue_id,
8049 (void *)&cmd_read_rxd_txd_desc_id,
8055 struct cmd_quit_result {
8056 cmdline_fixed_string_t quit;
8059 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8061 __rte_unused void *data)
8066 cmdline_parse_token_string_t cmd_quit_quit =
8067 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8069 cmdline_parse_inst_t cmd_quit = {
8070 .f = cmd_quit_parsed,
8072 .help_str = "quit: Exit application",
8074 (void *)&cmd_quit_quit,
8079 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8080 struct cmd_mac_addr_result {
8081 cmdline_fixed_string_t mac_addr_cmd;
8082 cmdline_fixed_string_t what;
8084 struct rte_ether_addr address;
8087 static void cmd_mac_addr_parsed(void *parsed_result,
8088 __rte_unused struct cmdline *cl,
8089 __rte_unused void *data)
8091 struct cmd_mac_addr_result *res = parsed_result;
8094 if (strcmp(res->what, "add") == 0)
8095 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8096 else if (strcmp(res->what, "set") == 0)
8097 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8100 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8102 /* check the return value and print it if is < 0 */
8104 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8108 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8109 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8111 cmdline_parse_token_string_t cmd_mac_addr_what =
8112 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8114 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8115 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8117 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8118 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8120 cmdline_parse_inst_t cmd_mac_addr = {
8121 .f = cmd_mac_addr_parsed,
8123 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8124 "Add/Remove/Set MAC address on port_id",
8126 (void *)&cmd_mac_addr_cmd,
8127 (void *)&cmd_mac_addr_what,
8128 (void *)&cmd_mac_addr_portnum,
8129 (void *)&cmd_mac_addr_addr,
8134 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8135 struct cmd_eth_peer_result {
8136 cmdline_fixed_string_t set;
8137 cmdline_fixed_string_t eth_peer;
8139 cmdline_fixed_string_t peer_addr;
8142 static void cmd_set_eth_peer_parsed(void *parsed_result,
8143 __rte_unused struct cmdline *cl,
8144 __rte_unused void *data)
8146 struct cmd_eth_peer_result *res = parsed_result;
8148 if (test_done == 0) {
8149 printf("Please stop forwarding first\n");
8152 if (!strcmp(res->eth_peer, "eth-peer")) {
8153 set_fwd_eth_peer(res->port_id, res->peer_addr);
8157 cmdline_parse_token_string_t cmd_eth_peer_set =
8158 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8159 cmdline_parse_token_string_t cmd_eth_peer =
8160 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8161 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8162 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8163 cmdline_parse_token_string_t cmd_eth_peer_addr =
8164 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8166 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8167 .f = cmd_set_eth_peer_parsed,
8169 .help_str = "set eth-peer <port_id> <peer_mac>",
8171 (void *)&cmd_eth_peer_set,
8172 (void *)&cmd_eth_peer,
8173 (void *)&cmd_eth_peer_port_id,
8174 (void *)&cmd_eth_peer_addr,
8179 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8180 struct cmd_set_qmap_result {
8181 cmdline_fixed_string_t set;
8182 cmdline_fixed_string_t qmap;
8183 cmdline_fixed_string_t what;
8190 cmd_set_qmap_parsed(void *parsed_result,
8191 __rte_unused struct cmdline *cl,
8192 __rte_unused void *data)
8194 struct cmd_set_qmap_result *res = parsed_result;
8195 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8197 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8200 cmdline_parse_token_string_t cmd_setqmap_set =
8201 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8203 cmdline_parse_token_string_t cmd_setqmap_qmap =
8204 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8206 cmdline_parse_token_string_t cmd_setqmap_what =
8207 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8209 cmdline_parse_token_num_t cmd_setqmap_portid =
8210 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8212 cmdline_parse_token_num_t cmd_setqmap_queueid =
8213 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8215 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8216 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8219 cmdline_parse_inst_t cmd_set_qmap = {
8220 .f = cmd_set_qmap_parsed,
8222 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8223 "Set statistics mapping value on tx|rx queue_id of port_id",
8225 (void *)&cmd_setqmap_set,
8226 (void *)&cmd_setqmap_qmap,
8227 (void *)&cmd_setqmap_what,
8228 (void *)&cmd_setqmap_portid,
8229 (void *)&cmd_setqmap_queueid,
8230 (void *)&cmd_setqmap_mapvalue,
8235 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8236 struct cmd_set_xstats_hide_zero_result {
8237 cmdline_fixed_string_t keyword;
8238 cmdline_fixed_string_t name;
8239 cmdline_fixed_string_t on_off;
8243 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8244 __rte_unused struct cmdline *cl,
8245 __rte_unused void *data)
8247 struct cmd_set_xstats_hide_zero_result *res;
8248 uint16_t on_off = 0;
8250 res = parsed_result;
8251 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8252 set_xstats_hide_zero(on_off);
8255 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8256 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8258 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8259 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8260 name, "xstats-hide-zero");
8261 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8262 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8265 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8266 .f = cmd_set_xstats_hide_zero_parsed,
8268 .help_str = "set xstats-hide-zero on|off",
8270 (void *)&cmd_set_xstats_hide_zero_keyword,
8271 (void *)&cmd_set_xstats_hide_zero_name,
8272 (void *)&cmd_set_xstats_hide_zero_on_off,
8277 /* *** CONFIGURE UNICAST HASH TABLE *** */
8278 struct cmd_set_uc_hash_table {
8279 cmdline_fixed_string_t set;
8280 cmdline_fixed_string_t port;
8282 cmdline_fixed_string_t what;
8283 struct rte_ether_addr address;
8284 cmdline_fixed_string_t mode;
8288 cmd_set_uc_hash_parsed(void *parsed_result,
8289 __rte_unused struct cmdline *cl,
8290 __rte_unused void *data)
8293 struct cmd_set_uc_hash_table *res = parsed_result;
8295 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8297 if (strcmp(res->what, "uta") == 0)
8298 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8299 &res->address,(uint8_t)is_on);
8301 printf("bad unicast hash table parameter, return code = %d \n", ret);
8305 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8306 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8308 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8309 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8311 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8312 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8314 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8315 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8317 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8318 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8320 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8321 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8324 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8325 .f = cmd_set_uc_hash_parsed,
8327 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8329 (void *)&cmd_set_uc_hash_set,
8330 (void *)&cmd_set_uc_hash_port,
8331 (void *)&cmd_set_uc_hash_portid,
8332 (void *)&cmd_set_uc_hash_what,
8333 (void *)&cmd_set_uc_hash_mac,
8334 (void *)&cmd_set_uc_hash_mode,
8339 struct cmd_set_uc_all_hash_table {
8340 cmdline_fixed_string_t set;
8341 cmdline_fixed_string_t port;
8343 cmdline_fixed_string_t what;
8344 cmdline_fixed_string_t value;
8345 cmdline_fixed_string_t mode;
8349 cmd_set_uc_all_hash_parsed(void *parsed_result,
8350 __rte_unused struct cmdline *cl,
8351 __rte_unused void *data)
8354 struct cmd_set_uc_all_hash_table *res = parsed_result;
8356 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8358 if ((strcmp(res->what, "uta") == 0) &&
8359 (strcmp(res->value, "all") == 0))
8360 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8362 printf("bad unicast hash table parameter,"
8363 "return code = %d \n", ret);
8366 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8367 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8369 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8370 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8372 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8373 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8375 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8376 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8378 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8379 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8381 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8382 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8385 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8386 .f = cmd_set_uc_all_hash_parsed,
8388 .help_str = "set port <port_id> uta all on|off",
8390 (void *)&cmd_set_uc_all_hash_set,
8391 (void *)&cmd_set_uc_all_hash_port,
8392 (void *)&cmd_set_uc_all_hash_portid,
8393 (void *)&cmd_set_uc_all_hash_what,
8394 (void *)&cmd_set_uc_all_hash_value,
8395 (void *)&cmd_set_uc_all_hash_mode,
8400 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8401 struct cmd_set_vf_macvlan_filter {
8402 cmdline_fixed_string_t set;
8403 cmdline_fixed_string_t port;
8405 cmdline_fixed_string_t vf;
8407 struct rte_ether_addr address;
8408 cmdline_fixed_string_t filter_type;
8409 cmdline_fixed_string_t mode;
8413 cmd_set_vf_macvlan_parsed(void *parsed_result,
8414 __rte_unused struct cmdline *cl,
8415 __rte_unused void *data)
8418 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8419 struct rte_eth_mac_filter filter;
8421 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8423 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8425 /* set VF MAC filter */
8429 filter.dst_id = res->vf_id;
8431 if (!strcmp(res->filter_type, "exact-mac"))
8432 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8433 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8434 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8435 else if (!strcmp(res->filter_type, "hashmac"))
8436 filter.filter_type = RTE_MAC_HASH_MATCH;
8437 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8438 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8440 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8443 ret = rte_eth_dev_filter_ctrl(res->port_id,
8444 RTE_ETH_FILTER_MACVLAN,
8448 ret = rte_eth_dev_filter_ctrl(res->port_id,
8449 RTE_ETH_FILTER_MACVLAN,
8450 RTE_ETH_FILTER_DELETE,
8454 printf("bad set MAC hash parameter, return code = %d\n", ret);
8458 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8459 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8461 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8462 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8464 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8465 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8467 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8468 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8470 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8471 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8473 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8474 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8476 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8477 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8478 filter_type, "exact-mac#exact-mac-vlan"
8479 "#hashmac#hashmac-vlan");
8480 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8481 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8484 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8485 .f = cmd_set_vf_macvlan_parsed,
8487 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8488 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8489 "Exact match rule: exact match of MAC or MAC and VLAN; "
8490 "hash match rule: hash match of MAC and exact match of VLAN",
8492 (void *)&cmd_set_vf_macvlan_set,
8493 (void *)&cmd_set_vf_macvlan_port,
8494 (void *)&cmd_set_vf_macvlan_portid,
8495 (void *)&cmd_set_vf_macvlan_vf,
8496 (void *)&cmd_set_vf_macvlan_vf_id,
8497 (void *)&cmd_set_vf_macvlan_mac,
8498 (void *)&cmd_set_vf_macvlan_filter_type,
8499 (void *)&cmd_set_vf_macvlan_mode,
8504 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8505 struct cmd_set_vf_traffic {
8506 cmdline_fixed_string_t set;
8507 cmdline_fixed_string_t port;
8509 cmdline_fixed_string_t vf;
8511 cmdline_fixed_string_t what;
8512 cmdline_fixed_string_t mode;
8516 cmd_set_vf_traffic_parsed(void *parsed_result,
8517 __rte_unused struct cmdline *cl,
8518 __rte_unused void *data)
8520 struct cmd_set_vf_traffic *res = parsed_result;
8521 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8522 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8524 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8527 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8528 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8530 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8531 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8533 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8534 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8536 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8537 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8539 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8540 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8542 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8543 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8545 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8546 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8549 cmdline_parse_inst_t cmd_set_vf_traffic = {
8550 .f = cmd_set_vf_traffic_parsed,
8552 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8554 (void *)&cmd_setvf_traffic_set,
8555 (void *)&cmd_setvf_traffic_port,
8556 (void *)&cmd_setvf_traffic_portid,
8557 (void *)&cmd_setvf_traffic_vf,
8558 (void *)&cmd_setvf_traffic_vfid,
8559 (void *)&cmd_setvf_traffic_what,
8560 (void *)&cmd_setvf_traffic_mode,
8565 /* *** CONFIGURE VF RECEIVE MODE *** */
8566 struct cmd_set_vf_rxmode {
8567 cmdline_fixed_string_t set;
8568 cmdline_fixed_string_t port;
8570 cmdline_fixed_string_t vf;
8572 cmdline_fixed_string_t what;
8573 cmdline_fixed_string_t mode;
8574 cmdline_fixed_string_t on;
8578 cmd_set_vf_rxmode_parsed(void *parsed_result,
8579 __rte_unused struct cmdline *cl,
8580 __rte_unused void *data)
8583 uint16_t vf_rxmode = 0;
8584 struct cmd_set_vf_rxmode *res = parsed_result;
8586 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8587 if (!strcmp(res->what,"rxmode")) {
8588 if (!strcmp(res->mode, "AUPE"))
8589 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8590 else if (!strcmp(res->mode, "ROPE"))
8591 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8592 else if (!strcmp(res->mode, "BAM"))
8593 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8594 else if (!strncmp(res->mode, "MPE",3))
8595 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8598 RTE_SET_USED(is_on);
8600 #ifdef RTE_LIBRTE_IXGBE_PMD
8601 if (ret == -ENOTSUP)
8602 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8603 vf_rxmode, (uint8_t)is_on);
8605 #ifdef RTE_LIBRTE_BNXT_PMD
8606 if (ret == -ENOTSUP)
8607 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8608 vf_rxmode, (uint8_t)is_on);
8611 printf("bad VF receive mode parameter, return code = %d \n",
8615 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8616 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8618 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8619 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8621 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8622 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8624 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8625 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8627 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8628 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8630 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8631 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8633 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8634 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8635 mode, "AUPE#ROPE#BAM#MPE");
8636 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8637 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8640 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8641 .f = cmd_set_vf_rxmode_parsed,
8643 .help_str = "set port <port_id> vf <vf_id> rxmode "
8644 "AUPE|ROPE|BAM|MPE on|off",
8646 (void *)&cmd_set_vf_rxmode_set,
8647 (void *)&cmd_set_vf_rxmode_port,
8648 (void *)&cmd_set_vf_rxmode_portid,
8649 (void *)&cmd_set_vf_rxmode_vf,
8650 (void *)&cmd_set_vf_rxmode_vfid,
8651 (void *)&cmd_set_vf_rxmode_what,
8652 (void *)&cmd_set_vf_rxmode_mode,
8653 (void *)&cmd_set_vf_rxmode_on,
8658 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8659 struct cmd_vf_mac_addr_result {
8660 cmdline_fixed_string_t mac_addr_cmd;
8661 cmdline_fixed_string_t what;
8662 cmdline_fixed_string_t port;
8664 cmdline_fixed_string_t vf;
8666 struct rte_ether_addr address;
8669 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8670 __rte_unused struct cmdline *cl,
8671 __rte_unused void *data)
8673 struct cmd_vf_mac_addr_result *res = parsed_result;
8676 if (strcmp(res->what, "add") != 0)
8679 #ifdef RTE_LIBRTE_I40E_PMD
8680 if (ret == -ENOTSUP)
8681 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8684 #ifdef RTE_LIBRTE_BNXT_PMD
8685 if (ret == -ENOTSUP)
8686 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8691 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8695 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8696 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8697 mac_addr_cmd,"mac_addr");
8698 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8699 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8701 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8702 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8704 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8705 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8707 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8708 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8710 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8711 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8713 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8714 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8717 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8718 .f = cmd_vf_mac_addr_parsed,
8720 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8721 "Add MAC address filtering for a VF on port_id",
8723 (void *)&cmd_vf_mac_addr_cmd,
8724 (void *)&cmd_vf_mac_addr_what,
8725 (void *)&cmd_vf_mac_addr_port,
8726 (void *)&cmd_vf_mac_addr_portnum,
8727 (void *)&cmd_vf_mac_addr_vf,
8728 (void *)&cmd_vf_mac_addr_vfnum,
8729 (void *)&cmd_vf_mac_addr_addr,
8734 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8735 struct cmd_vf_rx_vlan_filter {
8736 cmdline_fixed_string_t rx_vlan;
8737 cmdline_fixed_string_t what;
8739 cmdline_fixed_string_t port;
8741 cmdline_fixed_string_t vf;
8746 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8747 __rte_unused struct cmdline *cl,
8748 __rte_unused void *data)
8750 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8753 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8755 #ifdef RTE_LIBRTE_IXGBE_PMD
8756 if (ret == -ENOTSUP)
8757 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8758 res->vlan_id, res->vf_mask, is_add);
8760 #ifdef RTE_LIBRTE_I40E_PMD
8761 if (ret == -ENOTSUP)
8762 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8763 res->vlan_id, res->vf_mask, is_add);
8765 #ifdef RTE_LIBRTE_BNXT_PMD
8766 if (ret == -ENOTSUP)
8767 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8768 res->vlan_id, res->vf_mask, is_add);
8775 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8776 res->vlan_id, res->vf_mask);
8779 printf("invalid port_id %d\n", res->port_id);
8782 printf("function not implemented or supported\n");
8785 printf("programming error: (%s)\n", strerror(-ret));
8789 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8790 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8791 rx_vlan, "rx_vlan");
8792 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8793 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8795 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8796 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8798 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8799 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8801 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8802 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8804 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8805 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8807 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8808 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8811 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8812 .f = cmd_vf_rx_vlan_filter_parsed,
8814 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8815 "(vf_mask = hexadecimal VF mask)",
8817 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8818 (void *)&cmd_vf_rx_vlan_filter_what,
8819 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8820 (void *)&cmd_vf_rx_vlan_filter_port,
8821 (void *)&cmd_vf_rx_vlan_filter_portid,
8822 (void *)&cmd_vf_rx_vlan_filter_vf,
8823 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8828 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8829 struct cmd_queue_rate_limit_result {
8830 cmdline_fixed_string_t set;
8831 cmdline_fixed_string_t port;
8833 cmdline_fixed_string_t queue;
8835 cmdline_fixed_string_t rate;
8839 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8840 __rte_unused struct cmdline *cl,
8841 __rte_unused void *data)
8843 struct cmd_queue_rate_limit_result *res = parsed_result;
8846 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8847 && (strcmp(res->queue, "queue") == 0)
8848 && (strcmp(res->rate, "rate") == 0))
8849 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8852 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8856 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8857 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8859 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8860 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8862 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8863 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8865 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8866 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8868 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8869 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8871 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8872 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8874 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8875 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8878 cmdline_parse_inst_t cmd_queue_rate_limit = {
8879 .f = cmd_queue_rate_limit_parsed,
8881 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8882 "Set rate limit for a queue on port_id",
8884 (void *)&cmd_queue_rate_limit_set,
8885 (void *)&cmd_queue_rate_limit_port,
8886 (void *)&cmd_queue_rate_limit_portnum,
8887 (void *)&cmd_queue_rate_limit_queue,
8888 (void *)&cmd_queue_rate_limit_queuenum,
8889 (void *)&cmd_queue_rate_limit_rate,
8890 (void *)&cmd_queue_rate_limit_ratenum,
8895 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8896 struct cmd_vf_rate_limit_result {
8897 cmdline_fixed_string_t set;
8898 cmdline_fixed_string_t port;
8900 cmdline_fixed_string_t vf;
8902 cmdline_fixed_string_t rate;
8904 cmdline_fixed_string_t q_msk;
8908 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8909 __rte_unused struct cmdline *cl,
8910 __rte_unused void *data)
8912 struct cmd_vf_rate_limit_result *res = parsed_result;
8915 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8916 && (strcmp(res->vf, "vf") == 0)
8917 && (strcmp(res->rate, "rate") == 0)
8918 && (strcmp(res->q_msk, "queue_mask") == 0))
8919 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8920 res->rate_num, res->q_msk_val);
8922 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8926 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8927 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8929 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8930 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8932 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8933 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8935 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8936 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8938 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8939 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8941 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8942 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8944 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8945 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8947 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8948 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8949 q_msk, "queue_mask");
8950 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8951 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8954 cmdline_parse_inst_t cmd_vf_rate_limit = {
8955 .f = cmd_vf_rate_limit_parsed,
8957 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8958 "queue_mask <queue_mask_value>: "
8959 "Set rate limit for queues of VF on port_id",
8961 (void *)&cmd_vf_rate_limit_set,
8962 (void *)&cmd_vf_rate_limit_port,
8963 (void *)&cmd_vf_rate_limit_portnum,
8964 (void *)&cmd_vf_rate_limit_vf,
8965 (void *)&cmd_vf_rate_limit_vfnum,
8966 (void *)&cmd_vf_rate_limit_rate,
8967 (void *)&cmd_vf_rate_limit_ratenum,
8968 (void *)&cmd_vf_rate_limit_q_msk,
8969 (void *)&cmd_vf_rate_limit_q_msk_val,
8974 /* *** ADD TUNNEL FILTER OF A PORT *** */
8975 struct cmd_tunnel_filter_result {
8976 cmdline_fixed_string_t cmd;
8977 cmdline_fixed_string_t what;
8979 struct rte_ether_addr outer_mac;
8980 struct rte_ether_addr inner_mac;
8981 cmdline_ipaddr_t ip_value;
8982 uint16_t inner_vlan;
8983 cmdline_fixed_string_t tunnel_type;
8984 cmdline_fixed_string_t filter_type;
8990 cmd_tunnel_filter_parsed(void *parsed_result,
8991 __rte_unused struct cmdline *cl,
8992 __rte_unused void *data)
8994 struct cmd_tunnel_filter_result *res = parsed_result;
8995 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8998 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9000 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9001 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9002 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9004 if (res->ip_value.family == AF_INET) {
9005 tunnel_filter_conf.ip_addr.ipv4_addr =
9006 res->ip_value.addr.ipv4.s_addr;
9007 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9009 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9010 &(res->ip_value.addr.ipv6),
9011 sizeof(struct in6_addr));
9012 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9015 if (!strcmp(res->filter_type, "imac-ivlan"))
9016 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9017 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9018 tunnel_filter_conf.filter_type =
9019 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9020 else if (!strcmp(res->filter_type, "imac-tenid"))
9021 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9022 else if (!strcmp(res->filter_type, "imac"))
9023 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9024 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9025 tunnel_filter_conf.filter_type =
9026 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9027 else if (!strcmp(res->filter_type, "oip"))
9028 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9029 else if (!strcmp(res->filter_type, "iip"))
9030 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9032 printf("The filter type is not supported");
9036 if (!strcmp(res->tunnel_type, "vxlan"))
9037 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9038 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9039 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9040 else if (!strcmp(res->tunnel_type, "nvgre"))
9041 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9042 else if (!strcmp(res->tunnel_type, "ipingre"))
9043 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9045 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9049 tunnel_filter_conf.tenant_id = res->tenant_id;
9050 tunnel_filter_conf.queue_id = res->queue_num;
9051 if (!strcmp(res->what, "add"))
9052 ret = rte_eth_dev_filter_ctrl(res->port_id,
9053 RTE_ETH_FILTER_TUNNEL,
9055 &tunnel_filter_conf);
9057 ret = rte_eth_dev_filter_ctrl(res->port_id,
9058 RTE_ETH_FILTER_TUNNEL,
9059 RTE_ETH_FILTER_DELETE,
9060 &tunnel_filter_conf);
9062 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9066 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9067 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9068 cmd, "tunnel_filter");
9069 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9070 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9072 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9073 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9075 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9076 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9078 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9079 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9081 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9082 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9083 inner_vlan, UINT16);
9084 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9085 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9087 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9088 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9089 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9091 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9092 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9093 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9094 "imac#omac-imac-tenid");
9095 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9096 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9098 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9099 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9102 cmdline_parse_inst_t cmd_tunnel_filter = {
9103 .f = cmd_tunnel_filter_parsed,
9105 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9106 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9107 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9108 "<queue_id>: Add/Rm tunnel filter of a port",
9110 (void *)&cmd_tunnel_filter_cmd,
9111 (void *)&cmd_tunnel_filter_what,
9112 (void *)&cmd_tunnel_filter_port_id,
9113 (void *)&cmd_tunnel_filter_outer_mac,
9114 (void *)&cmd_tunnel_filter_inner_mac,
9115 (void *)&cmd_tunnel_filter_ip_value,
9116 (void *)&cmd_tunnel_filter_innner_vlan,
9117 (void *)&cmd_tunnel_filter_tunnel_type,
9118 (void *)&cmd_tunnel_filter_filter_type,
9119 (void *)&cmd_tunnel_filter_tenant_id,
9120 (void *)&cmd_tunnel_filter_queue_num,
9125 /* *** CONFIGURE TUNNEL UDP PORT *** */
9126 struct cmd_tunnel_udp_config {
9127 cmdline_fixed_string_t cmd;
9128 cmdline_fixed_string_t what;
9134 cmd_tunnel_udp_config_parsed(void *parsed_result,
9135 __rte_unused struct cmdline *cl,
9136 __rte_unused void *data)
9138 struct cmd_tunnel_udp_config *res = parsed_result;
9139 struct rte_eth_udp_tunnel tunnel_udp;
9142 tunnel_udp.udp_port = res->udp_port;
9144 if (!strcmp(res->cmd, "rx_vxlan_port"))
9145 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9147 if (!strcmp(res->what, "add"))
9148 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9151 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9155 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9158 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9159 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9160 cmd, "rx_vxlan_port");
9161 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9162 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9164 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9165 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9167 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9168 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9171 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9172 .f = cmd_tunnel_udp_config_parsed,
9174 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9175 "Add/Remove a tunneling UDP port filter",
9177 (void *)&cmd_tunnel_udp_config_cmd,
9178 (void *)&cmd_tunnel_udp_config_what,
9179 (void *)&cmd_tunnel_udp_config_udp_port,
9180 (void *)&cmd_tunnel_udp_config_port_id,
9185 struct cmd_config_tunnel_udp_port {
9186 cmdline_fixed_string_t port;
9187 cmdline_fixed_string_t config;
9189 cmdline_fixed_string_t udp_tunnel_port;
9190 cmdline_fixed_string_t action;
9191 cmdline_fixed_string_t tunnel_type;
9196 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9197 __rte_unused struct cmdline *cl,
9198 __rte_unused void *data)
9200 struct cmd_config_tunnel_udp_port *res = parsed_result;
9201 struct rte_eth_udp_tunnel tunnel_udp;
9204 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9207 tunnel_udp.udp_port = res->udp_port;
9209 if (!strcmp(res->tunnel_type, "vxlan")) {
9210 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9211 } else if (!strcmp(res->tunnel_type, "geneve")) {
9212 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9213 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9214 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9216 printf("Invalid tunnel type\n");
9220 if (!strcmp(res->action, "add"))
9221 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9224 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9228 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9231 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9232 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9234 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9235 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9237 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9238 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9240 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9241 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9244 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9245 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9247 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9248 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9249 "vxlan#geneve#vxlan-gpe");
9250 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9251 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9254 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9255 .f = cmd_cfg_tunnel_udp_port_parsed,
9257 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9259 (void *)&cmd_config_tunnel_udp_port_port,
9260 (void *)&cmd_config_tunnel_udp_port_config,
9261 (void *)&cmd_config_tunnel_udp_port_port_id,
9262 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9263 (void *)&cmd_config_tunnel_udp_port_action,
9264 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9265 (void *)&cmd_config_tunnel_udp_port_value,
9270 /* *** GLOBAL CONFIG *** */
9271 struct cmd_global_config_result {
9272 cmdline_fixed_string_t cmd;
9274 cmdline_fixed_string_t cfg_type;
9279 cmd_global_config_parsed(void *parsed_result,
9280 __rte_unused struct cmdline *cl,
9281 __rte_unused void *data)
9283 struct cmd_global_config_result *res = parsed_result;
9284 struct rte_eth_global_cfg conf;
9287 memset(&conf, 0, sizeof(conf));
9288 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9289 conf.cfg.gre_key_len = res->len;
9290 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9291 RTE_ETH_FILTER_SET, &conf);
9293 printf("Global config error\n");
9296 cmdline_parse_token_string_t cmd_global_config_cmd =
9297 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9299 cmdline_parse_token_num_t cmd_global_config_port_id =
9300 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9302 cmdline_parse_token_string_t cmd_global_config_type =
9303 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9304 cfg_type, "gre-key-len");
9305 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9306 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9309 cmdline_parse_inst_t cmd_global_config = {
9310 .f = cmd_global_config_parsed,
9311 .data = (void *)NULL,
9312 .help_str = "global_config <port_id> gre-key-len <key_len>",
9314 (void *)&cmd_global_config_cmd,
9315 (void *)&cmd_global_config_port_id,
9316 (void *)&cmd_global_config_type,
9317 (void *)&cmd_global_config_gre_key_len,
9322 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9323 struct cmd_set_mirror_mask_result {
9324 cmdline_fixed_string_t set;
9325 cmdline_fixed_string_t port;
9327 cmdline_fixed_string_t mirror;
9329 cmdline_fixed_string_t what;
9330 cmdline_fixed_string_t value;
9331 cmdline_fixed_string_t dstpool;
9333 cmdline_fixed_string_t on;
9336 cmdline_parse_token_string_t cmd_mirror_mask_set =
9337 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9339 cmdline_parse_token_string_t cmd_mirror_mask_port =
9340 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9342 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9343 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9345 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9346 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9347 mirror, "mirror-rule");
9348 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9349 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9351 cmdline_parse_token_string_t cmd_mirror_mask_what =
9352 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9353 what, "pool-mirror-up#pool-mirror-down"
9355 cmdline_parse_token_string_t cmd_mirror_mask_value =
9356 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9358 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9359 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9360 dstpool, "dst-pool");
9361 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9362 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9364 cmdline_parse_token_string_t cmd_mirror_mask_on =
9365 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9369 cmd_set_mirror_mask_parsed(void *parsed_result,
9370 __rte_unused struct cmdline *cl,
9371 __rte_unused void *data)
9374 struct cmd_set_mirror_mask_result *res = parsed_result;
9375 struct rte_eth_mirror_conf mr_conf;
9377 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9379 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9381 mr_conf.dst_pool = res->dstpool_id;
9383 if (!strcmp(res->what, "pool-mirror-up")) {
9384 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9385 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9386 } else if (!strcmp(res->what, "pool-mirror-down")) {
9387 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9388 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9389 } else if (!strcmp(res->what, "vlan-mirror")) {
9390 mr_conf.rule_type = ETH_MIRROR_VLAN;
9391 nb_item = parse_item_list(res->value, "vlan",
9392 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9396 for (i = 0; i < nb_item; i++) {
9397 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9398 printf("Invalid vlan_id: must be < 4096\n");
9402 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9403 mr_conf.vlan.vlan_mask |= 1ULL << i;
9407 if (!strcmp(res->on, "on"))
9408 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9411 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9414 printf("mirror rule add error: (%s)\n", strerror(-ret));
9417 cmdline_parse_inst_t cmd_set_mirror_mask = {
9418 .f = cmd_set_mirror_mask_parsed,
9420 .help_str = "set port <port_id> mirror-rule <rule_id> "
9421 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9422 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9424 (void *)&cmd_mirror_mask_set,
9425 (void *)&cmd_mirror_mask_port,
9426 (void *)&cmd_mirror_mask_portid,
9427 (void *)&cmd_mirror_mask_mirror,
9428 (void *)&cmd_mirror_mask_ruleid,
9429 (void *)&cmd_mirror_mask_what,
9430 (void *)&cmd_mirror_mask_value,
9431 (void *)&cmd_mirror_mask_dstpool,
9432 (void *)&cmd_mirror_mask_poolid,
9433 (void *)&cmd_mirror_mask_on,
9438 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9439 struct cmd_set_mirror_link_result {
9440 cmdline_fixed_string_t set;
9441 cmdline_fixed_string_t port;
9443 cmdline_fixed_string_t mirror;
9445 cmdline_fixed_string_t what;
9446 cmdline_fixed_string_t dstpool;
9448 cmdline_fixed_string_t on;
9451 cmdline_parse_token_string_t cmd_mirror_link_set =
9452 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9454 cmdline_parse_token_string_t cmd_mirror_link_port =
9455 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9457 cmdline_parse_token_num_t cmd_mirror_link_portid =
9458 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9460 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9461 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9462 mirror, "mirror-rule");
9463 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9464 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9466 cmdline_parse_token_string_t cmd_mirror_link_what =
9467 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9468 what, "uplink-mirror#downlink-mirror");
9469 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9470 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9471 dstpool, "dst-pool");
9472 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9473 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9475 cmdline_parse_token_string_t cmd_mirror_link_on =
9476 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9480 cmd_set_mirror_link_parsed(void *parsed_result,
9481 __rte_unused struct cmdline *cl,
9482 __rte_unused void *data)
9485 struct cmd_set_mirror_link_result *res = parsed_result;
9486 struct rte_eth_mirror_conf mr_conf;
9488 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9489 if (!strcmp(res->what, "uplink-mirror"))
9490 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9492 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9494 mr_conf.dst_pool = res->dstpool_id;
9496 if (!strcmp(res->on, "on"))
9497 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9500 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9503 /* check the return value and print it if is < 0 */
9505 printf("mirror rule add error: (%s)\n", strerror(-ret));
9509 cmdline_parse_inst_t cmd_set_mirror_link = {
9510 .f = cmd_set_mirror_link_parsed,
9512 .help_str = "set port <port_id> mirror-rule <rule_id> "
9513 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9515 (void *)&cmd_mirror_link_set,
9516 (void *)&cmd_mirror_link_port,
9517 (void *)&cmd_mirror_link_portid,
9518 (void *)&cmd_mirror_link_mirror,
9519 (void *)&cmd_mirror_link_ruleid,
9520 (void *)&cmd_mirror_link_what,
9521 (void *)&cmd_mirror_link_dstpool,
9522 (void *)&cmd_mirror_link_poolid,
9523 (void *)&cmd_mirror_link_on,
9528 /* *** RESET VM MIRROR RULE *** */
9529 struct cmd_rm_mirror_rule_result {
9530 cmdline_fixed_string_t reset;
9531 cmdline_fixed_string_t port;
9533 cmdline_fixed_string_t mirror;
9537 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9538 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9540 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9541 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9543 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9544 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9546 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9547 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9548 mirror, "mirror-rule");
9549 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9550 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9554 cmd_reset_mirror_rule_parsed(void *parsed_result,
9555 __rte_unused struct cmdline *cl,
9556 __rte_unused void *data)
9559 struct cmd_set_mirror_link_result *res = parsed_result;
9561 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9563 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9566 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9567 .f = cmd_reset_mirror_rule_parsed,
9569 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9571 (void *)&cmd_rm_mirror_rule_reset,
9572 (void *)&cmd_rm_mirror_rule_port,
9573 (void *)&cmd_rm_mirror_rule_portid,
9574 (void *)&cmd_rm_mirror_rule_mirror,
9575 (void *)&cmd_rm_mirror_rule_ruleid,
9580 /* ******************************************************************************** */
9582 struct cmd_dump_result {
9583 cmdline_fixed_string_t dump;
9587 dump_struct_sizes(void)
9589 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9590 DUMP_SIZE(struct rte_mbuf);
9591 DUMP_SIZE(struct rte_mempool);
9592 DUMP_SIZE(struct rte_ring);
9597 /* Dump the socket memory statistics on console */
9599 dump_socket_mem(FILE *f)
9601 struct rte_malloc_socket_stats socket_stats;
9606 unsigned int n_alloc = 0;
9607 unsigned int n_free = 0;
9608 static size_t last_allocs;
9609 static size_t last_total;
9612 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9613 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9614 !socket_stats.heap_totalsz_bytes)
9616 total += socket_stats.heap_totalsz_bytes;
9617 alloc += socket_stats.heap_allocsz_bytes;
9618 free += socket_stats.heap_freesz_bytes;
9619 n_alloc += socket_stats.alloc_count;
9620 n_free += socket_stats.free_count;
9622 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9624 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9625 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9626 (double)socket_stats.heap_allocsz_bytes * 100 /
9627 (double)socket_stats.heap_totalsz_bytes,
9628 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9629 socket_stats.alloc_count,
9630 socket_stats.free_count);
9633 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9634 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9635 (double)alloc * 100 / (double)total,
9636 (double)free / (1024 * 1024),
9639 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9640 ((double)total - (double)last_total) / (1024 * 1024),
9641 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9642 last_allocs = alloc;
9646 static void cmd_dump_parsed(void *parsed_result,
9647 __rte_unused struct cmdline *cl,
9648 __rte_unused void *data)
9650 struct cmd_dump_result *res = parsed_result;
9652 if (!strcmp(res->dump, "dump_physmem"))
9653 rte_dump_physmem_layout(stdout);
9654 else if (!strcmp(res->dump, "dump_socket_mem"))
9655 dump_socket_mem(stdout);
9656 else if (!strcmp(res->dump, "dump_memzone"))
9657 rte_memzone_dump(stdout);
9658 else if (!strcmp(res->dump, "dump_struct_sizes"))
9659 dump_struct_sizes();
9660 else if (!strcmp(res->dump, "dump_ring"))
9661 rte_ring_list_dump(stdout);
9662 else if (!strcmp(res->dump, "dump_mempool"))
9663 rte_mempool_list_dump(stdout);
9664 else if (!strcmp(res->dump, "dump_devargs"))
9665 rte_devargs_dump(stdout);
9666 else if (!strcmp(res->dump, "dump_log_types"))
9667 rte_log_dump(stdout);
9670 cmdline_parse_token_string_t cmd_dump_dump =
9671 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9675 "dump_struct_sizes#"
9681 cmdline_parse_inst_t cmd_dump = {
9682 .f = cmd_dump_parsed, /* function to call */
9683 .data = NULL, /* 2nd arg of func */
9684 .help_str = "Dump status",
9685 .tokens = { /* token list, NULL terminated */
9686 (void *)&cmd_dump_dump,
9691 /* ******************************************************************************** */
9693 struct cmd_dump_one_result {
9694 cmdline_fixed_string_t dump;
9695 cmdline_fixed_string_t name;
9698 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9699 __rte_unused void *data)
9701 struct cmd_dump_one_result *res = parsed_result;
9703 if (!strcmp(res->dump, "dump_ring")) {
9705 r = rte_ring_lookup(res->name);
9707 cmdline_printf(cl, "Cannot find ring\n");
9710 rte_ring_dump(stdout, r);
9711 } else if (!strcmp(res->dump, "dump_mempool")) {
9712 struct rte_mempool *mp;
9713 mp = rte_mempool_lookup(res->name);
9715 cmdline_printf(cl, "Cannot find mempool\n");
9718 rte_mempool_dump(stdout, mp);
9722 cmdline_parse_token_string_t cmd_dump_one_dump =
9723 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9724 "dump_ring#dump_mempool");
9726 cmdline_parse_token_string_t cmd_dump_one_name =
9727 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9729 cmdline_parse_inst_t cmd_dump_one = {
9730 .f = cmd_dump_one_parsed, /* function to call */
9731 .data = NULL, /* 2nd arg of func */
9732 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9733 .tokens = { /* token list, NULL terminated */
9734 (void *)&cmd_dump_one_dump,
9735 (void *)&cmd_dump_one_name,
9740 /* *** Add/Del syn filter *** */
9741 struct cmd_syn_filter_result {
9742 cmdline_fixed_string_t filter;
9744 cmdline_fixed_string_t ops;
9745 cmdline_fixed_string_t priority;
9746 cmdline_fixed_string_t high;
9747 cmdline_fixed_string_t queue;
9752 cmd_syn_filter_parsed(void *parsed_result,
9753 __rte_unused struct cmdline *cl,
9754 __rte_unused void *data)
9756 struct cmd_syn_filter_result *res = parsed_result;
9757 struct rte_eth_syn_filter syn_filter;
9760 ret = rte_eth_dev_filter_supported(res->port_id,
9761 RTE_ETH_FILTER_SYN);
9763 printf("syn filter is not supported on port %u.\n",
9768 memset(&syn_filter, 0, sizeof(syn_filter));
9770 if (!strcmp(res->ops, "add")) {
9771 if (!strcmp(res->high, "high"))
9772 syn_filter.hig_pri = 1;
9774 syn_filter.hig_pri = 0;
9776 syn_filter.queue = res->queue_id;
9777 ret = rte_eth_dev_filter_ctrl(res->port_id,
9782 ret = rte_eth_dev_filter_ctrl(res->port_id,
9784 RTE_ETH_FILTER_DELETE,
9788 printf("syn filter programming error: (%s)\n",
9792 cmdline_parse_token_string_t cmd_syn_filter_filter =
9793 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9794 filter, "syn_filter");
9795 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9796 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9798 cmdline_parse_token_string_t cmd_syn_filter_ops =
9799 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9801 cmdline_parse_token_string_t cmd_syn_filter_priority =
9802 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9803 priority, "priority");
9804 cmdline_parse_token_string_t cmd_syn_filter_high =
9805 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9807 cmdline_parse_token_string_t cmd_syn_filter_queue =
9808 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9810 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9811 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9814 cmdline_parse_inst_t cmd_syn_filter = {
9815 .f = cmd_syn_filter_parsed,
9817 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9818 "<queue_id>: Add/Delete syn filter",
9820 (void *)&cmd_syn_filter_filter,
9821 (void *)&cmd_syn_filter_port_id,
9822 (void *)&cmd_syn_filter_ops,
9823 (void *)&cmd_syn_filter_priority,
9824 (void *)&cmd_syn_filter_high,
9825 (void *)&cmd_syn_filter_queue,
9826 (void *)&cmd_syn_filter_queue_id,
9831 /* *** queue region set *** */
9832 struct cmd_queue_region_result {
9833 cmdline_fixed_string_t set;
9834 cmdline_fixed_string_t port;
9836 cmdline_fixed_string_t cmd;
9837 cmdline_fixed_string_t region;
9839 cmdline_fixed_string_t queue_start_index;
9841 cmdline_fixed_string_t queue_num;
9842 uint8_t queue_num_value;
9846 cmd_queue_region_parsed(void *parsed_result,
9847 __rte_unused struct cmdline *cl,
9848 __rte_unused void *data)
9850 struct cmd_queue_region_result *res = parsed_result;
9852 #ifdef RTE_LIBRTE_I40E_PMD
9853 struct rte_pmd_i40e_queue_region_conf region_conf;
9854 enum rte_pmd_i40e_queue_region_op op_type;
9857 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9860 #ifdef RTE_LIBRTE_I40E_PMD
9861 memset(®ion_conf, 0, sizeof(region_conf));
9862 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9863 region_conf.region_id = res->region_id;
9864 region_conf.queue_num = res->queue_num_value;
9865 region_conf.queue_start_index = res->queue_id;
9867 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9868 op_type, ®ion_conf);
9875 printf("function not implemented or supported\n");
9878 printf("queue region config error: (%s)\n", strerror(-ret));
9882 cmdline_parse_token_string_t cmd_queue_region_set =
9883 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9885 cmdline_parse_token_string_t cmd_queue_region_port =
9886 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9887 cmdline_parse_token_num_t cmd_queue_region_port_id =
9888 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9890 cmdline_parse_token_string_t cmd_queue_region_cmd =
9891 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9892 cmd, "queue-region");
9893 cmdline_parse_token_string_t cmd_queue_region_id =
9894 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9895 region, "region_id");
9896 cmdline_parse_token_num_t cmd_queue_region_index =
9897 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9899 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9900 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9901 queue_start_index, "queue_start_index");
9902 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9903 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9905 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9906 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9907 queue_num, "queue_num");
9908 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9909 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9910 queue_num_value, UINT8);
9912 cmdline_parse_inst_t cmd_queue_region = {
9913 .f = cmd_queue_region_parsed,
9915 .help_str = "set port <port_id> queue-region region_id <value> "
9916 "queue_start_index <value> queue_num <value>: Set a queue region",
9918 (void *)&cmd_queue_region_set,
9919 (void *)&cmd_queue_region_port,
9920 (void *)&cmd_queue_region_port_id,
9921 (void *)&cmd_queue_region_cmd,
9922 (void *)&cmd_queue_region_id,
9923 (void *)&cmd_queue_region_index,
9924 (void *)&cmd_queue_region_queue_start_index,
9925 (void *)&cmd_queue_region_queue_id,
9926 (void *)&cmd_queue_region_queue_num,
9927 (void *)&cmd_queue_region_queue_num_value,
9932 /* *** queue region and flowtype set *** */
9933 struct cmd_region_flowtype_result {
9934 cmdline_fixed_string_t set;
9935 cmdline_fixed_string_t port;
9937 cmdline_fixed_string_t cmd;
9938 cmdline_fixed_string_t region;
9940 cmdline_fixed_string_t flowtype;
9941 uint8_t flowtype_id;
9945 cmd_region_flowtype_parsed(void *parsed_result,
9946 __rte_unused struct cmdline *cl,
9947 __rte_unused void *data)
9949 struct cmd_region_flowtype_result *res = parsed_result;
9951 #ifdef RTE_LIBRTE_I40E_PMD
9952 struct rte_pmd_i40e_queue_region_conf region_conf;
9953 enum rte_pmd_i40e_queue_region_op op_type;
9956 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9959 #ifdef RTE_LIBRTE_I40E_PMD
9960 memset(®ion_conf, 0, sizeof(region_conf));
9962 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9963 region_conf.region_id = res->region_id;
9964 region_conf.hw_flowtype = res->flowtype_id;
9966 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9967 op_type, ®ion_conf);
9974 printf("function not implemented or supported\n");
9977 printf("region flowtype config error: (%s)\n", strerror(-ret));
9981 cmdline_parse_token_string_t cmd_region_flowtype_set =
9982 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9984 cmdline_parse_token_string_t cmd_region_flowtype_port =
9985 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9987 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9988 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9990 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9991 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9992 cmd, "queue-region");
9993 cmdline_parse_token_string_t cmd_region_flowtype_index =
9994 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9995 region, "region_id");
9996 cmdline_parse_token_num_t cmd_region_flowtype_id =
9997 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9999 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10000 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10001 flowtype, "flowtype");
10002 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10003 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10004 flowtype_id, UINT8);
10005 cmdline_parse_inst_t cmd_region_flowtype = {
10006 .f = cmd_region_flowtype_parsed,
10008 .help_str = "set port <port_id> queue-region region_id <value> "
10009 "flowtype <value>: Set a flowtype region index",
10011 (void *)&cmd_region_flowtype_set,
10012 (void *)&cmd_region_flowtype_port,
10013 (void *)&cmd_region_flowtype_port_index,
10014 (void *)&cmd_region_flowtype_cmd,
10015 (void *)&cmd_region_flowtype_index,
10016 (void *)&cmd_region_flowtype_id,
10017 (void *)&cmd_region_flowtype_flow_index,
10018 (void *)&cmd_region_flowtype_flow_id,
10023 /* *** User Priority (UP) to queue region (region_id) set *** */
10024 struct cmd_user_priority_region_result {
10025 cmdline_fixed_string_t set;
10026 cmdline_fixed_string_t port;
10028 cmdline_fixed_string_t cmd;
10029 cmdline_fixed_string_t user_priority;
10030 uint8_t user_priority_id;
10031 cmdline_fixed_string_t region;
10036 cmd_user_priority_region_parsed(void *parsed_result,
10037 __rte_unused struct cmdline *cl,
10038 __rte_unused void *data)
10040 struct cmd_user_priority_region_result *res = parsed_result;
10041 int ret = -ENOTSUP;
10042 #ifdef RTE_LIBRTE_I40E_PMD
10043 struct rte_pmd_i40e_queue_region_conf region_conf;
10044 enum rte_pmd_i40e_queue_region_op op_type;
10047 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10050 #ifdef RTE_LIBRTE_I40E_PMD
10051 memset(®ion_conf, 0, sizeof(region_conf));
10052 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10053 region_conf.user_priority = res->user_priority_id;
10054 region_conf.region_id = res->region_id;
10056 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10057 op_type, ®ion_conf);
10064 printf("function not implemented or supported\n");
10067 printf("user_priority region config error: (%s)\n",
10072 cmdline_parse_token_string_t cmd_user_priority_region_set =
10073 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10075 cmdline_parse_token_string_t cmd_user_priority_region_port =
10076 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10078 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10079 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10081 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10082 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10083 cmd, "queue-region");
10084 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10085 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10086 user_priority, "UP");
10087 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10088 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10089 user_priority_id, UINT8);
10090 cmdline_parse_token_string_t cmd_user_priority_region_region =
10091 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10092 region, "region_id");
10093 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10094 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10097 cmdline_parse_inst_t cmd_user_priority_region = {
10098 .f = cmd_user_priority_region_parsed,
10100 .help_str = "set port <port_id> queue-region UP <value> "
10101 "region_id <value>: Set the mapping of User Priority (UP) "
10102 "to queue region (region_id) ",
10104 (void *)&cmd_user_priority_region_set,
10105 (void *)&cmd_user_priority_region_port,
10106 (void *)&cmd_user_priority_region_port_index,
10107 (void *)&cmd_user_priority_region_cmd,
10108 (void *)&cmd_user_priority_region_UP,
10109 (void *)&cmd_user_priority_region_UP_id,
10110 (void *)&cmd_user_priority_region_region,
10111 (void *)&cmd_user_priority_region_region_id,
10116 /* *** flush all queue region related configuration *** */
10117 struct cmd_flush_queue_region_result {
10118 cmdline_fixed_string_t set;
10119 cmdline_fixed_string_t port;
10121 cmdline_fixed_string_t cmd;
10122 cmdline_fixed_string_t flush;
10123 cmdline_fixed_string_t what;
10127 cmd_flush_queue_region_parsed(void *parsed_result,
10128 __rte_unused struct cmdline *cl,
10129 __rte_unused void *data)
10131 struct cmd_flush_queue_region_result *res = parsed_result;
10132 int ret = -ENOTSUP;
10133 #ifdef RTE_LIBRTE_I40E_PMD
10134 struct rte_pmd_i40e_queue_region_conf region_conf;
10135 enum rte_pmd_i40e_queue_region_op op_type;
10138 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10141 #ifdef RTE_LIBRTE_I40E_PMD
10142 memset(®ion_conf, 0, sizeof(region_conf));
10144 if (strcmp(res->what, "on") == 0)
10145 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10147 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10149 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10150 op_type, ®ion_conf);
10157 printf("function not implemented or supported\n");
10160 printf("queue region config flush error: (%s)\n",
10165 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10166 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10168 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10169 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10171 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10172 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10174 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10175 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10176 cmd, "queue-region");
10177 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10178 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10180 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10181 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10184 cmdline_parse_inst_t cmd_flush_queue_region = {
10185 .f = cmd_flush_queue_region_parsed,
10187 .help_str = "set port <port_id> queue-region flush on|off"
10188 ": flush all queue region related configuration",
10190 (void *)&cmd_flush_queue_region_set,
10191 (void *)&cmd_flush_queue_region_port,
10192 (void *)&cmd_flush_queue_region_port_index,
10193 (void *)&cmd_flush_queue_region_cmd,
10194 (void *)&cmd_flush_queue_region_flush,
10195 (void *)&cmd_flush_queue_region_what,
10200 /* *** get all queue region related configuration info *** */
10201 struct cmd_show_queue_region_info {
10202 cmdline_fixed_string_t show;
10203 cmdline_fixed_string_t port;
10205 cmdline_fixed_string_t cmd;
10209 cmd_show_queue_region_info_parsed(void *parsed_result,
10210 __rte_unused struct cmdline *cl,
10211 __rte_unused void *data)
10213 struct cmd_show_queue_region_info *res = parsed_result;
10214 int ret = -ENOTSUP;
10215 #ifdef RTE_LIBRTE_I40E_PMD
10216 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10217 enum rte_pmd_i40e_queue_region_op op_type;
10220 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10223 #ifdef RTE_LIBRTE_I40E_PMD
10224 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10226 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10228 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10229 op_type, &rte_pmd_regions);
10231 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10238 printf("function not implemented or supported\n");
10241 printf("queue region config info show error: (%s)\n",
10246 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10247 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10249 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10250 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10252 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10253 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10255 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10256 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10257 cmd, "queue-region");
10259 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10260 .f = cmd_show_queue_region_info_parsed,
10262 .help_str = "show port <port_id> queue-region"
10263 ": show all queue region related configuration info",
10265 (void *)&cmd_show_queue_region_info_get,
10266 (void *)&cmd_show_queue_region_info_port,
10267 (void *)&cmd_show_queue_region_info_port_index,
10268 (void *)&cmd_show_queue_region_info_cmd,
10273 /* *** ADD/REMOVE A 2tuple FILTER *** */
10274 struct cmd_2tuple_filter_result {
10275 cmdline_fixed_string_t filter;
10277 cmdline_fixed_string_t ops;
10278 cmdline_fixed_string_t dst_port;
10279 uint16_t dst_port_value;
10280 cmdline_fixed_string_t protocol;
10281 uint8_t protocol_value;
10282 cmdline_fixed_string_t mask;
10283 uint8_t mask_value;
10284 cmdline_fixed_string_t tcp_flags;
10285 uint8_t tcp_flags_value;
10286 cmdline_fixed_string_t priority;
10287 uint8_t priority_value;
10288 cmdline_fixed_string_t queue;
10293 cmd_2tuple_filter_parsed(void *parsed_result,
10294 __rte_unused struct cmdline *cl,
10295 __rte_unused void *data)
10297 struct rte_eth_ntuple_filter filter;
10298 struct cmd_2tuple_filter_result *res = parsed_result;
10301 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10303 printf("ntuple filter is not supported on port %u.\n",
10308 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10310 filter.flags = RTE_2TUPLE_FLAGS;
10311 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10312 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10313 filter.proto = res->protocol_value;
10314 filter.priority = res->priority_value;
10315 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10316 printf("nonzero tcp_flags is only meaningful"
10317 " when protocol is TCP.\n");
10320 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10321 printf("invalid TCP flags.\n");
10325 if (res->tcp_flags_value != 0) {
10326 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10327 filter.tcp_flags = res->tcp_flags_value;
10330 /* need convert to big endian. */
10331 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10332 filter.queue = res->queue_id;
10334 if (!strcmp(res->ops, "add"))
10335 ret = rte_eth_dev_filter_ctrl(res->port_id,
10336 RTE_ETH_FILTER_NTUPLE,
10337 RTE_ETH_FILTER_ADD,
10340 ret = rte_eth_dev_filter_ctrl(res->port_id,
10341 RTE_ETH_FILTER_NTUPLE,
10342 RTE_ETH_FILTER_DELETE,
10345 printf("2tuple filter programming error: (%s)\n",
10350 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10351 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10352 filter, "2tuple_filter");
10353 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10354 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10356 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10357 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10359 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10360 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10361 dst_port, "dst_port");
10362 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10363 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10364 dst_port_value, UINT16);
10365 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10366 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10367 protocol, "protocol");
10368 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10369 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10370 protocol_value, UINT8);
10371 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10372 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10374 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10375 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10377 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10378 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10379 tcp_flags, "tcp_flags");
10380 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10381 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10382 tcp_flags_value, UINT8);
10383 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10384 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10385 priority, "priority");
10386 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10387 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10388 priority_value, UINT8);
10389 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10390 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10392 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10393 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10396 cmdline_parse_inst_t cmd_2tuple_filter = {
10397 .f = cmd_2tuple_filter_parsed,
10399 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10400 "<value> mask <value> tcp_flags <value> priority <value> queue "
10401 "<queue_id>: Add a 2tuple filter",
10403 (void *)&cmd_2tuple_filter_filter,
10404 (void *)&cmd_2tuple_filter_port_id,
10405 (void *)&cmd_2tuple_filter_ops,
10406 (void *)&cmd_2tuple_filter_dst_port,
10407 (void *)&cmd_2tuple_filter_dst_port_value,
10408 (void *)&cmd_2tuple_filter_protocol,
10409 (void *)&cmd_2tuple_filter_protocol_value,
10410 (void *)&cmd_2tuple_filter_mask,
10411 (void *)&cmd_2tuple_filter_mask_value,
10412 (void *)&cmd_2tuple_filter_tcp_flags,
10413 (void *)&cmd_2tuple_filter_tcp_flags_value,
10414 (void *)&cmd_2tuple_filter_priority,
10415 (void *)&cmd_2tuple_filter_priority_value,
10416 (void *)&cmd_2tuple_filter_queue,
10417 (void *)&cmd_2tuple_filter_queue_id,
10422 /* *** ADD/REMOVE A 5tuple FILTER *** */
10423 struct cmd_5tuple_filter_result {
10424 cmdline_fixed_string_t filter;
10426 cmdline_fixed_string_t ops;
10427 cmdline_fixed_string_t dst_ip;
10428 cmdline_ipaddr_t dst_ip_value;
10429 cmdline_fixed_string_t src_ip;
10430 cmdline_ipaddr_t src_ip_value;
10431 cmdline_fixed_string_t dst_port;
10432 uint16_t dst_port_value;
10433 cmdline_fixed_string_t src_port;
10434 uint16_t src_port_value;
10435 cmdline_fixed_string_t protocol;
10436 uint8_t protocol_value;
10437 cmdline_fixed_string_t mask;
10438 uint8_t mask_value;
10439 cmdline_fixed_string_t tcp_flags;
10440 uint8_t tcp_flags_value;
10441 cmdline_fixed_string_t priority;
10442 uint8_t priority_value;
10443 cmdline_fixed_string_t queue;
10448 cmd_5tuple_filter_parsed(void *parsed_result,
10449 __rte_unused struct cmdline *cl,
10450 __rte_unused void *data)
10452 struct rte_eth_ntuple_filter filter;
10453 struct cmd_5tuple_filter_result *res = parsed_result;
10456 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10458 printf("ntuple filter is not supported on port %u.\n",
10463 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10465 filter.flags = RTE_5TUPLE_FLAGS;
10466 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10467 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10468 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10469 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10470 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10471 filter.proto = res->protocol_value;
10472 filter.priority = res->priority_value;
10473 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10474 printf("nonzero tcp_flags is only meaningful"
10475 " when protocol is TCP.\n");
10478 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10479 printf("invalid TCP flags.\n");
10483 if (res->tcp_flags_value != 0) {
10484 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10485 filter.tcp_flags = res->tcp_flags_value;
10488 if (res->dst_ip_value.family == AF_INET)
10489 /* no need to convert, already big endian. */
10490 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10492 if (filter.dst_ip_mask == 0) {
10493 printf("can not support ipv6 involved compare.\n");
10499 if (res->src_ip_value.family == AF_INET)
10500 /* no need to convert, already big endian. */
10501 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10503 if (filter.src_ip_mask == 0) {
10504 printf("can not support ipv6 involved compare.\n");
10509 /* need convert to big endian. */
10510 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10511 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10512 filter.queue = res->queue_id;
10514 if (!strcmp(res->ops, "add"))
10515 ret = rte_eth_dev_filter_ctrl(res->port_id,
10516 RTE_ETH_FILTER_NTUPLE,
10517 RTE_ETH_FILTER_ADD,
10520 ret = rte_eth_dev_filter_ctrl(res->port_id,
10521 RTE_ETH_FILTER_NTUPLE,
10522 RTE_ETH_FILTER_DELETE,
10525 printf("5tuple filter programming error: (%s)\n",
10529 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10530 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10531 filter, "5tuple_filter");
10532 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10533 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10535 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10536 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10538 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10539 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10541 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10542 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10544 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10545 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10547 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10548 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10550 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10551 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10552 dst_port, "dst_port");
10553 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10554 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10555 dst_port_value, UINT16);
10556 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10557 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10558 src_port, "src_port");
10559 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10560 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10561 src_port_value, UINT16);
10562 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10563 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10564 protocol, "protocol");
10565 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10566 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10567 protocol_value, UINT8);
10568 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10569 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10571 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10572 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10574 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10575 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10576 tcp_flags, "tcp_flags");
10577 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10578 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10579 tcp_flags_value, UINT8);
10580 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10581 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10582 priority, "priority");
10583 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10584 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10585 priority_value, UINT8);
10586 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10587 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10589 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10590 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10593 cmdline_parse_inst_t cmd_5tuple_filter = {
10594 .f = cmd_5tuple_filter_parsed,
10596 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10597 "src_ip <value> dst_port <value> src_port <value> "
10598 "protocol <value> mask <value> tcp_flags <value> "
10599 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10601 (void *)&cmd_5tuple_filter_filter,
10602 (void *)&cmd_5tuple_filter_port_id,
10603 (void *)&cmd_5tuple_filter_ops,
10604 (void *)&cmd_5tuple_filter_dst_ip,
10605 (void *)&cmd_5tuple_filter_dst_ip_value,
10606 (void *)&cmd_5tuple_filter_src_ip,
10607 (void *)&cmd_5tuple_filter_src_ip_value,
10608 (void *)&cmd_5tuple_filter_dst_port,
10609 (void *)&cmd_5tuple_filter_dst_port_value,
10610 (void *)&cmd_5tuple_filter_src_port,
10611 (void *)&cmd_5tuple_filter_src_port_value,
10612 (void *)&cmd_5tuple_filter_protocol,
10613 (void *)&cmd_5tuple_filter_protocol_value,
10614 (void *)&cmd_5tuple_filter_mask,
10615 (void *)&cmd_5tuple_filter_mask_value,
10616 (void *)&cmd_5tuple_filter_tcp_flags,
10617 (void *)&cmd_5tuple_filter_tcp_flags_value,
10618 (void *)&cmd_5tuple_filter_priority,
10619 (void *)&cmd_5tuple_filter_priority_value,
10620 (void *)&cmd_5tuple_filter_queue,
10621 (void *)&cmd_5tuple_filter_queue_id,
10626 /* *** ADD/REMOVE A flex FILTER *** */
10627 struct cmd_flex_filter_result {
10628 cmdline_fixed_string_t filter;
10629 cmdline_fixed_string_t ops;
10631 cmdline_fixed_string_t len;
10633 cmdline_fixed_string_t bytes;
10634 cmdline_fixed_string_t bytes_value;
10635 cmdline_fixed_string_t mask;
10636 cmdline_fixed_string_t mask_value;
10637 cmdline_fixed_string_t priority;
10638 uint8_t priority_value;
10639 cmdline_fixed_string_t queue;
10643 static int xdigit2val(unsigned char c)
10648 else if (isupper(c))
10649 val = c - 'A' + 10;
10651 val = c - 'a' + 10;
10656 cmd_flex_filter_parsed(void *parsed_result,
10657 __rte_unused struct cmdline *cl,
10658 __rte_unused void *data)
10661 struct rte_eth_flex_filter filter;
10662 struct cmd_flex_filter_result *res = parsed_result;
10663 char *bytes_ptr, *mask_ptr;
10664 uint16_t len, i, j = 0;
10669 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10670 printf("the len exceed the max length 128\n");
10673 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10674 filter.len = res->len_value;
10675 filter.priority = res->priority_value;
10676 filter.queue = res->queue_id;
10677 bytes_ptr = res->bytes_value;
10678 mask_ptr = res->mask_value;
10680 /* translate bytes string to array. */
10681 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10682 (bytes_ptr[1] == 'X')))
10684 len = strnlen(bytes_ptr, res->len_value * 2);
10685 if (len == 0 || (len % 8 != 0)) {
10686 printf("please check len and bytes input\n");
10689 for (i = 0; i < len; i++) {
10691 if (isxdigit(c) == 0) {
10692 /* invalid characters. */
10693 printf("invalid input\n");
10696 val = xdigit2val(c);
10699 filter.bytes[j] = byte;
10700 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10707 /* translate mask string to uint8_t array. */
10708 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10709 (mask_ptr[1] == 'X')))
10711 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10713 printf("invalid input\n");
10718 for (i = 0; i < len; i++) {
10720 if (isxdigit(c) == 0) {
10721 /* invalid characters. */
10722 printf("invalid input\n");
10725 val = xdigit2val(c);
10728 filter.mask[j] = byte;
10729 printf("mask[%d]:%02x ", j, filter.mask[j]);
10737 if (!strcmp(res->ops, "add"))
10738 ret = rte_eth_dev_filter_ctrl(res->port_id,
10739 RTE_ETH_FILTER_FLEXIBLE,
10740 RTE_ETH_FILTER_ADD,
10743 ret = rte_eth_dev_filter_ctrl(res->port_id,
10744 RTE_ETH_FILTER_FLEXIBLE,
10745 RTE_ETH_FILTER_DELETE,
10749 printf("flex filter setting error: (%s)\n", strerror(-ret));
10752 cmdline_parse_token_string_t cmd_flex_filter_filter =
10753 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10754 filter, "flex_filter");
10755 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10756 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10758 cmdline_parse_token_string_t cmd_flex_filter_ops =
10759 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10761 cmdline_parse_token_string_t cmd_flex_filter_len =
10762 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10764 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10765 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10767 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10768 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10770 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10771 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10772 bytes_value, NULL);
10773 cmdline_parse_token_string_t cmd_flex_filter_mask =
10774 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10776 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10777 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10779 cmdline_parse_token_string_t cmd_flex_filter_priority =
10780 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10781 priority, "priority");
10782 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10783 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10784 priority_value, UINT8);
10785 cmdline_parse_token_string_t cmd_flex_filter_queue =
10786 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10788 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10789 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10791 cmdline_parse_inst_t cmd_flex_filter = {
10792 .f = cmd_flex_filter_parsed,
10794 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10795 "<value> mask <value> priority <value> queue <queue_id>: "
10796 "Add/Del a flex filter",
10798 (void *)&cmd_flex_filter_filter,
10799 (void *)&cmd_flex_filter_port_id,
10800 (void *)&cmd_flex_filter_ops,
10801 (void *)&cmd_flex_filter_len,
10802 (void *)&cmd_flex_filter_len_value,
10803 (void *)&cmd_flex_filter_bytes,
10804 (void *)&cmd_flex_filter_bytes_value,
10805 (void *)&cmd_flex_filter_mask,
10806 (void *)&cmd_flex_filter_mask_value,
10807 (void *)&cmd_flex_filter_priority,
10808 (void *)&cmd_flex_filter_priority_value,
10809 (void *)&cmd_flex_filter_queue,
10810 (void *)&cmd_flex_filter_queue_id,
10815 /* *** Filters Control *** */
10817 /* *** deal with ethertype filter *** */
10818 struct cmd_ethertype_filter_result {
10819 cmdline_fixed_string_t filter;
10821 cmdline_fixed_string_t ops;
10822 cmdline_fixed_string_t mac;
10823 struct rte_ether_addr mac_addr;
10824 cmdline_fixed_string_t ethertype;
10825 uint16_t ethertype_value;
10826 cmdline_fixed_string_t drop;
10827 cmdline_fixed_string_t queue;
10831 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10832 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10833 filter, "ethertype_filter");
10834 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10835 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10837 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10838 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10840 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10841 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10842 mac, "mac_addr#mac_ignr");
10843 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10844 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10846 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10847 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10848 ethertype, "ethertype");
10849 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10850 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10851 ethertype_value, UINT16);
10852 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10853 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10855 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10856 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10858 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10859 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10863 cmd_ethertype_filter_parsed(void *parsed_result,
10864 __rte_unused struct cmdline *cl,
10865 __rte_unused void *data)
10867 struct cmd_ethertype_filter_result *res = parsed_result;
10868 struct rte_eth_ethertype_filter filter;
10871 ret = rte_eth_dev_filter_supported(res->port_id,
10872 RTE_ETH_FILTER_ETHERTYPE);
10874 printf("ethertype filter is not supported on port %u.\n",
10879 memset(&filter, 0, sizeof(filter));
10880 if (!strcmp(res->mac, "mac_addr")) {
10881 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10882 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10883 sizeof(struct rte_ether_addr));
10885 if (!strcmp(res->drop, "drop"))
10886 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10887 filter.ether_type = res->ethertype_value;
10888 filter.queue = res->queue_id;
10890 if (!strcmp(res->ops, "add"))
10891 ret = rte_eth_dev_filter_ctrl(res->port_id,
10892 RTE_ETH_FILTER_ETHERTYPE,
10893 RTE_ETH_FILTER_ADD,
10896 ret = rte_eth_dev_filter_ctrl(res->port_id,
10897 RTE_ETH_FILTER_ETHERTYPE,
10898 RTE_ETH_FILTER_DELETE,
10901 printf("ethertype filter programming error: (%s)\n",
10905 cmdline_parse_inst_t cmd_ethertype_filter = {
10906 .f = cmd_ethertype_filter_parsed,
10908 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10909 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10910 "Add or delete an ethertype filter entry",
10912 (void *)&cmd_ethertype_filter_filter,
10913 (void *)&cmd_ethertype_filter_port_id,
10914 (void *)&cmd_ethertype_filter_ops,
10915 (void *)&cmd_ethertype_filter_mac,
10916 (void *)&cmd_ethertype_filter_mac_addr,
10917 (void *)&cmd_ethertype_filter_ethertype,
10918 (void *)&cmd_ethertype_filter_ethertype_value,
10919 (void *)&cmd_ethertype_filter_drop,
10920 (void *)&cmd_ethertype_filter_queue,
10921 (void *)&cmd_ethertype_filter_queue_id,
10926 /* *** deal with flow director filter *** */
10927 struct cmd_flow_director_result {
10928 cmdline_fixed_string_t flow_director_filter;
10930 cmdline_fixed_string_t mode;
10931 cmdline_fixed_string_t mode_value;
10932 cmdline_fixed_string_t ops;
10933 cmdline_fixed_string_t flow;
10934 cmdline_fixed_string_t flow_type;
10935 cmdline_fixed_string_t ether;
10936 uint16_t ether_type;
10937 cmdline_fixed_string_t src;
10938 cmdline_ipaddr_t ip_src;
10940 cmdline_fixed_string_t dst;
10941 cmdline_ipaddr_t ip_dst;
10943 cmdline_fixed_string_t verify_tag;
10944 uint32_t verify_tag_value;
10945 cmdline_fixed_string_t tos;
10947 cmdline_fixed_string_t proto;
10948 uint8_t proto_value;
10949 cmdline_fixed_string_t ttl;
10951 cmdline_fixed_string_t vlan;
10952 uint16_t vlan_value;
10953 cmdline_fixed_string_t flexbytes;
10954 cmdline_fixed_string_t flexbytes_value;
10955 cmdline_fixed_string_t pf_vf;
10956 cmdline_fixed_string_t drop;
10957 cmdline_fixed_string_t queue;
10959 cmdline_fixed_string_t fd_id;
10960 uint32_t fd_id_value;
10961 cmdline_fixed_string_t mac;
10962 struct rte_ether_addr mac_addr;
10963 cmdline_fixed_string_t tunnel;
10964 cmdline_fixed_string_t tunnel_type;
10965 cmdline_fixed_string_t tunnel_id;
10966 uint32_t tunnel_id_value;
10967 cmdline_fixed_string_t packet;
10972 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10975 const char *p, *p0 = q_arg;
10977 unsigned long int_fld;
10978 char *str_fld[max_num];
10983 p = strchr(p0, '(');
10987 p0 = strchr(p, ')');
10992 if (size >= sizeof(s))
10995 snprintf(s, sizeof(s), "%.*s", size, p);
10996 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10997 if (ret < 0 || ret > max_num)
10999 for (i = 0; i < ret; i++) {
11001 int_fld = strtoul(str_fld[i], &end, 0);
11002 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11004 flexbytes[i] = (uint8_t)int_fld;
11010 str2flowtype(char *string)
11013 static const struct {
11016 } flowtype_str[] = {
11017 {"raw", RTE_ETH_FLOW_RAW},
11018 {"ipv4", RTE_ETH_FLOW_IPV4},
11019 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11020 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11021 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11022 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11023 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11024 {"ipv6", RTE_ETH_FLOW_IPV6},
11025 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11026 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11027 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11028 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11029 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11030 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11033 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11034 if (!strcmp(flowtype_str[i].str, string))
11035 return flowtype_str[i].type;
11038 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11039 return (uint16_t)atoi(string);
11041 return RTE_ETH_FLOW_UNKNOWN;
11044 static enum rte_eth_fdir_tunnel_type
11045 str2fdir_tunneltype(char *string)
11049 static const struct {
11051 enum rte_eth_fdir_tunnel_type type;
11052 } tunneltype_str[] = {
11053 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11054 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11057 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11058 if (!strcmp(tunneltype_str[i].str, string))
11059 return tunneltype_str[i].type;
11061 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11064 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11066 if ((ip_addr).family == AF_INET) \
11067 (ip) = (ip_addr).addr.ipv4.s_addr; \
11069 printf("invalid parameter.\n"); \
11074 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11076 if ((ip_addr).family == AF_INET6) \
11077 rte_memcpy(&(ip), \
11078 &((ip_addr).addr.ipv6), \
11079 sizeof(struct in6_addr)); \
11081 printf("invalid parameter.\n"); \
11087 cmd_flow_director_filter_parsed(void *parsed_result,
11088 __rte_unused struct cmdline *cl,
11089 __rte_unused void *data)
11091 struct cmd_flow_director_result *res = parsed_result;
11092 struct rte_eth_fdir_filter entry;
11093 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11095 unsigned long vf_id;
11098 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11100 printf("flow director is not supported on port %u.\n",
11104 memset(flexbytes, 0, sizeof(flexbytes));
11105 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11107 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11108 if (strcmp(res->mode_value, "MAC-VLAN")) {
11109 printf("Please set mode to MAC-VLAN.\n");
11112 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11113 if (strcmp(res->mode_value, "Tunnel")) {
11114 printf("Please set mode to Tunnel.\n");
11118 if (!strcmp(res->mode_value, "raw")) {
11119 #ifdef RTE_LIBRTE_I40E_PMD
11120 struct rte_pmd_i40e_flow_type_mapping
11121 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11122 struct rte_pmd_i40e_pkt_template_conf conf;
11123 uint16_t flow_type = str2flowtype(res->flow_type);
11124 uint16_t i, port = res->port_id;
11127 memset(&conf, 0, sizeof(conf));
11129 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11130 printf("Invalid flow type specified.\n");
11133 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11137 if (mapping[flow_type].pctype == 0ULL) {
11138 printf("Invalid flow type specified.\n");
11141 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11142 if (mapping[flow_type].pctype & (1ULL << i)) {
11143 conf.input.pctype = i;
11148 conf.input.packet = open_file(res->filepath,
11149 &conf.input.length);
11150 if (!conf.input.packet)
11152 if (!strcmp(res->drop, "drop"))
11153 conf.action.behavior =
11154 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11156 conf.action.behavior =
11157 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11158 conf.action.report_status =
11159 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11160 conf.action.rx_queue = res->queue_id;
11161 conf.soft_id = res->fd_id_value;
11162 add = strcmp(res->ops, "del") ? 1 : 0;
11163 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11167 printf("flow director config error: (%s)\n",
11169 close_file(conf.input.packet);
11172 } else if (strcmp(res->mode_value, "IP")) {
11173 printf("Please set mode to IP or raw.\n");
11176 entry.input.flow_type = str2flowtype(res->flow_type);
11179 ret = parse_flexbytes(res->flexbytes_value,
11181 RTE_ETH_FDIR_MAX_FLEXLEN);
11183 printf("error: Cannot parse flexbytes input.\n");
11187 switch (entry.input.flow_type) {
11188 case RTE_ETH_FLOW_FRAG_IPV4:
11189 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11190 entry.input.flow.ip4_flow.proto = res->proto_value;
11192 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11193 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11194 IPV4_ADDR_TO_UINT(res->ip_dst,
11195 entry.input.flow.ip4_flow.dst_ip);
11196 IPV4_ADDR_TO_UINT(res->ip_src,
11197 entry.input.flow.ip4_flow.src_ip);
11198 entry.input.flow.ip4_flow.tos = res->tos_value;
11199 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11200 /* need convert to big endian. */
11201 entry.input.flow.udp4_flow.dst_port =
11202 rte_cpu_to_be_16(res->port_dst);
11203 entry.input.flow.udp4_flow.src_port =
11204 rte_cpu_to_be_16(res->port_src);
11206 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11207 IPV4_ADDR_TO_UINT(res->ip_dst,
11208 entry.input.flow.sctp4_flow.ip.dst_ip);
11209 IPV4_ADDR_TO_UINT(res->ip_src,
11210 entry.input.flow.sctp4_flow.ip.src_ip);
11211 entry.input.flow.ip4_flow.tos = res->tos_value;
11212 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11213 /* need convert to big endian. */
11214 entry.input.flow.sctp4_flow.dst_port =
11215 rte_cpu_to_be_16(res->port_dst);
11216 entry.input.flow.sctp4_flow.src_port =
11217 rte_cpu_to_be_16(res->port_src);
11218 entry.input.flow.sctp4_flow.verify_tag =
11219 rte_cpu_to_be_32(res->verify_tag_value);
11221 case RTE_ETH_FLOW_FRAG_IPV6:
11222 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11223 entry.input.flow.ipv6_flow.proto = res->proto_value;
11225 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11226 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11227 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11228 entry.input.flow.ipv6_flow.dst_ip);
11229 IPV6_ADDR_TO_ARRAY(res->ip_src,
11230 entry.input.flow.ipv6_flow.src_ip);
11231 entry.input.flow.ipv6_flow.tc = res->tos_value;
11232 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11233 /* need convert to big endian. */
11234 entry.input.flow.udp6_flow.dst_port =
11235 rte_cpu_to_be_16(res->port_dst);
11236 entry.input.flow.udp6_flow.src_port =
11237 rte_cpu_to_be_16(res->port_src);
11239 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11240 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11241 entry.input.flow.sctp6_flow.ip.dst_ip);
11242 IPV6_ADDR_TO_ARRAY(res->ip_src,
11243 entry.input.flow.sctp6_flow.ip.src_ip);
11244 entry.input.flow.ipv6_flow.tc = res->tos_value;
11245 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11246 /* need convert to big endian. */
11247 entry.input.flow.sctp6_flow.dst_port =
11248 rte_cpu_to_be_16(res->port_dst);
11249 entry.input.flow.sctp6_flow.src_port =
11250 rte_cpu_to_be_16(res->port_src);
11251 entry.input.flow.sctp6_flow.verify_tag =
11252 rte_cpu_to_be_32(res->verify_tag_value);
11254 case RTE_ETH_FLOW_L2_PAYLOAD:
11255 entry.input.flow.l2_flow.ether_type =
11256 rte_cpu_to_be_16(res->ether_type);
11262 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11263 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11265 sizeof(struct rte_ether_addr));
11267 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11268 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11270 sizeof(struct rte_ether_addr));
11271 entry.input.flow.tunnel_flow.tunnel_type =
11272 str2fdir_tunneltype(res->tunnel_type);
11273 entry.input.flow.tunnel_flow.tunnel_id =
11274 rte_cpu_to_be_32(res->tunnel_id_value);
11277 rte_memcpy(entry.input.flow_ext.flexbytes,
11279 RTE_ETH_FDIR_MAX_FLEXLEN);
11281 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11283 entry.action.flex_off = 0; /*use 0 by default */
11284 if (!strcmp(res->drop, "drop"))
11285 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11287 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11289 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11290 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11291 if (!strcmp(res->pf_vf, "pf"))
11292 entry.input.flow_ext.is_vf = 0;
11293 else if (!strncmp(res->pf_vf, "vf", 2)) {
11294 struct rte_eth_dev_info dev_info;
11296 ret = eth_dev_info_get_print_err(res->port_id,
11302 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11303 if (errno != 0 || *end != '\0' ||
11304 vf_id >= dev_info.max_vfs) {
11305 printf("invalid parameter %s.\n", res->pf_vf);
11308 entry.input.flow_ext.is_vf = 1;
11309 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11311 printf("invalid parameter %s.\n", res->pf_vf);
11316 /* set to report FD ID by default */
11317 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11318 entry.action.rx_queue = res->queue_id;
11319 entry.soft_id = res->fd_id_value;
11320 if (!strcmp(res->ops, "add"))
11321 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11322 RTE_ETH_FILTER_ADD, &entry);
11323 else if (!strcmp(res->ops, "del"))
11324 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11325 RTE_ETH_FILTER_DELETE, &entry);
11327 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11328 RTE_ETH_FILTER_UPDATE, &entry);
11330 printf("flow director programming error: (%s)\n",
11334 cmdline_parse_token_string_t cmd_flow_director_filter =
11335 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11336 flow_director_filter, "flow_director_filter");
11337 cmdline_parse_token_num_t cmd_flow_director_port_id =
11338 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11340 cmdline_parse_token_string_t cmd_flow_director_ops =
11341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11342 ops, "add#del#update");
11343 cmdline_parse_token_string_t cmd_flow_director_flow =
11344 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11346 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11349 cmdline_parse_token_string_t cmd_flow_director_ether =
11350 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11352 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11353 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11354 ether_type, UINT16);
11355 cmdline_parse_token_string_t cmd_flow_director_src =
11356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11358 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11359 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11361 cmdline_parse_token_num_t cmd_flow_director_port_src =
11362 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11364 cmdline_parse_token_string_t cmd_flow_director_dst =
11365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11367 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11368 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11370 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11371 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11373 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11374 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11375 verify_tag, "verify_tag");
11376 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11377 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11378 verify_tag_value, UINT32);
11379 cmdline_parse_token_string_t cmd_flow_director_tos =
11380 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11382 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11383 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11385 cmdline_parse_token_string_t cmd_flow_director_proto =
11386 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11388 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11389 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11390 proto_value, UINT8);
11391 cmdline_parse_token_string_t cmd_flow_director_ttl =
11392 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11394 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11395 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11397 cmdline_parse_token_string_t cmd_flow_director_vlan =
11398 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11400 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11401 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11402 vlan_value, UINT16);
11403 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11404 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11405 flexbytes, "flexbytes");
11406 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11407 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11408 flexbytes_value, NULL);
11409 cmdline_parse_token_string_t cmd_flow_director_drop =
11410 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11412 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11413 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11415 cmdline_parse_token_string_t cmd_flow_director_queue =
11416 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11418 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11419 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11421 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11422 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11424 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11425 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11426 fd_id_value, UINT32);
11428 cmdline_parse_token_string_t cmd_flow_director_mode =
11429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11431 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11432 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11434 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11435 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11436 mode_value, "MAC-VLAN");
11437 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11439 mode_value, "Tunnel");
11440 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11441 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11442 mode_value, "raw");
11443 cmdline_parse_token_string_t cmd_flow_director_mac =
11444 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11446 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11447 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11449 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11450 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11452 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11453 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11454 tunnel_type, "NVGRE#VxLAN");
11455 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11456 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11457 tunnel_id, "tunnel-id");
11458 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11459 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11460 tunnel_id_value, UINT32);
11461 cmdline_parse_token_string_t cmd_flow_director_packet =
11462 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11464 cmdline_parse_token_string_t cmd_flow_director_filepath =
11465 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11468 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11469 .f = cmd_flow_director_filter_parsed,
11471 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11472 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11473 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11474 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11475 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11476 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11477 "fd_id <fd_id_value>: "
11478 "Add or delete an ip flow director entry on NIC",
11480 (void *)&cmd_flow_director_filter,
11481 (void *)&cmd_flow_director_port_id,
11482 (void *)&cmd_flow_director_mode,
11483 (void *)&cmd_flow_director_mode_ip,
11484 (void *)&cmd_flow_director_ops,
11485 (void *)&cmd_flow_director_flow,
11486 (void *)&cmd_flow_director_flow_type,
11487 (void *)&cmd_flow_director_src,
11488 (void *)&cmd_flow_director_ip_src,
11489 (void *)&cmd_flow_director_dst,
11490 (void *)&cmd_flow_director_ip_dst,
11491 (void *)&cmd_flow_director_tos,
11492 (void *)&cmd_flow_director_tos_value,
11493 (void *)&cmd_flow_director_proto,
11494 (void *)&cmd_flow_director_proto_value,
11495 (void *)&cmd_flow_director_ttl,
11496 (void *)&cmd_flow_director_ttl_value,
11497 (void *)&cmd_flow_director_vlan,
11498 (void *)&cmd_flow_director_vlan_value,
11499 (void *)&cmd_flow_director_flexbytes,
11500 (void *)&cmd_flow_director_flexbytes_value,
11501 (void *)&cmd_flow_director_drop,
11502 (void *)&cmd_flow_director_pf_vf,
11503 (void *)&cmd_flow_director_queue,
11504 (void *)&cmd_flow_director_queue_id,
11505 (void *)&cmd_flow_director_fd_id,
11506 (void *)&cmd_flow_director_fd_id_value,
11511 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11512 .f = cmd_flow_director_filter_parsed,
11514 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11515 "director entry on NIC",
11517 (void *)&cmd_flow_director_filter,
11518 (void *)&cmd_flow_director_port_id,
11519 (void *)&cmd_flow_director_mode,
11520 (void *)&cmd_flow_director_mode_ip,
11521 (void *)&cmd_flow_director_ops,
11522 (void *)&cmd_flow_director_flow,
11523 (void *)&cmd_flow_director_flow_type,
11524 (void *)&cmd_flow_director_src,
11525 (void *)&cmd_flow_director_ip_src,
11526 (void *)&cmd_flow_director_port_src,
11527 (void *)&cmd_flow_director_dst,
11528 (void *)&cmd_flow_director_ip_dst,
11529 (void *)&cmd_flow_director_port_dst,
11530 (void *)&cmd_flow_director_tos,
11531 (void *)&cmd_flow_director_tos_value,
11532 (void *)&cmd_flow_director_ttl,
11533 (void *)&cmd_flow_director_ttl_value,
11534 (void *)&cmd_flow_director_vlan,
11535 (void *)&cmd_flow_director_vlan_value,
11536 (void *)&cmd_flow_director_flexbytes,
11537 (void *)&cmd_flow_director_flexbytes_value,
11538 (void *)&cmd_flow_director_drop,
11539 (void *)&cmd_flow_director_pf_vf,
11540 (void *)&cmd_flow_director_queue,
11541 (void *)&cmd_flow_director_queue_id,
11542 (void *)&cmd_flow_director_fd_id,
11543 (void *)&cmd_flow_director_fd_id_value,
11548 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11549 .f = cmd_flow_director_filter_parsed,
11551 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11552 "director entry on NIC",
11554 (void *)&cmd_flow_director_filter,
11555 (void *)&cmd_flow_director_port_id,
11556 (void *)&cmd_flow_director_mode,
11557 (void *)&cmd_flow_director_mode_ip,
11558 (void *)&cmd_flow_director_ops,
11559 (void *)&cmd_flow_director_flow,
11560 (void *)&cmd_flow_director_flow_type,
11561 (void *)&cmd_flow_director_src,
11562 (void *)&cmd_flow_director_ip_src,
11563 (void *)&cmd_flow_director_port_src,
11564 (void *)&cmd_flow_director_dst,
11565 (void *)&cmd_flow_director_ip_dst,
11566 (void *)&cmd_flow_director_port_dst,
11567 (void *)&cmd_flow_director_verify_tag,
11568 (void *)&cmd_flow_director_verify_tag_value,
11569 (void *)&cmd_flow_director_tos,
11570 (void *)&cmd_flow_director_tos_value,
11571 (void *)&cmd_flow_director_ttl,
11572 (void *)&cmd_flow_director_ttl_value,
11573 (void *)&cmd_flow_director_vlan,
11574 (void *)&cmd_flow_director_vlan_value,
11575 (void *)&cmd_flow_director_flexbytes,
11576 (void *)&cmd_flow_director_flexbytes_value,
11577 (void *)&cmd_flow_director_drop,
11578 (void *)&cmd_flow_director_pf_vf,
11579 (void *)&cmd_flow_director_queue,
11580 (void *)&cmd_flow_director_queue_id,
11581 (void *)&cmd_flow_director_fd_id,
11582 (void *)&cmd_flow_director_fd_id_value,
11587 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11588 .f = cmd_flow_director_filter_parsed,
11590 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11591 "director entry on NIC",
11593 (void *)&cmd_flow_director_filter,
11594 (void *)&cmd_flow_director_port_id,
11595 (void *)&cmd_flow_director_mode,
11596 (void *)&cmd_flow_director_mode_ip,
11597 (void *)&cmd_flow_director_ops,
11598 (void *)&cmd_flow_director_flow,
11599 (void *)&cmd_flow_director_flow_type,
11600 (void *)&cmd_flow_director_ether,
11601 (void *)&cmd_flow_director_ether_type,
11602 (void *)&cmd_flow_director_flexbytes,
11603 (void *)&cmd_flow_director_flexbytes_value,
11604 (void *)&cmd_flow_director_drop,
11605 (void *)&cmd_flow_director_pf_vf,
11606 (void *)&cmd_flow_director_queue,
11607 (void *)&cmd_flow_director_queue_id,
11608 (void *)&cmd_flow_director_fd_id,
11609 (void *)&cmd_flow_director_fd_id_value,
11614 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11615 .f = cmd_flow_director_filter_parsed,
11617 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11618 "director entry on NIC",
11620 (void *)&cmd_flow_director_filter,
11621 (void *)&cmd_flow_director_port_id,
11622 (void *)&cmd_flow_director_mode,
11623 (void *)&cmd_flow_director_mode_mac_vlan,
11624 (void *)&cmd_flow_director_ops,
11625 (void *)&cmd_flow_director_mac,
11626 (void *)&cmd_flow_director_mac_addr,
11627 (void *)&cmd_flow_director_vlan,
11628 (void *)&cmd_flow_director_vlan_value,
11629 (void *)&cmd_flow_director_flexbytes,
11630 (void *)&cmd_flow_director_flexbytes_value,
11631 (void *)&cmd_flow_director_drop,
11632 (void *)&cmd_flow_director_queue,
11633 (void *)&cmd_flow_director_queue_id,
11634 (void *)&cmd_flow_director_fd_id,
11635 (void *)&cmd_flow_director_fd_id_value,
11640 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11641 .f = cmd_flow_director_filter_parsed,
11643 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11644 "director entry on NIC",
11646 (void *)&cmd_flow_director_filter,
11647 (void *)&cmd_flow_director_port_id,
11648 (void *)&cmd_flow_director_mode,
11649 (void *)&cmd_flow_director_mode_tunnel,
11650 (void *)&cmd_flow_director_ops,
11651 (void *)&cmd_flow_director_mac,
11652 (void *)&cmd_flow_director_mac_addr,
11653 (void *)&cmd_flow_director_vlan,
11654 (void *)&cmd_flow_director_vlan_value,
11655 (void *)&cmd_flow_director_tunnel,
11656 (void *)&cmd_flow_director_tunnel_type,
11657 (void *)&cmd_flow_director_tunnel_id,
11658 (void *)&cmd_flow_director_tunnel_id_value,
11659 (void *)&cmd_flow_director_flexbytes,
11660 (void *)&cmd_flow_director_flexbytes_value,
11661 (void *)&cmd_flow_director_drop,
11662 (void *)&cmd_flow_director_queue,
11663 (void *)&cmd_flow_director_queue_id,
11664 (void *)&cmd_flow_director_fd_id,
11665 (void *)&cmd_flow_director_fd_id_value,
11670 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11671 .f = cmd_flow_director_filter_parsed,
11673 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11674 "director entry on NIC",
11676 (void *)&cmd_flow_director_filter,
11677 (void *)&cmd_flow_director_port_id,
11678 (void *)&cmd_flow_director_mode,
11679 (void *)&cmd_flow_director_mode_raw,
11680 (void *)&cmd_flow_director_ops,
11681 (void *)&cmd_flow_director_flow,
11682 (void *)&cmd_flow_director_flow_type,
11683 (void *)&cmd_flow_director_drop,
11684 (void *)&cmd_flow_director_queue,
11685 (void *)&cmd_flow_director_queue_id,
11686 (void *)&cmd_flow_director_fd_id,
11687 (void *)&cmd_flow_director_fd_id_value,
11688 (void *)&cmd_flow_director_packet,
11689 (void *)&cmd_flow_director_filepath,
11694 struct cmd_flush_flow_director_result {
11695 cmdline_fixed_string_t flush_flow_director;
11699 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11700 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11701 flush_flow_director, "flush_flow_director");
11702 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11703 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11707 cmd_flush_flow_director_parsed(void *parsed_result,
11708 __rte_unused struct cmdline *cl,
11709 __rte_unused void *data)
11711 struct cmd_flow_director_result *res = parsed_result;
11714 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11716 printf("flow director is not supported on port %u.\n",
11721 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11722 RTE_ETH_FILTER_FLUSH, NULL);
11724 printf("flow director table flushing error: (%s)\n",
11728 cmdline_parse_inst_t cmd_flush_flow_director = {
11729 .f = cmd_flush_flow_director_parsed,
11731 .help_str = "flush_flow_director <port_id>: "
11732 "Flush all flow director entries of a device on NIC",
11734 (void *)&cmd_flush_flow_director_flush,
11735 (void *)&cmd_flush_flow_director_port_id,
11740 /* *** deal with flow director mask *** */
11741 struct cmd_flow_director_mask_result {
11742 cmdline_fixed_string_t flow_director_mask;
11744 cmdline_fixed_string_t mode;
11745 cmdline_fixed_string_t mode_value;
11746 cmdline_fixed_string_t vlan;
11747 uint16_t vlan_mask;
11748 cmdline_fixed_string_t src_mask;
11749 cmdline_ipaddr_t ipv4_src;
11750 cmdline_ipaddr_t ipv6_src;
11752 cmdline_fixed_string_t dst_mask;
11753 cmdline_ipaddr_t ipv4_dst;
11754 cmdline_ipaddr_t ipv6_dst;
11756 cmdline_fixed_string_t mac;
11757 uint8_t mac_addr_byte_mask;
11758 cmdline_fixed_string_t tunnel_id;
11759 uint32_t tunnel_id_mask;
11760 cmdline_fixed_string_t tunnel_type;
11761 uint8_t tunnel_type_mask;
11765 cmd_flow_director_mask_parsed(void *parsed_result,
11766 __rte_unused struct cmdline *cl,
11767 __rte_unused void *data)
11769 struct cmd_flow_director_mask_result *res = parsed_result;
11770 struct rte_eth_fdir_masks *mask;
11771 struct rte_port *port;
11773 port = &ports[res->port_id];
11774 /** Check if the port is not started **/
11775 if (port->port_status != RTE_PORT_STOPPED) {
11776 printf("Please stop port %d first\n", res->port_id);
11780 mask = &port->dev_conf.fdir_conf.mask;
11782 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11783 if (strcmp(res->mode_value, "MAC-VLAN")) {
11784 printf("Please set mode to MAC-VLAN.\n");
11788 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11789 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11790 if (strcmp(res->mode_value, "Tunnel")) {
11791 printf("Please set mode to Tunnel.\n");
11795 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11796 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11797 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11798 mask->tunnel_type_mask = res->tunnel_type_mask;
11800 if (strcmp(res->mode_value, "IP")) {
11801 printf("Please set mode to IP.\n");
11805 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11806 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11807 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11808 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11809 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11810 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11811 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11814 cmd_reconfig_device_queue(res->port_id, 1, 1);
11817 cmdline_parse_token_string_t cmd_flow_director_mask =
11818 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11819 flow_director_mask, "flow_director_mask");
11820 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11821 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11823 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11824 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11826 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11827 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11828 vlan_mask, UINT16);
11829 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11830 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11831 src_mask, "src_mask");
11832 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11833 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11835 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11836 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11838 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11839 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11841 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11842 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11843 dst_mask, "dst_mask");
11844 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11845 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11847 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11848 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11850 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11851 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11854 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11857 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11860 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11862 mode_value, "MAC-VLAN");
11863 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11865 mode_value, "Tunnel");
11866 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11869 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11870 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11871 mac_addr_byte_mask, UINT8);
11872 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11874 tunnel_type, "tunnel-type");
11875 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11876 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11877 tunnel_type_mask, UINT8);
11878 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11880 tunnel_id, "tunnel-id");
11881 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11882 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11883 tunnel_id_mask, UINT32);
11885 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11886 .f = cmd_flow_director_mask_parsed,
11888 .help_str = "flow_director_mask ... : "
11889 "Set IP mode flow director's mask on NIC",
11891 (void *)&cmd_flow_director_mask,
11892 (void *)&cmd_flow_director_mask_port_id,
11893 (void *)&cmd_flow_director_mask_mode,
11894 (void *)&cmd_flow_director_mask_mode_ip,
11895 (void *)&cmd_flow_director_mask_vlan,
11896 (void *)&cmd_flow_director_mask_vlan_value,
11897 (void *)&cmd_flow_director_mask_src,
11898 (void *)&cmd_flow_director_mask_ipv4_src,
11899 (void *)&cmd_flow_director_mask_ipv6_src,
11900 (void *)&cmd_flow_director_mask_port_src,
11901 (void *)&cmd_flow_director_mask_dst,
11902 (void *)&cmd_flow_director_mask_ipv4_dst,
11903 (void *)&cmd_flow_director_mask_ipv6_dst,
11904 (void *)&cmd_flow_director_mask_port_dst,
11909 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11910 .f = cmd_flow_director_mask_parsed,
11912 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11913 "flow director's mask on NIC",
11915 (void *)&cmd_flow_director_mask,
11916 (void *)&cmd_flow_director_mask_port_id,
11917 (void *)&cmd_flow_director_mask_mode,
11918 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11919 (void *)&cmd_flow_director_mask_vlan,
11920 (void *)&cmd_flow_director_mask_vlan_value,
11925 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11926 .f = cmd_flow_director_mask_parsed,
11928 .help_str = "flow_director_mask ... : Set tunnel mode "
11929 "flow director's mask on NIC",
11931 (void *)&cmd_flow_director_mask,
11932 (void *)&cmd_flow_director_mask_port_id,
11933 (void *)&cmd_flow_director_mask_mode,
11934 (void *)&cmd_flow_director_mask_mode_tunnel,
11935 (void *)&cmd_flow_director_mask_vlan,
11936 (void *)&cmd_flow_director_mask_vlan_value,
11937 (void *)&cmd_flow_director_mask_mac,
11938 (void *)&cmd_flow_director_mask_mac_value,
11939 (void *)&cmd_flow_director_mask_tunnel_type,
11940 (void *)&cmd_flow_director_mask_tunnel_type_value,
11941 (void *)&cmd_flow_director_mask_tunnel_id,
11942 (void *)&cmd_flow_director_mask_tunnel_id_value,
11947 /* *** deal with flow director mask on flexible payload *** */
11948 struct cmd_flow_director_flex_mask_result {
11949 cmdline_fixed_string_t flow_director_flexmask;
11951 cmdline_fixed_string_t flow;
11952 cmdline_fixed_string_t flow_type;
11953 cmdline_fixed_string_t mask;
11957 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11958 __rte_unused struct cmdline *cl,
11959 __rte_unused void *data)
11961 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11962 struct rte_eth_fdir_info fdir_info;
11963 struct rte_eth_fdir_flex_mask flex_mask;
11964 struct rte_port *port;
11965 uint64_t flow_type_mask;
11969 port = &ports[res->port_id];
11970 /** Check if the port is not started **/
11971 if (port->port_status != RTE_PORT_STOPPED) {
11972 printf("Please stop port %d first\n", res->port_id);
11976 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11977 ret = parse_flexbytes(res->mask,
11979 RTE_ETH_FDIR_MAX_FLEXLEN);
11981 printf("error: Cannot parse mask input.\n");
11985 memset(&fdir_info, 0, sizeof(fdir_info));
11986 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11987 RTE_ETH_FILTER_INFO, &fdir_info);
11989 printf("Cannot get FDir filter info\n");
11993 if (!strcmp(res->flow_type, "none")) {
11994 /* means don't specify the flow type */
11995 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11996 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11997 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11998 0, sizeof(struct rte_eth_fdir_flex_mask));
11999 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12000 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12002 sizeof(struct rte_eth_fdir_flex_mask));
12003 cmd_reconfig_device_queue(res->port_id, 1, 1);
12006 flow_type_mask = fdir_info.flow_types_mask[0];
12007 if (!strcmp(res->flow_type, "all")) {
12008 if (!flow_type_mask) {
12009 printf("No flow type supported\n");
12012 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12013 if (flow_type_mask & (1ULL << i)) {
12014 flex_mask.flow_type = i;
12015 fdir_set_flex_mask(res->port_id, &flex_mask);
12018 cmd_reconfig_device_queue(res->port_id, 1, 1);
12021 flex_mask.flow_type = str2flowtype(res->flow_type);
12022 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12023 printf("Flow type %s not supported on port %d\n",
12024 res->flow_type, res->port_id);
12027 fdir_set_flex_mask(res->port_id, &flex_mask);
12028 cmd_reconfig_device_queue(res->port_id, 1, 1);
12031 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12032 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12033 flow_director_flexmask,
12034 "flow_director_flex_mask");
12035 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12036 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12038 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12039 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12041 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12042 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12043 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12044 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12045 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12046 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12049 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12050 .f = cmd_flow_director_flex_mask_parsed,
12052 .help_str = "flow_director_flex_mask ... : "
12053 "Set flow director's flex mask on NIC",
12055 (void *)&cmd_flow_director_flexmask,
12056 (void *)&cmd_flow_director_flexmask_port_id,
12057 (void *)&cmd_flow_director_flexmask_flow,
12058 (void *)&cmd_flow_director_flexmask_flow_type,
12059 (void *)&cmd_flow_director_flexmask_mask,
12064 /* *** deal with flow director flexible payload configuration *** */
12065 struct cmd_flow_director_flexpayload_result {
12066 cmdline_fixed_string_t flow_director_flexpayload;
12068 cmdline_fixed_string_t payload_layer;
12069 cmdline_fixed_string_t payload_cfg;
12073 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12076 const char *p, *p0 = q_arg;
12078 unsigned long int_fld;
12079 char *str_fld[max_num];
12084 p = strchr(p0, '(');
12088 p0 = strchr(p, ')');
12093 if (size >= sizeof(s))
12096 snprintf(s, sizeof(s), "%.*s", size, p);
12097 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12098 if (ret < 0 || ret > max_num)
12100 for (i = 0; i < ret; i++) {
12102 int_fld = strtoul(str_fld[i], &end, 0);
12103 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12105 offsets[i] = (uint16_t)int_fld;
12111 cmd_flow_director_flxpld_parsed(void *parsed_result,
12112 __rte_unused struct cmdline *cl,
12113 __rte_unused void *data)
12115 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12116 struct rte_eth_flex_payload_cfg flex_cfg;
12117 struct rte_port *port;
12120 port = &ports[res->port_id];
12121 /** Check if the port is not started **/
12122 if (port->port_status != RTE_PORT_STOPPED) {
12123 printf("Please stop port %d first\n", res->port_id);
12127 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12129 if (!strcmp(res->payload_layer, "raw"))
12130 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12131 else if (!strcmp(res->payload_layer, "l2"))
12132 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12133 else if (!strcmp(res->payload_layer, "l3"))
12134 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12135 else if (!strcmp(res->payload_layer, "l4"))
12136 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12138 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12139 RTE_ETH_FDIR_MAX_FLEXLEN);
12141 printf("error: Cannot parse flex payload input.\n");
12145 fdir_set_flex_payload(res->port_id, &flex_cfg);
12146 cmd_reconfig_device_queue(res->port_id, 1, 1);
12149 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12150 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12151 flow_director_flexpayload,
12152 "flow_director_flex_payload");
12153 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12154 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12156 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12157 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12158 payload_layer, "raw#l2#l3#l4");
12159 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12160 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12161 payload_cfg, NULL);
12163 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12164 .f = cmd_flow_director_flxpld_parsed,
12166 .help_str = "flow_director_flexpayload ... : "
12167 "Set flow director's flex payload on NIC",
12169 (void *)&cmd_flow_director_flexpayload,
12170 (void *)&cmd_flow_director_flexpayload_port_id,
12171 (void *)&cmd_flow_director_flexpayload_payload_layer,
12172 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12177 /* Generic flow interface command. */
12178 extern cmdline_parse_inst_t cmd_flow;
12180 /* *** Classification Filters Control *** */
12181 /* *** Get symmetric hash enable per port *** */
12182 struct cmd_get_sym_hash_ena_per_port_result {
12183 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12188 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12189 __rte_unused struct cmdline *cl,
12190 __rte_unused void *data)
12192 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12193 struct rte_eth_hash_filter_info info;
12196 if (rte_eth_dev_filter_supported(res->port_id,
12197 RTE_ETH_FILTER_HASH) < 0) {
12198 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12203 memset(&info, 0, sizeof(info));
12204 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12205 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12206 RTE_ETH_FILTER_GET, &info);
12209 printf("Cannot get symmetric hash enable per port "
12210 "on port %u\n", res->port_id);
12214 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12215 "enabled" : "disabled", res->port_id);
12218 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12219 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12220 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12221 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12222 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12225 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12226 .f = cmd_get_sym_hash_per_port_parsed,
12228 .help_str = "get_sym_hash_ena_per_port <port_id>",
12230 (void *)&cmd_get_sym_hash_ena_per_port_all,
12231 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12236 /* *** Set symmetric hash enable per port *** */
12237 struct cmd_set_sym_hash_ena_per_port_result {
12238 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12239 cmdline_fixed_string_t enable;
12244 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12245 __rte_unused struct cmdline *cl,
12246 __rte_unused void *data)
12248 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12249 struct rte_eth_hash_filter_info info;
12252 if (rte_eth_dev_filter_supported(res->port_id,
12253 RTE_ETH_FILTER_HASH) < 0) {
12254 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12259 memset(&info, 0, sizeof(info));
12260 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12261 if (!strcmp(res->enable, "enable"))
12262 info.info.enable = 1;
12263 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12264 RTE_ETH_FILTER_SET, &info);
12266 printf("Cannot set symmetric hash enable per port on "
12267 "port %u\n", res->port_id);
12270 printf("Symmetric hash has been set to %s on port %u\n",
12271 res->enable, res->port_id);
12274 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12275 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12276 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12277 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12278 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12280 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12281 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12282 enable, "enable#disable");
12284 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12285 .f = cmd_set_sym_hash_per_port_parsed,
12287 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12289 (void *)&cmd_set_sym_hash_ena_per_port_all,
12290 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12291 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12296 /* Get global config of hash function */
12297 struct cmd_get_hash_global_config_result {
12298 cmdline_fixed_string_t get_hash_global_config;
12303 flowtype_to_str(uint16_t ftype)
12309 } ftype_table[] = {
12310 {"ipv4", RTE_ETH_FLOW_IPV4},
12311 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12312 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12313 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12314 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12315 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12316 {"ipv6", RTE_ETH_FLOW_IPV6},
12317 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12318 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12319 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12320 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12321 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12322 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12323 {"port", RTE_ETH_FLOW_PORT},
12324 {"vxlan", RTE_ETH_FLOW_VXLAN},
12325 {"geneve", RTE_ETH_FLOW_GENEVE},
12326 {"nvgre", RTE_ETH_FLOW_NVGRE},
12327 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12330 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12331 if (ftype_table[i].ftype == ftype)
12332 return ftype_table[i].str;
12339 cmd_get_hash_global_config_parsed(void *parsed_result,
12340 __rte_unused struct cmdline *cl,
12341 __rte_unused void *data)
12343 struct cmd_get_hash_global_config_result *res = parsed_result;
12344 struct rte_eth_hash_filter_info info;
12345 uint32_t idx, offset;
12350 if (rte_eth_dev_filter_supported(res->port_id,
12351 RTE_ETH_FILTER_HASH) < 0) {
12352 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12357 memset(&info, 0, sizeof(info));
12358 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12359 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12360 RTE_ETH_FILTER_GET, &info);
12362 printf("Cannot get hash global configurations by port %d\n",
12367 switch (info.info.global_conf.hash_func) {
12368 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12369 printf("Hash function is Toeplitz\n");
12371 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12372 printf("Hash function is Simple XOR\n");
12374 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12375 printf("Hash function is Symmetric Toeplitz\n");
12378 printf("Unknown hash function\n");
12382 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12383 idx = i / UINT64_BIT;
12384 offset = i % UINT64_BIT;
12385 if (!(info.info.global_conf.valid_bit_mask[idx] &
12388 str = flowtype_to_str(i);
12391 printf("Symmetric hash is %s globally for flow type %s "
12393 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12394 (1ULL << offset)) ? "enabled" : "disabled"), str,
12399 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12400 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12401 get_hash_global_config, "get_hash_global_config");
12402 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12403 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12406 cmdline_parse_inst_t cmd_get_hash_global_config = {
12407 .f = cmd_get_hash_global_config_parsed,
12409 .help_str = "get_hash_global_config <port_id>",
12411 (void *)&cmd_get_hash_global_config_all,
12412 (void *)&cmd_get_hash_global_config_port_id,
12417 /* Set global config of hash function */
12418 struct cmd_set_hash_global_config_result {
12419 cmdline_fixed_string_t set_hash_global_config;
12421 cmdline_fixed_string_t hash_func;
12422 cmdline_fixed_string_t flow_type;
12423 cmdline_fixed_string_t enable;
12427 cmd_set_hash_global_config_parsed(void *parsed_result,
12428 __rte_unused struct cmdline *cl,
12429 __rte_unused void *data)
12431 struct cmd_set_hash_global_config_result *res = parsed_result;
12432 struct rte_eth_hash_filter_info info;
12433 uint32_t ftype, idx, offset;
12436 if (rte_eth_dev_filter_supported(res->port_id,
12437 RTE_ETH_FILTER_HASH) < 0) {
12438 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12442 memset(&info, 0, sizeof(info));
12443 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12444 if (!strcmp(res->hash_func, "toeplitz"))
12445 info.info.global_conf.hash_func =
12446 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12447 else if (!strcmp(res->hash_func, "simple_xor"))
12448 info.info.global_conf.hash_func =
12449 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12450 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12451 info.info.global_conf.hash_func =
12452 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12453 else if (!strcmp(res->hash_func, "default"))
12454 info.info.global_conf.hash_func =
12455 RTE_ETH_HASH_FUNCTION_DEFAULT;
12457 ftype = str2flowtype(res->flow_type);
12458 idx = ftype / UINT64_BIT;
12459 offset = ftype % UINT64_BIT;
12460 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12461 if (!strcmp(res->enable, "enable"))
12462 info.info.global_conf.sym_hash_enable_mask[idx] |=
12464 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12465 RTE_ETH_FILTER_SET, &info);
12467 printf("Cannot set global hash configurations by port %d\n",
12470 printf("Global hash configurations have been set "
12471 "successfully by port %d\n", res->port_id);
12474 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12475 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12476 set_hash_global_config, "set_hash_global_config");
12477 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12478 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12480 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12481 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12482 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12483 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12484 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12486 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12487 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12488 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12489 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12490 enable, "enable#disable");
12492 cmdline_parse_inst_t cmd_set_hash_global_config = {
12493 .f = cmd_set_hash_global_config_parsed,
12495 .help_str = "set_hash_global_config <port_id> "
12496 "toeplitz|simple_xor|symmetric_toeplitz|default "
12497 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12498 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12499 "l2_payload enable|disable",
12501 (void *)&cmd_set_hash_global_config_all,
12502 (void *)&cmd_set_hash_global_config_port_id,
12503 (void *)&cmd_set_hash_global_config_hash_func,
12504 (void *)&cmd_set_hash_global_config_flow_type,
12505 (void *)&cmd_set_hash_global_config_enable,
12510 /* Set hash input set */
12511 struct cmd_set_hash_input_set_result {
12512 cmdline_fixed_string_t set_hash_input_set;
12514 cmdline_fixed_string_t flow_type;
12515 cmdline_fixed_string_t inset_field;
12516 cmdline_fixed_string_t select;
12519 static enum rte_eth_input_set_field
12520 str2inset(char *string)
12524 static const struct {
12526 enum rte_eth_input_set_field inset;
12527 } inset_table[] = {
12528 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12529 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12530 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12531 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12532 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12533 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12534 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12535 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12536 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12537 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12538 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12539 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12540 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12541 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12542 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12543 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12544 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12545 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12546 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12547 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12548 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12549 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12550 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12551 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12552 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12553 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12554 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12555 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12556 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12557 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12558 {"none", RTE_ETH_INPUT_SET_NONE},
12561 for (i = 0; i < RTE_DIM(inset_table); i++) {
12562 if (!strcmp(string, inset_table[i].str))
12563 return inset_table[i].inset;
12566 return RTE_ETH_INPUT_SET_UNKNOWN;
12570 cmd_set_hash_input_set_parsed(void *parsed_result,
12571 __rte_unused struct cmdline *cl,
12572 __rte_unused void *data)
12574 struct cmd_set_hash_input_set_result *res = parsed_result;
12575 struct rte_eth_hash_filter_info info;
12577 memset(&info, 0, sizeof(info));
12578 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12579 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12580 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12581 info.info.input_set_conf.inset_size = 1;
12582 if (!strcmp(res->select, "select"))
12583 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12584 else if (!strcmp(res->select, "add"))
12585 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12586 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12587 RTE_ETH_FILTER_SET, &info);
12590 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12591 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12592 set_hash_input_set, "set_hash_input_set");
12593 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12594 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12596 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12597 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12599 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12600 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12602 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12603 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12604 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12605 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12606 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12608 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12609 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12610 select, "select#add");
12612 cmdline_parse_inst_t cmd_set_hash_input_set = {
12613 .f = cmd_set_hash_input_set_parsed,
12615 .help_str = "set_hash_input_set <port_id> "
12616 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12617 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12618 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12619 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12620 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12621 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12622 "fld-7th|fld-8th|none select|add",
12624 (void *)&cmd_set_hash_input_set_cmd,
12625 (void *)&cmd_set_hash_input_set_port_id,
12626 (void *)&cmd_set_hash_input_set_flow_type,
12627 (void *)&cmd_set_hash_input_set_field,
12628 (void *)&cmd_set_hash_input_set_select,
12633 /* Set flow director input set */
12634 struct cmd_set_fdir_input_set_result {
12635 cmdline_fixed_string_t set_fdir_input_set;
12637 cmdline_fixed_string_t flow_type;
12638 cmdline_fixed_string_t inset_field;
12639 cmdline_fixed_string_t select;
12643 cmd_set_fdir_input_set_parsed(void *parsed_result,
12644 __rte_unused struct cmdline *cl,
12645 __rte_unused void *data)
12647 struct cmd_set_fdir_input_set_result *res = parsed_result;
12648 struct rte_eth_fdir_filter_info info;
12650 memset(&info, 0, sizeof(info));
12651 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12652 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12653 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12654 info.info.input_set_conf.inset_size = 1;
12655 if (!strcmp(res->select, "select"))
12656 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12657 else if (!strcmp(res->select, "add"))
12658 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12659 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12660 RTE_ETH_FILTER_SET, &info);
12663 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12664 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12665 set_fdir_input_set, "set_fdir_input_set");
12666 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12667 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12669 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12670 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12672 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12673 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12674 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12675 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12677 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12678 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12679 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12680 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12681 "sctp-veri-tag#none");
12682 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12683 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12684 select, "select#add");
12686 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12687 .f = cmd_set_fdir_input_set_parsed,
12689 .help_str = "set_fdir_input_set <port_id> "
12690 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12691 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12692 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12693 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12694 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12695 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12696 "sctp-veri-tag|none select|add",
12698 (void *)&cmd_set_fdir_input_set_cmd,
12699 (void *)&cmd_set_fdir_input_set_port_id,
12700 (void *)&cmd_set_fdir_input_set_flow_type,
12701 (void *)&cmd_set_fdir_input_set_field,
12702 (void *)&cmd_set_fdir_input_set_select,
12707 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12708 struct cmd_mcast_addr_result {
12709 cmdline_fixed_string_t mcast_addr_cmd;
12710 cmdline_fixed_string_t what;
12712 struct rte_ether_addr mc_addr;
12715 static void cmd_mcast_addr_parsed(void *parsed_result,
12716 __rte_unused struct cmdline *cl,
12717 __rte_unused void *data)
12719 struct cmd_mcast_addr_result *res = parsed_result;
12721 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12722 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12723 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12724 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12725 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12728 if (strcmp(res->what, "add") == 0)
12729 mcast_addr_add(res->port_num, &res->mc_addr);
12731 mcast_addr_remove(res->port_num, &res->mc_addr);
12734 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12735 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12736 mcast_addr_cmd, "mcast_addr");
12737 cmdline_parse_token_string_t cmd_mcast_addr_what =
12738 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12740 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12741 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12742 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12743 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12745 cmdline_parse_inst_t cmd_mcast_addr = {
12746 .f = cmd_mcast_addr_parsed,
12748 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12749 "Add/Remove multicast MAC address on port_id",
12751 (void *)&cmd_mcast_addr_cmd,
12752 (void *)&cmd_mcast_addr_what,
12753 (void *)&cmd_mcast_addr_portnum,
12754 (void *)&cmd_mcast_addr_addr,
12759 /* l2 tunnel config
12760 * only support E-tag now.
12763 /* Ether type config */
12764 struct cmd_config_l2_tunnel_eth_type_result {
12765 cmdline_fixed_string_t port;
12766 cmdline_fixed_string_t config;
12767 cmdline_fixed_string_t all;
12769 cmdline_fixed_string_t l2_tunnel;
12770 cmdline_fixed_string_t l2_tunnel_type;
12771 cmdline_fixed_string_t eth_type;
12772 uint16_t eth_type_val;
12775 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12776 TOKEN_STRING_INITIALIZER
12777 (struct cmd_config_l2_tunnel_eth_type_result,
12779 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12780 TOKEN_STRING_INITIALIZER
12781 (struct cmd_config_l2_tunnel_eth_type_result,
12783 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12784 TOKEN_STRING_INITIALIZER
12785 (struct cmd_config_l2_tunnel_eth_type_result,
12787 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12788 TOKEN_NUM_INITIALIZER
12789 (struct cmd_config_l2_tunnel_eth_type_result,
12791 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12792 TOKEN_STRING_INITIALIZER
12793 (struct cmd_config_l2_tunnel_eth_type_result,
12794 l2_tunnel, "l2-tunnel");
12795 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12796 TOKEN_STRING_INITIALIZER
12797 (struct cmd_config_l2_tunnel_eth_type_result,
12798 l2_tunnel_type, "E-tag");
12799 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12800 TOKEN_STRING_INITIALIZER
12801 (struct cmd_config_l2_tunnel_eth_type_result,
12802 eth_type, "ether-type");
12803 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12804 TOKEN_NUM_INITIALIZER
12805 (struct cmd_config_l2_tunnel_eth_type_result,
12806 eth_type_val, UINT16);
12808 static enum rte_eth_tunnel_type
12809 str2fdir_l2_tunnel_type(char *string)
12813 static const struct {
12815 enum rte_eth_tunnel_type type;
12816 } l2_tunnel_type_str[] = {
12817 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12820 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12821 if (!strcmp(l2_tunnel_type_str[i].str, string))
12822 return l2_tunnel_type_str[i].type;
12824 return RTE_TUNNEL_TYPE_NONE;
12827 /* ether type config for all ports */
12829 cmd_config_l2_tunnel_eth_type_all_parsed
12830 (void *parsed_result,
12831 __rte_unused struct cmdline *cl,
12832 __rte_unused void *data)
12834 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12835 struct rte_eth_l2_tunnel_conf entry;
12838 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12839 entry.ether_type = res->eth_type_val;
12841 RTE_ETH_FOREACH_DEV(pid) {
12842 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12846 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12847 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12849 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12851 (void *)&cmd_config_l2_tunnel_eth_type_port,
12852 (void *)&cmd_config_l2_tunnel_eth_type_config,
12853 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12854 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12855 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12856 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12857 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12862 /* ether type config for a specific port */
12864 cmd_config_l2_tunnel_eth_type_specific_parsed(
12865 void *parsed_result,
12866 __rte_unused struct cmdline *cl,
12867 __rte_unused void *data)
12869 struct cmd_config_l2_tunnel_eth_type_result *res =
12871 struct rte_eth_l2_tunnel_conf entry;
12873 if (port_id_is_invalid(res->id, ENABLED_WARN))
12876 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12877 entry.ether_type = res->eth_type_val;
12879 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12882 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12883 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12885 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12887 (void *)&cmd_config_l2_tunnel_eth_type_port,
12888 (void *)&cmd_config_l2_tunnel_eth_type_config,
12889 (void *)&cmd_config_l2_tunnel_eth_type_id,
12890 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12891 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12892 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12893 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12898 /* Enable/disable l2 tunnel */
12899 struct cmd_config_l2_tunnel_en_dis_result {
12900 cmdline_fixed_string_t port;
12901 cmdline_fixed_string_t config;
12902 cmdline_fixed_string_t all;
12904 cmdline_fixed_string_t l2_tunnel;
12905 cmdline_fixed_string_t l2_tunnel_type;
12906 cmdline_fixed_string_t en_dis;
12909 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12910 TOKEN_STRING_INITIALIZER
12911 (struct cmd_config_l2_tunnel_en_dis_result,
12913 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12914 TOKEN_STRING_INITIALIZER
12915 (struct cmd_config_l2_tunnel_en_dis_result,
12917 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12918 TOKEN_STRING_INITIALIZER
12919 (struct cmd_config_l2_tunnel_en_dis_result,
12921 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12922 TOKEN_NUM_INITIALIZER
12923 (struct cmd_config_l2_tunnel_en_dis_result,
12925 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12926 TOKEN_STRING_INITIALIZER
12927 (struct cmd_config_l2_tunnel_en_dis_result,
12928 l2_tunnel, "l2-tunnel");
12929 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12930 TOKEN_STRING_INITIALIZER
12931 (struct cmd_config_l2_tunnel_en_dis_result,
12932 l2_tunnel_type, "E-tag");
12933 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12934 TOKEN_STRING_INITIALIZER
12935 (struct cmd_config_l2_tunnel_en_dis_result,
12936 en_dis, "enable#disable");
12938 /* enable/disable l2 tunnel for all ports */
12940 cmd_config_l2_tunnel_en_dis_all_parsed(
12941 void *parsed_result,
12942 __rte_unused struct cmdline *cl,
12943 __rte_unused void *data)
12945 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12946 struct rte_eth_l2_tunnel_conf entry;
12950 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12952 if (!strcmp("enable", res->en_dis))
12957 RTE_ETH_FOREACH_DEV(pid) {
12958 rte_eth_dev_l2_tunnel_offload_set(pid,
12960 ETH_L2_TUNNEL_ENABLE_MASK,
12965 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12966 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12968 .help_str = "port config all l2-tunnel E-tag enable|disable",
12970 (void *)&cmd_config_l2_tunnel_en_dis_port,
12971 (void *)&cmd_config_l2_tunnel_en_dis_config,
12972 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12973 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12974 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12975 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12980 /* enable/disable l2 tunnel for a port */
12982 cmd_config_l2_tunnel_en_dis_specific_parsed(
12983 void *parsed_result,
12984 __rte_unused struct cmdline *cl,
12985 __rte_unused void *data)
12987 struct cmd_config_l2_tunnel_en_dis_result *res =
12989 struct rte_eth_l2_tunnel_conf entry;
12991 if (port_id_is_invalid(res->id, ENABLED_WARN))
12994 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12996 if (!strcmp("enable", res->en_dis))
12997 rte_eth_dev_l2_tunnel_offload_set(res->id,
12999 ETH_L2_TUNNEL_ENABLE_MASK,
13002 rte_eth_dev_l2_tunnel_offload_set(res->id,
13004 ETH_L2_TUNNEL_ENABLE_MASK,
13008 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13009 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13011 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13013 (void *)&cmd_config_l2_tunnel_en_dis_port,
13014 (void *)&cmd_config_l2_tunnel_en_dis_config,
13015 (void *)&cmd_config_l2_tunnel_en_dis_id,
13016 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13017 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13018 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13023 /* E-tag configuration */
13025 /* Common result structure for all E-tag configuration */
13026 struct cmd_config_e_tag_result {
13027 cmdline_fixed_string_t e_tag;
13028 cmdline_fixed_string_t set;
13029 cmdline_fixed_string_t insertion;
13030 cmdline_fixed_string_t stripping;
13031 cmdline_fixed_string_t forwarding;
13032 cmdline_fixed_string_t filter;
13033 cmdline_fixed_string_t add;
13034 cmdline_fixed_string_t del;
13035 cmdline_fixed_string_t on;
13036 cmdline_fixed_string_t off;
13037 cmdline_fixed_string_t on_off;
13038 cmdline_fixed_string_t port_tag_id;
13039 uint32_t port_tag_id_val;
13040 cmdline_fixed_string_t e_tag_id;
13041 uint16_t e_tag_id_val;
13042 cmdline_fixed_string_t dst_pool;
13043 uint8_t dst_pool_val;
13044 cmdline_fixed_string_t port;
13046 cmdline_fixed_string_t vf;
13050 /* Common CLI fields for all E-tag configuration */
13051 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13052 TOKEN_STRING_INITIALIZER
13053 (struct cmd_config_e_tag_result,
13055 cmdline_parse_token_string_t cmd_config_e_tag_set =
13056 TOKEN_STRING_INITIALIZER
13057 (struct cmd_config_e_tag_result,
13059 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13060 TOKEN_STRING_INITIALIZER
13061 (struct cmd_config_e_tag_result,
13062 insertion, "insertion");
13063 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13064 TOKEN_STRING_INITIALIZER
13065 (struct cmd_config_e_tag_result,
13066 stripping, "stripping");
13067 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13068 TOKEN_STRING_INITIALIZER
13069 (struct cmd_config_e_tag_result,
13070 forwarding, "forwarding");
13071 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13072 TOKEN_STRING_INITIALIZER
13073 (struct cmd_config_e_tag_result,
13075 cmdline_parse_token_string_t cmd_config_e_tag_add =
13076 TOKEN_STRING_INITIALIZER
13077 (struct cmd_config_e_tag_result,
13079 cmdline_parse_token_string_t cmd_config_e_tag_del =
13080 TOKEN_STRING_INITIALIZER
13081 (struct cmd_config_e_tag_result,
13083 cmdline_parse_token_string_t cmd_config_e_tag_on =
13084 TOKEN_STRING_INITIALIZER
13085 (struct cmd_config_e_tag_result,
13087 cmdline_parse_token_string_t cmd_config_e_tag_off =
13088 TOKEN_STRING_INITIALIZER
13089 (struct cmd_config_e_tag_result,
13091 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13092 TOKEN_STRING_INITIALIZER
13093 (struct cmd_config_e_tag_result,
13095 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13096 TOKEN_STRING_INITIALIZER
13097 (struct cmd_config_e_tag_result,
13098 port_tag_id, "port-tag-id");
13099 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13100 TOKEN_NUM_INITIALIZER
13101 (struct cmd_config_e_tag_result,
13102 port_tag_id_val, UINT32);
13103 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13104 TOKEN_STRING_INITIALIZER
13105 (struct cmd_config_e_tag_result,
13106 e_tag_id, "e-tag-id");
13107 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13108 TOKEN_NUM_INITIALIZER
13109 (struct cmd_config_e_tag_result,
13110 e_tag_id_val, UINT16);
13111 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13112 TOKEN_STRING_INITIALIZER
13113 (struct cmd_config_e_tag_result,
13114 dst_pool, "dst-pool");
13115 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13116 TOKEN_NUM_INITIALIZER
13117 (struct cmd_config_e_tag_result,
13118 dst_pool_val, UINT8);
13119 cmdline_parse_token_string_t cmd_config_e_tag_port =
13120 TOKEN_STRING_INITIALIZER
13121 (struct cmd_config_e_tag_result,
13123 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13124 TOKEN_NUM_INITIALIZER
13125 (struct cmd_config_e_tag_result,
13127 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13128 TOKEN_STRING_INITIALIZER
13129 (struct cmd_config_e_tag_result,
13131 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13132 TOKEN_NUM_INITIALIZER
13133 (struct cmd_config_e_tag_result,
13136 /* E-tag insertion configuration */
13138 cmd_config_e_tag_insertion_en_parsed(
13139 void *parsed_result,
13140 __rte_unused struct cmdline *cl,
13141 __rte_unused void *data)
13143 struct cmd_config_e_tag_result *res =
13145 struct rte_eth_l2_tunnel_conf entry;
13147 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13150 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13151 entry.tunnel_id = res->port_tag_id_val;
13152 entry.vf_id = res->vf_id;
13153 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13155 ETH_L2_TUNNEL_INSERTION_MASK,
13160 cmd_config_e_tag_insertion_dis_parsed(
13161 void *parsed_result,
13162 __rte_unused struct cmdline *cl,
13163 __rte_unused void *data)
13165 struct cmd_config_e_tag_result *res =
13167 struct rte_eth_l2_tunnel_conf entry;
13169 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13172 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13173 entry.vf_id = res->vf_id;
13175 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13177 ETH_L2_TUNNEL_INSERTION_MASK,
13181 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13182 .f = cmd_config_e_tag_insertion_en_parsed,
13184 .help_str = "E-tag ... : E-tag insertion enable",
13186 (void *)&cmd_config_e_tag_e_tag,
13187 (void *)&cmd_config_e_tag_set,
13188 (void *)&cmd_config_e_tag_insertion,
13189 (void *)&cmd_config_e_tag_on,
13190 (void *)&cmd_config_e_tag_port_tag_id,
13191 (void *)&cmd_config_e_tag_port_tag_id_val,
13192 (void *)&cmd_config_e_tag_port,
13193 (void *)&cmd_config_e_tag_port_id,
13194 (void *)&cmd_config_e_tag_vf,
13195 (void *)&cmd_config_e_tag_vf_id,
13200 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13201 .f = cmd_config_e_tag_insertion_dis_parsed,
13203 .help_str = "E-tag ... : E-tag insertion disable",
13205 (void *)&cmd_config_e_tag_e_tag,
13206 (void *)&cmd_config_e_tag_set,
13207 (void *)&cmd_config_e_tag_insertion,
13208 (void *)&cmd_config_e_tag_off,
13209 (void *)&cmd_config_e_tag_port,
13210 (void *)&cmd_config_e_tag_port_id,
13211 (void *)&cmd_config_e_tag_vf,
13212 (void *)&cmd_config_e_tag_vf_id,
13217 /* E-tag stripping configuration */
13219 cmd_config_e_tag_stripping_parsed(
13220 void *parsed_result,
13221 __rte_unused struct cmdline *cl,
13222 __rte_unused void *data)
13224 struct cmd_config_e_tag_result *res =
13226 struct rte_eth_l2_tunnel_conf entry;
13228 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13231 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13233 if (!strcmp(res->on_off, "on"))
13234 rte_eth_dev_l2_tunnel_offload_set
13237 ETH_L2_TUNNEL_STRIPPING_MASK,
13240 rte_eth_dev_l2_tunnel_offload_set
13243 ETH_L2_TUNNEL_STRIPPING_MASK,
13247 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13248 .f = cmd_config_e_tag_stripping_parsed,
13250 .help_str = "E-tag ... : E-tag stripping enable/disable",
13252 (void *)&cmd_config_e_tag_e_tag,
13253 (void *)&cmd_config_e_tag_set,
13254 (void *)&cmd_config_e_tag_stripping,
13255 (void *)&cmd_config_e_tag_on_off,
13256 (void *)&cmd_config_e_tag_port,
13257 (void *)&cmd_config_e_tag_port_id,
13262 /* E-tag forwarding configuration */
13264 cmd_config_e_tag_forwarding_parsed(
13265 void *parsed_result,
13266 __rte_unused struct cmdline *cl,
13267 __rte_unused void *data)
13269 struct cmd_config_e_tag_result *res = parsed_result;
13270 struct rte_eth_l2_tunnel_conf entry;
13272 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13275 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13277 if (!strcmp(res->on_off, "on"))
13278 rte_eth_dev_l2_tunnel_offload_set
13281 ETH_L2_TUNNEL_FORWARDING_MASK,
13284 rte_eth_dev_l2_tunnel_offload_set
13287 ETH_L2_TUNNEL_FORWARDING_MASK,
13291 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13292 .f = cmd_config_e_tag_forwarding_parsed,
13294 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13296 (void *)&cmd_config_e_tag_e_tag,
13297 (void *)&cmd_config_e_tag_set,
13298 (void *)&cmd_config_e_tag_forwarding,
13299 (void *)&cmd_config_e_tag_on_off,
13300 (void *)&cmd_config_e_tag_port,
13301 (void *)&cmd_config_e_tag_port_id,
13306 /* E-tag filter configuration */
13308 cmd_config_e_tag_filter_add_parsed(
13309 void *parsed_result,
13310 __rte_unused struct cmdline *cl,
13311 __rte_unused void *data)
13313 struct cmd_config_e_tag_result *res = parsed_result;
13314 struct rte_eth_l2_tunnel_conf entry;
13317 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13320 if (res->e_tag_id_val > 0x3fff) {
13321 printf("e-tag-id must be equal or less than 0x3fff.\n");
13325 ret = rte_eth_dev_filter_supported(res->port_id,
13326 RTE_ETH_FILTER_L2_TUNNEL);
13328 printf("E-tag filter is not supported on port %u.\n",
13333 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13334 entry.tunnel_id = res->e_tag_id_val;
13335 entry.pool = res->dst_pool_val;
13337 ret = rte_eth_dev_filter_ctrl(res->port_id,
13338 RTE_ETH_FILTER_L2_TUNNEL,
13339 RTE_ETH_FILTER_ADD,
13342 printf("E-tag filter programming error: (%s)\n",
13346 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13347 .f = cmd_config_e_tag_filter_add_parsed,
13349 .help_str = "E-tag ... : E-tag filter add",
13351 (void *)&cmd_config_e_tag_e_tag,
13352 (void *)&cmd_config_e_tag_set,
13353 (void *)&cmd_config_e_tag_filter,
13354 (void *)&cmd_config_e_tag_add,
13355 (void *)&cmd_config_e_tag_e_tag_id,
13356 (void *)&cmd_config_e_tag_e_tag_id_val,
13357 (void *)&cmd_config_e_tag_dst_pool,
13358 (void *)&cmd_config_e_tag_dst_pool_val,
13359 (void *)&cmd_config_e_tag_port,
13360 (void *)&cmd_config_e_tag_port_id,
13366 cmd_config_e_tag_filter_del_parsed(
13367 void *parsed_result,
13368 __rte_unused struct cmdline *cl,
13369 __rte_unused void *data)
13371 struct cmd_config_e_tag_result *res = parsed_result;
13372 struct rte_eth_l2_tunnel_conf entry;
13375 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13378 if (res->e_tag_id_val > 0x3fff) {
13379 printf("e-tag-id must be less than 0x3fff.\n");
13383 ret = rte_eth_dev_filter_supported(res->port_id,
13384 RTE_ETH_FILTER_L2_TUNNEL);
13386 printf("E-tag filter is not supported on port %u.\n",
13391 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13392 entry.tunnel_id = res->e_tag_id_val;
13394 ret = rte_eth_dev_filter_ctrl(res->port_id,
13395 RTE_ETH_FILTER_L2_TUNNEL,
13396 RTE_ETH_FILTER_DELETE,
13399 printf("E-tag filter programming error: (%s)\n",
13403 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13404 .f = cmd_config_e_tag_filter_del_parsed,
13406 .help_str = "E-tag ... : E-tag filter delete",
13408 (void *)&cmd_config_e_tag_e_tag,
13409 (void *)&cmd_config_e_tag_set,
13410 (void *)&cmd_config_e_tag_filter,
13411 (void *)&cmd_config_e_tag_del,
13412 (void *)&cmd_config_e_tag_e_tag_id,
13413 (void *)&cmd_config_e_tag_e_tag_id_val,
13414 (void *)&cmd_config_e_tag_port,
13415 (void *)&cmd_config_e_tag_port_id,
13420 /* vf vlan anti spoof configuration */
13422 /* Common result structure for vf vlan anti spoof */
13423 struct cmd_vf_vlan_anti_spoof_result {
13424 cmdline_fixed_string_t set;
13425 cmdline_fixed_string_t vf;
13426 cmdline_fixed_string_t vlan;
13427 cmdline_fixed_string_t antispoof;
13430 cmdline_fixed_string_t on_off;
13433 /* Common CLI fields for vf vlan anti spoof enable disable */
13434 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13435 TOKEN_STRING_INITIALIZER
13436 (struct cmd_vf_vlan_anti_spoof_result,
13438 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13439 TOKEN_STRING_INITIALIZER
13440 (struct cmd_vf_vlan_anti_spoof_result,
13442 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13443 TOKEN_STRING_INITIALIZER
13444 (struct cmd_vf_vlan_anti_spoof_result,
13446 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13447 TOKEN_STRING_INITIALIZER
13448 (struct cmd_vf_vlan_anti_spoof_result,
13449 antispoof, "antispoof");
13450 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13451 TOKEN_NUM_INITIALIZER
13452 (struct cmd_vf_vlan_anti_spoof_result,
13454 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13455 TOKEN_NUM_INITIALIZER
13456 (struct cmd_vf_vlan_anti_spoof_result,
13458 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13459 TOKEN_STRING_INITIALIZER
13460 (struct cmd_vf_vlan_anti_spoof_result,
13464 cmd_set_vf_vlan_anti_spoof_parsed(
13465 void *parsed_result,
13466 __rte_unused struct cmdline *cl,
13467 __rte_unused void *data)
13469 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13470 int ret = -ENOTSUP;
13472 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13474 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13477 #ifdef RTE_LIBRTE_IXGBE_PMD
13478 if (ret == -ENOTSUP)
13479 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13480 res->vf_id, is_on);
13482 #ifdef RTE_LIBRTE_I40E_PMD
13483 if (ret == -ENOTSUP)
13484 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13485 res->vf_id, is_on);
13487 #ifdef RTE_LIBRTE_BNXT_PMD
13488 if (ret == -ENOTSUP)
13489 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13490 res->vf_id, is_on);
13497 printf("invalid vf_id %d\n", res->vf_id);
13500 printf("invalid port_id %d\n", res->port_id);
13503 printf("function not implemented\n");
13506 printf("programming error: (%s)\n", strerror(-ret));
13510 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13511 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13513 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13515 (void *)&cmd_vf_vlan_anti_spoof_set,
13516 (void *)&cmd_vf_vlan_anti_spoof_vf,
13517 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13518 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13519 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13520 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13521 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13526 /* vf mac anti spoof configuration */
13528 /* Common result structure for vf mac anti spoof */
13529 struct cmd_vf_mac_anti_spoof_result {
13530 cmdline_fixed_string_t set;
13531 cmdline_fixed_string_t vf;
13532 cmdline_fixed_string_t mac;
13533 cmdline_fixed_string_t antispoof;
13536 cmdline_fixed_string_t on_off;
13539 /* Common CLI fields for vf mac anti spoof enable disable */
13540 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13541 TOKEN_STRING_INITIALIZER
13542 (struct cmd_vf_mac_anti_spoof_result,
13544 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13545 TOKEN_STRING_INITIALIZER
13546 (struct cmd_vf_mac_anti_spoof_result,
13548 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13549 TOKEN_STRING_INITIALIZER
13550 (struct cmd_vf_mac_anti_spoof_result,
13552 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13553 TOKEN_STRING_INITIALIZER
13554 (struct cmd_vf_mac_anti_spoof_result,
13555 antispoof, "antispoof");
13556 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13557 TOKEN_NUM_INITIALIZER
13558 (struct cmd_vf_mac_anti_spoof_result,
13560 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13561 TOKEN_NUM_INITIALIZER
13562 (struct cmd_vf_mac_anti_spoof_result,
13564 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13565 TOKEN_STRING_INITIALIZER
13566 (struct cmd_vf_mac_anti_spoof_result,
13570 cmd_set_vf_mac_anti_spoof_parsed(
13571 void *parsed_result,
13572 __rte_unused struct cmdline *cl,
13573 __rte_unused void *data)
13575 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13576 int ret = -ENOTSUP;
13578 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13580 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13583 #ifdef RTE_LIBRTE_IXGBE_PMD
13584 if (ret == -ENOTSUP)
13585 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13586 res->vf_id, is_on);
13588 #ifdef RTE_LIBRTE_I40E_PMD
13589 if (ret == -ENOTSUP)
13590 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13591 res->vf_id, is_on);
13593 #ifdef RTE_LIBRTE_BNXT_PMD
13594 if (ret == -ENOTSUP)
13595 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13596 res->vf_id, is_on);
13603 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13606 printf("invalid port_id %d\n", res->port_id);
13609 printf("function not implemented\n");
13612 printf("programming error: (%s)\n", strerror(-ret));
13616 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13617 .f = cmd_set_vf_mac_anti_spoof_parsed,
13619 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13621 (void *)&cmd_vf_mac_anti_spoof_set,
13622 (void *)&cmd_vf_mac_anti_spoof_vf,
13623 (void *)&cmd_vf_mac_anti_spoof_mac,
13624 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13625 (void *)&cmd_vf_mac_anti_spoof_port_id,
13626 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13627 (void *)&cmd_vf_mac_anti_spoof_on_off,
13632 /* vf vlan strip queue configuration */
13634 /* Common result structure for vf mac anti spoof */
13635 struct cmd_vf_vlan_stripq_result {
13636 cmdline_fixed_string_t set;
13637 cmdline_fixed_string_t vf;
13638 cmdline_fixed_string_t vlan;
13639 cmdline_fixed_string_t stripq;
13642 cmdline_fixed_string_t on_off;
13645 /* Common CLI fields for vf vlan strip enable disable */
13646 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13647 TOKEN_STRING_INITIALIZER
13648 (struct cmd_vf_vlan_stripq_result,
13650 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13651 TOKEN_STRING_INITIALIZER
13652 (struct cmd_vf_vlan_stripq_result,
13654 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13655 TOKEN_STRING_INITIALIZER
13656 (struct cmd_vf_vlan_stripq_result,
13658 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13659 TOKEN_STRING_INITIALIZER
13660 (struct cmd_vf_vlan_stripq_result,
13662 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13663 TOKEN_NUM_INITIALIZER
13664 (struct cmd_vf_vlan_stripq_result,
13666 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13667 TOKEN_NUM_INITIALIZER
13668 (struct cmd_vf_vlan_stripq_result,
13670 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13671 TOKEN_STRING_INITIALIZER
13672 (struct cmd_vf_vlan_stripq_result,
13676 cmd_set_vf_vlan_stripq_parsed(
13677 void *parsed_result,
13678 __rte_unused struct cmdline *cl,
13679 __rte_unused void *data)
13681 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13682 int ret = -ENOTSUP;
13684 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13686 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13689 #ifdef RTE_LIBRTE_IXGBE_PMD
13690 if (ret == -ENOTSUP)
13691 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13692 res->vf_id, is_on);
13694 #ifdef RTE_LIBRTE_I40E_PMD
13695 if (ret == -ENOTSUP)
13696 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13697 res->vf_id, is_on);
13699 #ifdef RTE_LIBRTE_BNXT_PMD
13700 if (ret == -ENOTSUP)
13701 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13702 res->vf_id, is_on);
13709 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13712 printf("invalid port_id %d\n", res->port_id);
13715 printf("function not implemented\n");
13718 printf("programming error: (%s)\n", strerror(-ret));
13722 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13723 .f = cmd_set_vf_vlan_stripq_parsed,
13725 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13727 (void *)&cmd_vf_vlan_stripq_set,
13728 (void *)&cmd_vf_vlan_stripq_vf,
13729 (void *)&cmd_vf_vlan_stripq_vlan,
13730 (void *)&cmd_vf_vlan_stripq_stripq,
13731 (void *)&cmd_vf_vlan_stripq_port_id,
13732 (void *)&cmd_vf_vlan_stripq_vf_id,
13733 (void *)&cmd_vf_vlan_stripq_on_off,
13738 /* vf vlan insert configuration */
13740 /* Common result structure for vf vlan insert */
13741 struct cmd_vf_vlan_insert_result {
13742 cmdline_fixed_string_t set;
13743 cmdline_fixed_string_t vf;
13744 cmdline_fixed_string_t vlan;
13745 cmdline_fixed_string_t insert;
13751 /* Common CLI fields for vf vlan insert enable disable */
13752 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13753 TOKEN_STRING_INITIALIZER
13754 (struct cmd_vf_vlan_insert_result,
13756 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13757 TOKEN_STRING_INITIALIZER
13758 (struct cmd_vf_vlan_insert_result,
13760 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13761 TOKEN_STRING_INITIALIZER
13762 (struct cmd_vf_vlan_insert_result,
13764 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13765 TOKEN_STRING_INITIALIZER
13766 (struct cmd_vf_vlan_insert_result,
13768 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13769 TOKEN_NUM_INITIALIZER
13770 (struct cmd_vf_vlan_insert_result,
13772 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13773 TOKEN_NUM_INITIALIZER
13774 (struct cmd_vf_vlan_insert_result,
13776 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13777 TOKEN_NUM_INITIALIZER
13778 (struct cmd_vf_vlan_insert_result,
13782 cmd_set_vf_vlan_insert_parsed(
13783 void *parsed_result,
13784 __rte_unused struct cmdline *cl,
13785 __rte_unused void *data)
13787 struct cmd_vf_vlan_insert_result *res = parsed_result;
13788 int ret = -ENOTSUP;
13790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13793 #ifdef RTE_LIBRTE_IXGBE_PMD
13794 if (ret == -ENOTSUP)
13795 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13798 #ifdef RTE_LIBRTE_I40E_PMD
13799 if (ret == -ENOTSUP)
13800 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13803 #ifdef RTE_LIBRTE_BNXT_PMD
13804 if (ret == -ENOTSUP)
13805 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13813 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13816 printf("invalid port_id %d\n", res->port_id);
13819 printf("function not implemented\n");
13822 printf("programming error: (%s)\n", strerror(-ret));
13826 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13827 .f = cmd_set_vf_vlan_insert_parsed,
13829 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13831 (void *)&cmd_vf_vlan_insert_set,
13832 (void *)&cmd_vf_vlan_insert_vf,
13833 (void *)&cmd_vf_vlan_insert_vlan,
13834 (void *)&cmd_vf_vlan_insert_insert,
13835 (void *)&cmd_vf_vlan_insert_port_id,
13836 (void *)&cmd_vf_vlan_insert_vf_id,
13837 (void *)&cmd_vf_vlan_insert_vlan_id,
13842 /* tx loopback configuration */
13844 /* Common result structure for tx loopback */
13845 struct cmd_tx_loopback_result {
13846 cmdline_fixed_string_t set;
13847 cmdline_fixed_string_t tx;
13848 cmdline_fixed_string_t loopback;
13850 cmdline_fixed_string_t on_off;
13853 /* Common CLI fields for tx loopback enable disable */
13854 cmdline_parse_token_string_t cmd_tx_loopback_set =
13855 TOKEN_STRING_INITIALIZER
13856 (struct cmd_tx_loopback_result,
13858 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13859 TOKEN_STRING_INITIALIZER
13860 (struct cmd_tx_loopback_result,
13862 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13863 TOKEN_STRING_INITIALIZER
13864 (struct cmd_tx_loopback_result,
13865 loopback, "loopback");
13866 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13867 TOKEN_NUM_INITIALIZER
13868 (struct cmd_tx_loopback_result,
13870 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13871 TOKEN_STRING_INITIALIZER
13872 (struct cmd_tx_loopback_result,
13876 cmd_set_tx_loopback_parsed(
13877 void *parsed_result,
13878 __rte_unused struct cmdline *cl,
13879 __rte_unused void *data)
13881 struct cmd_tx_loopback_result *res = parsed_result;
13882 int ret = -ENOTSUP;
13884 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13886 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13889 #ifdef RTE_LIBRTE_IXGBE_PMD
13890 if (ret == -ENOTSUP)
13891 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13893 #ifdef RTE_LIBRTE_I40E_PMD
13894 if (ret == -ENOTSUP)
13895 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13897 #ifdef RTE_LIBRTE_BNXT_PMD
13898 if (ret == -ENOTSUP)
13899 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13901 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13902 if (ret == -ENOTSUP)
13903 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13910 printf("invalid is_on %d\n", is_on);
13913 printf("invalid port_id %d\n", res->port_id);
13916 printf("function not implemented\n");
13919 printf("programming error: (%s)\n", strerror(-ret));
13923 cmdline_parse_inst_t cmd_set_tx_loopback = {
13924 .f = cmd_set_tx_loopback_parsed,
13926 .help_str = "set tx loopback <port_id> on|off",
13928 (void *)&cmd_tx_loopback_set,
13929 (void *)&cmd_tx_loopback_tx,
13930 (void *)&cmd_tx_loopback_loopback,
13931 (void *)&cmd_tx_loopback_port_id,
13932 (void *)&cmd_tx_loopback_on_off,
13937 /* all queues drop enable configuration */
13939 /* Common result structure for all queues drop enable */
13940 struct cmd_all_queues_drop_en_result {
13941 cmdline_fixed_string_t set;
13942 cmdline_fixed_string_t all;
13943 cmdline_fixed_string_t queues;
13944 cmdline_fixed_string_t drop;
13946 cmdline_fixed_string_t on_off;
13949 /* Common CLI fields for tx loopback enable disable */
13950 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13951 TOKEN_STRING_INITIALIZER
13952 (struct cmd_all_queues_drop_en_result,
13954 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13955 TOKEN_STRING_INITIALIZER
13956 (struct cmd_all_queues_drop_en_result,
13958 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13959 TOKEN_STRING_INITIALIZER
13960 (struct cmd_all_queues_drop_en_result,
13962 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13963 TOKEN_STRING_INITIALIZER
13964 (struct cmd_all_queues_drop_en_result,
13966 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13967 TOKEN_NUM_INITIALIZER
13968 (struct cmd_all_queues_drop_en_result,
13970 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13971 TOKEN_STRING_INITIALIZER
13972 (struct cmd_all_queues_drop_en_result,
13976 cmd_set_all_queues_drop_en_parsed(
13977 void *parsed_result,
13978 __rte_unused struct cmdline *cl,
13979 __rte_unused void *data)
13981 struct cmd_all_queues_drop_en_result *res = parsed_result;
13982 int ret = -ENOTSUP;
13983 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13985 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13988 #ifdef RTE_LIBRTE_IXGBE_PMD
13989 if (ret == -ENOTSUP)
13990 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13992 #ifdef RTE_LIBRTE_BNXT_PMD
13993 if (ret == -ENOTSUP)
13994 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14000 printf("invalid is_on %d\n", is_on);
14003 printf("invalid port_id %d\n", res->port_id);
14006 printf("function not implemented\n");
14009 printf("programming error: (%s)\n", strerror(-ret));
14013 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14014 .f = cmd_set_all_queues_drop_en_parsed,
14016 .help_str = "set all queues drop <port_id> on|off",
14018 (void *)&cmd_all_queues_drop_en_set,
14019 (void *)&cmd_all_queues_drop_en_all,
14020 (void *)&cmd_all_queues_drop_en_queues,
14021 (void *)&cmd_all_queues_drop_en_drop,
14022 (void *)&cmd_all_queues_drop_en_port_id,
14023 (void *)&cmd_all_queues_drop_en_on_off,
14028 /* vf split drop enable configuration */
14030 /* Common result structure for vf split drop enable */
14031 struct cmd_vf_split_drop_en_result {
14032 cmdline_fixed_string_t set;
14033 cmdline_fixed_string_t vf;
14034 cmdline_fixed_string_t split;
14035 cmdline_fixed_string_t drop;
14038 cmdline_fixed_string_t on_off;
14041 /* Common CLI fields for vf split drop enable disable */
14042 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14043 TOKEN_STRING_INITIALIZER
14044 (struct cmd_vf_split_drop_en_result,
14046 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14047 TOKEN_STRING_INITIALIZER
14048 (struct cmd_vf_split_drop_en_result,
14050 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14051 TOKEN_STRING_INITIALIZER
14052 (struct cmd_vf_split_drop_en_result,
14054 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14055 TOKEN_STRING_INITIALIZER
14056 (struct cmd_vf_split_drop_en_result,
14058 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14059 TOKEN_NUM_INITIALIZER
14060 (struct cmd_vf_split_drop_en_result,
14062 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14063 TOKEN_NUM_INITIALIZER
14064 (struct cmd_vf_split_drop_en_result,
14066 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14067 TOKEN_STRING_INITIALIZER
14068 (struct cmd_vf_split_drop_en_result,
14072 cmd_set_vf_split_drop_en_parsed(
14073 void *parsed_result,
14074 __rte_unused struct cmdline *cl,
14075 __rte_unused void *data)
14077 struct cmd_vf_split_drop_en_result *res = parsed_result;
14078 int ret = -ENOTSUP;
14079 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14081 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14084 #ifdef RTE_LIBRTE_IXGBE_PMD
14085 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14092 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14095 printf("invalid port_id %d\n", res->port_id);
14098 printf("not supported on port %d\n", res->port_id);
14101 printf("programming error: (%s)\n", strerror(-ret));
14105 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14106 .f = cmd_set_vf_split_drop_en_parsed,
14108 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14110 (void *)&cmd_vf_split_drop_en_set,
14111 (void *)&cmd_vf_split_drop_en_vf,
14112 (void *)&cmd_vf_split_drop_en_split,
14113 (void *)&cmd_vf_split_drop_en_drop,
14114 (void *)&cmd_vf_split_drop_en_port_id,
14115 (void *)&cmd_vf_split_drop_en_vf_id,
14116 (void *)&cmd_vf_split_drop_en_on_off,
14121 /* vf mac address configuration */
14123 /* Common result structure for vf mac address */
14124 struct cmd_set_vf_mac_addr_result {
14125 cmdline_fixed_string_t set;
14126 cmdline_fixed_string_t vf;
14127 cmdline_fixed_string_t mac;
14128 cmdline_fixed_string_t addr;
14131 struct rte_ether_addr mac_addr;
14135 /* Common CLI fields for vf split drop enable disable */
14136 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14137 TOKEN_STRING_INITIALIZER
14138 (struct cmd_set_vf_mac_addr_result,
14140 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14141 TOKEN_STRING_INITIALIZER
14142 (struct cmd_set_vf_mac_addr_result,
14144 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14145 TOKEN_STRING_INITIALIZER
14146 (struct cmd_set_vf_mac_addr_result,
14148 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14149 TOKEN_STRING_INITIALIZER
14150 (struct cmd_set_vf_mac_addr_result,
14152 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14153 TOKEN_NUM_INITIALIZER
14154 (struct cmd_set_vf_mac_addr_result,
14156 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14157 TOKEN_NUM_INITIALIZER
14158 (struct cmd_set_vf_mac_addr_result,
14160 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14161 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14165 cmd_set_vf_mac_addr_parsed(
14166 void *parsed_result,
14167 __rte_unused struct cmdline *cl,
14168 __rte_unused void *data)
14170 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14171 int ret = -ENOTSUP;
14173 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14176 #ifdef RTE_LIBRTE_IXGBE_PMD
14177 if (ret == -ENOTSUP)
14178 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14181 #ifdef RTE_LIBRTE_I40E_PMD
14182 if (ret == -ENOTSUP)
14183 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14186 #ifdef RTE_LIBRTE_BNXT_PMD
14187 if (ret == -ENOTSUP)
14188 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14196 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14199 printf("invalid port_id %d\n", res->port_id);
14202 printf("function not implemented\n");
14205 printf("programming error: (%s)\n", strerror(-ret));
14209 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14210 .f = cmd_set_vf_mac_addr_parsed,
14212 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14214 (void *)&cmd_set_vf_mac_addr_set,
14215 (void *)&cmd_set_vf_mac_addr_vf,
14216 (void *)&cmd_set_vf_mac_addr_mac,
14217 (void *)&cmd_set_vf_mac_addr_addr,
14218 (void *)&cmd_set_vf_mac_addr_port_id,
14219 (void *)&cmd_set_vf_mac_addr_vf_id,
14220 (void *)&cmd_set_vf_mac_addr_mac_addr,
14225 /* MACsec configuration */
14227 /* Common result structure for MACsec offload enable */
14228 struct cmd_macsec_offload_on_result {
14229 cmdline_fixed_string_t set;
14230 cmdline_fixed_string_t macsec;
14231 cmdline_fixed_string_t offload;
14233 cmdline_fixed_string_t on;
14234 cmdline_fixed_string_t encrypt;
14235 cmdline_fixed_string_t en_on_off;
14236 cmdline_fixed_string_t replay_protect;
14237 cmdline_fixed_string_t rp_on_off;
14240 /* Common CLI fields for MACsec offload disable */
14241 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14242 TOKEN_STRING_INITIALIZER
14243 (struct cmd_macsec_offload_on_result,
14245 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14246 TOKEN_STRING_INITIALIZER
14247 (struct cmd_macsec_offload_on_result,
14249 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14250 TOKEN_STRING_INITIALIZER
14251 (struct cmd_macsec_offload_on_result,
14252 offload, "offload");
14253 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14254 TOKEN_NUM_INITIALIZER
14255 (struct cmd_macsec_offload_on_result,
14257 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14258 TOKEN_STRING_INITIALIZER
14259 (struct cmd_macsec_offload_on_result,
14261 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14262 TOKEN_STRING_INITIALIZER
14263 (struct cmd_macsec_offload_on_result,
14264 encrypt, "encrypt");
14265 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14266 TOKEN_STRING_INITIALIZER
14267 (struct cmd_macsec_offload_on_result,
14268 en_on_off, "on#off");
14269 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14270 TOKEN_STRING_INITIALIZER
14271 (struct cmd_macsec_offload_on_result,
14272 replay_protect, "replay-protect");
14273 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14274 TOKEN_STRING_INITIALIZER
14275 (struct cmd_macsec_offload_on_result,
14276 rp_on_off, "on#off");
14279 cmd_set_macsec_offload_on_parsed(
14280 void *parsed_result,
14281 __rte_unused struct cmdline *cl,
14282 __rte_unused void *data)
14284 struct cmd_macsec_offload_on_result *res = parsed_result;
14285 int ret = -ENOTSUP;
14286 portid_t port_id = res->port_id;
14287 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14288 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14289 struct rte_eth_dev_info dev_info;
14291 if (port_id_is_invalid(port_id, ENABLED_WARN))
14293 if (!port_is_stopped(port_id)) {
14294 printf("Please stop port %d first\n", port_id);
14298 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14302 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14303 #ifdef RTE_LIBRTE_IXGBE_PMD
14304 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14312 ports[port_id].dev_conf.txmode.offloads |=
14313 DEV_TX_OFFLOAD_MACSEC_INSERT;
14314 cmd_reconfig_device_queue(port_id, 1, 1);
14317 printf("invalid port_id %d\n", port_id);
14320 printf("not supported on port %d\n", port_id);
14323 printf("programming error: (%s)\n", strerror(-ret));
14327 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14328 .f = cmd_set_macsec_offload_on_parsed,
14330 .help_str = "set macsec offload <port_id> on "
14331 "encrypt on|off replay-protect on|off",
14333 (void *)&cmd_macsec_offload_on_set,
14334 (void *)&cmd_macsec_offload_on_macsec,
14335 (void *)&cmd_macsec_offload_on_offload,
14336 (void *)&cmd_macsec_offload_on_port_id,
14337 (void *)&cmd_macsec_offload_on_on,
14338 (void *)&cmd_macsec_offload_on_encrypt,
14339 (void *)&cmd_macsec_offload_on_en_on_off,
14340 (void *)&cmd_macsec_offload_on_replay_protect,
14341 (void *)&cmd_macsec_offload_on_rp_on_off,
14346 /* Common result structure for MACsec offload disable */
14347 struct cmd_macsec_offload_off_result {
14348 cmdline_fixed_string_t set;
14349 cmdline_fixed_string_t macsec;
14350 cmdline_fixed_string_t offload;
14352 cmdline_fixed_string_t off;
14355 /* Common CLI fields for MACsec offload disable */
14356 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14357 TOKEN_STRING_INITIALIZER
14358 (struct cmd_macsec_offload_off_result,
14360 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14361 TOKEN_STRING_INITIALIZER
14362 (struct cmd_macsec_offload_off_result,
14364 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14365 TOKEN_STRING_INITIALIZER
14366 (struct cmd_macsec_offload_off_result,
14367 offload, "offload");
14368 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14369 TOKEN_NUM_INITIALIZER
14370 (struct cmd_macsec_offload_off_result,
14372 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14373 TOKEN_STRING_INITIALIZER
14374 (struct cmd_macsec_offload_off_result,
14378 cmd_set_macsec_offload_off_parsed(
14379 void *parsed_result,
14380 __rte_unused struct cmdline *cl,
14381 __rte_unused void *data)
14383 struct cmd_macsec_offload_off_result *res = parsed_result;
14384 int ret = -ENOTSUP;
14385 struct rte_eth_dev_info dev_info;
14386 portid_t port_id = res->port_id;
14388 if (port_id_is_invalid(port_id, ENABLED_WARN))
14390 if (!port_is_stopped(port_id)) {
14391 printf("Please stop port %d first\n", port_id);
14395 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14399 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14400 #ifdef RTE_LIBRTE_IXGBE_PMD
14401 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14406 ports[port_id].dev_conf.txmode.offloads &=
14407 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14408 cmd_reconfig_device_queue(port_id, 1, 1);
14411 printf("invalid port_id %d\n", port_id);
14414 printf("not supported on port %d\n", port_id);
14417 printf("programming error: (%s)\n", strerror(-ret));
14421 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14422 .f = cmd_set_macsec_offload_off_parsed,
14424 .help_str = "set macsec offload <port_id> off",
14426 (void *)&cmd_macsec_offload_off_set,
14427 (void *)&cmd_macsec_offload_off_macsec,
14428 (void *)&cmd_macsec_offload_off_offload,
14429 (void *)&cmd_macsec_offload_off_port_id,
14430 (void *)&cmd_macsec_offload_off_off,
14435 /* Common result structure for MACsec secure connection configure */
14436 struct cmd_macsec_sc_result {
14437 cmdline_fixed_string_t set;
14438 cmdline_fixed_string_t macsec;
14439 cmdline_fixed_string_t sc;
14440 cmdline_fixed_string_t tx_rx;
14442 struct rte_ether_addr mac;
14446 /* Common CLI fields for MACsec secure connection configure */
14447 cmdline_parse_token_string_t cmd_macsec_sc_set =
14448 TOKEN_STRING_INITIALIZER
14449 (struct cmd_macsec_sc_result,
14451 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14452 TOKEN_STRING_INITIALIZER
14453 (struct cmd_macsec_sc_result,
14455 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14456 TOKEN_STRING_INITIALIZER
14457 (struct cmd_macsec_sc_result,
14459 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14460 TOKEN_STRING_INITIALIZER
14461 (struct cmd_macsec_sc_result,
14463 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14464 TOKEN_NUM_INITIALIZER
14465 (struct cmd_macsec_sc_result,
14467 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14468 TOKEN_ETHERADDR_INITIALIZER
14469 (struct cmd_macsec_sc_result,
14471 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14472 TOKEN_NUM_INITIALIZER
14473 (struct cmd_macsec_sc_result,
14477 cmd_set_macsec_sc_parsed(
14478 void *parsed_result,
14479 __rte_unused struct cmdline *cl,
14480 __rte_unused void *data)
14482 struct cmd_macsec_sc_result *res = parsed_result;
14483 int ret = -ENOTSUP;
14484 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14486 #ifdef RTE_LIBRTE_IXGBE_PMD
14488 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14489 res->mac.addr_bytes) :
14490 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14491 res->mac.addr_bytes, res->pi);
14493 RTE_SET_USED(is_tx);
14499 printf("invalid port_id %d\n", res->port_id);
14502 printf("not supported on port %d\n", res->port_id);
14505 printf("programming error: (%s)\n", strerror(-ret));
14509 cmdline_parse_inst_t cmd_set_macsec_sc = {
14510 .f = cmd_set_macsec_sc_parsed,
14512 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14514 (void *)&cmd_macsec_sc_set,
14515 (void *)&cmd_macsec_sc_macsec,
14516 (void *)&cmd_macsec_sc_sc,
14517 (void *)&cmd_macsec_sc_tx_rx,
14518 (void *)&cmd_macsec_sc_port_id,
14519 (void *)&cmd_macsec_sc_mac,
14520 (void *)&cmd_macsec_sc_pi,
14525 /* Common result structure for MACsec secure connection configure */
14526 struct cmd_macsec_sa_result {
14527 cmdline_fixed_string_t set;
14528 cmdline_fixed_string_t macsec;
14529 cmdline_fixed_string_t sa;
14530 cmdline_fixed_string_t tx_rx;
14535 cmdline_fixed_string_t key;
14538 /* Common CLI fields for MACsec secure connection configure */
14539 cmdline_parse_token_string_t cmd_macsec_sa_set =
14540 TOKEN_STRING_INITIALIZER
14541 (struct cmd_macsec_sa_result,
14543 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14544 TOKEN_STRING_INITIALIZER
14545 (struct cmd_macsec_sa_result,
14547 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14548 TOKEN_STRING_INITIALIZER
14549 (struct cmd_macsec_sa_result,
14551 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14552 TOKEN_STRING_INITIALIZER
14553 (struct cmd_macsec_sa_result,
14555 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14556 TOKEN_NUM_INITIALIZER
14557 (struct cmd_macsec_sa_result,
14559 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14560 TOKEN_NUM_INITIALIZER
14561 (struct cmd_macsec_sa_result,
14563 cmdline_parse_token_num_t cmd_macsec_sa_an =
14564 TOKEN_NUM_INITIALIZER
14565 (struct cmd_macsec_sa_result,
14567 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14568 TOKEN_NUM_INITIALIZER
14569 (struct cmd_macsec_sa_result,
14571 cmdline_parse_token_string_t cmd_macsec_sa_key =
14572 TOKEN_STRING_INITIALIZER
14573 (struct cmd_macsec_sa_result,
14577 cmd_set_macsec_sa_parsed(
14578 void *parsed_result,
14579 __rte_unused struct cmdline *cl,
14580 __rte_unused void *data)
14582 struct cmd_macsec_sa_result *res = parsed_result;
14583 int ret = -ENOTSUP;
14584 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14585 uint8_t key[16] = { 0 };
14591 key_len = strlen(res->key) / 2;
14595 for (i = 0; i < key_len; i++) {
14596 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14599 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14602 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14605 #ifdef RTE_LIBRTE_IXGBE_PMD
14607 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14608 res->idx, res->an, res->pn, key) :
14609 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14610 res->idx, res->an, res->pn, key);
14612 RTE_SET_USED(is_tx);
14619 printf("invalid idx %d or an %d\n", res->idx, res->an);
14622 printf("invalid port_id %d\n", res->port_id);
14625 printf("not supported on port %d\n", res->port_id);
14628 printf("programming error: (%s)\n", strerror(-ret));
14632 cmdline_parse_inst_t cmd_set_macsec_sa = {
14633 .f = cmd_set_macsec_sa_parsed,
14635 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14637 (void *)&cmd_macsec_sa_set,
14638 (void *)&cmd_macsec_sa_macsec,
14639 (void *)&cmd_macsec_sa_sa,
14640 (void *)&cmd_macsec_sa_tx_rx,
14641 (void *)&cmd_macsec_sa_port_id,
14642 (void *)&cmd_macsec_sa_idx,
14643 (void *)&cmd_macsec_sa_an,
14644 (void *)&cmd_macsec_sa_pn,
14645 (void *)&cmd_macsec_sa_key,
14650 /* VF unicast promiscuous mode configuration */
14652 /* Common result structure for VF unicast promiscuous mode */
14653 struct cmd_vf_promisc_result {
14654 cmdline_fixed_string_t set;
14655 cmdline_fixed_string_t vf;
14656 cmdline_fixed_string_t promisc;
14659 cmdline_fixed_string_t on_off;
14662 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14663 cmdline_parse_token_string_t cmd_vf_promisc_set =
14664 TOKEN_STRING_INITIALIZER
14665 (struct cmd_vf_promisc_result,
14667 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14668 TOKEN_STRING_INITIALIZER
14669 (struct cmd_vf_promisc_result,
14671 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14672 TOKEN_STRING_INITIALIZER
14673 (struct cmd_vf_promisc_result,
14674 promisc, "promisc");
14675 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14676 TOKEN_NUM_INITIALIZER
14677 (struct cmd_vf_promisc_result,
14679 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14680 TOKEN_NUM_INITIALIZER
14681 (struct cmd_vf_promisc_result,
14683 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14684 TOKEN_STRING_INITIALIZER
14685 (struct cmd_vf_promisc_result,
14689 cmd_set_vf_promisc_parsed(
14690 void *parsed_result,
14691 __rte_unused struct cmdline *cl,
14692 __rte_unused void *data)
14694 struct cmd_vf_promisc_result *res = parsed_result;
14695 int ret = -ENOTSUP;
14697 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14702 #ifdef RTE_LIBRTE_I40E_PMD
14703 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14704 res->vf_id, is_on);
14711 printf("invalid vf_id %d\n", res->vf_id);
14714 printf("invalid port_id %d\n", res->port_id);
14717 printf("function not implemented\n");
14720 printf("programming error: (%s)\n", strerror(-ret));
14724 cmdline_parse_inst_t cmd_set_vf_promisc = {
14725 .f = cmd_set_vf_promisc_parsed,
14727 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14728 "Set unicast promiscuous mode for a VF from the PF",
14730 (void *)&cmd_vf_promisc_set,
14731 (void *)&cmd_vf_promisc_vf,
14732 (void *)&cmd_vf_promisc_promisc,
14733 (void *)&cmd_vf_promisc_port_id,
14734 (void *)&cmd_vf_promisc_vf_id,
14735 (void *)&cmd_vf_promisc_on_off,
14740 /* VF multicast promiscuous mode configuration */
14742 /* Common result structure for VF multicast promiscuous mode */
14743 struct cmd_vf_allmulti_result {
14744 cmdline_fixed_string_t set;
14745 cmdline_fixed_string_t vf;
14746 cmdline_fixed_string_t allmulti;
14749 cmdline_fixed_string_t on_off;
14752 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14753 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14754 TOKEN_STRING_INITIALIZER
14755 (struct cmd_vf_allmulti_result,
14757 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14758 TOKEN_STRING_INITIALIZER
14759 (struct cmd_vf_allmulti_result,
14761 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14762 TOKEN_STRING_INITIALIZER
14763 (struct cmd_vf_allmulti_result,
14764 allmulti, "allmulti");
14765 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14766 TOKEN_NUM_INITIALIZER
14767 (struct cmd_vf_allmulti_result,
14769 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14770 TOKEN_NUM_INITIALIZER
14771 (struct cmd_vf_allmulti_result,
14773 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14774 TOKEN_STRING_INITIALIZER
14775 (struct cmd_vf_allmulti_result,
14779 cmd_set_vf_allmulti_parsed(
14780 void *parsed_result,
14781 __rte_unused struct cmdline *cl,
14782 __rte_unused void *data)
14784 struct cmd_vf_allmulti_result *res = parsed_result;
14785 int ret = -ENOTSUP;
14787 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14789 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14792 #ifdef RTE_LIBRTE_I40E_PMD
14793 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14794 res->vf_id, is_on);
14801 printf("invalid vf_id %d\n", res->vf_id);
14804 printf("invalid port_id %d\n", res->port_id);
14807 printf("function not implemented\n");
14810 printf("programming error: (%s)\n", strerror(-ret));
14814 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14815 .f = cmd_set_vf_allmulti_parsed,
14817 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14818 "Set multicast promiscuous mode for a VF from the PF",
14820 (void *)&cmd_vf_allmulti_set,
14821 (void *)&cmd_vf_allmulti_vf,
14822 (void *)&cmd_vf_allmulti_allmulti,
14823 (void *)&cmd_vf_allmulti_port_id,
14824 (void *)&cmd_vf_allmulti_vf_id,
14825 (void *)&cmd_vf_allmulti_on_off,
14830 /* vf broadcast mode configuration */
14832 /* Common result structure for vf broadcast */
14833 struct cmd_set_vf_broadcast_result {
14834 cmdline_fixed_string_t set;
14835 cmdline_fixed_string_t vf;
14836 cmdline_fixed_string_t broadcast;
14839 cmdline_fixed_string_t on_off;
14842 /* Common CLI fields for vf broadcast enable disable */
14843 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14844 TOKEN_STRING_INITIALIZER
14845 (struct cmd_set_vf_broadcast_result,
14847 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14848 TOKEN_STRING_INITIALIZER
14849 (struct cmd_set_vf_broadcast_result,
14851 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14852 TOKEN_STRING_INITIALIZER
14853 (struct cmd_set_vf_broadcast_result,
14854 broadcast, "broadcast");
14855 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14856 TOKEN_NUM_INITIALIZER
14857 (struct cmd_set_vf_broadcast_result,
14859 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14860 TOKEN_NUM_INITIALIZER
14861 (struct cmd_set_vf_broadcast_result,
14863 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14864 TOKEN_STRING_INITIALIZER
14865 (struct cmd_set_vf_broadcast_result,
14869 cmd_set_vf_broadcast_parsed(
14870 void *parsed_result,
14871 __rte_unused struct cmdline *cl,
14872 __rte_unused void *data)
14874 struct cmd_set_vf_broadcast_result *res = parsed_result;
14875 int ret = -ENOTSUP;
14877 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14879 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14882 #ifdef RTE_LIBRTE_I40E_PMD
14883 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14884 res->vf_id, is_on);
14891 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14894 printf("invalid port_id %d\n", res->port_id);
14897 printf("function not implemented\n");
14900 printf("programming error: (%s)\n", strerror(-ret));
14904 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14905 .f = cmd_set_vf_broadcast_parsed,
14907 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14909 (void *)&cmd_set_vf_broadcast_set,
14910 (void *)&cmd_set_vf_broadcast_vf,
14911 (void *)&cmd_set_vf_broadcast_broadcast,
14912 (void *)&cmd_set_vf_broadcast_port_id,
14913 (void *)&cmd_set_vf_broadcast_vf_id,
14914 (void *)&cmd_set_vf_broadcast_on_off,
14919 /* vf vlan tag configuration */
14921 /* Common result structure for vf vlan tag */
14922 struct cmd_set_vf_vlan_tag_result {
14923 cmdline_fixed_string_t set;
14924 cmdline_fixed_string_t vf;
14925 cmdline_fixed_string_t vlan;
14926 cmdline_fixed_string_t tag;
14929 cmdline_fixed_string_t on_off;
14932 /* Common CLI fields for vf vlan tag enable disable */
14933 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14934 TOKEN_STRING_INITIALIZER
14935 (struct cmd_set_vf_vlan_tag_result,
14937 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14938 TOKEN_STRING_INITIALIZER
14939 (struct cmd_set_vf_vlan_tag_result,
14941 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14942 TOKEN_STRING_INITIALIZER
14943 (struct cmd_set_vf_vlan_tag_result,
14945 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14946 TOKEN_STRING_INITIALIZER
14947 (struct cmd_set_vf_vlan_tag_result,
14949 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14950 TOKEN_NUM_INITIALIZER
14951 (struct cmd_set_vf_vlan_tag_result,
14953 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14954 TOKEN_NUM_INITIALIZER
14955 (struct cmd_set_vf_vlan_tag_result,
14957 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14958 TOKEN_STRING_INITIALIZER
14959 (struct cmd_set_vf_vlan_tag_result,
14963 cmd_set_vf_vlan_tag_parsed(
14964 void *parsed_result,
14965 __rte_unused struct cmdline *cl,
14966 __rte_unused void *data)
14968 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14969 int ret = -ENOTSUP;
14971 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14973 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14976 #ifdef RTE_LIBRTE_I40E_PMD
14977 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14978 res->vf_id, is_on);
14985 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14988 printf("invalid port_id %d\n", res->port_id);
14991 printf("function not implemented\n");
14994 printf("programming error: (%s)\n", strerror(-ret));
14998 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14999 .f = cmd_set_vf_vlan_tag_parsed,
15001 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15003 (void *)&cmd_set_vf_vlan_tag_set,
15004 (void *)&cmd_set_vf_vlan_tag_vf,
15005 (void *)&cmd_set_vf_vlan_tag_vlan,
15006 (void *)&cmd_set_vf_vlan_tag_tag,
15007 (void *)&cmd_set_vf_vlan_tag_port_id,
15008 (void *)&cmd_set_vf_vlan_tag_vf_id,
15009 (void *)&cmd_set_vf_vlan_tag_on_off,
15014 /* Common definition of VF and TC TX bandwidth configuration */
15015 struct cmd_vf_tc_bw_result {
15016 cmdline_fixed_string_t set;
15017 cmdline_fixed_string_t vf;
15018 cmdline_fixed_string_t tc;
15019 cmdline_fixed_string_t tx;
15020 cmdline_fixed_string_t min_bw;
15021 cmdline_fixed_string_t max_bw;
15022 cmdline_fixed_string_t strict_link_prio;
15027 cmdline_fixed_string_t bw_list;
15031 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15032 TOKEN_STRING_INITIALIZER
15033 (struct cmd_vf_tc_bw_result,
15035 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15036 TOKEN_STRING_INITIALIZER
15037 (struct cmd_vf_tc_bw_result,
15039 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15040 TOKEN_STRING_INITIALIZER
15041 (struct cmd_vf_tc_bw_result,
15043 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15044 TOKEN_STRING_INITIALIZER
15045 (struct cmd_vf_tc_bw_result,
15047 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15048 TOKEN_STRING_INITIALIZER
15049 (struct cmd_vf_tc_bw_result,
15050 strict_link_prio, "strict-link-priority");
15051 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15052 TOKEN_STRING_INITIALIZER
15053 (struct cmd_vf_tc_bw_result,
15054 min_bw, "min-bandwidth");
15055 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15056 TOKEN_STRING_INITIALIZER
15057 (struct cmd_vf_tc_bw_result,
15058 max_bw, "max-bandwidth");
15059 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15060 TOKEN_NUM_INITIALIZER
15061 (struct cmd_vf_tc_bw_result,
15063 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15064 TOKEN_NUM_INITIALIZER
15065 (struct cmd_vf_tc_bw_result,
15067 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15068 TOKEN_NUM_INITIALIZER
15069 (struct cmd_vf_tc_bw_result,
15071 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15072 TOKEN_NUM_INITIALIZER
15073 (struct cmd_vf_tc_bw_result,
15075 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15076 TOKEN_STRING_INITIALIZER
15077 (struct cmd_vf_tc_bw_result,
15079 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15080 TOKEN_NUM_INITIALIZER
15081 (struct cmd_vf_tc_bw_result,
15084 /* VF max bandwidth setting */
15086 cmd_vf_max_bw_parsed(
15087 void *parsed_result,
15088 __rte_unused struct cmdline *cl,
15089 __rte_unused void *data)
15091 struct cmd_vf_tc_bw_result *res = parsed_result;
15092 int ret = -ENOTSUP;
15094 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15097 #ifdef RTE_LIBRTE_I40E_PMD
15098 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15099 res->vf_id, res->bw);
15106 printf("invalid vf_id %d or bandwidth %d\n",
15107 res->vf_id, res->bw);
15110 printf("invalid port_id %d\n", res->port_id);
15113 printf("function not implemented\n");
15116 printf("programming error: (%s)\n", strerror(-ret));
15120 cmdline_parse_inst_t cmd_vf_max_bw = {
15121 .f = cmd_vf_max_bw_parsed,
15123 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15125 (void *)&cmd_vf_tc_bw_set,
15126 (void *)&cmd_vf_tc_bw_vf,
15127 (void *)&cmd_vf_tc_bw_tx,
15128 (void *)&cmd_vf_tc_bw_max_bw,
15129 (void *)&cmd_vf_tc_bw_port_id,
15130 (void *)&cmd_vf_tc_bw_vf_id,
15131 (void *)&cmd_vf_tc_bw_bw,
15137 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15142 const char *p, *p0 = str;
15149 p = strchr(p0, '(');
15151 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15155 p0 = strchr(p, ')');
15157 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15161 if (size >= sizeof(s)) {
15162 printf("The string size exceeds the internal buffer size\n");
15165 snprintf(s, sizeof(s), "%.*s", size, p);
15166 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15168 printf("Failed to get the bandwidth list. ");
15172 for (i = 0; i < ret; i++)
15173 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15178 /* TC min bandwidth setting */
15180 cmd_vf_tc_min_bw_parsed(
15181 void *parsed_result,
15182 __rte_unused struct cmdline *cl,
15183 __rte_unused void *data)
15185 struct cmd_vf_tc_bw_result *res = parsed_result;
15188 int ret = -ENOTSUP;
15190 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15193 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15197 #ifdef RTE_LIBRTE_I40E_PMD
15198 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15206 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15209 printf("invalid port_id %d\n", res->port_id);
15212 printf("function not implemented\n");
15215 printf("programming error: (%s)\n", strerror(-ret));
15219 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15220 .f = cmd_vf_tc_min_bw_parsed,
15222 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15223 " <bw1, bw2, ...>",
15225 (void *)&cmd_vf_tc_bw_set,
15226 (void *)&cmd_vf_tc_bw_vf,
15227 (void *)&cmd_vf_tc_bw_tc,
15228 (void *)&cmd_vf_tc_bw_tx,
15229 (void *)&cmd_vf_tc_bw_min_bw,
15230 (void *)&cmd_vf_tc_bw_port_id,
15231 (void *)&cmd_vf_tc_bw_vf_id,
15232 (void *)&cmd_vf_tc_bw_bw_list,
15238 cmd_tc_min_bw_parsed(
15239 void *parsed_result,
15240 __rte_unused struct cmdline *cl,
15241 __rte_unused void *data)
15243 struct cmd_vf_tc_bw_result *res = parsed_result;
15244 struct rte_port *port;
15247 int ret = -ENOTSUP;
15249 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15252 port = &ports[res->port_id];
15253 /** Check if the port is not started **/
15254 if (port->port_status != RTE_PORT_STOPPED) {
15255 printf("Please stop port %d first\n", res->port_id);
15259 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15263 #ifdef RTE_LIBRTE_IXGBE_PMD
15264 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15271 printf("invalid bandwidth\n");
15274 printf("invalid port_id %d\n", res->port_id);
15277 printf("function not implemented\n");
15280 printf("programming error: (%s)\n", strerror(-ret));
15284 cmdline_parse_inst_t cmd_tc_min_bw = {
15285 .f = cmd_tc_min_bw_parsed,
15287 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15289 (void *)&cmd_vf_tc_bw_set,
15290 (void *)&cmd_vf_tc_bw_tc,
15291 (void *)&cmd_vf_tc_bw_tx,
15292 (void *)&cmd_vf_tc_bw_min_bw,
15293 (void *)&cmd_vf_tc_bw_port_id,
15294 (void *)&cmd_vf_tc_bw_bw_list,
15299 /* TC max bandwidth setting */
15301 cmd_vf_tc_max_bw_parsed(
15302 void *parsed_result,
15303 __rte_unused struct cmdline *cl,
15304 __rte_unused void *data)
15306 struct cmd_vf_tc_bw_result *res = parsed_result;
15307 int ret = -ENOTSUP;
15309 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15312 #ifdef RTE_LIBRTE_I40E_PMD
15313 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15314 res->tc_no, res->bw);
15321 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15322 res->vf_id, res->tc_no, res->bw);
15325 printf("invalid port_id %d\n", res->port_id);
15328 printf("function not implemented\n");
15331 printf("programming error: (%s)\n", strerror(-ret));
15335 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15336 .f = cmd_vf_tc_max_bw_parsed,
15338 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15341 (void *)&cmd_vf_tc_bw_set,
15342 (void *)&cmd_vf_tc_bw_vf,
15343 (void *)&cmd_vf_tc_bw_tc,
15344 (void *)&cmd_vf_tc_bw_tx,
15345 (void *)&cmd_vf_tc_bw_max_bw,
15346 (void *)&cmd_vf_tc_bw_port_id,
15347 (void *)&cmd_vf_tc_bw_vf_id,
15348 (void *)&cmd_vf_tc_bw_tc_no,
15349 (void *)&cmd_vf_tc_bw_bw,
15355 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15357 /* *** Set Port default Traffic Management Hierarchy *** */
15358 struct cmd_set_port_tm_hierarchy_default_result {
15359 cmdline_fixed_string_t set;
15360 cmdline_fixed_string_t port;
15361 cmdline_fixed_string_t tm;
15362 cmdline_fixed_string_t hierarchy;
15363 cmdline_fixed_string_t def;
15367 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15368 TOKEN_STRING_INITIALIZER(
15369 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15370 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15371 TOKEN_STRING_INITIALIZER(
15372 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15373 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15374 TOKEN_STRING_INITIALIZER(
15375 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15376 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15377 TOKEN_STRING_INITIALIZER(
15378 struct cmd_set_port_tm_hierarchy_default_result,
15379 hierarchy, "hierarchy");
15380 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15381 TOKEN_STRING_INITIALIZER(
15382 struct cmd_set_port_tm_hierarchy_default_result,
15384 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15385 TOKEN_NUM_INITIALIZER(
15386 struct cmd_set_port_tm_hierarchy_default_result,
15389 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15390 __rte_unused struct cmdline *cl,
15391 __rte_unused void *data)
15393 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15394 struct rte_port *p;
15395 portid_t port_id = res->port_id;
15397 if (port_id_is_invalid(port_id, ENABLED_WARN))
15400 p = &ports[port_id];
15402 /* Forward mode: tm */
15403 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15404 printf(" softnicfwd mode not enabled(error)\n");
15408 /* Set the default tm hierarchy */
15409 p->softport.default_tm_hierarchy_enable = 1;
15412 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15413 .f = cmd_set_port_tm_hierarchy_default_parsed,
15415 .help_str = "set port tm hierarchy default <port_id>",
15417 (void *)&cmd_set_port_tm_hierarchy_default_set,
15418 (void *)&cmd_set_port_tm_hierarchy_default_port,
15419 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15420 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15421 (void *)&cmd_set_port_tm_hierarchy_default_default,
15422 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15428 /** Set VXLAN encapsulation details */
15429 struct cmd_set_vxlan_result {
15430 cmdline_fixed_string_t set;
15431 cmdline_fixed_string_t vxlan;
15432 cmdline_fixed_string_t pos_token;
15433 cmdline_fixed_string_t ip_version;
15434 uint32_t vlan_present:1;
15438 cmdline_ipaddr_t ip_src;
15439 cmdline_ipaddr_t ip_dst;
15443 struct rte_ether_addr eth_src;
15444 struct rte_ether_addr eth_dst;
15447 cmdline_parse_token_string_t cmd_set_vxlan_set =
15448 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15449 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15450 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15451 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15452 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15454 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15455 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15456 "vxlan-with-vlan");
15457 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15458 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15460 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15461 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15463 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15464 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15466 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15467 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15468 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15469 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15471 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15472 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15473 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15474 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15476 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15477 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15478 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15479 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15481 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15482 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15483 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15484 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15486 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15487 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15488 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15489 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15491 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15492 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15493 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15494 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15496 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15497 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15498 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15499 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15501 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15502 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15503 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15504 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15506 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15507 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15508 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15509 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15511 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15512 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15514 static void cmd_set_vxlan_parsed(void *parsed_result,
15515 __rte_unused struct cmdline *cl,
15516 __rte_unused void *data)
15518 struct cmd_set_vxlan_result *res = parsed_result;
15523 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15526 vxlan_encap_conf.select_tos_ttl = 0;
15527 if (strcmp(res->vxlan, "vxlan") == 0)
15528 vxlan_encap_conf.select_vlan = 0;
15529 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15530 vxlan_encap_conf.select_vlan = 1;
15531 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15532 vxlan_encap_conf.select_vlan = 0;
15533 vxlan_encap_conf.select_tos_ttl = 1;
15535 if (strcmp(res->ip_version, "ipv4") == 0)
15536 vxlan_encap_conf.select_ipv4 = 1;
15537 else if (strcmp(res->ip_version, "ipv6") == 0)
15538 vxlan_encap_conf.select_ipv4 = 0;
15541 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15542 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15543 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15544 vxlan_encap_conf.ip_tos = res->tos;
15545 vxlan_encap_conf.ip_ttl = res->ttl;
15546 if (vxlan_encap_conf.select_ipv4) {
15547 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15548 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15550 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15551 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15553 if (vxlan_encap_conf.select_vlan)
15554 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15555 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15556 RTE_ETHER_ADDR_LEN);
15557 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15558 RTE_ETHER_ADDR_LEN);
15561 cmdline_parse_inst_t cmd_set_vxlan = {
15562 .f = cmd_set_vxlan_parsed,
15564 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15565 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15566 " eth-src <eth-src> eth-dst <eth-dst>",
15568 (void *)&cmd_set_vxlan_set,
15569 (void *)&cmd_set_vxlan_vxlan,
15570 (void *)&cmd_set_vxlan_ip_version,
15571 (void *)&cmd_set_vxlan_ip_version_value,
15572 (void *)&cmd_set_vxlan_vni,
15573 (void *)&cmd_set_vxlan_vni_value,
15574 (void *)&cmd_set_vxlan_udp_src,
15575 (void *)&cmd_set_vxlan_udp_src_value,
15576 (void *)&cmd_set_vxlan_udp_dst,
15577 (void *)&cmd_set_vxlan_udp_dst_value,
15578 (void *)&cmd_set_vxlan_ip_src,
15579 (void *)&cmd_set_vxlan_ip_src_value,
15580 (void *)&cmd_set_vxlan_ip_dst,
15581 (void *)&cmd_set_vxlan_ip_dst_value,
15582 (void *)&cmd_set_vxlan_eth_src,
15583 (void *)&cmd_set_vxlan_eth_src_value,
15584 (void *)&cmd_set_vxlan_eth_dst,
15585 (void *)&cmd_set_vxlan_eth_dst_value,
15590 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15591 .f = cmd_set_vxlan_parsed,
15593 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15594 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15595 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15596 " eth-dst <eth-dst>",
15598 (void *)&cmd_set_vxlan_set,
15599 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15600 (void *)&cmd_set_vxlan_ip_version,
15601 (void *)&cmd_set_vxlan_ip_version_value,
15602 (void *)&cmd_set_vxlan_vni,
15603 (void *)&cmd_set_vxlan_vni_value,
15604 (void *)&cmd_set_vxlan_udp_src,
15605 (void *)&cmd_set_vxlan_udp_src_value,
15606 (void *)&cmd_set_vxlan_udp_dst,
15607 (void *)&cmd_set_vxlan_udp_dst_value,
15608 (void *)&cmd_set_vxlan_ip_tos,
15609 (void *)&cmd_set_vxlan_ip_tos_value,
15610 (void *)&cmd_set_vxlan_ip_ttl,
15611 (void *)&cmd_set_vxlan_ip_ttl_value,
15612 (void *)&cmd_set_vxlan_ip_src,
15613 (void *)&cmd_set_vxlan_ip_src_value,
15614 (void *)&cmd_set_vxlan_ip_dst,
15615 (void *)&cmd_set_vxlan_ip_dst_value,
15616 (void *)&cmd_set_vxlan_eth_src,
15617 (void *)&cmd_set_vxlan_eth_src_value,
15618 (void *)&cmd_set_vxlan_eth_dst,
15619 (void *)&cmd_set_vxlan_eth_dst_value,
15624 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15625 .f = cmd_set_vxlan_parsed,
15627 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15628 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15629 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15632 (void *)&cmd_set_vxlan_set,
15633 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15634 (void *)&cmd_set_vxlan_ip_version,
15635 (void *)&cmd_set_vxlan_ip_version_value,
15636 (void *)&cmd_set_vxlan_vni,
15637 (void *)&cmd_set_vxlan_vni_value,
15638 (void *)&cmd_set_vxlan_udp_src,
15639 (void *)&cmd_set_vxlan_udp_src_value,
15640 (void *)&cmd_set_vxlan_udp_dst,
15641 (void *)&cmd_set_vxlan_udp_dst_value,
15642 (void *)&cmd_set_vxlan_ip_src,
15643 (void *)&cmd_set_vxlan_ip_src_value,
15644 (void *)&cmd_set_vxlan_ip_dst,
15645 (void *)&cmd_set_vxlan_ip_dst_value,
15646 (void *)&cmd_set_vxlan_vlan,
15647 (void *)&cmd_set_vxlan_vlan_value,
15648 (void *)&cmd_set_vxlan_eth_src,
15649 (void *)&cmd_set_vxlan_eth_src_value,
15650 (void *)&cmd_set_vxlan_eth_dst,
15651 (void *)&cmd_set_vxlan_eth_dst_value,
15656 /** Set NVGRE encapsulation details */
15657 struct cmd_set_nvgre_result {
15658 cmdline_fixed_string_t set;
15659 cmdline_fixed_string_t nvgre;
15660 cmdline_fixed_string_t pos_token;
15661 cmdline_fixed_string_t ip_version;
15663 cmdline_ipaddr_t ip_src;
15664 cmdline_ipaddr_t ip_dst;
15666 struct rte_ether_addr eth_src;
15667 struct rte_ether_addr eth_dst;
15670 cmdline_parse_token_string_t cmd_set_nvgre_set =
15671 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15672 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15673 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15674 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15675 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15676 "nvgre-with-vlan");
15677 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15678 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15680 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15681 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15683 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15684 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15686 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15687 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15688 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15689 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15691 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15692 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15693 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15694 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15696 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15697 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15698 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15699 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15701 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15702 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15703 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15704 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15706 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15707 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15708 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15709 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15711 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15712 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15714 static void cmd_set_nvgre_parsed(void *parsed_result,
15715 __rte_unused struct cmdline *cl,
15716 __rte_unused void *data)
15718 struct cmd_set_nvgre_result *res = parsed_result;
15720 uint32_t nvgre_tni;
15723 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15726 if (strcmp(res->nvgre, "nvgre") == 0)
15727 nvgre_encap_conf.select_vlan = 0;
15728 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15729 nvgre_encap_conf.select_vlan = 1;
15730 if (strcmp(res->ip_version, "ipv4") == 0)
15731 nvgre_encap_conf.select_ipv4 = 1;
15732 else if (strcmp(res->ip_version, "ipv6") == 0)
15733 nvgre_encap_conf.select_ipv4 = 0;
15736 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15737 if (nvgre_encap_conf.select_ipv4) {
15738 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15739 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15741 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15742 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15744 if (nvgre_encap_conf.select_vlan)
15745 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15746 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15747 RTE_ETHER_ADDR_LEN);
15748 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15749 RTE_ETHER_ADDR_LEN);
15752 cmdline_parse_inst_t cmd_set_nvgre = {
15753 .f = cmd_set_nvgre_parsed,
15755 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15756 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15757 " eth-dst <eth-dst>",
15759 (void *)&cmd_set_nvgre_set,
15760 (void *)&cmd_set_nvgre_nvgre,
15761 (void *)&cmd_set_nvgre_ip_version,
15762 (void *)&cmd_set_nvgre_ip_version_value,
15763 (void *)&cmd_set_nvgre_tni,
15764 (void *)&cmd_set_nvgre_tni_value,
15765 (void *)&cmd_set_nvgre_ip_src,
15766 (void *)&cmd_set_nvgre_ip_src_value,
15767 (void *)&cmd_set_nvgre_ip_dst,
15768 (void *)&cmd_set_nvgre_ip_dst_value,
15769 (void *)&cmd_set_nvgre_eth_src,
15770 (void *)&cmd_set_nvgre_eth_src_value,
15771 (void *)&cmd_set_nvgre_eth_dst,
15772 (void *)&cmd_set_nvgre_eth_dst_value,
15777 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15778 .f = cmd_set_nvgre_parsed,
15780 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15781 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15782 " eth-src <eth-src> eth-dst <eth-dst>",
15784 (void *)&cmd_set_nvgre_set,
15785 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15786 (void *)&cmd_set_nvgre_ip_version,
15787 (void *)&cmd_set_nvgre_ip_version_value,
15788 (void *)&cmd_set_nvgre_tni,
15789 (void *)&cmd_set_nvgre_tni_value,
15790 (void *)&cmd_set_nvgre_ip_src,
15791 (void *)&cmd_set_nvgre_ip_src_value,
15792 (void *)&cmd_set_nvgre_ip_dst,
15793 (void *)&cmd_set_nvgre_ip_dst_value,
15794 (void *)&cmd_set_nvgre_vlan,
15795 (void *)&cmd_set_nvgre_vlan_value,
15796 (void *)&cmd_set_nvgre_eth_src,
15797 (void *)&cmd_set_nvgre_eth_src_value,
15798 (void *)&cmd_set_nvgre_eth_dst,
15799 (void *)&cmd_set_nvgre_eth_dst_value,
15804 /** Set L2 encapsulation details */
15805 struct cmd_set_l2_encap_result {
15806 cmdline_fixed_string_t set;
15807 cmdline_fixed_string_t l2_encap;
15808 cmdline_fixed_string_t pos_token;
15809 cmdline_fixed_string_t ip_version;
15810 uint32_t vlan_present:1;
15812 struct rte_ether_addr eth_src;
15813 struct rte_ether_addr eth_dst;
15816 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15817 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15818 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15819 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15820 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15821 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15822 "l2_encap-with-vlan");
15823 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15824 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15826 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15827 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15829 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15830 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15832 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15833 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15834 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15835 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15837 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15838 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15839 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15840 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15842 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15843 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15845 static void cmd_set_l2_encap_parsed(void *parsed_result,
15846 __rte_unused struct cmdline *cl,
15847 __rte_unused void *data)
15849 struct cmd_set_l2_encap_result *res = parsed_result;
15851 if (strcmp(res->l2_encap, "l2_encap") == 0)
15852 l2_encap_conf.select_vlan = 0;
15853 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15854 l2_encap_conf.select_vlan = 1;
15855 if (strcmp(res->ip_version, "ipv4") == 0)
15856 l2_encap_conf.select_ipv4 = 1;
15857 else if (strcmp(res->ip_version, "ipv6") == 0)
15858 l2_encap_conf.select_ipv4 = 0;
15861 if (l2_encap_conf.select_vlan)
15862 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15863 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15864 RTE_ETHER_ADDR_LEN);
15865 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15866 RTE_ETHER_ADDR_LEN);
15869 cmdline_parse_inst_t cmd_set_l2_encap = {
15870 .f = cmd_set_l2_encap_parsed,
15872 .help_str = "set l2_encap ip-version ipv4|ipv6"
15873 " eth-src <eth-src> eth-dst <eth-dst>",
15875 (void *)&cmd_set_l2_encap_set,
15876 (void *)&cmd_set_l2_encap_l2_encap,
15877 (void *)&cmd_set_l2_encap_ip_version,
15878 (void *)&cmd_set_l2_encap_ip_version_value,
15879 (void *)&cmd_set_l2_encap_eth_src,
15880 (void *)&cmd_set_l2_encap_eth_src_value,
15881 (void *)&cmd_set_l2_encap_eth_dst,
15882 (void *)&cmd_set_l2_encap_eth_dst_value,
15887 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15888 .f = cmd_set_l2_encap_parsed,
15890 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15891 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15893 (void *)&cmd_set_l2_encap_set,
15894 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15895 (void *)&cmd_set_l2_encap_ip_version,
15896 (void *)&cmd_set_l2_encap_ip_version_value,
15897 (void *)&cmd_set_l2_encap_vlan,
15898 (void *)&cmd_set_l2_encap_vlan_value,
15899 (void *)&cmd_set_l2_encap_eth_src,
15900 (void *)&cmd_set_l2_encap_eth_src_value,
15901 (void *)&cmd_set_l2_encap_eth_dst,
15902 (void *)&cmd_set_l2_encap_eth_dst_value,
15907 /** Set L2 decapsulation details */
15908 struct cmd_set_l2_decap_result {
15909 cmdline_fixed_string_t set;
15910 cmdline_fixed_string_t l2_decap;
15911 cmdline_fixed_string_t pos_token;
15912 uint32_t vlan_present:1;
15915 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15916 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15917 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15918 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15920 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15921 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15922 "l2_decap-with-vlan");
15924 static void cmd_set_l2_decap_parsed(void *parsed_result,
15925 __rte_unused struct cmdline *cl,
15926 __rte_unused void *data)
15928 struct cmd_set_l2_decap_result *res = parsed_result;
15930 if (strcmp(res->l2_decap, "l2_decap") == 0)
15931 l2_decap_conf.select_vlan = 0;
15932 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15933 l2_decap_conf.select_vlan = 1;
15936 cmdline_parse_inst_t cmd_set_l2_decap = {
15937 .f = cmd_set_l2_decap_parsed,
15939 .help_str = "set l2_decap",
15941 (void *)&cmd_set_l2_decap_set,
15942 (void *)&cmd_set_l2_decap_l2_decap,
15947 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15948 .f = cmd_set_l2_decap_parsed,
15950 .help_str = "set l2_decap-with-vlan",
15952 (void *)&cmd_set_l2_decap_set,
15953 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15958 /** Set MPLSoGRE encapsulation details */
15959 struct cmd_set_mplsogre_encap_result {
15960 cmdline_fixed_string_t set;
15961 cmdline_fixed_string_t mplsogre;
15962 cmdline_fixed_string_t pos_token;
15963 cmdline_fixed_string_t ip_version;
15964 uint32_t vlan_present:1;
15966 cmdline_ipaddr_t ip_src;
15967 cmdline_ipaddr_t ip_dst;
15969 struct rte_ether_addr eth_src;
15970 struct rte_ether_addr eth_dst;
15973 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15974 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15976 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15977 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15979 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15980 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15981 mplsogre, "mplsogre_encap-with-vlan");
15982 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15983 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15984 pos_token, "ip-version");
15985 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15986 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15987 ip_version, "ipv4#ipv6");
15988 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15989 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15990 pos_token, "label");
15991 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15992 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15994 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15995 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15996 pos_token, "ip-src");
15997 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15998 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15999 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16000 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16001 pos_token, "ip-dst");
16002 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16003 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16004 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16005 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16006 pos_token, "vlan-tci");
16007 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16008 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16010 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16011 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16012 pos_token, "eth-src");
16013 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16014 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16016 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16017 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16018 pos_token, "eth-dst");
16019 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16020 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16023 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16024 __rte_unused struct cmdline *cl,
16025 __rte_unused void *data)
16027 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16029 uint32_t mplsogre_label;
16032 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16035 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16036 mplsogre_encap_conf.select_vlan = 0;
16037 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16038 mplsogre_encap_conf.select_vlan = 1;
16039 if (strcmp(res->ip_version, "ipv4") == 0)
16040 mplsogre_encap_conf.select_ipv4 = 1;
16041 else if (strcmp(res->ip_version, "ipv6") == 0)
16042 mplsogre_encap_conf.select_ipv4 = 0;
16045 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16046 if (mplsogre_encap_conf.select_ipv4) {
16047 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16048 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16050 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16051 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16053 if (mplsogre_encap_conf.select_vlan)
16054 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16055 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16056 RTE_ETHER_ADDR_LEN);
16057 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16058 RTE_ETHER_ADDR_LEN);
16061 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16062 .f = cmd_set_mplsogre_encap_parsed,
16064 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16065 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16066 " eth-dst <eth-dst>",
16068 (void *)&cmd_set_mplsogre_encap_set,
16069 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16070 (void *)&cmd_set_mplsogre_encap_ip_version,
16071 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16072 (void *)&cmd_set_mplsogre_encap_label,
16073 (void *)&cmd_set_mplsogre_encap_label_value,
16074 (void *)&cmd_set_mplsogre_encap_ip_src,
16075 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16076 (void *)&cmd_set_mplsogre_encap_ip_dst,
16077 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16078 (void *)&cmd_set_mplsogre_encap_eth_src,
16079 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16080 (void *)&cmd_set_mplsogre_encap_eth_dst,
16081 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16086 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16087 .f = cmd_set_mplsogre_encap_parsed,
16089 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16090 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16091 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16093 (void *)&cmd_set_mplsogre_encap_set,
16094 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16095 (void *)&cmd_set_mplsogre_encap_ip_version,
16096 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16097 (void *)&cmd_set_mplsogre_encap_label,
16098 (void *)&cmd_set_mplsogre_encap_label_value,
16099 (void *)&cmd_set_mplsogre_encap_ip_src,
16100 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16101 (void *)&cmd_set_mplsogre_encap_ip_dst,
16102 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16103 (void *)&cmd_set_mplsogre_encap_vlan,
16104 (void *)&cmd_set_mplsogre_encap_vlan_value,
16105 (void *)&cmd_set_mplsogre_encap_eth_src,
16106 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16107 (void *)&cmd_set_mplsogre_encap_eth_dst,
16108 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16113 /** Set MPLSoGRE decapsulation details */
16114 struct cmd_set_mplsogre_decap_result {
16115 cmdline_fixed_string_t set;
16116 cmdline_fixed_string_t mplsogre;
16117 cmdline_fixed_string_t pos_token;
16118 cmdline_fixed_string_t ip_version;
16119 uint32_t vlan_present:1;
16122 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16123 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16125 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16126 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16128 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16129 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16130 mplsogre, "mplsogre_decap-with-vlan");
16131 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16132 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16133 pos_token, "ip-version");
16134 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16135 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16136 ip_version, "ipv4#ipv6");
16138 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16139 __rte_unused struct cmdline *cl,
16140 __rte_unused void *data)
16142 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16144 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16145 mplsogre_decap_conf.select_vlan = 0;
16146 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16147 mplsogre_decap_conf.select_vlan = 1;
16148 if (strcmp(res->ip_version, "ipv4") == 0)
16149 mplsogre_decap_conf.select_ipv4 = 1;
16150 else if (strcmp(res->ip_version, "ipv6") == 0)
16151 mplsogre_decap_conf.select_ipv4 = 0;
16154 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16155 .f = cmd_set_mplsogre_decap_parsed,
16157 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16159 (void *)&cmd_set_mplsogre_decap_set,
16160 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16161 (void *)&cmd_set_mplsogre_decap_ip_version,
16162 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16167 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16168 .f = cmd_set_mplsogre_decap_parsed,
16170 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16172 (void *)&cmd_set_mplsogre_decap_set,
16173 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16174 (void *)&cmd_set_mplsogre_decap_ip_version,
16175 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16180 /** Set MPLSoUDP encapsulation details */
16181 struct cmd_set_mplsoudp_encap_result {
16182 cmdline_fixed_string_t set;
16183 cmdline_fixed_string_t mplsoudp;
16184 cmdline_fixed_string_t pos_token;
16185 cmdline_fixed_string_t ip_version;
16186 uint32_t vlan_present:1;
16190 cmdline_ipaddr_t ip_src;
16191 cmdline_ipaddr_t ip_dst;
16193 struct rte_ether_addr eth_src;
16194 struct rte_ether_addr eth_dst;
16197 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16198 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16200 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16201 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16203 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16204 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16205 mplsoudp, "mplsoudp_encap-with-vlan");
16206 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16207 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16208 pos_token, "ip-version");
16209 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16210 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16211 ip_version, "ipv4#ipv6");
16212 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16213 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16214 pos_token, "label");
16215 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16216 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16218 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16219 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16220 pos_token, "udp-src");
16221 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16222 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16224 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16225 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16226 pos_token, "udp-dst");
16227 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16228 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16230 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16231 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16232 pos_token, "ip-src");
16233 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16234 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16235 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16236 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16237 pos_token, "ip-dst");
16238 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16239 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16240 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16241 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16242 pos_token, "vlan-tci");
16243 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16244 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16246 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16247 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16248 pos_token, "eth-src");
16249 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16250 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16252 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16253 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16254 pos_token, "eth-dst");
16255 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16256 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16259 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16260 __rte_unused struct cmdline *cl,
16261 __rte_unused void *data)
16263 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16265 uint32_t mplsoudp_label;
16268 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16271 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16272 mplsoudp_encap_conf.select_vlan = 0;
16273 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16274 mplsoudp_encap_conf.select_vlan = 1;
16275 if (strcmp(res->ip_version, "ipv4") == 0)
16276 mplsoudp_encap_conf.select_ipv4 = 1;
16277 else if (strcmp(res->ip_version, "ipv6") == 0)
16278 mplsoudp_encap_conf.select_ipv4 = 0;
16281 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16282 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16283 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16284 if (mplsoudp_encap_conf.select_ipv4) {
16285 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16286 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16288 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16289 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16291 if (mplsoudp_encap_conf.select_vlan)
16292 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16293 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16294 RTE_ETHER_ADDR_LEN);
16295 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16296 RTE_ETHER_ADDR_LEN);
16299 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16300 .f = cmd_set_mplsoudp_encap_parsed,
16302 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16303 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16304 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16306 (void *)&cmd_set_mplsoudp_encap_set,
16307 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16308 (void *)&cmd_set_mplsoudp_encap_ip_version,
16309 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16310 (void *)&cmd_set_mplsoudp_encap_label,
16311 (void *)&cmd_set_mplsoudp_encap_label_value,
16312 (void *)&cmd_set_mplsoudp_encap_udp_src,
16313 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16314 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16315 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16316 (void *)&cmd_set_mplsoudp_encap_ip_src,
16317 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16318 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16319 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16320 (void *)&cmd_set_mplsoudp_encap_eth_src,
16321 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16322 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16323 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16328 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16329 .f = cmd_set_mplsoudp_encap_parsed,
16331 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16332 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16333 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16334 " eth-src <eth-src> eth-dst <eth-dst>",
16336 (void *)&cmd_set_mplsoudp_encap_set,
16337 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16338 (void *)&cmd_set_mplsoudp_encap_ip_version,
16339 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16340 (void *)&cmd_set_mplsoudp_encap_label,
16341 (void *)&cmd_set_mplsoudp_encap_label_value,
16342 (void *)&cmd_set_mplsoudp_encap_udp_src,
16343 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16344 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16345 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16346 (void *)&cmd_set_mplsoudp_encap_ip_src,
16347 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16348 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16349 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16350 (void *)&cmd_set_mplsoudp_encap_vlan,
16351 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16352 (void *)&cmd_set_mplsoudp_encap_eth_src,
16353 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16354 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16355 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16360 /** Set MPLSoUDP decapsulation details */
16361 struct cmd_set_mplsoudp_decap_result {
16362 cmdline_fixed_string_t set;
16363 cmdline_fixed_string_t mplsoudp;
16364 cmdline_fixed_string_t pos_token;
16365 cmdline_fixed_string_t ip_version;
16366 uint32_t vlan_present:1;
16369 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16370 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16372 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16373 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16375 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16376 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16377 mplsoudp, "mplsoudp_decap-with-vlan");
16378 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16379 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16380 pos_token, "ip-version");
16381 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16382 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16383 ip_version, "ipv4#ipv6");
16385 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16386 __rte_unused struct cmdline *cl,
16387 __rte_unused void *data)
16389 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16391 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16392 mplsoudp_decap_conf.select_vlan = 0;
16393 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16394 mplsoudp_decap_conf.select_vlan = 1;
16395 if (strcmp(res->ip_version, "ipv4") == 0)
16396 mplsoudp_decap_conf.select_ipv4 = 1;
16397 else if (strcmp(res->ip_version, "ipv6") == 0)
16398 mplsoudp_decap_conf.select_ipv4 = 0;
16401 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16402 .f = cmd_set_mplsoudp_decap_parsed,
16404 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16406 (void *)&cmd_set_mplsoudp_decap_set,
16407 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16408 (void *)&cmd_set_mplsoudp_decap_ip_version,
16409 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16414 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16415 .f = cmd_set_mplsoudp_decap_parsed,
16417 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16419 (void *)&cmd_set_mplsoudp_decap_set,
16420 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16421 (void *)&cmd_set_mplsoudp_decap_ip_version,
16422 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16427 /* Strict link priority scheduling mode setting */
16429 cmd_strict_link_prio_parsed(
16430 void *parsed_result,
16431 __rte_unused struct cmdline *cl,
16432 __rte_unused void *data)
16434 struct cmd_vf_tc_bw_result *res = parsed_result;
16435 int ret = -ENOTSUP;
16437 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16440 #ifdef RTE_LIBRTE_I40E_PMD
16441 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16448 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16451 printf("invalid port_id %d\n", res->port_id);
16454 printf("function not implemented\n");
16457 printf("programming error: (%s)\n", strerror(-ret));
16461 cmdline_parse_inst_t cmd_strict_link_prio = {
16462 .f = cmd_strict_link_prio_parsed,
16464 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16466 (void *)&cmd_vf_tc_bw_set,
16467 (void *)&cmd_vf_tc_bw_tx,
16468 (void *)&cmd_vf_tc_bw_strict_link_prio,
16469 (void *)&cmd_vf_tc_bw_port_id,
16470 (void *)&cmd_vf_tc_bw_tc_map,
16475 /* Load dynamic device personalization*/
16476 struct cmd_ddp_add_result {
16477 cmdline_fixed_string_t ddp;
16478 cmdline_fixed_string_t add;
16483 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16484 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16485 cmdline_parse_token_string_t cmd_ddp_add_add =
16486 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16487 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16488 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16489 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16490 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16493 cmd_ddp_add_parsed(
16494 void *parsed_result,
16495 __rte_unused struct cmdline *cl,
16496 __rte_unused void *data)
16498 struct cmd_ddp_add_result *res = parsed_result;
16504 int ret = -ENOTSUP;
16506 if (!all_ports_stopped()) {
16507 printf("Please stop all ports first\n");
16511 filepath = strdup(res->filepath);
16512 if (filepath == NULL) {
16513 printf("Failed to allocate memory\n");
16516 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16518 buff = open_file(file_fld[0], &size);
16520 free((void *)filepath);
16524 #ifdef RTE_LIBRTE_I40E_PMD
16525 if (ret == -ENOTSUP)
16526 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16528 RTE_PMD_I40E_PKG_OP_WR_ADD);
16531 if (ret == -EEXIST)
16532 printf("Profile has already existed.\n");
16534 printf("Failed to load profile.\n");
16535 else if (file_num == 2)
16536 save_file(file_fld[1], buff, size);
16539 free((void *)filepath);
16542 cmdline_parse_inst_t cmd_ddp_add = {
16543 .f = cmd_ddp_add_parsed,
16545 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16547 (void *)&cmd_ddp_add_ddp,
16548 (void *)&cmd_ddp_add_add,
16549 (void *)&cmd_ddp_add_port_id,
16550 (void *)&cmd_ddp_add_filepath,
16555 /* Delete dynamic device personalization*/
16556 struct cmd_ddp_del_result {
16557 cmdline_fixed_string_t ddp;
16558 cmdline_fixed_string_t del;
16563 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16564 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16565 cmdline_parse_token_string_t cmd_ddp_del_del =
16566 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16567 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16568 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16569 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16570 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16573 cmd_ddp_del_parsed(
16574 void *parsed_result,
16575 __rte_unused struct cmdline *cl,
16576 __rte_unused void *data)
16578 struct cmd_ddp_del_result *res = parsed_result;
16581 int ret = -ENOTSUP;
16583 if (!all_ports_stopped()) {
16584 printf("Please stop all ports first\n");
16588 buff = open_file(res->filepath, &size);
16592 #ifdef RTE_LIBRTE_I40E_PMD
16593 if (ret == -ENOTSUP)
16594 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16596 RTE_PMD_I40E_PKG_OP_WR_DEL);
16599 if (ret == -EACCES)
16600 printf("Profile does not exist.\n");
16602 printf("Failed to delete profile.\n");
16607 cmdline_parse_inst_t cmd_ddp_del = {
16608 .f = cmd_ddp_del_parsed,
16610 .help_str = "ddp del <port_id> <backup_profile_path>",
16612 (void *)&cmd_ddp_del_ddp,
16613 (void *)&cmd_ddp_del_del,
16614 (void *)&cmd_ddp_del_port_id,
16615 (void *)&cmd_ddp_del_filepath,
16620 /* Get dynamic device personalization profile info */
16621 struct cmd_ddp_info_result {
16622 cmdline_fixed_string_t ddp;
16623 cmdline_fixed_string_t get;
16624 cmdline_fixed_string_t info;
16628 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16629 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16630 cmdline_parse_token_string_t cmd_ddp_info_get =
16631 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16632 cmdline_parse_token_string_t cmd_ddp_info_info =
16633 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16634 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16635 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16638 cmd_ddp_info_parsed(
16639 void *parsed_result,
16640 __rte_unused struct cmdline *cl,
16641 __rte_unused void *data)
16643 struct cmd_ddp_info_result *res = parsed_result;
16646 int ret = -ENOTSUP;
16647 #ifdef RTE_LIBRTE_I40E_PMD
16650 uint32_t buff_size = 0;
16651 struct rte_pmd_i40e_profile_info info;
16652 uint32_t dev_num = 0;
16653 struct rte_pmd_i40e_ddp_device_id *devs;
16654 uint32_t proto_num = 0;
16655 struct rte_pmd_i40e_proto_info *proto = NULL;
16656 uint32_t pctype_num = 0;
16657 struct rte_pmd_i40e_ptype_info *pctype;
16658 uint32_t ptype_num = 0;
16659 struct rte_pmd_i40e_ptype_info *ptype;
16664 pkg = open_file(res->filepath, &pkg_size);
16668 #ifdef RTE_LIBRTE_I40E_PMD
16669 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16670 (uint8_t *)&info, sizeof(info),
16671 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16673 printf("Global Track id: 0x%x\n", info.track_id);
16674 printf("Global Version: %d.%d.%d.%d\n",
16675 info.version.major,
16676 info.version.minor,
16677 info.version.update,
16678 info.version.draft);
16679 printf("Global Package name: %s\n\n", info.name);
16682 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16683 (uint8_t *)&info, sizeof(info),
16684 RTE_PMD_I40E_PKG_INFO_HEADER);
16686 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16687 printf("i40e Profile Version: %d.%d.%d.%d\n",
16688 info.version.major,
16689 info.version.minor,
16690 info.version.update,
16691 info.version.draft);
16692 printf("i40e Profile name: %s\n\n", info.name);
16695 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16696 (uint8_t *)&buff_size, sizeof(buff_size),
16697 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16698 if (!ret && buff_size) {
16699 buff = (uint8_t *)malloc(buff_size);
16701 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16703 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16705 printf("Package Notes:\n%s\n\n", buff);
16710 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16711 (uint8_t *)&dev_num, sizeof(dev_num),
16712 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16713 if (!ret && dev_num) {
16714 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16715 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16717 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16718 (uint8_t *)devs, buff_size,
16719 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16721 printf("List of supported devices:\n");
16722 for (i = 0; i < dev_num; i++) {
16723 printf(" %04X:%04X %04X:%04X\n",
16724 devs[i].vendor_dev_id >> 16,
16725 devs[i].vendor_dev_id & 0xFFFF,
16726 devs[i].sub_vendor_dev_id >> 16,
16727 devs[i].sub_vendor_dev_id & 0xFFFF);
16735 /* get information about protocols and packet types */
16736 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16737 (uint8_t *)&proto_num, sizeof(proto_num),
16738 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16739 if (ret || !proto_num)
16740 goto no_print_return;
16742 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16743 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16745 goto no_print_return;
16747 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16749 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16751 printf("List of used protocols:\n");
16752 for (i = 0; i < proto_num; i++)
16753 printf(" %2u: %s\n", proto[i].proto_id,
16757 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16758 (uint8_t *)&pctype_num, sizeof(pctype_num),
16759 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16760 if (ret || !pctype_num)
16761 goto no_print_pctypes;
16763 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16764 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16766 goto no_print_pctypes;
16768 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16770 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16773 goto no_print_pctypes;
16776 printf("List of defined packet classification types:\n");
16777 for (i = 0; i < pctype_num; i++) {
16778 printf(" %2u:", pctype[i].ptype_id);
16779 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16780 proto_id = pctype[i].protocols[j];
16781 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16782 for (n = 0; n < proto_num; n++) {
16783 if (proto[n].proto_id == proto_id) {
16784 printf(" %s", proto[n].name);
16797 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16799 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16800 if (ret || !ptype_num)
16801 goto no_print_return;
16803 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16804 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16806 goto no_print_return;
16808 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16810 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16813 goto no_print_return;
16815 printf("List of defined packet types:\n");
16816 for (i = 0; i < ptype_num; i++) {
16817 printf(" %2u:", ptype[i].ptype_id);
16818 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16819 proto_id = ptype[i].protocols[j];
16820 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16821 for (n = 0; n < proto_num; n++) {
16822 if (proto[n].proto_id == proto_id) {
16823 printf(" %s", proto[n].name);
16839 if (ret == -ENOTSUP)
16840 printf("Function not supported in PMD driver\n");
16844 cmdline_parse_inst_t cmd_ddp_get_info = {
16845 .f = cmd_ddp_info_parsed,
16847 .help_str = "ddp get info <profile_path>",
16849 (void *)&cmd_ddp_info_ddp,
16850 (void *)&cmd_ddp_info_get,
16851 (void *)&cmd_ddp_info_info,
16852 (void *)&cmd_ddp_info_filepath,
16857 /* Get dynamic device personalization profile info list*/
16858 #define PROFILE_INFO_SIZE 48
16859 #define MAX_PROFILE_NUM 16
16861 struct cmd_ddp_get_list_result {
16862 cmdline_fixed_string_t ddp;
16863 cmdline_fixed_string_t get;
16864 cmdline_fixed_string_t list;
16868 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16869 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16870 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16871 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16872 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16873 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16874 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16875 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16878 cmd_ddp_get_list_parsed(
16879 __rte_unused void *parsed_result,
16880 __rte_unused struct cmdline *cl,
16881 __rte_unused void *data)
16883 #ifdef RTE_LIBRTE_I40E_PMD
16884 struct cmd_ddp_get_list_result *res = parsed_result;
16885 struct rte_pmd_i40e_profile_list *p_list;
16886 struct rte_pmd_i40e_profile_info *p_info;
16891 int ret = -ENOTSUP;
16893 #ifdef RTE_LIBRTE_I40E_PMD
16894 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16895 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16897 printf("%s: Failed to malloc buffer\n", __func__);
16901 if (ret == -ENOTSUP)
16902 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16903 (uint8_t *)p_list, size);
16906 p_num = p_list->p_count;
16907 printf("Profile number is: %d\n\n", p_num);
16909 for (i = 0; i < p_num; i++) {
16910 p_info = &p_list->p_info[i];
16911 printf("Profile %d:\n", i);
16912 printf("Track id: 0x%x\n", p_info->track_id);
16913 printf("Version: %d.%d.%d.%d\n",
16914 p_info->version.major,
16915 p_info->version.minor,
16916 p_info->version.update,
16917 p_info->version.draft);
16918 printf("Profile name: %s\n\n", p_info->name);
16926 printf("Failed to get ddp list\n");
16929 cmdline_parse_inst_t cmd_ddp_get_list = {
16930 .f = cmd_ddp_get_list_parsed,
16932 .help_str = "ddp get list <port_id>",
16934 (void *)&cmd_ddp_get_list_ddp,
16935 (void *)&cmd_ddp_get_list_get,
16936 (void *)&cmd_ddp_get_list_list,
16937 (void *)&cmd_ddp_get_list_port_id,
16942 /* Configure input set */
16943 struct cmd_cfg_input_set_result {
16944 cmdline_fixed_string_t port;
16945 cmdline_fixed_string_t cfg;
16947 cmdline_fixed_string_t pctype;
16949 cmdline_fixed_string_t inset_type;
16950 cmdline_fixed_string_t opt;
16951 cmdline_fixed_string_t field;
16956 cmd_cfg_input_set_parsed(
16957 __rte_unused void *parsed_result,
16958 __rte_unused struct cmdline *cl,
16959 __rte_unused void *data)
16961 #ifdef RTE_LIBRTE_I40E_PMD
16962 struct cmd_cfg_input_set_result *res = parsed_result;
16963 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16964 struct rte_pmd_i40e_inset inset;
16966 int ret = -ENOTSUP;
16968 if (!all_ports_stopped()) {
16969 printf("Please stop all ports first\n");
16973 #ifdef RTE_LIBRTE_I40E_PMD
16974 if (!strcmp(res->inset_type, "hash_inset"))
16975 inset_type = INSET_HASH;
16976 else if (!strcmp(res->inset_type, "fdir_inset"))
16977 inset_type = INSET_FDIR;
16978 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16979 inset_type = INSET_FDIR_FLX;
16980 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16981 &inset, inset_type);
16983 printf("Failed to get input set.\n");
16987 if (!strcmp(res->opt, "get")) {
16988 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16991 printf("Field index %d is enabled.\n", res->field_idx);
16993 printf("Field index %d is disabled.\n", res->field_idx);
16995 } else if (!strcmp(res->opt, "set"))
16996 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16998 else if (!strcmp(res->opt, "clear"))
16999 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17002 printf("Failed to configure input set field.\n");
17006 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17007 &inset, inset_type);
17009 printf("Failed to set input set.\n");
17014 if (ret == -ENOTSUP)
17015 printf("Function not supported\n");
17018 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17019 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17021 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17022 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17024 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17025 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17027 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17028 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17030 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17031 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17033 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17034 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17036 "hash_inset#fdir_inset#fdir_flx_inset");
17037 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17038 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17039 opt, "get#set#clear");
17040 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17041 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17043 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17044 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17047 cmdline_parse_inst_t cmd_cfg_input_set = {
17048 .f = cmd_cfg_input_set_parsed,
17050 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17051 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17053 (void *)&cmd_cfg_input_set_port,
17054 (void *)&cmd_cfg_input_set_cfg,
17055 (void *)&cmd_cfg_input_set_port_id,
17056 (void *)&cmd_cfg_input_set_pctype,
17057 (void *)&cmd_cfg_input_set_pctype_id,
17058 (void *)&cmd_cfg_input_set_inset_type,
17059 (void *)&cmd_cfg_input_set_opt,
17060 (void *)&cmd_cfg_input_set_field,
17061 (void *)&cmd_cfg_input_set_field_idx,
17066 /* Clear input set */
17067 struct cmd_clear_input_set_result {
17068 cmdline_fixed_string_t port;
17069 cmdline_fixed_string_t cfg;
17071 cmdline_fixed_string_t pctype;
17073 cmdline_fixed_string_t inset_type;
17074 cmdline_fixed_string_t clear;
17075 cmdline_fixed_string_t all;
17079 cmd_clear_input_set_parsed(
17080 __rte_unused void *parsed_result,
17081 __rte_unused struct cmdline *cl,
17082 __rte_unused void *data)
17084 #ifdef RTE_LIBRTE_I40E_PMD
17085 struct cmd_clear_input_set_result *res = parsed_result;
17086 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17087 struct rte_pmd_i40e_inset inset;
17089 int ret = -ENOTSUP;
17091 if (!all_ports_stopped()) {
17092 printf("Please stop all ports first\n");
17096 #ifdef RTE_LIBRTE_I40E_PMD
17097 if (!strcmp(res->inset_type, "hash_inset"))
17098 inset_type = INSET_HASH;
17099 else if (!strcmp(res->inset_type, "fdir_inset"))
17100 inset_type = INSET_FDIR;
17101 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17102 inset_type = INSET_FDIR_FLX;
17104 memset(&inset, 0, sizeof(inset));
17106 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17107 &inset, inset_type);
17109 printf("Failed to clear input set.\n");
17115 if (ret == -ENOTSUP)
17116 printf("Function not supported\n");
17119 cmdline_parse_token_string_t cmd_clear_input_set_port =
17120 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17122 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17123 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17125 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17126 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17128 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17129 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17131 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17132 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17134 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17135 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17137 "hash_inset#fdir_inset#fdir_flx_inset");
17138 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17139 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17141 cmdline_parse_token_string_t cmd_clear_input_set_all =
17142 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17145 cmdline_parse_inst_t cmd_clear_input_set = {
17146 .f = cmd_clear_input_set_parsed,
17148 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17149 "fdir_inset|fdir_flx_inset clear all",
17151 (void *)&cmd_clear_input_set_port,
17152 (void *)&cmd_clear_input_set_cfg,
17153 (void *)&cmd_clear_input_set_port_id,
17154 (void *)&cmd_clear_input_set_pctype,
17155 (void *)&cmd_clear_input_set_pctype_id,
17156 (void *)&cmd_clear_input_set_inset_type,
17157 (void *)&cmd_clear_input_set_clear,
17158 (void *)&cmd_clear_input_set_all,
17163 /* show vf stats */
17165 /* Common result structure for show vf stats */
17166 struct cmd_show_vf_stats_result {
17167 cmdline_fixed_string_t show;
17168 cmdline_fixed_string_t vf;
17169 cmdline_fixed_string_t stats;
17174 /* Common CLI fields show vf stats*/
17175 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17176 TOKEN_STRING_INITIALIZER
17177 (struct cmd_show_vf_stats_result,
17179 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17180 TOKEN_STRING_INITIALIZER
17181 (struct cmd_show_vf_stats_result,
17183 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17184 TOKEN_STRING_INITIALIZER
17185 (struct cmd_show_vf_stats_result,
17187 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17188 TOKEN_NUM_INITIALIZER
17189 (struct cmd_show_vf_stats_result,
17191 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17192 TOKEN_NUM_INITIALIZER
17193 (struct cmd_show_vf_stats_result,
17197 cmd_show_vf_stats_parsed(
17198 void *parsed_result,
17199 __rte_unused struct cmdline *cl,
17200 __rte_unused void *data)
17202 struct cmd_show_vf_stats_result *res = parsed_result;
17203 struct rte_eth_stats stats;
17204 int ret = -ENOTSUP;
17205 static const char *nic_stats_border = "########################";
17207 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17210 memset(&stats, 0, sizeof(stats));
17212 #ifdef RTE_LIBRTE_I40E_PMD
17213 if (ret == -ENOTSUP)
17214 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17218 #ifdef RTE_LIBRTE_BNXT_PMD
17219 if (ret == -ENOTSUP)
17220 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17229 printf("invalid vf_id %d\n", res->vf_id);
17232 printf("invalid port_id %d\n", res->port_id);
17235 printf("function not implemented\n");
17238 printf("programming error: (%s)\n", strerror(-ret));
17241 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17242 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17244 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17246 stats.ipackets, stats.imissed, stats.ibytes);
17247 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17248 printf(" RX-nombuf: %-10"PRIu64"\n",
17250 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17252 stats.opackets, stats.oerrors, stats.obytes);
17254 printf(" %s############################%s\n",
17255 nic_stats_border, nic_stats_border);
17258 cmdline_parse_inst_t cmd_show_vf_stats = {
17259 .f = cmd_show_vf_stats_parsed,
17261 .help_str = "show vf stats <port_id> <vf_id>",
17263 (void *)&cmd_show_vf_stats_show,
17264 (void *)&cmd_show_vf_stats_vf,
17265 (void *)&cmd_show_vf_stats_stats,
17266 (void *)&cmd_show_vf_stats_port_id,
17267 (void *)&cmd_show_vf_stats_vf_id,
17272 /* clear vf stats */
17274 /* Common result structure for clear vf stats */
17275 struct cmd_clear_vf_stats_result {
17276 cmdline_fixed_string_t clear;
17277 cmdline_fixed_string_t vf;
17278 cmdline_fixed_string_t stats;
17283 /* Common CLI fields clear vf stats*/
17284 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17285 TOKEN_STRING_INITIALIZER
17286 (struct cmd_clear_vf_stats_result,
17288 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17289 TOKEN_STRING_INITIALIZER
17290 (struct cmd_clear_vf_stats_result,
17292 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17293 TOKEN_STRING_INITIALIZER
17294 (struct cmd_clear_vf_stats_result,
17296 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17297 TOKEN_NUM_INITIALIZER
17298 (struct cmd_clear_vf_stats_result,
17300 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17301 TOKEN_NUM_INITIALIZER
17302 (struct cmd_clear_vf_stats_result,
17306 cmd_clear_vf_stats_parsed(
17307 void *parsed_result,
17308 __rte_unused struct cmdline *cl,
17309 __rte_unused void *data)
17311 struct cmd_clear_vf_stats_result *res = parsed_result;
17312 int ret = -ENOTSUP;
17314 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17317 #ifdef RTE_LIBRTE_I40E_PMD
17318 if (ret == -ENOTSUP)
17319 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17322 #ifdef RTE_LIBRTE_BNXT_PMD
17323 if (ret == -ENOTSUP)
17324 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17332 printf("invalid vf_id %d\n", res->vf_id);
17335 printf("invalid port_id %d\n", res->port_id);
17338 printf("function not implemented\n");
17341 printf("programming error: (%s)\n", strerror(-ret));
17345 cmdline_parse_inst_t cmd_clear_vf_stats = {
17346 .f = cmd_clear_vf_stats_parsed,
17348 .help_str = "clear vf stats <port_id> <vf_id>",
17350 (void *)&cmd_clear_vf_stats_clear,
17351 (void *)&cmd_clear_vf_stats_vf,
17352 (void *)&cmd_clear_vf_stats_stats,
17353 (void *)&cmd_clear_vf_stats_port_id,
17354 (void *)&cmd_clear_vf_stats_vf_id,
17359 /* port config pctype mapping reset */
17361 /* Common result structure for port config pctype mapping reset */
17362 struct cmd_pctype_mapping_reset_result {
17363 cmdline_fixed_string_t port;
17364 cmdline_fixed_string_t config;
17366 cmdline_fixed_string_t pctype;
17367 cmdline_fixed_string_t mapping;
17368 cmdline_fixed_string_t reset;
17371 /* Common CLI fields for port config pctype mapping reset*/
17372 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17373 TOKEN_STRING_INITIALIZER
17374 (struct cmd_pctype_mapping_reset_result,
17376 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17377 TOKEN_STRING_INITIALIZER
17378 (struct cmd_pctype_mapping_reset_result,
17380 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17381 TOKEN_NUM_INITIALIZER
17382 (struct cmd_pctype_mapping_reset_result,
17384 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17385 TOKEN_STRING_INITIALIZER
17386 (struct cmd_pctype_mapping_reset_result,
17388 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17389 TOKEN_STRING_INITIALIZER
17390 (struct cmd_pctype_mapping_reset_result,
17391 mapping, "mapping");
17392 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17393 TOKEN_STRING_INITIALIZER
17394 (struct cmd_pctype_mapping_reset_result,
17398 cmd_pctype_mapping_reset_parsed(
17399 void *parsed_result,
17400 __rte_unused struct cmdline *cl,
17401 __rte_unused void *data)
17403 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17404 int ret = -ENOTSUP;
17406 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17409 #ifdef RTE_LIBRTE_I40E_PMD
17410 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17417 printf("invalid port_id %d\n", res->port_id);
17420 printf("function not implemented\n");
17423 printf("programming error: (%s)\n", strerror(-ret));
17427 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17428 .f = cmd_pctype_mapping_reset_parsed,
17430 .help_str = "port config <port_id> pctype mapping reset",
17432 (void *)&cmd_pctype_mapping_reset_port,
17433 (void *)&cmd_pctype_mapping_reset_config,
17434 (void *)&cmd_pctype_mapping_reset_port_id,
17435 (void *)&cmd_pctype_mapping_reset_pctype,
17436 (void *)&cmd_pctype_mapping_reset_mapping,
17437 (void *)&cmd_pctype_mapping_reset_reset,
17442 /* show port pctype mapping */
17444 /* Common result structure for show port pctype mapping */
17445 struct cmd_pctype_mapping_get_result {
17446 cmdline_fixed_string_t show;
17447 cmdline_fixed_string_t port;
17449 cmdline_fixed_string_t pctype;
17450 cmdline_fixed_string_t mapping;
17453 /* Common CLI fields for pctype mapping get */
17454 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17455 TOKEN_STRING_INITIALIZER
17456 (struct cmd_pctype_mapping_get_result,
17458 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17459 TOKEN_STRING_INITIALIZER
17460 (struct cmd_pctype_mapping_get_result,
17462 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17463 TOKEN_NUM_INITIALIZER
17464 (struct cmd_pctype_mapping_get_result,
17466 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17467 TOKEN_STRING_INITIALIZER
17468 (struct cmd_pctype_mapping_get_result,
17470 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17471 TOKEN_STRING_INITIALIZER
17472 (struct cmd_pctype_mapping_get_result,
17473 mapping, "mapping");
17476 cmd_pctype_mapping_get_parsed(
17477 void *parsed_result,
17478 __rte_unused struct cmdline *cl,
17479 __rte_unused void *data)
17481 struct cmd_pctype_mapping_get_result *res = parsed_result;
17482 int ret = -ENOTSUP;
17483 #ifdef RTE_LIBRTE_I40E_PMD
17484 struct rte_pmd_i40e_flow_type_mapping
17485 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17486 int i, j, first_pctype;
17489 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17492 #ifdef RTE_LIBRTE_I40E_PMD
17493 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17500 printf("invalid port_id %d\n", res->port_id);
17503 printf("function not implemented\n");
17506 printf("programming error: (%s)\n", strerror(-ret));
17510 #ifdef RTE_LIBRTE_I40E_PMD
17511 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17512 if (mapping[i].pctype != 0ULL) {
17515 printf("pctype: ");
17516 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17517 if (mapping[i].pctype & (1ULL << j)) {
17518 printf(first_pctype ?
17519 "%02d" : ",%02d", j);
17523 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17529 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17530 .f = cmd_pctype_mapping_get_parsed,
17532 .help_str = "show port <port_id> pctype mapping",
17534 (void *)&cmd_pctype_mapping_get_show,
17535 (void *)&cmd_pctype_mapping_get_port,
17536 (void *)&cmd_pctype_mapping_get_port_id,
17537 (void *)&cmd_pctype_mapping_get_pctype,
17538 (void *)&cmd_pctype_mapping_get_mapping,
17543 /* port config pctype mapping update */
17545 /* Common result structure for port config pctype mapping update */
17546 struct cmd_pctype_mapping_update_result {
17547 cmdline_fixed_string_t port;
17548 cmdline_fixed_string_t config;
17550 cmdline_fixed_string_t pctype;
17551 cmdline_fixed_string_t mapping;
17552 cmdline_fixed_string_t update;
17553 cmdline_fixed_string_t pctype_list;
17554 uint16_t flow_type;
17557 /* Common CLI fields for pctype mapping update*/
17558 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17559 TOKEN_STRING_INITIALIZER
17560 (struct cmd_pctype_mapping_update_result,
17562 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17563 TOKEN_STRING_INITIALIZER
17564 (struct cmd_pctype_mapping_update_result,
17566 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17567 TOKEN_NUM_INITIALIZER
17568 (struct cmd_pctype_mapping_update_result,
17570 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17571 TOKEN_STRING_INITIALIZER
17572 (struct cmd_pctype_mapping_update_result,
17574 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17575 TOKEN_STRING_INITIALIZER
17576 (struct cmd_pctype_mapping_update_result,
17577 mapping, "mapping");
17578 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17579 TOKEN_STRING_INITIALIZER
17580 (struct cmd_pctype_mapping_update_result,
17582 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17583 TOKEN_STRING_INITIALIZER
17584 (struct cmd_pctype_mapping_update_result,
17585 pctype_list, NULL);
17586 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17587 TOKEN_NUM_INITIALIZER
17588 (struct cmd_pctype_mapping_update_result,
17589 flow_type, UINT16);
17592 cmd_pctype_mapping_update_parsed(
17593 void *parsed_result,
17594 __rte_unused struct cmdline *cl,
17595 __rte_unused void *data)
17597 struct cmd_pctype_mapping_update_result *res = parsed_result;
17598 int ret = -ENOTSUP;
17599 #ifdef RTE_LIBRTE_I40E_PMD
17600 struct rte_pmd_i40e_flow_type_mapping mapping;
17602 unsigned int nb_item;
17603 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17606 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17609 #ifdef RTE_LIBRTE_I40E_PMD
17610 nb_item = parse_item_list(res->pctype_list, "pctypes",
17611 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17612 mapping.flow_type = res->flow_type;
17613 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17614 mapping.pctype |= (1ULL << pctype_list[i]);
17615 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17625 printf("invalid pctype or flow type\n");
17628 printf("invalid port_id %d\n", res->port_id);
17631 printf("function not implemented\n");
17634 printf("programming error: (%s)\n", strerror(-ret));
17638 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17639 .f = cmd_pctype_mapping_update_parsed,
17641 .help_str = "port config <port_id> pctype mapping update"
17642 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17644 (void *)&cmd_pctype_mapping_update_port,
17645 (void *)&cmd_pctype_mapping_update_config,
17646 (void *)&cmd_pctype_mapping_update_port_id,
17647 (void *)&cmd_pctype_mapping_update_pctype,
17648 (void *)&cmd_pctype_mapping_update_mapping,
17649 (void *)&cmd_pctype_mapping_update_update,
17650 (void *)&cmd_pctype_mapping_update_pc_type,
17651 (void *)&cmd_pctype_mapping_update_flow_type,
17656 /* ptype mapping get */
17658 /* Common result structure for ptype mapping get */
17659 struct cmd_ptype_mapping_get_result {
17660 cmdline_fixed_string_t ptype;
17661 cmdline_fixed_string_t mapping;
17662 cmdline_fixed_string_t get;
17664 uint8_t valid_only;
17667 /* Common CLI fields for ptype mapping get */
17668 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17669 TOKEN_STRING_INITIALIZER
17670 (struct cmd_ptype_mapping_get_result,
17672 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17673 TOKEN_STRING_INITIALIZER
17674 (struct cmd_ptype_mapping_get_result,
17675 mapping, "mapping");
17676 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17677 TOKEN_STRING_INITIALIZER
17678 (struct cmd_ptype_mapping_get_result,
17680 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17681 TOKEN_NUM_INITIALIZER
17682 (struct cmd_ptype_mapping_get_result,
17684 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17685 TOKEN_NUM_INITIALIZER
17686 (struct cmd_ptype_mapping_get_result,
17687 valid_only, UINT8);
17690 cmd_ptype_mapping_get_parsed(
17691 void *parsed_result,
17692 __rte_unused struct cmdline *cl,
17693 __rte_unused void *data)
17695 struct cmd_ptype_mapping_get_result *res = parsed_result;
17696 int ret = -ENOTSUP;
17697 #ifdef RTE_LIBRTE_I40E_PMD
17698 int max_ptype_num = 256;
17699 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17704 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17707 #ifdef RTE_LIBRTE_I40E_PMD
17708 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17719 printf("invalid port_id %d\n", res->port_id);
17722 printf("function not implemented\n");
17725 printf("programming error: (%s)\n", strerror(-ret));
17728 #ifdef RTE_LIBRTE_I40E_PMD
17730 for (i = 0; i < count; i++)
17731 printf("%3d\t0x%08x\n",
17732 mapping[i].hw_ptype, mapping[i].sw_ptype);
17737 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17738 .f = cmd_ptype_mapping_get_parsed,
17740 .help_str = "ptype mapping get <port_id> <valid_only>",
17742 (void *)&cmd_ptype_mapping_get_ptype,
17743 (void *)&cmd_ptype_mapping_get_mapping,
17744 (void *)&cmd_ptype_mapping_get_get,
17745 (void *)&cmd_ptype_mapping_get_port_id,
17746 (void *)&cmd_ptype_mapping_get_valid_only,
17751 /* ptype mapping replace */
17753 /* Common result structure for ptype mapping replace */
17754 struct cmd_ptype_mapping_replace_result {
17755 cmdline_fixed_string_t ptype;
17756 cmdline_fixed_string_t mapping;
17757 cmdline_fixed_string_t replace;
17764 /* Common CLI fields for ptype mapping replace */
17765 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17766 TOKEN_STRING_INITIALIZER
17767 (struct cmd_ptype_mapping_replace_result,
17769 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17770 TOKEN_STRING_INITIALIZER
17771 (struct cmd_ptype_mapping_replace_result,
17772 mapping, "mapping");
17773 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17774 TOKEN_STRING_INITIALIZER
17775 (struct cmd_ptype_mapping_replace_result,
17776 replace, "replace");
17777 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17778 TOKEN_NUM_INITIALIZER
17779 (struct cmd_ptype_mapping_replace_result,
17781 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17782 TOKEN_NUM_INITIALIZER
17783 (struct cmd_ptype_mapping_replace_result,
17785 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17786 TOKEN_NUM_INITIALIZER
17787 (struct cmd_ptype_mapping_replace_result,
17789 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17790 TOKEN_NUM_INITIALIZER
17791 (struct cmd_ptype_mapping_replace_result,
17795 cmd_ptype_mapping_replace_parsed(
17796 void *parsed_result,
17797 __rte_unused struct cmdline *cl,
17798 __rte_unused void *data)
17800 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17801 int ret = -ENOTSUP;
17803 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17806 #ifdef RTE_LIBRTE_I40E_PMD
17807 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17817 printf("invalid ptype 0x%8x or 0x%8x\n",
17818 res->target, res->pkt_type);
17821 printf("invalid port_id %d\n", res->port_id);
17824 printf("function not implemented\n");
17827 printf("programming error: (%s)\n", strerror(-ret));
17831 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17832 .f = cmd_ptype_mapping_replace_parsed,
17835 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17837 (void *)&cmd_ptype_mapping_replace_ptype,
17838 (void *)&cmd_ptype_mapping_replace_mapping,
17839 (void *)&cmd_ptype_mapping_replace_replace,
17840 (void *)&cmd_ptype_mapping_replace_port_id,
17841 (void *)&cmd_ptype_mapping_replace_target,
17842 (void *)&cmd_ptype_mapping_replace_mask,
17843 (void *)&cmd_ptype_mapping_replace_pkt_type,
17848 /* ptype mapping reset */
17850 /* Common result structure for ptype mapping reset */
17851 struct cmd_ptype_mapping_reset_result {
17852 cmdline_fixed_string_t ptype;
17853 cmdline_fixed_string_t mapping;
17854 cmdline_fixed_string_t reset;
17858 /* Common CLI fields for ptype mapping reset*/
17859 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17860 TOKEN_STRING_INITIALIZER
17861 (struct cmd_ptype_mapping_reset_result,
17863 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17864 TOKEN_STRING_INITIALIZER
17865 (struct cmd_ptype_mapping_reset_result,
17866 mapping, "mapping");
17867 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17868 TOKEN_STRING_INITIALIZER
17869 (struct cmd_ptype_mapping_reset_result,
17871 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17872 TOKEN_NUM_INITIALIZER
17873 (struct cmd_ptype_mapping_reset_result,
17877 cmd_ptype_mapping_reset_parsed(
17878 void *parsed_result,
17879 __rte_unused struct cmdline *cl,
17880 __rte_unused void *data)
17882 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17883 int ret = -ENOTSUP;
17885 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17888 #ifdef RTE_LIBRTE_I40E_PMD
17889 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17896 printf("invalid port_id %d\n", res->port_id);
17899 printf("function not implemented\n");
17902 printf("programming error: (%s)\n", strerror(-ret));
17906 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17907 .f = cmd_ptype_mapping_reset_parsed,
17909 .help_str = "ptype mapping reset <port_id>",
17911 (void *)&cmd_ptype_mapping_reset_ptype,
17912 (void *)&cmd_ptype_mapping_reset_mapping,
17913 (void *)&cmd_ptype_mapping_reset_reset,
17914 (void *)&cmd_ptype_mapping_reset_port_id,
17919 /* ptype mapping update */
17921 /* Common result structure for ptype mapping update */
17922 struct cmd_ptype_mapping_update_result {
17923 cmdline_fixed_string_t ptype;
17924 cmdline_fixed_string_t mapping;
17925 cmdline_fixed_string_t reset;
17931 /* Common CLI fields for ptype mapping update*/
17932 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17933 TOKEN_STRING_INITIALIZER
17934 (struct cmd_ptype_mapping_update_result,
17936 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17937 TOKEN_STRING_INITIALIZER
17938 (struct cmd_ptype_mapping_update_result,
17939 mapping, "mapping");
17940 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17941 TOKEN_STRING_INITIALIZER
17942 (struct cmd_ptype_mapping_update_result,
17944 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17945 TOKEN_NUM_INITIALIZER
17946 (struct cmd_ptype_mapping_update_result,
17948 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17949 TOKEN_NUM_INITIALIZER
17950 (struct cmd_ptype_mapping_update_result,
17952 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17953 TOKEN_NUM_INITIALIZER
17954 (struct cmd_ptype_mapping_update_result,
17958 cmd_ptype_mapping_update_parsed(
17959 void *parsed_result,
17960 __rte_unused struct cmdline *cl,
17961 __rte_unused void *data)
17963 struct cmd_ptype_mapping_update_result *res = parsed_result;
17964 int ret = -ENOTSUP;
17965 #ifdef RTE_LIBRTE_I40E_PMD
17966 struct rte_pmd_i40e_ptype_mapping mapping;
17968 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17971 #ifdef RTE_LIBRTE_I40E_PMD
17972 mapping.hw_ptype = res->hw_ptype;
17973 mapping.sw_ptype = res->sw_ptype;
17974 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17984 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17987 printf("invalid port_id %d\n", res->port_id);
17990 printf("function not implemented\n");
17993 printf("programming error: (%s)\n", strerror(-ret));
17997 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17998 .f = cmd_ptype_mapping_update_parsed,
18000 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18002 (void *)&cmd_ptype_mapping_update_ptype,
18003 (void *)&cmd_ptype_mapping_update_mapping,
18004 (void *)&cmd_ptype_mapping_update_update,
18005 (void *)&cmd_ptype_mapping_update_port_id,
18006 (void *)&cmd_ptype_mapping_update_hw_ptype,
18007 (void *)&cmd_ptype_mapping_update_sw_ptype,
18012 /* Common result structure for file commands */
18013 struct cmd_cmdfile_result {
18014 cmdline_fixed_string_t load;
18015 cmdline_fixed_string_t filename;
18018 /* Common CLI fields for file commands */
18019 cmdline_parse_token_string_t cmd_load_cmdfile =
18020 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18021 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18022 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18025 cmd_load_from_file_parsed(
18026 void *parsed_result,
18027 __rte_unused struct cmdline *cl,
18028 __rte_unused void *data)
18030 struct cmd_cmdfile_result *res = parsed_result;
18032 cmdline_read_from_file(res->filename);
18035 cmdline_parse_inst_t cmd_load_from_file = {
18036 .f = cmd_load_from_file_parsed,
18038 .help_str = "load <filename>",
18040 (void *)&cmd_load_cmdfile,
18041 (void *)&cmd_load_cmdfile_filename,
18046 /* Get Rx offloads capabilities */
18047 struct cmd_rx_offload_get_capa_result {
18048 cmdline_fixed_string_t show;
18049 cmdline_fixed_string_t port;
18051 cmdline_fixed_string_t rx_offload;
18052 cmdline_fixed_string_t capabilities;
18055 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18056 TOKEN_STRING_INITIALIZER
18057 (struct cmd_rx_offload_get_capa_result,
18059 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18060 TOKEN_STRING_INITIALIZER
18061 (struct cmd_rx_offload_get_capa_result,
18063 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18064 TOKEN_NUM_INITIALIZER
18065 (struct cmd_rx_offload_get_capa_result,
18067 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18068 TOKEN_STRING_INITIALIZER
18069 (struct cmd_rx_offload_get_capa_result,
18070 rx_offload, "rx_offload");
18071 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18072 TOKEN_STRING_INITIALIZER
18073 (struct cmd_rx_offload_get_capa_result,
18074 capabilities, "capabilities");
18077 print_rx_offloads(uint64_t offloads)
18079 uint64_t single_offload;
18087 begin = __builtin_ctzll(offloads);
18088 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18090 single_offload = 1ULL << begin;
18091 for (bit = begin; bit < end; bit++) {
18092 if (offloads & single_offload)
18094 rte_eth_dev_rx_offload_name(single_offload));
18095 single_offload <<= 1;
18100 cmd_rx_offload_get_capa_parsed(
18101 void *parsed_result,
18102 __rte_unused struct cmdline *cl,
18103 __rte_unused void *data)
18105 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18106 struct rte_eth_dev_info dev_info;
18107 portid_t port_id = res->port_id;
18108 uint64_t queue_offloads;
18109 uint64_t port_offloads;
18112 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18116 queue_offloads = dev_info.rx_queue_offload_capa;
18117 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18119 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18120 printf(" Per Queue :");
18121 print_rx_offloads(queue_offloads);
18124 printf(" Per Port :");
18125 print_rx_offloads(port_offloads);
18129 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18130 .f = cmd_rx_offload_get_capa_parsed,
18132 .help_str = "show port <port_id> rx_offload capabilities",
18134 (void *)&cmd_rx_offload_get_capa_show,
18135 (void *)&cmd_rx_offload_get_capa_port,
18136 (void *)&cmd_rx_offload_get_capa_port_id,
18137 (void *)&cmd_rx_offload_get_capa_rx_offload,
18138 (void *)&cmd_rx_offload_get_capa_capabilities,
18143 /* Get Rx offloads configuration */
18144 struct cmd_rx_offload_get_configuration_result {
18145 cmdline_fixed_string_t show;
18146 cmdline_fixed_string_t port;
18148 cmdline_fixed_string_t rx_offload;
18149 cmdline_fixed_string_t configuration;
18152 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18153 TOKEN_STRING_INITIALIZER
18154 (struct cmd_rx_offload_get_configuration_result,
18156 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18157 TOKEN_STRING_INITIALIZER
18158 (struct cmd_rx_offload_get_configuration_result,
18160 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18161 TOKEN_NUM_INITIALIZER
18162 (struct cmd_rx_offload_get_configuration_result,
18164 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18165 TOKEN_STRING_INITIALIZER
18166 (struct cmd_rx_offload_get_configuration_result,
18167 rx_offload, "rx_offload");
18168 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18169 TOKEN_STRING_INITIALIZER
18170 (struct cmd_rx_offload_get_configuration_result,
18171 configuration, "configuration");
18174 cmd_rx_offload_get_configuration_parsed(
18175 void *parsed_result,
18176 __rte_unused struct cmdline *cl,
18177 __rte_unused void *data)
18179 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18180 struct rte_eth_dev_info dev_info;
18181 portid_t port_id = res->port_id;
18182 struct rte_port *port = &ports[port_id];
18183 uint64_t port_offloads;
18184 uint64_t queue_offloads;
18185 uint16_t nb_rx_queues;
18189 printf("Rx Offloading Configuration of port %d :\n", port_id);
18191 port_offloads = port->dev_conf.rxmode.offloads;
18193 print_rx_offloads(port_offloads);
18196 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18200 nb_rx_queues = dev_info.nb_rx_queues;
18201 for (q = 0; q < nb_rx_queues; q++) {
18202 queue_offloads = port->rx_conf[q].offloads;
18203 printf(" Queue[%2d] :", q);
18204 print_rx_offloads(queue_offloads);
18210 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18211 .f = cmd_rx_offload_get_configuration_parsed,
18213 .help_str = "show port <port_id> rx_offload configuration",
18215 (void *)&cmd_rx_offload_get_configuration_show,
18216 (void *)&cmd_rx_offload_get_configuration_port,
18217 (void *)&cmd_rx_offload_get_configuration_port_id,
18218 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18219 (void *)&cmd_rx_offload_get_configuration_configuration,
18224 /* Enable/Disable a per port offloading */
18225 struct cmd_config_per_port_rx_offload_result {
18226 cmdline_fixed_string_t port;
18227 cmdline_fixed_string_t config;
18229 cmdline_fixed_string_t rx_offload;
18230 cmdline_fixed_string_t offload;
18231 cmdline_fixed_string_t on_off;
18234 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18235 TOKEN_STRING_INITIALIZER
18236 (struct cmd_config_per_port_rx_offload_result,
18238 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18239 TOKEN_STRING_INITIALIZER
18240 (struct cmd_config_per_port_rx_offload_result,
18242 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18243 TOKEN_NUM_INITIALIZER
18244 (struct cmd_config_per_port_rx_offload_result,
18246 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18247 TOKEN_STRING_INITIALIZER
18248 (struct cmd_config_per_port_rx_offload_result,
18249 rx_offload, "rx_offload");
18250 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18251 TOKEN_STRING_INITIALIZER
18252 (struct cmd_config_per_port_rx_offload_result,
18253 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18254 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18255 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18256 "scatter#timestamp#security#keep_crc#rss_hash");
18257 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18258 TOKEN_STRING_INITIALIZER
18259 (struct cmd_config_per_port_rx_offload_result,
18263 search_rx_offload(const char *name)
18265 uint64_t single_offload;
18266 const char *single_name;
18270 single_offload = 1;
18271 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18272 single_name = rte_eth_dev_rx_offload_name(single_offload);
18273 if (!strcasecmp(single_name, name)) {
18277 single_offload <<= 1;
18281 return single_offload;
18287 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18288 __rte_unused struct cmdline *cl,
18289 __rte_unused void *data)
18291 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18292 portid_t port_id = res->port_id;
18293 struct rte_eth_dev_info dev_info;
18294 struct rte_port *port = &ports[port_id];
18295 uint64_t single_offload;
18296 uint16_t nb_rx_queues;
18300 if (port->port_status != RTE_PORT_STOPPED) {
18301 printf("Error: Can't config offload when Port %d "
18302 "is not stopped\n", port_id);
18306 single_offload = search_rx_offload(res->offload);
18307 if (single_offload == 0) {
18308 printf("Unknown offload name: %s\n", res->offload);
18312 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18316 nb_rx_queues = dev_info.nb_rx_queues;
18317 if (!strcmp(res->on_off, "on")) {
18318 port->dev_conf.rxmode.offloads |= single_offload;
18319 for (q = 0; q < nb_rx_queues; q++)
18320 port->rx_conf[q].offloads |= single_offload;
18322 port->dev_conf.rxmode.offloads &= ~single_offload;
18323 for (q = 0; q < nb_rx_queues; q++)
18324 port->rx_conf[q].offloads &= ~single_offload;
18327 cmd_reconfig_device_queue(port_id, 1, 1);
18330 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18331 .f = cmd_config_per_port_rx_offload_parsed,
18333 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18334 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18335 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18336 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18339 (void *)&cmd_config_per_port_rx_offload_result_port,
18340 (void *)&cmd_config_per_port_rx_offload_result_config,
18341 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18342 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18343 (void *)&cmd_config_per_port_rx_offload_result_offload,
18344 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18349 /* Enable/Disable a per queue offloading */
18350 struct cmd_config_per_queue_rx_offload_result {
18351 cmdline_fixed_string_t port;
18353 cmdline_fixed_string_t rxq;
18355 cmdline_fixed_string_t rx_offload;
18356 cmdline_fixed_string_t offload;
18357 cmdline_fixed_string_t on_off;
18360 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18361 TOKEN_STRING_INITIALIZER
18362 (struct cmd_config_per_queue_rx_offload_result,
18364 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18365 TOKEN_NUM_INITIALIZER
18366 (struct cmd_config_per_queue_rx_offload_result,
18368 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18369 TOKEN_STRING_INITIALIZER
18370 (struct cmd_config_per_queue_rx_offload_result,
18372 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18373 TOKEN_NUM_INITIALIZER
18374 (struct cmd_config_per_queue_rx_offload_result,
18376 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18377 TOKEN_STRING_INITIALIZER
18378 (struct cmd_config_per_queue_rx_offload_result,
18379 rx_offload, "rx_offload");
18380 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18381 TOKEN_STRING_INITIALIZER
18382 (struct cmd_config_per_queue_rx_offload_result,
18383 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18384 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18385 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18386 "scatter#timestamp#security#keep_crc");
18387 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18388 TOKEN_STRING_INITIALIZER
18389 (struct cmd_config_per_queue_rx_offload_result,
18393 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18394 __rte_unused struct cmdline *cl,
18395 __rte_unused void *data)
18397 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18398 struct rte_eth_dev_info dev_info;
18399 portid_t port_id = res->port_id;
18400 uint16_t queue_id = res->queue_id;
18401 struct rte_port *port = &ports[port_id];
18402 uint64_t single_offload;
18405 if (port->port_status != RTE_PORT_STOPPED) {
18406 printf("Error: Can't config offload when Port %d "
18407 "is not stopped\n", port_id);
18411 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18415 if (queue_id >= dev_info.nb_rx_queues) {
18416 printf("Error: input queue_id should be 0 ... "
18417 "%d\n", dev_info.nb_rx_queues - 1);
18421 single_offload = search_rx_offload(res->offload);
18422 if (single_offload == 0) {
18423 printf("Unknown offload name: %s\n", res->offload);
18427 if (!strcmp(res->on_off, "on"))
18428 port->rx_conf[queue_id].offloads |= single_offload;
18430 port->rx_conf[queue_id].offloads &= ~single_offload;
18432 cmd_reconfig_device_queue(port_id, 1, 1);
18435 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18436 .f = cmd_config_per_queue_rx_offload_parsed,
18438 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18439 "vlan_strip|ipv4_cksum|"
18440 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18441 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18442 "jumbo_frame|scatter|timestamp|security|keep_crc "
18445 (void *)&cmd_config_per_queue_rx_offload_result_port,
18446 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18447 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18448 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18449 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18450 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18451 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18456 /* Get Tx offloads capabilities */
18457 struct cmd_tx_offload_get_capa_result {
18458 cmdline_fixed_string_t show;
18459 cmdline_fixed_string_t port;
18461 cmdline_fixed_string_t tx_offload;
18462 cmdline_fixed_string_t capabilities;
18465 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18466 TOKEN_STRING_INITIALIZER
18467 (struct cmd_tx_offload_get_capa_result,
18469 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18470 TOKEN_STRING_INITIALIZER
18471 (struct cmd_tx_offload_get_capa_result,
18473 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18474 TOKEN_NUM_INITIALIZER
18475 (struct cmd_tx_offload_get_capa_result,
18477 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18478 TOKEN_STRING_INITIALIZER
18479 (struct cmd_tx_offload_get_capa_result,
18480 tx_offload, "tx_offload");
18481 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18482 TOKEN_STRING_INITIALIZER
18483 (struct cmd_tx_offload_get_capa_result,
18484 capabilities, "capabilities");
18487 print_tx_offloads(uint64_t offloads)
18489 uint64_t single_offload;
18497 begin = __builtin_ctzll(offloads);
18498 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18500 single_offload = 1ULL << begin;
18501 for (bit = begin; bit < end; bit++) {
18502 if (offloads & single_offload)
18504 rte_eth_dev_tx_offload_name(single_offload));
18505 single_offload <<= 1;
18510 cmd_tx_offload_get_capa_parsed(
18511 void *parsed_result,
18512 __rte_unused struct cmdline *cl,
18513 __rte_unused void *data)
18515 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18516 struct rte_eth_dev_info dev_info;
18517 portid_t port_id = res->port_id;
18518 uint64_t queue_offloads;
18519 uint64_t port_offloads;
18522 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18526 queue_offloads = dev_info.tx_queue_offload_capa;
18527 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18529 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18530 printf(" Per Queue :");
18531 print_tx_offloads(queue_offloads);
18534 printf(" Per Port :");
18535 print_tx_offloads(port_offloads);
18539 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18540 .f = cmd_tx_offload_get_capa_parsed,
18542 .help_str = "show port <port_id> tx_offload capabilities",
18544 (void *)&cmd_tx_offload_get_capa_show,
18545 (void *)&cmd_tx_offload_get_capa_port,
18546 (void *)&cmd_tx_offload_get_capa_port_id,
18547 (void *)&cmd_tx_offload_get_capa_tx_offload,
18548 (void *)&cmd_tx_offload_get_capa_capabilities,
18553 /* Get Tx offloads configuration */
18554 struct cmd_tx_offload_get_configuration_result {
18555 cmdline_fixed_string_t show;
18556 cmdline_fixed_string_t port;
18558 cmdline_fixed_string_t tx_offload;
18559 cmdline_fixed_string_t configuration;
18562 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18563 TOKEN_STRING_INITIALIZER
18564 (struct cmd_tx_offload_get_configuration_result,
18566 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18567 TOKEN_STRING_INITIALIZER
18568 (struct cmd_tx_offload_get_configuration_result,
18570 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18571 TOKEN_NUM_INITIALIZER
18572 (struct cmd_tx_offload_get_configuration_result,
18574 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18575 TOKEN_STRING_INITIALIZER
18576 (struct cmd_tx_offload_get_configuration_result,
18577 tx_offload, "tx_offload");
18578 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18579 TOKEN_STRING_INITIALIZER
18580 (struct cmd_tx_offload_get_configuration_result,
18581 configuration, "configuration");
18584 cmd_tx_offload_get_configuration_parsed(
18585 void *parsed_result,
18586 __rte_unused struct cmdline *cl,
18587 __rte_unused void *data)
18589 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18590 struct rte_eth_dev_info dev_info;
18591 portid_t port_id = res->port_id;
18592 struct rte_port *port = &ports[port_id];
18593 uint64_t port_offloads;
18594 uint64_t queue_offloads;
18595 uint16_t nb_tx_queues;
18599 printf("Tx Offloading Configuration of port %d :\n", port_id);
18601 port_offloads = port->dev_conf.txmode.offloads;
18603 print_tx_offloads(port_offloads);
18606 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18610 nb_tx_queues = dev_info.nb_tx_queues;
18611 for (q = 0; q < nb_tx_queues; q++) {
18612 queue_offloads = port->tx_conf[q].offloads;
18613 printf(" Queue[%2d] :", q);
18614 print_tx_offloads(queue_offloads);
18620 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18621 .f = cmd_tx_offload_get_configuration_parsed,
18623 .help_str = "show port <port_id> tx_offload configuration",
18625 (void *)&cmd_tx_offload_get_configuration_show,
18626 (void *)&cmd_tx_offload_get_configuration_port,
18627 (void *)&cmd_tx_offload_get_configuration_port_id,
18628 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18629 (void *)&cmd_tx_offload_get_configuration_configuration,
18634 /* Enable/Disable a per port offloading */
18635 struct cmd_config_per_port_tx_offload_result {
18636 cmdline_fixed_string_t port;
18637 cmdline_fixed_string_t config;
18639 cmdline_fixed_string_t tx_offload;
18640 cmdline_fixed_string_t offload;
18641 cmdline_fixed_string_t on_off;
18644 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18645 TOKEN_STRING_INITIALIZER
18646 (struct cmd_config_per_port_tx_offload_result,
18648 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18649 TOKEN_STRING_INITIALIZER
18650 (struct cmd_config_per_port_tx_offload_result,
18652 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18653 TOKEN_NUM_INITIALIZER
18654 (struct cmd_config_per_port_tx_offload_result,
18656 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18657 TOKEN_STRING_INITIALIZER
18658 (struct cmd_config_per_port_tx_offload_result,
18659 tx_offload, "tx_offload");
18660 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18661 TOKEN_STRING_INITIALIZER
18662 (struct cmd_config_per_port_tx_offload_result,
18663 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18664 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18665 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18666 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18667 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18668 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18669 TOKEN_STRING_INITIALIZER
18670 (struct cmd_config_per_port_tx_offload_result,
18674 search_tx_offload(const char *name)
18676 uint64_t single_offload;
18677 const char *single_name;
18681 single_offload = 1;
18682 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18683 single_name = rte_eth_dev_tx_offload_name(single_offload);
18684 if (single_name == NULL)
18686 if (!strcasecmp(single_name, name)) {
18689 } else if (!strcasecmp(single_name, "UNKNOWN"))
18691 single_offload <<= 1;
18695 return single_offload;
18701 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18702 __rte_unused struct cmdline *cl,
18703 __rte_unused void *data)
18705 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18706 portid_t port_id = res->port_id;
18707 struct rte_eth_dev_info dev_info;
18708 struct rte_port *port = &ports[port_id];
18709 uint64_t single_offload;
18710 uint16_t nb_tx_queues;
18714 if (port->port_status != RTE_PORT_STOPPED) {
18715 printf("Error: Can't config offload when Port %d "
18716 "is not stopped\n", port_id);
18720 single_offload = search_tx_offload(res->offload);
18721 if (single_offload == 0) {
18722 printf("Unknown offload name: %s\n", res->offload);
18726 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18730 nb_tx_queues = dev_info.nb_tx_queues;
18731 if (!strcmp(res->on_off, "on")) {
18732 port->dev_conf.txmode.offloads |= single_offload;
18733 for (q = 0; q < nb_tx_queues; q++)
18734 port->tx_conf[q].offloads |= single_offload;
18736 port->dev_conf.txmode.offloads &= ~single_offload;
18737 for (q = 0; q < nb_tx_queues; q++)
18738 port->tx_conf[q].offloads &= ~single_offload;
18741 cmd_reconfig_device_queue(port_id, 1, 1);
18744 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18745 .f = cmd_config_per_port_tx_offload_parsed,
18747 .help_str = "port config <port_id> tx_offload "
18748 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18749 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18750 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18751 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18752 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18754 (void *)&cmd_config_per_port_tx_offload_result_port,
18755 (void *)&cmd_config_per_port_tx_offload_result_config,
18756 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18757 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18758 (void *)&cmd_config_per_port_tx_offload_result_offload,
18759 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18764 /* Enable/Disable a per queue offloading */
18765 struct cmd_config_per_queue_tx_offload_result {
18766 cmdline_fixed_string_t port;
18768 cmdline_fixed_string_t txq;
18770 cmdline_fixed_string_t tx_offload;
18771 cmdline_fixed_string_t offload;
18772 cmdline_fixed_string_t on_off;
18775 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18776 TOKEN_STRING_INITIALIZER
18777 (struct cmd_config_per_queue_tx_offload_result,
18779 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18780 TOKEN_NUM_INITIALIZER
18781 (struct cmd_config_per_queue_tx_offload_result,
18783 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18784 TOKEN_STRING_INITIALIZER
18785 (struct cmd_config_per_queue_tx_offload_result,
18787 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18788 TOKEN_NUM_INITIALIZER
18789 (struct cmd_config_per_queue_tx_offload_result,
18791 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18792 TOKEN_STRING_INITIALIZER
18793 (struct cmd_config_per_queue_tx_offload_result,
18794 tx_offload, "tx_offload");
18795 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18796 TOKEN_STRING_INITIALIZER
18797 (struct cmd_config_per_queue_tx_offload_result,
18798 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18799 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18800 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18801 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18802 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18803 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18804 TOKEN_STRING_INITIALIZER
18805 (struct cmd_config_per_queue_tx_offload_result,
18809 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18810 __rte_unused struct cmdline *cl,
18811 __rte_unused void *data)
18813 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18814 struct rte_eth_dev_info dev_info;
18815 portid_t port_id = res->port_id;
18816 uint16_t queue_id = res->queue_id;
18817 struct rte_port *port = &ports[port_id];
18818 uint64_t single_offload;
18821 if (port->port_status != RTE_PORT_STOPPED) {
18822 printf("Error: Can't config offload when Port %d "
18823 "is not stopped\n", port_id);
18827 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18831 if (queue_id >= dev_info.nb_tx_queues) {
18832 printf("Error: input queue_id should be 0 ... "
18833 "%d\n", dev_info.nb_tx_queues - 1);
18837 single_offload = search_tx_offload(res->offload);
18838 if (single_offload == 0) {
18839 printf("Unknown offload name: %s\n", res->offload);
18843 if (!strcmp(res->on_off, "on"))
18844 port->tx_conf[queue_id].offloads |= single_offload;
18846 port->tx_conf[queue_id].offloads &= ~single_offload;
18848 cmd_reconfig_device_queue(port_id, 1, 1);
18851 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18852 .f = cmd_config_per_queue_tx_offload_parsed,
18854 .help_str = "port <port_id> txq <queue_id> tx_offload "
18855 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18856 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18857 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18858 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18859 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18862 (void *)&cmd_config_per_queue_tx_offload_result_port,
18863 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18864 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18865 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18866 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18867 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18868 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18873 /* *** configure tx_metadata for specific port *** */
18874 struct cmd_config_tx_metadata_specific_result {
18875 cmdline_fixed_string_t port;
18876 cmdline_fixed_string_t keyword;
18878 cmdline_fixed_string_t item;
18883 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18884 __rte_unused struct cmdline *cl,
18885 __rte_unused void *data)
18887 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18889 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18891 ports[res->port_id].tx_metadata = res->value;
18892 /* Add/remove callback to insert valid metadata in every Tx packet. */
18893 if (ports[res->port_id].tx_metadata)
18894 add_tx_md_callback(res->port_id);
18896 remove_tx_md_callback(res->port_id);
18897 rte_flow_dynf_metadata_register();
18900 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18901 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18903 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18904 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18905 keyword, "config");
18906 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18907 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18909 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18910 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18911 item, "tx_metadata");
18912 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18913 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18916 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18917 .f = cmd_config_tx_metadata_specific_parsed,
18919 .help_str = "port config <port_id> tx_metadata <value>",
18921 (void *)&cmd_config_tx_metadata_specific_port,
18922 (void *)&cmd_config_tx_metadata_specific_keyword,
18923 (void *)&cmd_config_tx_metadata_specific_id,
18924 (void *)&cmd_config_tx_metadata_specific_item,
18925 (void *)&cmd_config_tx_metadata_specific_value,
18930 /* *** set dynf *** */
18931 struct cmd_config_tx_dynf_specific_result {
18932 cmdline_fixed_string_t port;
18933 cmdline_fixed_string_t keyword;
18935 cmdline_fixed_string_t item;
18936 cmdline_fixed_string_t name;
18937 cmdline_fixed_string_t value;
18941 cmd_config_dynf_specific_parsed(void *parsed_result,
18942 __rte_unused struct cmdline *cl,
18943 __rte_unused void *data)
18945 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18946 struct rte_mbuf_dynflag desc_flag;
18948 uint64_t old_port_flags;
18950 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18952 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18954 if (strlcpy(desc_flag.name, res->name,
18955 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18956 printf("Flag name too long\n");
18959 desc_flag.flags = 0;
18960 flag = rte_mbuf_dynflag_register(&desc_flag);
18962 printf("Can't register flag\n");
18965 strcpy(dynf_names[flag], desc_flag.name);
18967 old_port_flags = ports[res->port_id].mbuf_dynf;
18968 if (!strcmp(res->value, "set")) {
18969 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18970 if (old_port_flags == 0)
18971 add_tx_dynf_callback(res->port_id);
18973 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18974 if (ports[res->port_id].mbuf_dynf == 0)
18975 remove_tx_dynf_callback(res->port_id);
18979 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18980 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18982 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18983 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18984 keyword, "config");
18985 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18986 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18988 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18989 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18991 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18992 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18994 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18995 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18996 value, "set#clear");
18998 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18999 .f = cmd_config_dynf_specific_parsed,
19001 .help_str = "port config <port id> dynf <name> set|clear",
19003 (void *)&cmd_config_tx_dynf_specific_port,
19004 (void *)&cmd_config_tx_dynf_specific_keyword,
19005 (void *)&cmd_config_tx_dynf_specific_port_id,
19006 (void *)&cmd_config_tx_dynf_specific_item,
19007 (void *)&cmd_config_tx_dynf_specific_name,
19008 (void *)&cmd_config_tx_dynf_specific_value,
19013 /* *** display tx_metadata per port configuration *** */
19014 struct cmd_show_tx_metadata_result {
19015 cmdline_fixed_string_t cmd_show;
19016 cmdline_fixed_string_t cmd_port;
19017 cmdline_fixed_string_t cmd_keyword;
19022 cmd_show_tx_metadata_parsed(void *parsed_result,
19023 __rte_unused struct cmdline *cl,
19024 __rte_unused void *data)
19026 struct cmd_show_tx_metadata_result *res = parsed_result;
19028 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19029 printf("invalid port id %u\n", res->cmd_pid);
19032 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19033 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19034 ports[res->cmd_pid].tx_metadata);
19038 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19039 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19041 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19042 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19044 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19045 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19047 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19048 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19049 cmd_keyword, "tx_metadata");
19051 cmdline_parse_inst_t cmd_show_tx_metadata = {
19052 .f = cmd_show_tx_metadata_parsed,
19054 .help_str = "show port <port_id> tx_metadata",
19056 (void *)&cmd_show_tx_metadata_show,
19057 (void *)&cmd_show_tx_metadata_port,
19058 (void *)&cmd_show_tx_metadata_pid,
19059 (void *)&cmd_show_tx_metadata_keyword,
19064 /* show port supported ptypes */
19066 /* Common result structure for show port ptypes */
19067 struct cmd_show_port_supported_ptypes_result {
19068 cmdline_fixed_string_t show;
19069 cmdline_fixed_string_t port;
19071 cmdline_fixed_string_t ptypes;
19074 /* Common CLI fields for show port ptypes */
19075 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19076 TOKEN_STRING_INITIALIZER
19077 (struct cmd_show_port_supported_ptypes_result,
19079 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19080 TOKEN_STRING_INITIALIZER
19081 (struct cmd_show_port_supported_ptypes_result,
19083 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19084 TOKEN_NUM_INITIALIZER
19085 (struct cmd_show_port_supported_ptypes_result,
19087 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19088 TOKEN_STRING_INITIALIZER
19089 (struct cmd_show_port_supported_ptypes_result,
19093 cmd_show_port_supported_ptypes_parsed(
19094 void *parsed_result,
19095 __rte_unused struct cmdline *cl,
19096 __rte_unused void *data)
19098 #define RSVD_PTYPE_MASK 0xf0000000
19099 #define MAX_PTYPES_PER_LAYER 16
19100 #define LTYPE_NAMESIZE 32
19101 #define PTYPE_NAMESIZE 256
19102 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19103 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19104 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19105 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19106 uint16_t port_id = res->port_id;
19109 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19113 while (ptype_mask != RSVD_PTYPE_MASK) {
19115 switch (ptype_mask) {
19116 case RTE_PTYPE_L2_MASK:
19117 strlcpy(ltype, "L2", sizeof(ltype));
19119 case RTE_PTYPE_L3_MASK:
19120 strlcpy(ltype, "L3", sizeof(ltype));
19122 case RTE_PTYPE_L4_MASK:
19123 strlcpy(ltype, "L4", sizeof(ltype));
19125 case RTE_PTYPE_TUNNEL_MASK:
19126 strlcpy(ltype, "Tunnel", sizeof(ltype));
19128 case RTE_PTYPE_INNER_L2_MASK:
19129 strlcpy(ltype, "Inner L2", sizeof(ltype));
19131 case RTE_PTYPE_INNER_L3_MASK:
19132 strlcpy(ltype, "Inner L3", sizeof(ltype));
19134 case RTE_PTYPE_INNER_L4_MASK:
19135 strlcpy(ltype, "Inner L4", sizeof(ltype));
19141 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19142 ptype_mask, ptypes,
19143 MAX_PTYPES_PER_LAYER);
19146 printf("Supported %s ptypes:\n", ltype);
19148 printf("%s ptypes unsupported\n", ltype);
19150 for (i = 0; i < ret; ++i) {
19151 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19152 printf("%s\n", buf);
19159 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19160 .f = cmd_show_port_supported_ptypes_parsed,
19162 .help_str = "show port <port_id> ptypes",
19164 (void *)&cmd_show_port_supported_ptypes_show,
19165 (void *)&cmd_show_port_supported_ptypes_port,
19166 (void *)&cmd_show_port_supported_ptypes_port_id,
19167 (void *)&cmd_show_port_supported_ptypes_ptypes,
19172 /* *** display rx/tx descriptor status *** */
19173 struct cmd_show_rx_tx_desc_status_result {
19174 cmdline_fixed_string_t cmd_show;
19175 cmdline_fixed_string_t cmd_port;
19176 cmdline_fixed_string_t cmd_keyword;
19177 cmdline_fixed_string_t cmd_desc;
19178 cmdline_fixed_string_t cmd_status;
19185 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19186 __rte_unused struct cmdline *cl,
19187 __rte_unused void *data)
19189 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19192 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19193 printf("invalid port id %u\n", res->cmd_pid);
19197 if (!strcmp(res->cmd_keyword, "rxq")) {
19198 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19201 printf("Invalid queueid = %d\n", res->cmd_qid);
19204 if (rc == RTE_ETH_RX_DESC_AVAIL)
19205 printf("Desc status = AVAILABLE\n");
19206 else if (rc == RTE_ETH_RX_DESC_DONE)
19207 printf("Desc status = DONE\n");
19209 printf("Desc status = UNAVAILABLE\n");
19210 } else if (!strcmp(res->cmd_keyword, "txq")) {
19211 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19214 printf("Invalid queueid = %d\n", res->cmd_qid);
19217 if (rc == RTE_ETH_TX_DESC_FULL)
19218 printf("Desc status = FULL\n");
19219 else if (rc == RTE_ETH_TX_DESC_DONE)
19220 printf("Desc status = DONE\n");
19222 printf("Desc status = UNAVAILABLE\n");
19226 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19227 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19229 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19230 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19232 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19233 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19235 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19236 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19237 cmd_keyword, "rxq#txq");
19238 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19239 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19241 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19242 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19244 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19245 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19247 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19248 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19249 cmd_status, "status");
19250 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19251 .f = cmd_show_rx_tx_desc_status_parsed,
19253 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19256 (void *)&cmd_show_rx_tx_desc_status_show,
19257 (void *)&cmd_show_rx_tx_desc_status_port,
19258 (void *)&cmd_show_rx_tx_desc_status_pid,
19259 (void *)&cmd_show_rx_tx_desc_status_keyword,
19260 (void *)&cmd_show_rx_tx_desc_status_qid,
19261 (void *)&cmd_show_rx_tx_desc_status_desc,
19262 (void *)&cmd_show_rx_tx_desc_status_did,
19263 (void *)&cmd_show_rx_tx_desc_status_status,
19268 /* Common result structure for set port ptypes */
19269 struct cmd_set_port_ptypes_result {
19270 cmdline_fixed_string_t set;
19271 cmdline_fixed_string_t port;
19273 cmdline_fixed_string_t ptype_mask;
19277 /* Common CLI fields for set port ptypes */
19278 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19279 TOKEN_STRING_INITIALIZER
19280 (struct cmd_set_port_ptypes_result,
19282 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19283 TOKEN_STRING_INITIALIZER
19284 (struct cmd_set_port_ptypes_result,
19286 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19287 TOKEN_NUM_INITIALIZER
19288 (struct cmd_set_port_ptypes_result,
19290 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19291 TOKEN_STRING_INITIALIZER
19292 (struct cmd_set_port_ptypes_result,
19293 ptype_mask, "ptype_mask");
19294 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19295 TOKEN_NUM_INITIALIZER
19296 (struct cmd_set_port_ptypes_result,
19300 cmd_set_port_ptypes_parsed(
19301 void *parsed_result,
19302 __rte_unused struct cmdline *cl,
19303 __rte_unused void *data)
19305 struct cmd_set_port_ptypes_result *res = parsed_result;
19306 #define PTYPE_NAMESIZE 256
19307 char ptype_name[PTYPE_NAMESIZE];
19308 uint16_t port_id = res->port_id;
19309 uint32_t ptype_mask = res->mask;
19312 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19315 printf("Port %d doesn't support any ptypes.\n", port_id);
19319 uint32_t ptypes[ret];
19321 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19323 printf("Unable to set requested ptypes for Port %d\n", port_id);
19327 printf("Successfully set following ptypes for Port %d\n", port_id);
19328 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19329 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19330 printf("%s\n", ptype_name);
19333 clear_ptypes = false;
19336 cmdline_parse_inst_t cmd_set_port_ptypes = {
19337 .f = cmd_set_port_ptypes_parsed,
19339 .help_str = "set port <port_id> ptype_mask <mask>",
19341 (void *)&cmd_set_port_ptypes_set,
19342 (void *)&cmd_set_port_ptypes_port,
19343 (void *)&cmd_set_port_ptypes_port_id,
19344 (void *)&cmd_set_port_ptypes_mask_str,
19345 (void *)&cmd_set_port_ptypes_mask_u32,
19350 /* *** display mac addresses added to a port *** */
19351 struct cmd_showport_macs_result {
19352 cmdline_fixed_string_t cmd_show;
19353 cmdline_fixed_string_t cmd_port;
19354 cmdline_fixed_string_t cmd_keyword;
19359 cmd_showport_macs_parsed(void *parsed_result,
19360 __rte_unused struct cmdline *cl,
19361 __rte_unused void *data)
19363 struct cmd_showport_macs_result *res = parsed_result;
19365 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19368 if (!strcmp(res->cmd_keyword, "macs"))
19369 show_macs(res->cmd_pid);
19370 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19371 show_mcast_macs(res->cmd_pid);
19374 cmdline_parse_token_string_t cmd_showport_macs_show =
19375 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19377 cmdline_parse_token_string_t cmd_showport_macs_port =
19378 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19380 cmdline_parse_token_num_t cmd_showport_macs_pid =
19381 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19383 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19384 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19385 cmd_keyword, "macs#mcast_macs");
19387 cmdline_parse_inst_t cmd_showport_macs = {
19388 .f = cmd_showport_macs_parsed,
19390 .help_str = "show port <port_id> macs|mcast_macs",
19392 (void *)&cmd_showport_macs_show,
19393 (void *)&cmd_showport_macs_port,
19394 (void *)&cmd_showport_macs_pid,
19395 (void *)&cmd_showport_macs_keyword,
19400 /* ******************************************************************************** */
19402 /* list of instructions */
19403 cmdline_parse_ctx_t main_ctx[] = {
19404 (cmdline_parse_inst_t *)&cmd_help_brief,
19405 (cmdline_parse_inst_t *)&cmd_help_long,
19406 (cmdline_parse_inst_t *)&cmd_quit,
19407 (cmdline_parse_inst_t *)&cmd_load_from_file,
19408 (cmdline_parse_inst_t *)&cmd_showport,
19409 (cmdline_parse_inst_t *)&cmd_showqueue,
19410 (cmdline_parse_inst_t *)&cmd_showportall,
19411 (cmdline_parse_inst_t *)&cmd_showdevice,
19412 (cmdline_parse_inst_t *)&cmd_showcfg,
19413 (cmdline_parse_inst_t *)&cmd_showfwdall,
19414 (cmdline_parse_inst_t *)&cmd_start,
19415 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19416 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19417 (cmdline_parse_inst_t *)&cmd_set_link_up,
19418 (cmdline_parse_inst_t *)&cmd_set_link_down,
19419 (cmdline_parse_inst_t *)&cmd_reset,
19420 (cmdline_parse_inst_t *)&cmd_set_numbers,
19421 (cmdline_parse_inst_t *)&cmd_set_log,
19422 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19423 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19424 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19425 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19426 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19427 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19428 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19429 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19430 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19431 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19432 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19433 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19434 (cmdline_parse_inst_t *)&cmd_set_link_check,
19435 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19436 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19437 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19438 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19439 #ifdef RTE_LIBRTE_PMD_BOND
19440 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19441 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19442 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19443 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19444 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19445 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19446 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19447 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19448 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19449 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19450 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19452 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19453 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19454 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19455 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19456 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19457 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19458 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19459 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19460 (cmdline_parse_inst_t *)&cmd_csum_set,
19461 (cmdline_parse_inst_t *)&cmd_csum_show,
19462 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19463 (cmdline_parse_inst_t *)&cmd_tso_set,
19464 (cmdline_parse_inst_t *)&cmd_tso_show,
19465 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19466 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19467 (cmdline_parse_inst_t *)&cmd_gro_enable,
19468 (cmdline_parse_inst_t *)&cmd_gro_flush,
19469 (cmdline_parse_inst_t *)&cmd_gro_show,
19470 (cmdline_parse_inst_t *)&cmd_gso_enable,
19471 (cmdline_parse_inst_t *)&cmd_gso_size,
19472 (cmdline_parse_inst_t *)&cmd_gso_show,
19473 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19474 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19475 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19476 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19477 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19478 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19479 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19480 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19481 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19482 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19483 (cmdline_parse_inst_t *)&cmd_config_dcb,
19484 (cmdline_parse_inst_t *)&cmd_read_reg,
19485 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19486 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19487 (cmdline_parse_inst_t *)&cmd_write_reg,
19488 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19489 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19490 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19491 (cmdline_parse_inst_t *)&cmd_stop,
19492 (cmdline_parse_inst_t *)&cmd_mac_addr,
19493 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19494 (cmdline_parse_inst_t *)&cmd_set_qmap,
19495 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19496 (cmdline_parse_inst_t *)&cmd_operate_port,
19497 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19498 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19499 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19500 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19501 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19502 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19503 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19504 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19505 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19506 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19507 (cmdline_parse_inst_t *)&cmd_config_mtu,
19508 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19509 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19510 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19511 (cmdline_parse_inst_t *)&cmd_config_rss,
19512 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19513 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19514 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19515 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19516 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19517 (cmdline_parse_inst_t *)&cmd_showport_reta,
19518 (cmdline_parse_inst_t *)&cmd_showport_macs,
19519 (cmdline_parse_inst_t *)&cmd_config_burst,
19520 (cmdline_parse_inst_t *)&cmd_config_thresh,
19521 (cmdline_parse_inst_t *)&cmd_config_threshold,
19522 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19523 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19524 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19525 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19526 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19527 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19528 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19529 (cmdline_parse_inst_t *)&cmd_global_config,
19530 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19531 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19532 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19533 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19534 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19535 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19536 (cmdline_parse_inst_t *)&cmd_dump,
19537 (cmdline_parse_inst_t *)&cmd_dump_one,
19538 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19539 (cmdline_parse_inst_t *)&cmd_syn_filter,
19540 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19541 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19542 (cmdline_parse_inst_t *)&cmd_flex_filter,
19543 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19544 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19545 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19546 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19547 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19548 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19549 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19550 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19551 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19552 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19553 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19554 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19555 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19556 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19557 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19558 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19559 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19560 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19561 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19562 (cmdline_parse_inst_t *)&cmd_flow,
19563 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19564 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19565 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19566 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19567 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19568 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19569 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19570 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19571 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19572 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19573 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19574 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19575 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19576 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19577 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19578 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19579 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19580 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19581 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19582 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19583 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19584 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19585 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19586 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19587 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19588 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19589 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19590 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19591 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19592 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19593 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19594 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19595 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19596 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19597 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19598 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19599 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19600 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19601 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19602 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19603 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19604 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19605 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19606 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19607 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19608 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19609 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19610 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19611 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19612 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19613 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19615 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19616 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19617 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19618 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19619 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19620 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19621 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19622 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19623 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19624 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19625 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19626 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19627 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19628 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19629 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19630 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19631 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19632 (cmdline_parse_inst_t *)&cmd_ddp_add,
19633 (cmdline_parse_inst_t *)&cmd_ddp_del,
19634 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19635 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19636 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19637 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19638 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19639 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19640 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19641 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19642 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19643 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19644 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19645 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19647 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19648 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19649 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19650 (cmdline_parse_inst_t *)&cmd_queue_region,
19651 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19652 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19653 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19654 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19655 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19656 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19657 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19658 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19659 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19660 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19661 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19662 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19663 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19664 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19665 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19666 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19667 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19668 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19669 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19670 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19671 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19672 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19673 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19674 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19675 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19676 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19677 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19678 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19679 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19680 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19681 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19682 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19683 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19684 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19685 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19686 #ifdef RTE_LIBRTE_BPF
19687 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19688 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19690 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19691 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19692 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19693 (cmdline_parse_inst_t *)&cmd_set_raw,
19694 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19695 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19696 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19700 /* read cmdline commands from file */
19702 cmdline_read_from_file(const char *filename)
19704 struct cmdline *cl;
19706 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19708 printf("Failed to create file based cmdline context: %s\n",
19713 cmdline_interact(cl);
19718 printf("Read CLI commands from %s\n", filename);
19721 /* prompt function, called from main on MASTER lcore */
19725 /* initialize non-constant commands */
19726 cmd_set_fwd_mode_init();
19727 cmd_set_fwd_retry_mode_init();
19729 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19730 if (testpmd_cl == NULL)
19732 cmdline_interact(testpmd_cl);
19733 cmdline_stdin_exit(testpmd_cl);
19739 if (testpmd_cl != NULL)
19740 cmdline_quit(testpmd_cl);
19744 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19746 if (id == (portid_t)RTE_PORT_ALL) {
19749 RTE_ETH_FOREACH_DEV(pid) {
19750 /* check if need_reconfig has been set to 1 */
19751 if (ports[pid].need_reconfig == 0)
19752 ports[pid].need_reconfig = dev;
19753 /* check if need_reconfig_queues has been set to 1 */
19754 if (ports[pid].need_reconfig_queues == 0)
19755 ports[pid].need_reconfig_queues = queue;
19757 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19758 /* check if need_reconfig has been set to 1 */
19759 if (ports[id].need_reconfig == 0)
19760 ports[id].need_reconfig = dev;
19761 /* check if need_reconfig_queues has been set to 1 */
19762 if (ports[id].need_reconfig_queues == 0)
19763 ports[id].need_reconfig_queues = queue;