1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
53 #ifdef RTE_LIBRTE_PMD_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
58 #include <rte_pmd_dpaa.h>
60 #ifdef RTE_LIBRTE_IXGBE_PMD
61 #include <rte_pmd_ixgbe.h>
63 #ifdef RTE_LIBRTE_I40E_PMD
64 #include <rte_pmd_i40e.h>
66 #ifdef RTE_LIBRTE_BNXT_PMD
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
85 __rte_unused void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commmands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port X rss reta (size) (mask0,mask1,...)\n"
170 " Display the rss redirection table entry indicated"
171 " by masks on port X. size is used to indicate the"
172 " hardware supported reta size\n\n"
174 "show port (port_id) rss-hash [key]\n"
175 " Display the RSS hash functions and RSS hash key of port\n\n"
177 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
178 " Clear information for port_id, or all.\n\n"
180 "show (rxq|txq) info (port_id) (queue_id)\n"
181 " Display information for configured RX/TX queue.\n\n"
183 "show config (rxtx|cores|fwd|txpkts)\n"
184 " Display the given configuration.\n\n"
186 "read rxd (port_id) (queue_id) (rxd_id)\n"
187 " Display an RX descriptor of a port RX queue.\n\n"
189 "read txd (port_id) (queue_id) (txd_id)\n"
190 " Display a TX descriptor of a port TX queue.\n\n"
192 "ddp get list (port_id)\n"
193 " Get ddp profile info list\n\n"
195 "ddp get info (profile_path)\n"
196 " Get ddp profile information.\n\n"
198 "show vf stats (port_id) (vf_id)\n"
199 " Display a VF's statistics.\n\n"
201 "clear vf stats (port_id) (vf_id)\n"
202 " Reset a VF's statistics.\n\n"
204 "show port (port_id) pctype mapping\n"
205 " Get flow ptype to pctype mapping on a port\n\n"
207 "show port meter stats (port_id) (meter_id) (clear)\n"
208 " Get meter stats on a port\n\n"
210 "show fwd stats all\n"
211 " Display statistics for all fwd engines.\n\n"
213 "clear fwd stats all\n"
214 " Clear statistics for all fwd engines.\n\n"
216 "show port (port_id) rx_offload capabilities\n"
217 " List all per queue and per port Rx offloading"
218 " capabilities of a port\n\n"
220 "show port (port_id) rx_offload configuration\n"
221 " List port level and all queue level"
222 " Rx offloading configuration\n\n"
224 "show port (port_id) tx_offload capabilities\n"
225 " List all per queue and per port"
226 " Tx offloading capabilities of a port\n\n"
228 "show port (port_id) tx_offload configuration\n"
229 " List port level and all queue level"
230 " Tx offloading configuration\n\n"
232 "show port (port_id) tx_metadata\n"
233 " Show Tx metadata value set"
234 " for a specific port\n\n"
236 "show port (port_id) ptypes\n"
237 " Show port supported ptypes"
238 " for a specific port\n\n"
240 "show device info (<identifier>|all)"
241 " Show general information about devices probed.\n\n"
243 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
244 " Show status of rx|tx descriptor.\n\n"
246 "show port (port_id) macs|mcast_macs"
247 " Display list of mac addresses added to port.\n\n"
251 if (show_all || !strcmp(res->section, "config")) {
257 "Configuration changes only become active when"
258 " forwarding is started/restarted.\n\n"
261 " Reset forwarding to the default configuration.\n\n"
263 "set verbose (level)\n"
264 " Set the debug verbosity level X.\n\n"
266 "set log global|(type) (level)\n"
267 " Set the log level.\n\n"
270 " Set number of ports.\n\n"
273 " Set number of cores.\n\n"
275 "set coremask (mask)\n"
276 " Set the forwarding cores hexadecimal mask.\n\n"
278 "set portmask (mask)\n"
279 " Set the forwarding ports hexadecimal mask.\n\n"
282 " Set number of packets per burst.\n\n"
284 "set burst tx delay (microseconds) retry (num)\n"
285 " Set the transmit delay time and number of retries,"
286 " effective when retry is enabled.\n\n"
288 "set txpkts (x[,y]*)\n"
289 " Set the length of each segment of TXONLY"
290 " and optionally CSUM packets.\n\n"
292 "set txsplit (off|on|rand)\n"
293 " Set the split policy for the TX packets."
294 " Right now only applicable for CSUM and TXONLY"
297 "set corelist (x[,y]*)\n"
298 " Set the list of forwarding cores.\n\n"
300 "set portlist (x[,y]*)\n"
301 " Set the list of forwarding ports.\n\n"
303 "set port setup on (iterator|event)\n"
304 " Select how attached port is retrieved for setup.\n\n"
306 "set tx loopback (port_id) (on|off)\n"
307 " Enable or disable tx loopback.\n\n"
309 "set all queues drop (port_id) (on|off)\n"
310 " Set drop enable bit for all queues.\n\n"
312 "set vf split drop (port_id) (vf_id) (on|off)\n"
313 " Set split drop enable bit for a VF from the PF.\n\n"
315 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
316 " Set MAC antispoof for a VF from the PF.\n\n"
318 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
319 " Enable MACsec offload.\n\n"
321 "set macsec offload (port_id) off\n"
322 " Disable MACsec offload.\n\n"
324 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
325 " Configure MACsec secure connection (SC).\n\n"
327 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
328 " Configure MACsec secure association (SA).\n\n"
330 "set vf broadcast (port_id) (vf_id) (on|off)\n"
331 " Set VF broadcast for a VF from the PF.\n\n"
333 "vlan set stripq (on|off) (port_id,queue_id)\n"
334 " Set the VLAN strip for a queue on a port.\n\n"
336 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
337 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
339 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
340 " Set VLAN insert for a VF from the PF.\n\n"
342 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
343 " Set VLAN antispoof for a VF from the PF.\n\n"
345 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
346 " Set VLAN tag for a VF from the PF.\n\n"
348 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
349 " Set a VF's max bandwidth(Mbps).\n\n"
351 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
352 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
354 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
355 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
357 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
358 " Set some TCs' strict link priority mode on a physical port.\n\n"
360 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
361 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
363 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
364 " Set the VLAN strip or filter or qinq strip or extend\n\n"
366 "vlan set (inner|outer) tpid (value) (port_id)\n"
367 " Set the VLAN TPID for Packet Filtering on"
370 "rx_vlan add (vlan_id|all) (port_id)\n"
371 " Add a vlan_id, or all identifiers, to the set"
372 " of VLAN identifiers filtered by port_id.\n\n"
374 "rx_vlan rm (vlan_id|all) (port_id)\n"
375 " Remove a vlan_id, or all identifiers, from the set"
376 " of VLAN identifiers filtered by port_id.\n\n"
378 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
379 " Add a vlan_id, to the set of VLAN identifiers"
380 "filtered for VF(s) from port_id.\n\n"
382 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
383 " Remove a vlan_id, to the set of VLAN identifiers"
384 "filtered for VF(s) from port_id.\n\n"
386 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
387 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
388 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
389 " add a tunnel filter of a port.\n\n"
391 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
392 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
393 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
394 " remove a tunnel filter of a port.\n\n"
396 "rx_vxlan_port add (udp_port) (port_id)\n"
397 " Add an UDP port for VXLAN packet filter on a port\n\n"
399 "rx_vxlan_port rm (udp_port) (port_id)\n"
400 " Remove an UDP port for VXLAN packet filter on a port\n\n"
402 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
403 " Set hardware insertion of VLAN IDs (single or double VLAN "
404 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
406 "tx_vlan set pvid port_id vlan_id (on|off)\n"
407 " Set port based TX VLAN insertion.\n\n"
409 "tx_vlan reset (port_id)\n"
410 " Disable hardware insertion of a VLAN header in"
411 " packets sent on a port.\n\n"
413 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
414 " Select hardware or software calculation of the"
415 " checksum when transmitting a packet using the"
416 " csum forward engine.\n"
417 " ip|udp|tcp|sctp always concern the inner layer.\n"
418 " outer-ip concerns the outer IP layer in"
419 " outer-udp concerns the outer UDP layer in"
420 " case the packet is recognized as a tunnel packet by"
421 " the forward engine (vxlan, gre and ipip are supported)\n"
422 " Please check the NIC datasheet for HW limits.\n\n"
424 "csum parse-tunnel (on|off) (tx_port_id)\n"
425 " If disabled, treat tunnel packets as non-tunneled"
426 " packets (treat inner headers as payload). The port\n"
427 " argument is the port used for TX in csum forward"
430 "csum show (port_id)\n"
431 " Display tx checksum offload configuration\n\n"
433 "tso set (segsize) (portid)\n"
434 " Enable TCP Segmentation Offload in csum forward"
436 " Please check the NIC datasheet for HW limits.\n\n"
439 " Display the status of TCP Segmentation Offload.\n\n"
441 "set port (port_id) gro on|off\n"
442 " Enable or disable Generic Receive Offload in"
443 " csum forwarding engine.\n\n"
445 "show port (port_id) gro\n"
446 " Display GRO configuration.\n\n"
448 "set gro flush (cycles)\n"
449 " Set the cycle to flush GROed packets from"
450 " reassembly tables.\n\n"
452 "set port (port_id) gso (on|off)"
453 " Enable or disable Generic Segmentation Offload in"
454 " csum forwarding engine.\n\n"
456 "set gso segsz (length)\n"
457 " Set max packet length for output GSO segments,"
458 " including packet header and payload.\n\n"
460 "show port (port_id) gso\n"
461 " Show GSO configuration.\n\n"
464 " Set packet forwarding mode.\n\n"
466 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
467 " Add a MAC address on port_id.\n\n"
469 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
470 " Remove a MAC address from port_id.\n\n"
472 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
473 " Set the default MAC address for port_id.\n\n"
475 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
476 " Add a MAC address for a VF on the port.\n\n"
478 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
479 " Set the MAC address for a VF from the PF.\n\n"
481 "set eth-peer (port_id) (peer_addr)\n"
482 " set the peer address for certain port.\n\n"
484 "set port (port_id) uta (mac_address|all) (on|off)\n"
485 " Add/Remove a or all unicast hash filter(s)"
488 "set promisc (port_id|all) (on|off)\n"
489 " Set the promiscuous mode on port_id, or all.\n\n"
491 "set allmulti (port_id|all) (on|off)\n"
492 " Set the allmulti mode on port_id, or all.\n\n"
494 "set vf promisc (port_id) (vf_id) (on|off)\n"
495 " Set unicast promiscuous mode for a VF from the PF.\n\n"
497 "set vf allmulti (port_id) (vf_id) (on|off)\n"
498 " Set multicast promiscuous mode for a VF from the PF.\n\n"
500 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
501 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
502 " (on|off) autoneg (on|off) (port_id)\n"
503 "set flow_ctrl rx (on|off) (portid)\n"
504 "set flow_ctrl tx (on|off) (portid)\n"
505 "set flow_ctrl high_water (high_water) (portid)\n"
506 "set flow_ctrl low_water (low_water) (portid)\n"
507 "set flow_ctrl pause_time (pause_time) (portid)\n"
508 "set flow_ctrl send_xon (send_xon) (portid)\n"
509 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
510 "set flow_ctrl autoneg (on|off) (port_id)\n"
511 " Set the link flow control parameter on a port.\n\n"
513 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
514 " (low_water) (pause_time) (priority) (port_id)\n"
515 " Set the priority flow control parameter on a"
518 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
519 " Set statistics mapping (qmapping 0..15) for RX/TX"
521 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
522 " on port 0 to mapping 5.\n\n"
524 "set xstats-hide-zero on|off\n"
525 " Set the option to hide the zero values"
526 " for xstats display.\n"
528 "set port (port_id) vf (vf_id) rx|tx on|off\n"
529 " Enable/Disable a VF receive/tranmit from a port\n\n"
531 "set port (port_id) vf (vf_id) (mac_addr)"
532 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
533 " Add/Remove unicast or multicast MAC addr filter"
536 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
538 " AUPE:accepts untagged VLAN;"
539 "ROPE:accept unicast hash\n\n"
540 " BAM:accepts broadcast packets;"
541 "MPE:accepts all multicast packets\n\n"
542 " Enable/Disable a VF receive mode of a port\n\n"
544 "set port (port_id) queue (queue_id) rate (rate_num)\n"
545 " Set rate limit for a queue of a port\n\n"
547 "set port (port_id) vf (vf_id) rate (rate_num) "
548 "queue_mask (queue_mask_value)\n"
549 " Set rate limit for queues in VF of a port\n\n"
551 "set port (port_id) mirror-rule (rule_id)"
552 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
553 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
554 " Set pool or vlan type mirror rule on a port.\n"
555 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
556 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
559 "set port (port_id) mirror-rule (rule_id)"
560 " (uplink-mirror|downlink-mirror) dst-pool"
561 " (pool_id) (on|off)\n"
562 " Set uplink or downlink type mirror rule on a port.\n"
563 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
564 " 0 on' enable mirror income traffic to pool 0.\n\n"
566 "reset port (port_id) mirror-rule (rule_id)\n"
567 " Reset a mirror rule.\n\n"
569 "set flush_rx (on|off)\n"
570 " Flush (default) or don't flush RX streams before"
571 " forwarding. Mainly used with PCAP drivers.\n\n"
573 "set bypass mode (normal|bypass|isolate) (port_id)\n"
574 " Set the bypass mode for the lowest port on bypass enabled"
577 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
578 "mode (normal|bypass|isolate) (port_id)\n"
579 " Set the event required to initiate specified bypass mode for"
580 " the lowest port on a bypass enabled NIC where:\n"
581 " timeout = enable bypass after watchdog timeout.\n"
582 " os_on = enable bypass when OS/board is powered on.\n"
583 " os_off = enable bypass when OS/board is powered off.\n"
584 " power_on = enable bypass when power supply is turned on.\n"
585 " power_off = enable bypass when power supply is turned off."
588 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
589 " Set the bypass watchdog timeout to 'n' seconds"
590 " where 0 = instant.\n\n"
592 "show bypass config (port_id)\n"
593 " Show the bypass configuration for a bypass enabled NIC"
594 " using the lowest port on the NIC.\n\n"
596 #ifdef RTE_LIBRTE_PMD_BOND
597 "create bonded device (mode) (socket)\n"
598 " Create a new bonded device with specific bonding mode and socket.\n\n"
600 "add bonding slave (slave_id) (port_id)\n"
601 " Add a slave device to a bonded device.\n\n"
603 "remove bonding slave (slave_id) (port_id)\n"
604 " Remove a slave device from a bonded device.\n\n"
606 "set bonding mode (value) (port_id)\n"
607 " Set the bonding mode on a bonded device.\n\n"
609 "set bonding primary (slave_id) (port_id)\n"
610 " Set the primary slave for a bonded device.\n\n"
612 "show bonding config (port_id)\n"
613 " Show the bonding config for port_id.\n\n"
615 "set bonding mac_addr (port_id) (address)\n"
616 " Set the MAC address of a bonded device.\n\n"
618 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
619 " Set Aggregation mode for IEEE802.3AD (mode 4)"
621 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
622 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
624 "set bonding mon_period (port_id) (value)\n"
625 " Set the bonding link status monitoring polling period in ms.\n\n"
627 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
628 " Enable/disable dedicated queues for LACP control traffic.\n\n"
631 "set link-up port (port_id)\n"
632 " Set link up for a port.\n\n"
634 "set link-down port (port_id)\n"
635 " Set link down for a port.\n\n"
637 "E-tag set insertion on port-tag-id (value)"
638 " port (port_id) vf (vf_id)\n"
639 " Enable E-tag insertion for a VF on a port\n\n"
641 "E-tag set insertion off port (port_id) vf (vf_id)\n"
642 " Disable E-tag insertion for a VF on a port\n\n"
644 "E-tag set stripping (on|off) port (port_id)\n"
645 " Enable/disable E-tag stripping on a port\n\n"
647 "E-tag set forwarding (on|off) port (port_id)\n"
648 " Enable/disable E-tag based forwarding"
651 "E-tag set filter add e-tag-id (value) dst-pool"
652 " (pool_id) port (port_id)\n"
653 " Add an E-tag forwarding filter on a port\n\n"
655 "E-tag set filter del e-tag-id (value) port (port_id)\n"
656 " Delete an E-tag forwarding filter on a port\n\n"
658 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
659 " Load a profile package on a port\n\n"
661 "ddp del (port_id) (backup_profile_path)\n"
662 " Delete a profile package from a port\n\n"
664 "ptype mapping get (port_id) (valid_only)\n"
665 " Get ptype mapping on a port\n\n"
667 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
668 " Replace target with the pkt_type in ptype mapping\n\n"
670 "ptype mapping reset (port_id)\n"
671 " Reset ptype mapping on a port\n\n"
673 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
674 " Update a ptype mapping item on a port\n\n"
676 "set port (port_id) ptype_mask (ptype_mask)\n"
677 " set packet types classification for a specific port\n\n"
679 "set port (port_id) queue-region region_id (value) "
680 "queue_start_index (value) queue_num (value)\n"
681 " Set a queue region on a port\n\n"
683 "set port (port_id) queue-region region_id (value) "
685 " Set a flowtype region index on a port\n\n"
687 "set port (port_id) queue-region UP (value) region_id (value)\n"
688 " Set the mapping of User Priority to "
689 "queue region on a port\n\n"
691 "set port (port_id) queue-region flush (on|off)\n"
692 " flush all queue region related configuration\n\n"
694 "show port meter cap (port_id)\n"
695 " Show port meter capability information\n\n"
697 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
698 " meter profile add - srtcm rfc 2697\n\n"
700 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
701 " meter profile add - trtcm rfc 2698\n\n"
703 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
704 " meter profile add - trtcm rfc 4115\n\n"
706 "del port meter profile (port_id) (profile_id)\n"
707 " meter profile delete\n\n"
709 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
710 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
711 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
712 "(dscp_tbl_entry63)]\n"
715 "enable port meter (port_id) (mtr_id)\n"
718 "disable port meter (port_id) (mtr_id)\n"
721 "del port meter (port_id) (mtr_id)\n"
724 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
725 " meter update meter profile\n\n"
727 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
728 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
729 " update meter dscp table entries\n\n"
731 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
732 "(action0) [(action1) (action2)]\n"
733 " meter update policer action\n\n"
735 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
736 " meter update stats\n\n"
738 "show port (port_id) queue-region\n"
739 " show all queue region related configuration info\n\n"
741 , list_pkt_forwarding_modes()
745 if (show_all || !strcmp(res->section, "ports")) {
751 "----------------\n\n"
753 "port start (port_id|all)\n"
754 " Start all ports or port_id.\n\n"
756 "port stop (port_id|all)\n"
757 " Stop all ports or port_id.\n\n"
759 "port close (port_id|all)\n"
760 " Close all ports or port_id.\n\n"
762 "port reset (port_id|all)\n"
763 " Reset all ports or port_id.\n\n"
765 "port attach (ident)\n"
766 " Attach physical or virtual dev by pci address or virtual device name\n\n"
768 "port detach (port_id)\n"
769 " Detach physical or virtual dev by port_id\n\n"
771 "port config (port_id|all)"
772 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
773 " duplex (half|full|auto)\n"
774 " Set speed and duplex for all ports or port_id\n\n"
776 "port config (port_id|all) loopback (mode)\n"
777 " Set loopback mode for all ports or port_id\n\n"
779 "port config all (rxq|txq|rxd|txd) (value)\n"
780 " Set number for rxq/txq/rxd/txd.\n\n"
782 "port config all max-pkt-len (value)\n"
783 " Set the max packet length.\n\n"
785 "port config all max-lro-pkt-size (value)\n"
786 " Set the max LRO aggregated packet size.\n\n"
788 "port config all drop-en (on|off)\n"
789 " Enable or disable packet drop on all RX queues of all ports when no "
790 "receive buffers available.\n\n"
792 "port config all rss (all|default|ip|tcp|udp|sctp|"
793 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
794 " Set the RSS mode.\n\n"
796 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
797 " Set the RSS redirection table.\n\n"
799 "port config (port_id) dcb vt (on|off) (traffic_class)"
801 " Set the DCB mode.\n\n"
803 "port config all burst (value)\n"
804 " Set the number of packets per burst.\n\n"
806 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
808 " Set the ring prefetch/host/writeback threshold"
809 " for tx/rx queue.\n\n"
811 "port config all (txfreet|txrst|rxfreet) (value)\n"
812 " Set free threshold for rx/tx, or set"
813 " tx rs bit threshold.\n\n"
814 "port config mtu X value\n"
815 " Set the MTU of port X to a given value\n\n"
817 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
818 " Set a rx/tx queue's ring size configuration, the new"
819 " value will take effect after command that (re-)start the port"
820 " or command that setup the specific queue\n\n"
822 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
823 " Start/stop a rx/tx queue of port X. Only take effect"
824 " when port X is started\n\n"
826 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
827 " Switch on/off a deferred start of port X rx/tx queue. Only"
828 " take effect when port X is stopped.\n\n"
830 "port (port_id) (rxq|txq) (queue_id) setup\n"
831 " Setup a rx/tx queue of port X.\n\n"
833 "port config (port_id|all) l2-tunnel E-tag ether-type"
835 " Set the value of E-tag ether-type.\n\n"
837 "port config (port_id|all) l2-tunnel E-tag"
838 " (enable|disable)\n"
839 " Enable/disable the E-tag support.\n\n"
841 "port config (port_id) pctype mapping reset\n"
842 " Reset flow type to pctype mapping on a port\n\n"
844 "port config (port_id) pctype mapping update"
845 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
846 " Update a flow type to pctype mapping item on a port\n\n"
848 "port config (port_id) pctype (pctype_id) hash_inset|"
849 "fdir_inset|fdir_flx_inset get|set|clear field\n"
851 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
853 "port config (port_id) pctype (pctype_id) hash_inset|"
854 "fdir_inset|fdir_flx_inset clear all"
855 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
857 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
858 " Add/remove UDP tunnel port for tunneling offload\n\n"
860 "port config <port_id> rx_offload vlan_strip|"
861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 "outer_ipv4_cksum|macsec_strip|header_split|"
863 "vlan_filter|vlan_extend|jumbo_frame|"
864 "scatter|timestamp|security|keep_crc on|off\n"
865 " Enable or disable a per port Rx offloading"
866 " on all Rx queues of a port\n\n"
868 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
869 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 "outer_ipv4_cksum|macsec_strip|header_split|"
871 "vlan_filter|vlan_extend|jumbo_frame|"
872 "scatter|timestamp|security|keep_crc on|off\n"
873 " Enable or disable a per queue Rx offloading"
874 " only on a specific Rx queue\n\n"
876 "port config (port_id) tx_offload vlan_insert|"
877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
880 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
882 " Enable or disable a per port Tx offloading"
883 " on all Tx queues of a port\n\n"
885 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
886 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
889 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
891 " Enable or disable a per queue Tx offloading"
892 " only on a specific Tx queue\n\n"
894 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
895 " Load an eBPF program as a callback"
896 " for particular RX/TX queue\n\n"
898 "bpf-unload rx|tx (port) (queue)\n"
899 " Unload previously loaded eBPF program"
900 " for particular RX/TX queue\n\n"
902 "port config (port_id) tx_metadata (value)\n"
903 " Set Tx metadata value per port. Testpmd will add this value"
904 " to any Tx packet sent from this port\n\n"
906 "port config (port_id) dynf (name) set|clear\n"
907 " Register a dynf and Set/clear this flag on Tx. "
908 "Testpmd will set this value to any Tx packet "
909 "sent from this port\n\n"
913 if (show_all || !strcmp(res->section, "registers")) {
921 "read reg (port_id) (address)\n"
922 " Display value of a port register.\n\n"
924 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
925 " Display a port register bit field.\n\n"
927 "read regbit (port_id) (address) (bit_x)\n"
928 " Display a single port register bit.\n\n"
930 "write reg (port_id) (address) (value)\n"
931 " Set value of a port register.\n\n"
933 "write regfield (port_id) (address) (bit_x) (bit_y)"
935 " Set bit field of a port register.\n\n"
937 "write regbit (port_id) (address) (bit_x) (value)\n"
938 " Set single bit value of a port register.\n\n"
941 if (show_all || !strcmp(res->section, "filters")) {
949 "ethertype_filter (port_id) (add|del)"
950 " (mac_addr|mac_ignr) (mac_address) ethertype"
951 " (ether_type) (drop|fwd) queue (queue_id)\n"
952 " Add/Del an ethertype filter.\n\n"
954 "2tuple_filter (port_id) (add|del)"
955 " dst_port (dst_port_value) protocol (protocol_value)"
956 " mask (mask_value) tcp_flags (tcp_flags_value)"
957 " priority (prio_value) queue (queue_id)\n"
958 " Add/Del a 2tuple filter.\n\n"
960 "5tuple_filter (port_id) (add|del)"
961 " dst_ip (dst_address) src_ip (src_address)"
962 " dst_port (dst_port_value) src_port (src_port_value)"
963 " protocol (protocol_value)"
964 " mask (mask_value) tcp_flags (tcp_flags_value)"
965 " priority (prio_value) queue (queue_id)\n"
966 " Add/Del a 5tuple filter.\n\n"
968 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
969 " Add/Del syn filter.\n\n"
971 "flex_filter (port_id) (add|del) len (len_value)"
972 " bytes (bytes_value) mask (mask_value)"
973 " priority (prio_value) queue (queue_id)\n"
974 " Add/Del a flex filter.\n\n"
976 "flow_director_filter (port_id) mode IP (add|del|update)"
977 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
978 " src (src_ip_address) dst (dst_ip_address)"
979 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
980 " vlan (vlan_value) flexbytes (flexbytes_value)"
981 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
982 " fd_id (fd_id_value)\n"
983 " Add/Del an IP type flow director filter.\n\n"
985 "flow_director_filter (port_id) mode IP (add|del|update)"
986 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
987 " src (src_ip_address) (src_port)"
988 " dst (dst_ip_address) (dst_port)"
989 " tos (tos_value) ttl (ttl_value)"
990 " vlan (vlan_value) flexbytes (flexbytes_value)"
991 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
992 " fd_id (fd_id_value)\n"
993 " Add/Del an UDP/TCP type flow director filter.\n\n"
995 "flow_director_filter (port_id) mode IP (add|del|update)"
996 " flow (ipv4-sctp|ipv6-sctp)"
997 " src (src_ip_address) (src_port)"
998 " dst (dst_ip_address) (dst_port)"
999 " tag (verification_tag) "
1000 " tos (tos_value) ttl (ttl_value)"
1001 " vlan (vlan_value)"
1002 " flexbytes (flexbytes_value) (drop|fwd)"
1003 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1004 " Add/Del a SCTP type flow director filter.\n\n"
1006 "flow_director_filter (port_id) mode IP (add|del|update)"
1007 " flow l2_payload ether (ethertype)"
1008 " flexbytes (flexbytes_value) (drop|fwd)"
1009 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1010 " Add/Del a l2 payload type flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1013 " mac (mac_address) vlan (vlan_value)"
1014 " flexbytes (flexbytes_value) (drop|fwd)"
1015 " queue (queue_id) fd_id (fd_id_value)\n"
1016 " Add/Del a MAC-VLAN flow director filter.\n\n"
1018 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1019 " mac (mac_address) vlan (vlan_value)"
1020 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1021 " flexbytes (flexbytes_value) (drop|fwd)"
1022 " queue (queue_id) fd_id (fd_id_value)\n"
1023 " Add/Del a Tunnel flow director filter.\n\n"
1025 "flow_director_filter (port_id) mode raw (add|del|update)"
1026 " flow (flow_id) (drop|fwd) queue (queue_id)"
1027 " fd_id (fd_id_value) packet (packet file name)\n"
1028 " Add/Del a raw type flow director filter.\n\n"
1030 "flush_flow_director (port_id)\n"
1031 " Flush all flow director entries of a device.\n\n"
1033 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1034 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1035 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1036 " Set flow director IP mask.\n\n"
1038 "flow_director_mask (port_id) mode MAC-VLAN"
1039 " vlan (vlan_value)\n"
1040 " Set flow director MAC-VLAN mask.\n\n"
1042 "flow_director_mask (port_id) mode Tunnel"
1043 " vlan (vlan_value) mac (mac_value)"
1044 " tunnel-type (tunnel_type_value)"
1045 " tunnel-id (tunnel_id_value)\n"
1046 " Set flow director Tunnel mask.\n\n"
1048 "flow_director_flex_mask (port_id)"
1049 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1050 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1052 " Configure mask of flex payload.\n\n"
1054 "flow_director_flex_payload (port_id)"
1055 " (raw|l2|l3|l4) (config)\n"
1056 " Configure flex payload selection.\n\n"
1058 "get_sym_hash_ena_per_port (port_id)\n"
1059 " get symmetric hash enable configuration per port.\n\n"
1061 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1062 " set symmetric hash enable configuration per port"
1063 " to enable or disable.\n\n"
1065 "get_hash_global_config (port_id)\n"
1066 " Get the global configurations of hash filters.\n\n"
1068 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1069 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1070 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1071 " (enable|disable)\n"
1072 " Set the global configurations of hash filters.\n\n"
1074 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1075 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1076 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1077 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1078 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1079 "ipv6-next-header|udp-src-port|udp-dst-port|"
1080 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1081 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1082 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1083 "fld-8th|none) (select|add)\n"
1084 " Set the input set for hash.\n\n"
1086 "set_fdir_input_set (port_id) "
1087 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1088 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1089 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1090 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1091 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1092 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1093 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1095 " Set the input set for FDir.\n\n"
1097 "flow validate {port_id}"
1098 " [group {group_id}] [priority {level}]"
1099 " [ingress] [egress]"
1100 " pattern {item} [/ {item} [...]] / end"
1101 " actions {action} [/ {action} [...]] / end\n"
1102 " Check whether a flow rule can be created.\n\n"
1104 "flow create {port_id}"
1105 " [group {group_id}] [priority {level}]"
1106 " [ingress] [egress]"
1107 " pattern {item} [/ {item} [...]] / end"
1108 " actions {action} [/ {action} [...]] / end\n"
1109 " Create a flow rule.\n\n"
1111 "flow destroy {port_id} rule {rule_id} [...]\n"
1112 " Destroy specific flow rules.\n\n"
1114 "flow flush {port_id}\n"
1115 " Destroy all flow rules.\n\n"
1117 "flow query {port_id} {rule_id} {action}\n"
1118 " Query an existing flow rule.\n\n"
1120 "flow list {port_id} [group {group_id}] [...]\n"
1121 " List existing flow rules sorted by priority,"
1122 " filtered by group identifiers.\n\n"
1124 "flow isolate {port_id} {boolean}\n"
1125 " Restrict ingress traffic to the defined"
1128 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1129 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1130 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1131 " Configure the VXLAN encapsulation for flows.\n\n"
1133 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1134 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1135 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1136 " eth-dst (eth-dst)\n"
1137 " Configure the VXLAN encapsulation for flows.\n\n"
1139 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1140 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1141 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1142 " eth-dst (eth-dst)\n"
1143 " Configure the VXLAN encapsulation for flows.\n\n"
1145 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1146 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1148 " Configure the NVGRE encapsulation for flows.\n\n"
1150 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1151 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1152 " eth-src (eth-src) eth-dst (eth-dst)\n"
1153 " Configure the NVGRE encapsulation for flows.\n\n"
1155 "set raw_encap {flow items}\n"
1156 " Configure the encapsulation with raw data.\n\n"
1158 "set raw_decap {flow items}\n"
1159 " Configure the decapsulation with raw data.\n\n"
1164 if (show_all || !strcmp(res->section, "traffic_management")) {
1168 "Traffic Management:\n"
1170 "show port tm cap (port_id)\n"
1171 " Display the port TM capability.\n\n"
1173 "show port tm level cap (port_id) (level_id)\n"
1174 " Display the port TM hierarchical level capability.\n\n"
1176 "show port tm node cap (port_id) (node_id)\n"
1177 " Display the port TM node capability.\n\n"
1179 "show port tm node type (port_id) (node_id)\n"
1180 " Display the port TM node type.\n\n"
1182 "show port tm node stats (port_id) (node_id) (clear)\n"
1183 " Display the port TM node stats.\n\n"
1185 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1186 "set port tm hierarchy default (port_id)\n"
1187 " Set default traffic Management hierarchy on a port\n\n"
1190 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1191 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1192 " (packet_length_adjust)\n"
1193 " Add port tm node private shaper profile.\n\n"
1195 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1196 " Delete port tm node private shaper profile.\n\n"
1198 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1199 " (shaper_profile_id)\n"
1200 " Add/update port tm node shared shaper.\n\n"
1202 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1203 " Delete port tm node shared shaper.\n\n"
1205 "set port tm node shaper profile (port_id) (node_id)"
1206 " (shaper_profile_id)\n"
1207 " Set port tm node shaper profile.\n\n"
1209 "add port tm node wred profile (port_id) (wred_profile_id)"
1210 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1211 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1212 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1213 " Add port tm node wred profile.\n\n"
1215 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1216 " Delete port tm node wred profile.\n\n"
1218 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1219 " (priority) (weight) (level_id) (shaper_profile_id)"
1220 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1221 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1222 " Add port tm nonleaf node.\n\n"
1224 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1225 " (priority) (weight) (level_id) (shaper_profile_id)"
1226 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1227 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1228 " Add port tm leaf node.\n\n"
1230 "del port tm node (port_id) (node_id)\n"
1231 " Delete port tm node.\n\n"
1233 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1234 " (priority) (weight)\n"
1235 " Set port tm node parent.\n\n"
1237 "suspend port tm node (port_id) (node_id)"
1238 " Suspend tm node.\n\n"
1240 "resume port tm node (port_id) (node_id)"
1241 " Resume tm node.\n\n"
1243 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1244 " Commit tm hierarchy.\n\n"
1246 "set port tm mark ip_ecn (port) (green) (yellow)"
1248 " Enables/Disables the traffic management marking"
1249 " for IP ECN (Explicit Congestion Notification)"
1250 " packets on a given port\n\n"
1252 "set port tm mark ip_dscp (port) (green) (yellow)"
1254 " Enables/Disables the traffic management marking"
1255 " on the port for IP dscp packets\n\n"
1257 "set port tm mark vlan_dei (port) (green) (yellow)"
1259 " Enables/Disables the traffic management marking"
1260 " on the port for VLAN packets with DEI enabled\n\n"
1264 if (show_all || !strcmp(res->section, "devices")) {
1268 "Device Operations:\n"
1270 "device detach (identifier)\n"
1271 " Detach device by identifier.\n\n"
1277 cmdline_parse_token_string_t cmd_help_long_help =
1278 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1280 cmdline_parse_token_string_t cmd_help_long_section =
1281 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1282 "all#control#display#config#"
1283 "ports#registers#filters#traffic_management#devices");
1285 cmdline_parse_inst_t cmd_help_long = {
1286 .f = cmd_help_long_parsed,
1288 .help_str = "help all|control|display|config|ports|register|"
1289 "filters|traffic_management|devices: "
1292 (void *)&cmd_help_long_help,
1293 (void *)&cmd_help_long_section,
1299 /* *** start/stop/close all ports *** */
1300 struct cmd_operate_port_result {
1301 cmdline_fixed_string_t keyword;
1302 cmdline_fixed_string_t name;
1303 cmdline_fixed_string_t value;
1306 static void cmd_operate_port_parsed(void *parsed_result,
1307 __rte_unused struct cmdline *cl,
1308 __rte_unused void *data)
1310 struct cmd_operate_port_result *res = parsed_result;
1312 if (!strcmp(res->name, "start"))
1313 start_port(RTE_PORT_ALL);
1314 else if (!strcmp(res->name, "stop"))
1315 stop_port(RTE_PORT_ALL);
1316 else if (!strcmp(res->name, "close"))
1317 close_port(RTE_PORT_ALL);
1318 else if (!strcmp(res->name, "reset"))
1319 reset_port(RTE_PORT_ALL);
1321 printf("Unknown parameter\n");
1324 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1325 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1327 cmdline_parse_token_string_t cmd_operate_port_all_port =
1328 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1329 "start#stop#close#reset");
1330 cmdline_parse_token_string_t cmd_operate_port_all_all =
1331 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1333 cmdline_parse_inst_t cmd_operate_port = {
1334 .f = cmd_operate_port_parsed,
1336 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1338 (void *)&cmd_operate_port_all_cmd,
1339 (void *)&cmd_operate_port_all_port,
1340 (void *)&cmd_operate_port_all_all,
1345 /* *** start/stop/close specific port *** */
1346 struct cmd_operate_specific_port_result {
1347 cmdline_fixed_string_t keyword;
1348 cmdline_fixed_string_t name;
1352 static void cmd_operate_specific_port_parsed(void *parsed_result,
1353 __rte_unused struct cmdline *cl,
1354 __rte_unused void *data)
1356 struct cmd_operate_specific_port_result *res = parsed_result;
1358 if (!strcmp(res->name, "start"))
1359 start_port(res->value);
1360 else if (!strcmp(res->name, "stop"))
1361 stop_port(res->value);
1362 else if (!strcmp(res->name, "close"))
1363 close_port(res->value);
1364 else if (!strcmp(res->name, "reset"))
1365 reset_port(res->value);
1367 printf("Unknown parameter\n");
1370 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1371 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1373 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1374 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1375 name, "start#stop#close#reset");
1376 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1377 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1380 cmdline_parse_inst_t cmd_operate_specific_port = {
1381 .f = cmd_operate_specific_port_parsed,
1383 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1385 (void *)&cmd_operate_specific_port_cmd,
1386 (void *)&cmd_operate_specific_port_port,
1387 (void *)&cmd_operate_specific_port_id,
1392 /* *** enable port setup (after attach) via iterator or event *** */
1393 struct cmd_set_port_setup_on_result {
1394 cmdline_fixed_string_t set;
1395 cmdline_fixed_string_t port;
1396 cmdline_fixed_string_t setup;
1397 cmdline_fixed_string_t on;
1398 cmdline_fixed_string_t mode;
1401 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1402 __rte_unused struct cmdline *cl,
1403 __rte_unused void *data)
1405 struct cmd_set_port_setup_on_result *res = parsed_result;
1407 if (strcmp(res->mode, "event") == 0)
1408 setup_on_probe_event = true;
1409 else if (strcmp(res->mode, "iterator") == 0)
1410 setup_on_probe_event = false;
1412 printf("Unknown mode\n");
1415 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1416 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1418 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1419 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1421 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1422 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1424 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1425 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1427 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1428 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1429 mode, "iterator#event");
1431 cmdline_parse_inst_t cmd_set_port_setup_on = {
1432 .f = cmd_set_port_setup_on_parsed,
1434 .help_str = "set port setup on iterator|event",
1436 (void *)&cmd_set_port_setup_on_set,
1437 (void *)&cmd_set_port_setup_on_port,
1438 (void *)&cmd_set_port_setup_on_setup,
1439 (void *)&cmd_set_port_setup_on_on,
1440 (void *)&cmd_set_port_setup_on_mode,
1445 /* *** attach a specified port *** */
1446 struct cmd_operate_attach_port_result {
1447 cmdline_fixed_string_t port;
1448 cmdline_fixed_string_t keyword;
1449 cmdline_multi_string_t identifier;
1452 static void cmd_operate_attach_port_parsed(void *parsed_result,
1453 __rte_unused struct cmdline *cl,
1454 __rte_unused void *data)
1456 struct cmd_operate_attach_port_result *res = parsed_result;
1458 if (!strcmp(res->keyword, "attach"))
1459 attach_port(res->identifier);
1461 printf("Unknown parameter\n");
1464 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1465 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1467 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1468 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1470 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1471 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1472 identifier, TOKEN_STRING_MULTI);
1474 cmdline_parse_inst_t cmd_operate_attach_port = {
1475 .f = cmd_operate_attach_port_parsed,
1477 .help_str = "port attach <identifier>: "
1478 "(identifier: pci address or virtual dev name)",
1480 (void *)&cmd_operate_attach_port_port,
1481 (void *)&cmd_operate_attach_port_keyword,
1482 (void *)&cmd_operate_attach_port_identifier,
1487 /* *** detach a specified port *** */
1488 struct cmd_operate_detach_port_result {
1489 cmdline_fixed_string_t port;
1490 cmdline_fixed_string_t keyword;
1494 static void cmd_operate_detach_port_parsed(void *parsed_result,
1495 __rte_unused struct cmdline *cl,
1496 __rte_unused void *data)
1498 struct cmd_operate_detach_port_result *res = parsed_result;
1500 if (!strcmp(res->keyword, "detach")) {
1501 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1502 detach_port_device(res->port_id);
1504 printf("Unknown parameter\n");
1508 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1509 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1511 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1512 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1514 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1515 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1518 cmdline_parse_inst_t cmd_operate_detach_port = {
1519 .f = cmd_operate_detach_port_parsed,
1521 .help_str = "port detach <port_id>",
1523 (void *)&cmd_operate_detach_port_port,
1524 (void *)&cmd_operate_detach_port_keyword,
1525 (void *)&cmd_operate_detach_port_port_id,
1530 /* *** detach device by identifier *** */
1531 struct cmd_operate_detach_device_result {
1532 cmdline_fixed_string_t device;
1533 cmdline_fixed_string_t keyword;
1534 cmdline_fixed_string_t identifier;
1537 static void cmd_operate_detach_device_parsed(void *parsed_result,
1538 __rte_unused struct cmdline *cl,
1539 __rte_unused void *data)
1541 struct cmd_operate_detach_device_result *res = parsed_result;
1543 if (!strcmp(res->keyword, "detach"))
1544 detach_devargs(res->identifier);
1546 printf("Unknown parameter\n");
1549 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1550 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1552 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1553 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1555 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1556 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1559 cmdline_parse_inst_t cmd_operate_detach_device = {
1560 .f = cmd_operate_detach_device_parsed,
1562 .help_str = "device detach <identifier>:"
1563 "(identifier: pci address or virtual dev name)",
1565 (void *)&cmd_operate_detach_device_device,
1566 (void *)&cmd_operate_detach_device_keyword,
1567 (void *)&cmd_operate_detach_device_identifier,
1571 /* *** configure speed for all ports *** */
1572 struct cmd_config_speed_all {
1573 cmdline_fixed_string_t port;
1574 cmdline_fixed_string_t keyword;
1575 cmdline_fixed_string_t all;
1576 cmdline_fixed_string_t item1;
1577 cmdline_fixed_string_t item2;
1578 cmdline_fixed_string_t value1;
1579 cmdline_fixed_string_t value2;
1583 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1588 if (!strcmp(duplexstr, "half")) {
1589 duplex = ETH_LINK_HALF_DUPLEX;
1590 } else if (!strcmp(duplexstr, "full")) {
1591 duplex = ETH_LINK_FULL_DUPLEX;
1592 } else if (!strcmp(duplexstr, "auto")) {
1593 duplex = ETH_LINK_FULL_DUPLEX;
1595 printf("Unknown duplex parameter\n");
1599 if (!strcmp(speedstr, "10")) {
1600 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1601 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1602 } else if (!strcmp(speedstr, "100")) {
1603 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1604 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1606 if (duplex != ETH_LINK_FULL_DUPLEX) {
1607 printf("Invalid speed/duplex parameters\n");
1610 if (!strcmp(speedstr, "1000")) {
1611 *speed = ETH_LINK_SPEED_1G;
1612 } else if (!strcmp(speedstr, "10000")) {
1613 *speed = ETH_LINK_SPEED_10G;
1614 } else if (!strcmp(speedstr, "25000")) {
1615 *speed = ETH_LINK_SPEED_25G;
1616 } else if (!strcmp(speedstr, "40000")) {
1617 *speed = ETH_LINK_SPEED_40G;
1618 } else if (!strcmp(speedstr, "50000")) {
1619 *speed = ETH_LINK_SPEED_50G;
1620 } else if (!strcmp(speedstr, "100000")) {
1621 *speed = ETH_LINK_SPEED_100G;
1622 } else if (!strcmp(speedstr, "auto")) {
1623 *speed = ETH_LINK_SPEED_AUTONEG;
1625 printf("Unknown speed parameter\n");
1634 cmd_config_speed_all_parsed(void *parsed_result,
1635 __rte_unused struct cmdline *cl,
1636 __rte_unused void *data)
1638 struct cmd_config_speed_all *res = parsed_result;
1639 uint32_t link_speed;
1642 if (!all_ports_stopped()) {
1643 printf("Please stop all ports first\n");
1647 if (parse_and_check_speed_duplex(res->value1, res->value2,
1651 RTE_ETH_FOREACH_DEV(pid) {
1652 ports[pid].dev_conf.link_speeds = link_speed;
1655 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1658 cmdline_parse_token_string_t cmd_config_speed_all_port =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1660 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1663 cmdline_parse_token_string_t cmd_config_speed_all_all =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1665 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1667 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1669 "10#100#1000#10000#25000#40000#50000#100000#auto");
1670 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1672 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1673 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1676 cmdline_parse_inst_t cmd_config_speed_all = {
1677 .f = cmd_config_speed_all_parsed,
1679 .help_str = "port config all speed "
1680 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1683 (void *)&cmd_config_speed_all_port,
1684 (void *)&cmd_config_speed_all_keyword,
1685 (void *)&cmd_config_speed_all_all,
1686 (void *)&cmd_config_speed_all_item1,
1687 (void *)&cmd_config_speed_all_value1,
1688 (void *)&cmd_config_speed_all_item2,
1689 (void *)&cmd_config_speed_all_value2,
1694 /* *** configure speed for specific port *** */
1695 struct cmd_config_speed_specific {
1696 cmdline_fixed_string_t port;
1697 cmdline_fixed_string_t keyword;
1699 cmdline_fixed_string_t item1;
1700 cmdline_fixed_string_t item2;
1701 cmdline_fixed_string_t value1;
1702 cmdline_fixed_string_t value2;
1706 cmd_config_speed_specific_parsed(void *parsed_result,
1707 __rte_unused struct cmdline *cl,
1708 __rte_unused void *data)
1710 struct cmd_config_speed_specific *res = parsed_result;
1711 uint32_t link_speed;
1713 if (!all_ports_stopped()) {
1714 printf("Please stop all ports first\n");
1718 if (port_id_is_invalid(res->id, ENABLED_WARN))
1721 if (parse_and_check_speed_duplex(res->value1, res->value2,
1725 ports[res->id].dev_conf.link_speeds = link_speed;
1727 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1731 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1734 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1735 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1737 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1738 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1739 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1740 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1742 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1743 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1744 "10#100#1000#10000#25000#40000#50000#100000#auto");
1745 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1746 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1748 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1749 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1752 cmdline_parse_inst_t cmd_config_speed_specific = {
1753 .f = cmd_config_speed_specific_parsed,
1755 .help_str = "port config <port_id> speed "
1756 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1759 (void *)&cmd_config_speed_specific_port,
1760 (void *)&cmd_config_speed_specific_keyword,
1761 (void *)&cmd_config_speed_specific_id,
1762 (void *)&cmd_config_speed_specific_item1,
1763 (void *)&cmd_config_speed_specific_value1,
1764 (void *)&cmd_config_speed_specific_item2,
1765 (void *)&cmd_config_speed_specific_value2,
1770 /* *** configure loopback for all ports *** */
1771 struct cmd_config_loopback_all {
1772 cmdline_fixed_string_t port;
1773 cmdline_fixed_string_t keyword;
1774 cmdline_fixed_string_t all;
1775 cmdline_fixed_string_t item;
1780 cmd_config_loopback_all_parsed(void *parsed_result,
1781 __rte_unused struct cmdline *cl,
1782 __rte_unused void *data)
1784 struct cmd_config_loopback_all *res = parsed_result;
1787 if (!all_ports_stopped()) {
1788 printf("Please stop all ports first\n");
1792 RTE_ETH_FOREACH_DEV(pid) {
1793 ports[pid].dev_conf.lpbk_mode = res->mode;
1796 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1799 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1801 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1802 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1804 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1805 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1806 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1807 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1809 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1810 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1812 cmdline_parse_inst_t cmd_config_loopback_all = {
1813 .f = cmd_config_loopback_all_parsed,
1815 .help_str = "port config all loopback <mode>",
1817 (void *)&cmd_config_loopback_all_port,
1818 (void *)&cmd_config_loopback_all_keyword,
1819 (void *)&cmd_config_loopback_all_all,
1820 (void *)&cmd_config_loopback_all_item,
1821 (void *)&cmd_config_loopback_all_mode,
1826 /* *** configure loopback for specific port *** */
1827 struct cmd_config_loopback_specific {
1828 cmdline_fixed_string_t port;
1829 cmdline_fixed_string_t keyword;
1831 cmdline_fixed_string_t item;
1836 cmd_config_loopback_specific_parsed(void *parsed_result,
1837 __rte_unused struct cmdline *cl,
1838 __rte_unused void *data)
1840 struct cmd_config_loopback_specific *res = parsed_result;
1842 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1845 if (!port_is_stopped(res->port_id)) {
1846 printf("Please stop port %u first\n", res->port_id);
1850 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1852 cmd_reconfig_device_queue(res->port_id, 1, 1);
1856 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1859 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1862 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1863 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1865 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1868 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1869 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1872 cmdline_parse_inst_t cmd_config_loopback_specific = {
1873 .f = cmd_config_loopback_specific_parsed,
1875 .help_str = "port config <port_id> loopback <mode>",
1877 (void *)&cmd_config_loopback_specific_port,
1878 (void *)&cmd_config_loopback_specific_keyword,
1879 (void *)&cmd_config_loopback_specific_id,
1880 (void *)&cmd_config_loopback_specific_item,
1881 (void *)&cmd_config_loopback_specific_mode,
1886 /* *** configure txq/rxq, txd/rxd *** */
1887 struct cmd_config_rx_tx {
1888 cmdline_fixed_string_t port;
1889 cmdline_fixed_string_t keyword;
1890 cmdline_fixed_string_t all;
1891 cmdline_fixed_string_t name;
1896 cmd_config_rx_tx_parsed(void *parsed_result,
1897 __rte_unused struct cmdline *cl,
1898 __rte_unused void *data)
1900 struct cmd_config_rx_tx *res = parsed_result;
1902 if (!all_ports_stopped()) {
1903 printf("Please stop all ports first\n");
1906 if (!strcmp(res->name, "rxq")) {
1907 if (!res->value && !nb_txq) {
1908 printf("Warning: Either rx or tx queues should be non zero\n");
1911 if (check_nb_rxq(res->value) != 0)
1913 nb_rxq = res->value;
1915 else if (!strcmp(res->name, "txq")) {
1916 if (!res->value && !nb_rxq) {
1917 printf("Warning: Either rx or tx queues should be non zero\n");
1920 if (check_nb_txq(res->value) != 0)
1922 nb_txq = res->value;
1924 else if (!strcmp(res->name, "rxd")) {
1925 if (check_nb_rxd(res->value) != 0)
1927 nb_rxd = res->value;
1928 } else if (!strcmp(res->name, "txd")) {
1929 if (check_nb_txd(res->value) != 0)
1932 nb_txd = res->value;
1934 printf("Unknown parameter\n");
1942 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1945 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1946 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1947 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1948 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1949 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1950 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1951 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1952 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1954 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1955 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1957 cmdline_parse_inst_t cmd_config_rx_tx = {
1958 .f = cmd_config_rx_tx_parsed,
1960 .help_str = "port config all rxq|txq|rxd|txd <value>",
1962 (void *)&cmd_config_rx_tx_port,
1963 (void *)&cmd_config_rx_tx_keyword,
1964 (void *)&cmd_config_rx_tx_all,
1965 (void *)&cmd_config_rx_tx_name,
1966 (void *)&cmd_config_rx_tx_value,
1971 /* *** config max packet length *** */
1972 struct cmd_config_max_pkt_len_result {
1973 cmdline_fixed_string_t port;
1974 cmdline_fixed_string_t keyword;
1975 cmdline_fixed_string_t all;
1976 cmdline_fixed_string_t name;
1981 cmd_config_max_pkt_len_parsed(void *parsed_result,
1982 __rte_unused struct cmdline *cl,
1983 __rte_unused void *data)
1985 struct cmd_config_max_pkt_len_result *res = parsed_result;
1988 if (!all_ports_stopped()) {
1989 printf("Please stop all ports first\n");
1993 RTE_ETH_FOREACH_DEV(pid) {
1994 struct rte_port *port = &ports[pid];
1995 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1997 if (!strcmp(res->name, "max-pkt-len")) {
1998 if (res->value < RTE_ETHER_MIN_LEN) {
1999 printf("max-pkt-len can not be less than %d\n",
2003 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2006 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2007 if (res->value > RTE_ETHER_MAX_LEN)
2008 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2010 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2011 port->dev_conf.rxmode.offloads = rx_offloads;
2013 printf("Unknown parameter\n");
2020 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2023 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2024 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2026 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2027 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2029 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2030 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2032 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2035 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2036 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2039 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2040 .f = cmd_config_max_pkt_len_parsed,
2042 .help_str = "port config all max-pkt-len <value>",
2044 (void *)&cmd_config_max_pkt_len_port,
2045 (void *)&cmd_config_max_pkt_len_keyword,
2046 (void *)&cmd_config_max_pkt_len_all,
2047 (void *)&cmd_config_max_pkt_len_name,
2048 (void *)&cmd_config_max_pkt_len_value,
2053 /* *** config max LRO aggregated packet size *** */
2054 struct cmd_config_max_lro_pkt_size_result {
2055 cmdline_fixed_string_t port;
2056 cmdline_fixed_string_t keyword;
2057 cmdline_fixed_string_t all;
2058 cmdline_fixed_string_t name;
2063 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2064 __rte_unused struct cmdline *cl,
2065 __rte_unused void *data)
2067 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2070 if (!all_ports_stopped()) {
2071 printf("Please stop all ports first\n");
2075 RTE_ETH_FOREACH_DEV(pid) {
2076 struct rte_port *port = &ports[pid];
2078 if (!strcmp(res->name, "max-lro-pkt-size")) {
2080 port->dev_conf.rxmode.max_lro_pkt_size)
2083 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2085 printf("Unknown parameter\n");
2092 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2095 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2096 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2098 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2099 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2101 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2102 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2104 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2105 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2106 name, "max-lro-pkt-size");
2107 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2108 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2111 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2112 .f = cmd_config_max_lro_pkt_size_parsed,
2114 .help_str = "port config all max-lro-pkt-size <value>",
2116 (void *)&cmd_config_max_lro_pkt_size_port,
2117 (void *)&cmd_config_max_lro_pkt_size_keyword,
2118 (void *)&cmd_config_max_lro_pkt_size_all,
2119 (void *)&cmd_config_max_lro_pkt_size_name,
2120 (void *)&cmd_config_max_lro_pkt_size_value,
2125 /* *** configure port MTU *** */
2126 struct cmd_config_mtu_result {
2127 cmdline_fixed_string_t port;
2128 cmdline_fixed_string_t keyword;
2129 cmdline_fixed_string_t mtu;
2135 cmd_config_mtu_parsed(void *parsed_result,
2136 __rte_unused struct cmdline *cl,
2137 __rte_unused void *data)
2139 struct cmd_config_mtu_result *res = parsed_result;
2141 if (res->value < RTE_ETHER_MIN_LEN) {
2142 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2145 port_mtu_set(res->port_id, res->value);
2148 cmdline_parse_token_string_t cmd_config_mtu_port =
2149 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2151 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2152 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2154 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2155 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2157 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2158 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2159 cmdline_parse_token_num_t cmd_config_mtu_value =
2160 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2162 cmdline_parse_inst_t cmd_config_mtu = {
2163 .f = cmd_config_mtu_parsed,
2165 .help_str = "port config mtu <port_id> <value>",
2167 (void *)&cmd_config_mtu_port,
2168 (void *)&cmd_config_mtu_keyword,
2169 (void *)&cmd_config_mtu_mtu,
2170 (void *)&cmd_config_mtu_port_id,
2171 (void *)&cmd_config_mtu_value,
2176 /* *** configure rx mode *** */
2177 struct cmd_config_rx_mode_flag {
2178 cmdline_fixed_string_t port;
2179 cmdline_fixed_string_t keyword;
2180 cmdline_fixed_string_t all;
2181 cmdline_fixed_string_t name;
2182 cmdline_fixed_string_t value;
2186 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2187 __rte_unused struct cmdline *cl,
2188 __rte_unused void *data)
2190 struct cmd_config_rx_mode_flag *res = parsed_result;
2192 if (!all_ports_stopped()) {
2193 printf("Please stop all ports first\n");
2197 if (!strcmp(res->name, "drop-en")) {
2198 if (!strcmp(res->value, "on"))
2200 else if (!strcmp(res->value, "off"))
2203 printf("Unknown parameter\n");
2207 printf("Unknown parameter\n");
2213 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2216 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2217 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2218 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2219 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2221 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2222 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2223 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2224 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2226 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2227 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2230 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2231 .f = cmd_config_rx_mode_flag_parsed,
2233 .help_str = "port config all drop-en on|off",
2235 (void *)&cmd_config_rx_mode_flag_port,
2236 (void *)&cmd_config_rx_mode_flag_keyword,
2237 (void *)&cmd_config_rx_mode_flag_all,
2238 (void *)&cmd_config_rx_mode_flag_name,
2239 (void *)&cmd_config_rx_mode_flag_value,
2244 /* *** configure rss *** */
2245 struct cmd_config_rss {
2246 cmdline_fixed_string_t port;
2247 cmdline_fixed_string_t keyword;
2248 cmdline_fixed_string_t all;
2249 cmdline_fixed_string_t name;
2250 cmdline_fixed_string_t value;
2254 cmd_config_rss_parsed(void *parsed_result,
2255 __rte_unused struct cmdline *cl,
2256 __rte_unused void *data)
2258 struct cmd_config_rss *res = parsed_result;
2259 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2260 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2261 int use_default = 0;
2262 int all_updated = 1;
2267 if (!strcmp(res->value, "all"))
2268 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2269 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2270 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2271 ETH_RSS_AH | ETH_RSS_PFCP;
2272 else if (!strcmp(res->value, "eth"))
2273 rss_conf.rss_hf = ETH_RSS_ETH;
2274 else if (!strcmp(res->value, "vlan"))
2275 rss_conf.rss_hf = ETH_RSS_VLAN;
2276 else if (!strcmp(res->value, "ip"))
2277 rss_conf.rss_hf = ETH_RSS_IP;
2278 else if (!strcmp(res->value, "udp"))
2279 rss_conf.rss_hf = ETH_RSS_UDP;
2280 else if (!strcmp(res->value, "tcp"))
2281 rss_conf.rss_hf = ETH_RSS_TCP;
2282 else if (!strcmp(res->value, "sctp"))
2283 rss_conf.rss_hf = ETH_RSS_SCTP;
2284 else if (!strcmp(res->value, "ether"))
2285 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2286 else if (!strcmp(res->value, "port"))
2287 rss_conf.rss_hf = ETH_RSS_PORT;
2288 else if (!strcmp(res->value, "vxlan"))
2289 rss_conf.rss_hf = ETH_RSS_VXLAN;
2290 else if (!strcmp(res->value, "geneve"))
2291 rss_conf.rss_hf = ETH_RSS_GENEVE;
2292 else if (!strcmp(res->value, "nvgre"))
2293 rss_conf.rss_hf = ETH_RSS_NVGRE;
2294 else if (!strcmp(res->value, "l3-src-only"))
2295 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2296 else if (!strcmp(res->value, "l3-dst-only"))
2297 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2298 else if (!strcmp(res->value, "l4-src-only"))
2299 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2300 else if (!strcmp(res->value, "l4-dst-only"))
2301 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2302 else if (!strcmp(res->value, "l2-src-only"))
2303 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2304 else if (!strcmp(res->value, "l2-dst-only"))
2305 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2306 else if (!strcmp(res->value, "l2tpv3"))
2307 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2308 else if (!strcmp(res->value, "esp"))
2309 rss_conf.rss_hf = ETH_RSS_ESP;
2310 else if (!strcmp(res->value, "ah"))
2311 rss_conf.rss_hf = ETH_RSS_AH;
2312 else if (!strcmp(res->value, "pfcp"))
2313 rss_conf.rss_hf = ETH_RSS_PFCP;
2314 else if (!strcmp(res->value, "none"))
2315 rss_conf.rss_hf = 0;
2316 else if (!strcmp(res->value, "default"))
2318 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2319 atoi(res->value) < 64)
2320 rss_conf.rss_hf = 1ULL << atoi(res->value);
2322 printf("Unknown parameter\n");
2325 rss_conf.rss_key = NULL;
2326 /* Update global configuration for RSS types. */
2327 RTE_ETH_FOREACH_DEV(i) {
2328 struct rte_eth_rss_conf local_rss_conf;
2330 ret = eth_dev_info_get_print_err(i, &dev_info);
2335 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2337 local_rss_conf = rss_conf;
2338 local_rss_conf.rss_hf = rss_conf.rss_hf &
2339 dev_info.flow_type_rss_offloads;
2340 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2341 printf("Port %u modified RSS hash function based on hardware support,"
2342 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2343 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2345 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2348 printf("Configuration of RSS hash at ethernet port %d "
2349 "failed with error (%d): %s.\n",
2350 i, -diag, strerror(-diag));
2353 if (all_updated && !use_default) {
2354 rss_hf = rss_conf.rss_hf;
2355 printf("rss_hf %#"PRIx64"\n", rss_hf);
2359 cmdline_parse_token_string_t cmd_config_rss_port =
2360 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2361 cmdline_parse_token_string_t cmd_config_rss_keyword =
2362 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2363 cmdline_parse_token_string_t cmd_config_rss_all =
2364 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2365 cmdline_parse_token_string_t cmd_config_rss_name =
2366 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2367 cmdline_parse_token_string_t cmd_config_rss_value =
2368 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2370 cmdline_parse_inst_t cmd_config_rss = {
2371 .f = cmd_config_rss_parsed,
2373 .help_str = "port config all rss "
2374 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2375 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|<flowtype_id>",
2377 (void *)&cmd_config_rss_port,
2378 (void *)&cmd_config_rss_keyword,
2379 (void *)&cmd_config_rss_all,
2380 (void *)&cmd_config_rss_name,
2381 (void *)&cmd_config_rss_value,
2386 /* *** configure rss hash key *** */
2387 struct cmd_config_rss_hash_key {
2388 cmdline_fixed_string_t port;
2389 cmdline_fixed_string_t config;
2391 cmdline_fixed_string_t rss_hash_key;
2392 cmdline_fixed_string_t rss_type;
2393 cmdline_fixed_string_t key;
2397 hexa_digit_to_value(char hexa_digit)
2399 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2400 return (uint8_t) (hexa_digit - '0');
2401 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2402 return (uint8_t) ((hexa_digit - 'a') + 10);
2403 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2404 return (uint8_t) ((hexa_digit - 'A') + 10);
2405 /* Invalid hexa digit */
2410 parse_and_check_key_hexa_digit(char *key, int idx)
2414 hexa_v = hexa_digit_to_value(key[idx]);
2416 printf("invalid key: character %c at position %d is not a "
2417 "valid hexa digit\n", key[idx], idx);
2422 cmd_config_rss_hash_key_parsed(void *parsed_result,
2423 __rte_unused struct cmdline *cl,
2424 __rte_unused void *data)
2426 struct cmd_config_rss_hash_key *res = parsed_result;
2427 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2431 struct rte_eth_dev_info dev_info;
2432 uint8_t hash_key_size;
2436 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2440 if (dev_info.hash_key_size > 0 &&
2441 dev_info.hash_key_size <= sizeof(hash_key))
2442 hash_key_size = dev_info.hash_key_size;
2444 printf("dev_info did not provide a valid hash key size\n");
2447 /* Check the length of the RSS hash key */
2448 key_len = strlen(res->key);
2449 if (key_len != (hash_key_size * 2)) {
2450 printf("key length: %d invalid - key must be a string of %d"
2451 " hexa-decimal numbers\n",
2452 (int) key_len, hash_key_size * 2);
2455 /* Translate RSS hash key into binary representation */
2456 for (i = 0; i < hash_key_size; i++) {
2457 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2460 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2463 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2465 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2469 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2470 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2471 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2472 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2474 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2475 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2476 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2477 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2478 rss_hash_key, "rss-hash-key");
2479 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2480 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2481 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2482 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2483 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2484 "ipv6-tcp-ex#ipv6-udp-ex#"
2485 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2486 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2487 "l2tpv3#esp#ah#pfcp");
2488 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2489 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2491 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2492 .f = cmd_config_rss_hash_key_parsed,
2494 .help_str = "port config <port_id> rss-hash-key "
2495 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2496 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2497 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2498 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2499 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2500 "l2tpv3|esp|ah|pfcp "
2501 "<string of hex digits (variable length, NIC dependent)>",
2503 (void *)&cmd_config_rss_hash_key_port,
2504 (void *)&cmd_config_rss_hash_key_config,
2505 (void *)&cmd_config_rss_hash_key_port_id,
2506 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2507 (void *)&cmd_config_rss_hash_key_rss_type,
2508 (void *)&cmd_config_rss_hash_key_value,
2513 /* *** configure port rxq/txq ring size *** */
2514 struct cmd_config_rxtx_ring_size {
2515 cmdline_fixed_string_t port;
2516 cmdline_fixed_string_t config;
2518 cmdline_fixed_string_t rxtxq;
2520 cmdline_fixed_string_t rsize;
2525 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2526 __rte_unused struct cmdline *cl,
2527 __rte_unused void *data)
2529 struct cmd_config_rxtx_ring_size *res = parsed_result;
2530 struct rte_port *port;
2533 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2536 if (res->portid == (portid_t)RTE_PORT_ALL) {
2537 printf("Invalid port id\n");
2541 port = &ports[res->portid];
2543 if (!strcmp(res->rxtxq, "rxq"))
2545 else if (!strcmp(res->rxtxq, "txq"))
2548 printf("Unknown parameter\n");
2552 if (isrx && rx_queue_id_is_invalid(res->qid))
2554 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2557 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2558 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2564 port->nb_rx_desc[res->qid] = res->size;
2566 port->nb_tx_desc[res->qid] = res->size;
2568 cmd_reconfig_device_queue(res->portid, 0, 1);
2571 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2572 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2574 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2575 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2577 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2578 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2580 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2581 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2583 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2584 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2586 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2587 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2588 rsize, "ring_size");
2589 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2590 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2593 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2594 .f = cmd_config_rxtx_ring_size_parsed,
2596 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2598 (void *)&cmd_config_rxtx_ring_size_port,
2599 (void *)&cmd_config_rxtx_ring_size_config,
2600 (void *)&cmd_config_rxtx_ring_size_portid,
2601 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2602 (void *)&cmd_config_rxtx_ring_size_qid,
2603 (void *)&cmd_config_rxtx_ring_size_rsize,
2604 (void *)&cmd_config_rxtx_ring_size_size,
2609 /* *** configure port rxq/txq start/stop *** */
2610 struct cmd_config_rxtx_queue {
2611 cmdline_fixed_string_t port;
2613 cmdline_fixed_string_t rxtxq;
2615 cmdline_fixed_string_t opname;
2619 cmd_config_rxtx_queue_parsed(void *parsed_result,
2620 __rte_unused struct cmdline *cl,
2621 __rte_unused void *data)
2623 struct cmd_config_rxtx_queue *res = parsed_result;
2628 if (test_done == 0) {
2629 printf("Please stop forwarding first\n");
2633 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2636 if (port_is_started(res->portid) != 1) {
2637 printf("Please start port %u first\n", res->portid);
2641 if (!strcmp(res->rxtxq, "rxq"))
2643 else if (!strcmp(res->rxtxq, "txq"))
2646 printf("Unknown parameter\n");
2650 if (isrx && rx_queue_id_is_invalid(res->qid))
2652 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2655 if (!strcmp(res->opname, "start"))
2657 else if (!strcmp(res->opname, "stop"))
2660 printf("Unknown parameter\n");
2664 if (isstart && isrx)
2665 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2666 else if (!isstart && isrx)
2667 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2668 else if (isstart && !isrx)
2669 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2671 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2673 if (ret == -ENOTSUP)
2674 printf("Function not supported in PMD driver\n");
2677 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2678 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2679 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2680 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2681 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2682 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2683 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2684 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2685 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2686 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2689 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2690 .f = cmd_config_rxtx_queue_parsed,
2692 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2694 (void *)&cmd_config_rxtx_queue_port,
2695 (void *)&cmd_config_rxtx_queue_portid,
2696 (void *)&cmd_config_rxtx_queue_rxtxq,
2697 (void *)&cmd_config_rxtx_queue_qid,
2698 (void *)&cmd_config_rxtx_queue_opname,
2703 /* *** configure port rxq/txq deferred start on/off *** */
2704 struct cmd_config_deferred_start_rxtx_queue {
2705 cmdline_fixed_string_t port;
2707 cmdline_fixed_string_t rxtxq;
2709 cmdline_fixed_string_t opname;
2710 cmdline_fixed_string_t state;
2714 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2715 __rte_unused struct cmdline *cl,
2716 __rte_unused void *data)
2718 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2719 struct rte_port *port;
2722 uint8_t needreconfig = 0;
2724 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2727 if (port_is_started(res->port_id) != 0) {
2728 printf("Please stop port %u first\n", res->port_id);
2732 port = &ports[res->port_id];
2734 isrx = !strcmp(res->rxtxq, "rxq");
2736 if (isrx && rx_queue_id_is_invalid(res->qid))
2738 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2741 ison = !strcmp(res->state, "on");
2743 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2744 port->rx_conf[res->qid].rx_deferred_start = ison;
2746 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2747 port->tx_conf[res->qid].tx_deferred_start = ison;
2752 cmd_reconfig_device_queue(res->port_id, 0, 1);
2755 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2756 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2758 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2759 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2761 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2762 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2764 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2765 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2767 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2768 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2769 opname, "deferred_start");
2770 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2771 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2774 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2775 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2777 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2779 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2780 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2781 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2782 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2783 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2784 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2789 /* *** configure port rxq/txq setup *** */
2790 struct cmd_setup_rxtx_queue {
2791 cmdline_fixed_string_t port;
2793 cmdline_fixed_string_t rxtxq;
2795 cmdline_fixed_string_t setup;
2798 /* Common CLI fields for queue setup */
2799 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2800 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2801 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2802 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2803 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2804 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2805 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2806 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2807 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2808 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2811 cmd_setup_rxtx_queue_parsed(
2812 void *parsed_result,
2813 __rte_unused struct cmdline *cl,
2814 __rte_unused void *data)
2816 struct cmd_setup_rxtx_queue *res = parsed_result;
2817 struct rte_port *port;
2818 struct rte_mempool *mp;
2819 unsigned int socket_id;
2823 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2826 if (res->portid == (portid_t)RTE_PORT_ALL) {
2827 printf("Invalid port id\n");
2831 if (!strcmp(res->rxtxq, "rxq"))
2833 else if (!strcmp(res->rxtxq, "txq"))
2836 printf("Unknown parameter\n");
2840 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2841 printf("Invalid rx queue\n");
2843 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2844 printf("Invalid tx queue\n");
2848 port = &ports[res->portid];
2850 socket_id = rxring_numa[res->portid];
2851 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2852 socket_id = port->socket_id;
2854 mp = mbuf_pool_find(socket_id);
2856 printf("Failed to setup RX queue: "
2857 "No mempool allocation"
2858 " on the socket %d\n",
2859 rxring_numa[res->portid]);
2862 ret = rte_eth_rx_queue_setup(res->portid,
2864 port->nb_rx_desc[res->qid],
2866 &port->rx_conf[res->qid],
2869 printf("Failed to setup RX queue\n");
2871 socket_id = txring_numa[res->portid];
2872 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2873 socket_id = port->socket_id;
2875 ret = rte_eth_tx_queue_setup(res->portid,
2877 port->nb_tx_desc[res->qid],
2879 &port->tx_conf[res->qid]);
2881 printf("Failed to setup TX queue\n");
2885 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2886 .f = cmd_setup_rxtx_queue_parsed,
2888 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2890 (void *)&cmd_setup_rxtx_queue_port,
2891 (void *)&cmd_setup_rxtx_queue_portid,
2892 (void *)&cmd_setup_rxtx_queue_rxtxq,
2893 (void *)&cmd_setup_rxtx_queue_qid,
2894 (void *)&cmd_setup_rxtx_queue_setup,
2900 /* *** Configure RSS RETA *** */
2901 struct cmd_config_rss_reta {
2902 cmdline_fixed_string_t port;
2903 cmdline_fixed_string_t keyword;
2905 cmdline_fixed_string_t name;
2906 cmdline_fixed_string_t list_name;
2907 cmdline_fixed_string_t list_of_items;
2911 parse_reta_config(const char *str,
2912 struct rte_eth_rss_reta_entry64 *reta_conf,
2913 uint16_t nb_entries)
2917 uint16_t hash_index, idx, shift;
2920 const char *p, *p0 = str;
2927 unsigned long int_fld[_NUM_FLD];
2928 char *str_fld[_NUM_FLD];
2930 while ((p = strchr(p0,'(')) != NULL) {
2932 if((p0 = strchr(p,')')) == NULL)
2936 if(size >= sizeof(s))
2939 snprintf(s, sizeof(s), "%.*s", size, p);
2940 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2942 for (i = 0; i < _NUM_FLD; i++) {
2944 int_fld[i] = strtoul(str_fld[i], &end, 0);
2945 if (errno != 0 || end == str_fld[i] ||
2950 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2951 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2953 if (hash_index >= nb_entries) {
2954 printf("Invalid RETA hash index=%d\n", hash_index);
2958 idx = hash_index / RTE_RETA_GROUP_SIZE;
2959 shift = hash_index % RTE_RETA_GROUP_SIZE;
2960 reta_conf[idx].mask |= (1ULL << shift);
2961 reta_conf[idx].reta[shift] = nb_queue;
2968 cmd_set_rss_reta_parsed(void *parsed_result,
2969 __rte_unused struct cmdline *cl,
2970 __rte_unused void *data)
2973 struct rte_eth_dev_info dev_info;
2974 struct rte_eth_rss_reta_entry64 reta_conf[8];
2975 struct cmd_config_rss_reta *res = parsed_result;
2977 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2981 if (dev_info.reta_size == 0) {
2982 printf("Redirection table size is 0 which is "
2983 "invalid for RSS\n");
2986 printf("The reta size of port %d is %u\n",
2987 res->port_id, dev_info.reta_size);
2988 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2989 printf("Currently do not support more than %u entries of "
2990 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2994 memset(reta_conf, 0, sizeof(reta_conf));
2995 if (!strcmp(res->list_name, "reta")) {
2996 if (parse_reta_config(res->list_of_items, reta_conf,
2997 dev_info.reta_size)) {
2998 printf("Invalid RSS Redirection Table "
2999 "config entered\n");
3002 ret = rte_eth_dev_rss_reta_update(res->port_id,
3003 reta_conf, dev_info.reta_size);
3005 printf("Bad redirection table parameter, "
3006 "return code = %d \n", ret);
3010 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3011 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3012 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3013 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3014 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3015 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3016 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3017 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3018 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3019 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3020 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3021 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3023 cmdline_parse_inst_t cmd_config_rss_reta = {
3024 .f = cmd_set_rss_reta_parsed,
3026 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3028 (void *)&cmd_config_rss_reta_port,
3029 (void *)&cmd_config_rss_reta_keyword,
3030 (void *)&cmd_config_rss_reta_port_id,
3031 (void *)&cmd_config_rss_reta_name,
3032 (void *)&cmd_config_rss_reta_list_name,
3033 (void *)&cmd_config_rss_reta_list_of_items,
3038 /* *** SHOW PORT RETA INFO *** */
3039 struct cmd_showport_reta {
3040 cmdline_fixed_string_t show;
3041 cmdline_fixed_string_t port;
3043 cmdline_fixed_string_t rss;
3044 cmdline_fixed_string_t reta;
3046 cmdline_fixed_string_t list_of_items;
3050 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3051 uint16_t nb_entries,
3055 const char *p, *p0 = str;
3060 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3061 RTE_RETA_GROUP_SIZE;
3064 p = strchr(p0, '(');
3068 p0 = strchr(p, ')');
3072 if (size >= sizeof(s)) {
3073 printf("The string size exceeds the internal buffer size\n");
3076 snprintf(s, sizeof(s), "%.*s", size, p);
3077 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3078 if (ret <= 0 || ret != num) {
3079 printf("The bits of masks do not match the number of "
3080 "reta entries: %u\n", num);
3083 for (i = 0; i < ret; i++)
3084 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3090 cmd_showport_reta_parsed(void *parsed_result,
3091 __rte_unused struct cmdline *cl,
3092 __rte_unused void *data)
3094 struct cmd_showport_reta *res = parsed_result;
3095 struct rte_eth_rss_reta_entry64 reta_conf[8];
3096 struct rte_eth_dev_info dev_info;
3097 uint16_t max_reta_size;
3100 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3104 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3105 if (res->size == 0 || res->size > max_reta_size) {
3106 printf("Invalid redirection table size: %u (1-%u)\n",
3107 res->size, max_reta_size);
3111 memset(reta_conf, 0, sizeof(reta_conf));
3112 if (showport_parse_reta_config(reta_conf, res->size,
3113 res->list_of_items) < 0) {
3114 printf("Invalid string: %s for reta masks\n",
3115 res->list_of_items);
3118 port_rss_reta_info(res->port_id, reta_conf, res->size);
3121 cmdline_parse_token_string_t cmd_showport_reta_show =
3122 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3123 cmdline_parse_token_string_t cmd_showport_reta_port =
3124 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3125 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3126 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3127 cmdline_parse_token_string_t cmd_showport_reta_rss =
3128 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3129 cmdline_parse_token_string_t cmd_showport_reta_reta =
3130 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3131 cmdline_parse_token_num_t cmd_showport_reta_size =
3132 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3133 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3134 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3135 list_of_items, NULL);
3137 cmdline_parse_inst_t cmd_showport_reta = {
3138 .f = cmd_showport_reta_parsed,
3140 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3142 (void *)&cmd_showport_reta_show,
3143 (void *)&cmd_showport_reta_port,
3144 (void *)&cmd_showport_reta_port_id,
3145 (void *)&cmd_showport_reta_rss,
3146 (void *)&cmd_showport_reta_reta,
3147 (void *)&cmd_showport_reta_size,
3148 (void *)&cmd_showport_reta_list_of_items,
3153 /* *** Show RSS hash configuration *** */
3154 struct cmd_showport_rss_hash {
3155 cmdline_fixed_string_t show;
3156 cmdline_fixed_string_t port;
3158 cmdline_fixed_string_t rss_hash;
3159 cmdline_fixed_string_t rss_type;
3160 cmdline_fixed_string_t key; /* optional argument */
3163 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3164 __rte_unused struct cmdline *cl,
3167 struct cmd_showport_rss_hash *res = parsed_result;
3169 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3172 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3173 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3174 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3175 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3176 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3177 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3178 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3179 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3181 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3182 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3184 cmdline_parse_inst_t cmd_showport_rss_hash = {
3185 .f = cmd_showport_rss_hash_parsed,
3187 .help_str = "show port <port_id> rss-hash",
3189 (void *)&cmd_showport_rss_hash_show,
3190 (void *)&cmd_showport_rss_hash_port,
3191 (void *)&cmd_showport_rss_hash_port_id,
3192 (void *)&cmd_showport_rss_hash_rss_hash,
3197 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3198 .f = cmd_showport_rss_hash_parsed,
3200 .help_str = "show port <port_id> rss-hash key",
3202 (void *)&cmd_showport_rss_hash_show,
3203 (void *)&cmd_showport_rss_hash_port,
3204 (void *)&cmd_showport_rss_hash_port_id,
3205 (void *)&cmd_showport_rss_hash_rss_hash,
3206 (void *)&cmd_showport_rss_hash_rss_key,
3211 /* *** Configure DCB *** */
3212 struct cmd_config_dcb {
3213 cmdline_fixed_string_t port;
3214 cmdline_fixed_string_t config;
3216 cmdline_fixed_string_t dcb;
3217 cmdline_fixed_string_t vt;
3218 cmdline_fixed_string_t vt_en;
3220 cmdline_fixed_string_t pfc;
3221 cmdline_fixed_string_t pfc_en;
3225 cmd_config_dcb_parsed(void *parsed_result,
3226 __rte_unused struct cmdline *cl,
3227 __rte_unused void *data)
3229 struct cmd_config_dcb *res = parsed_result;
3230 portid_t port_id = res->port_id;
3231 struct rte_port *port;
3235 port = &ports[port_id];
3236 /** Check if the port is not started **/
3237 if (port->port_status != RTE_PORT_STOPPED) {
3238 printf("Please stop port %d first\n", port_id);
3242 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3243 printf("The invalid number of traffic class,"
3244 " only 4 or 8 allowed.\n");
3248 if (nb_fwd_lcores < res->num_tcs) {
3249 printf("nb_cores shouldn't be less than number of TCs.\n");
3252 if (!strncmp(res->pfc_en, "on", 2))
3257 /* DCB in VT mode */
3258 if (!strncmp(res->vt_en, "on", 2))
3259 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3260 (enum rte_eth_nb_tcs)res->num_tcs,
3263 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3264 (enum rte_eth_nb_tcs)res->num_tcs,
3269 printf("Cannot initialize network ports.\n");
3273 cmd_reconfig_device_queue(port_id, 1, 1);
3276 cmdline_parse_token_string_t cmd_config_dcb_port =
3277 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3278 cmdline_parse_token_string_t cmd_config_dcb_config =
3279 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3280 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3281 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3282 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3283 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3284 cmdline_parse_token_string_t cmd_config_dcb_vt =
3285 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3286 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3287 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3288 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3289 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3290 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3291 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3292 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3293 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3295 cmdline_parse_inst_t cmd_config_dcb = {
3296 .f = cmd_config_dcb_parsed,
3298 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3300 (void *)&cmd_config_dcb_port,
3301 (void *)&cmd_config_dcb_config,
3302 (void *)&cmd_config_dcb_port_id,
3303 (void *)&cmd_config_dcb_dcb,
3304 (void *)&cmd_config_dcb_vt,
3305 (void *)&cmd_config_dcb_vt_en,
3306 (void *)&cmd_config_dcb_num_tcs,
3307 (void *)&cmd_config_dcb_pfc,
3308 (void *)&cmd_config_dcb_pfc_en,
3313 /* *** configure number of packets per burst *** */
3314 struct cmd_config_burst {
3315 cmdline_fixed_string_t port;
3316 cmdline_fixed_string_t keyword;
3317 cmdline_fixed_string_t all;
3318 cmdline_fixed_string_t name;
3323 cmd_config_burst_parsed(void *parsed_result,
3324 __rte_unused struct cmdline *cl,
3325 __rte_unused void *data)
3327 struct cmd_config_burst *res = parsed_result;
3328 struct rte_eth_dev_info dev_info;
3329 uint16_t rec_nb_pkts;
3332 if (!all_ports_stopped()) {
3333 printf("Please stop all ports first\n");
3337 if (!strcmp(res->name, "burst")) {
3338 if (res->value == 0) {
3339 /* If user gives a value of zero, query the PMD for
3340 * its recommended Rx burst size. Testpmd uses a single
3341 * size for all ports, so assume all ports are the same
3342 * NIC model and use the values from Port 0.
3344 ret = eth_dev_info_get_print_err(0, &dev_info);
3348 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3350 if (rec_nb_pkts == 0) {
3351 printf("PMD does not recommend a burst size.\n"
3352 "User provided value must be between"
3353 " 1 and %d\n", MAX_PKT_BURST);
3355 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3356 printf("PMD recommended burst size of %d"
3357 " exceeds maximum value of %d\n",
3358 rec_nb_pkts, MAX_PKT_BURST);
3361 printf("Using PMD-provided burst value of %d\n",
3363 nb_pkt_per_burst = rec_nb_pkts;
3364 } else if (res->value > MAX_PKT_BURST) {
3365 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3368 nb_pkt_per_burst = res->value;
3370 printf("Unknown parameter\n");
3376 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3379 cmdline_parse_token_string_t cmd_config_burst_port =
3380 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3381 cmdline_parse_token_string_t cmd_config_burst_keyword =
3382 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3383 cmdline_parse_token_string_t cmd_config_burst_all =
3384 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3385 cmdline_parse_token_string_t cmd_config_burst_name =
3386 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3387 cmdline_parse_token_num_t cmd_config_burst_value =
3388 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3390 cmdline_parse_inst_t cmd_config_burst = {
3391 .f = cmd_config_burst_parsed,
3393 .help_str = "port config all burst <value>",
3395 (void *)&cmd_config_burst_port,
3396 (void *)&cmd_config_burst_keyword,
3397 (void *)&cmd_config_burst_all,
3398 (void *)&cmd_config_burst_name,
3399 (void *)&cmd_config_burst_value,
3404 /* *** configure rx/tx queues *** */
3405 struct cmd_config_thresh {
3406 cmdline_fixed_string_t port;
3407 cmdline_fixed_string_t keyword;
3408 cmdline_fixed_string_t all;
3409 cmdline_fixed_string_t name;
3414 cmd_config_thresh_parsed(void *parsed_result,
3415 __rte_unused struct cmdline *cl,
3416 __rte_unused void *data)
3418 struct cmd_config_thresh *res = parsed_result;
3420 if (!all_ports_stopped()) {
3421 printf("Please stop all ports first\n");
3425 if (!strcmp(res->name, "txpt"))
3426 tx_pthresh = res->value;
3427 else if(!strcmp(res->name, "txht"))
3428 tx_hthresh = res->value;
3429 else if(!strcmp(res->name, "txwt"))
3430 tx_wthresh = res->value;
3431 else if(!strcmp(res->name, "rxpt"))
3432 rx_pthresh = res->value;
3433 else if(!strcmp(res->name, "rxht"))
3434 rx_hthresh = res->value;
3435 else if(!strcmp(res->name, "rxwt"))
3436 rx_wthresh = res->value;
3438 printf("Unknown parameter\n");
3444 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3447 cmdline_parse_token_string_t cmd_config_thresh_port =
3448 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3449 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3450 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3451 cmdline_parse_token_string_t cmd_config_thresh_all =
3452 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3453 cmdline_parse_token_string_t cmd_config_thresh_name =
3454 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3455 "txpt#txht#txwt#rxpt#rxht#rxwt");
3456 cmdline_parse_token_num_t cmd_config_thresh_value =
3457 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3459 cmdline_parse_inst_t cmd_config_thresh = {
3460 .f = cmd_config_thresh_parsed,
3462 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3464 (void *)&cmd_config_thresh_port,
3465 (void *)&cmd_config_thresh_keyword,
3466 (void *)&cmd_config_thresh_all,
3467 (void *)&cmd_config_thresh_name,
3468 (void *)&cmd_config_thresh_value,
3473 /* *** configure free/rs threshold *** */
3474 struct cmd_config_threshold {
3475 cmdline_fixed_string_t port;
3476 cmdline_fixed_string_t keyword;
3477 cmdline_fixed_string_t all;
3478 cmdline_fixed_string_t name;
3483 cmd_config_threshold_parsed(void *parsed_result,
3484 __rte_unused struct cmdline *cl,
3485 __rte_unused void *data)
3487 struct cmd_config_threshold *res = parsed_result;
3489 if (!all_ports_stopped()) {
3490 printf("Please stop all ports first\n");
3494 if (!strcmp(res->name, "txfreet"))
3495 tx_free_thresh = res->value;
3496 else if (!strcmp(res->name, "txrst"))
3497 tx_rs_thresh = res->value;
3498 else if (!strcmp(res->name, "rxfreet"))
3499 rx_free_thresh = res->value;
3501 printf("Unknown parameter\n");
3507 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3510 cmdline_parse_token_string_t cmd_config_threshold_port =
3511 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3512 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3513 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3515 cmdline_parse_token_string_t cmd_config_threshold_all =
3516 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3517 cmdline_parse_token_string_t cmd_config_threshold_name =
3518 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3519 "txfreet#txrst#rxfreet");
3520 cmdline_parse_token_num_t cmd_config_threshold_value =
3521 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3523 cmdline_parse_inst_t cmd_config_threshold = {
3524 .f = cmd_config_threshold_parsed,
3526 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3528 (void *)&cmd_config_threshold_port,
3529 (void *)&cmd_config_threshold_keyword,
3530 (void *)&cmd_config_threshold_all,
3531 (void *)&cmd_config_threshold_name,
3532 (void *)&cmd_config_threshold_value,
3538 struct cmd_stop_result {
3539 cmdline_fixed_string_t stop;
3542 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3543 __rte_unused struct cmdline *cl,
3544 __rte_unused void *data)
3546 stop_packet_forwarding();
3549 cmdline_parse_token_string_t cmd_stop_stop =
3550 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3552 cmdline_parse_inst_t cmd_stop = {
3553 .f = cmd_stop_parsed,
3555 .help_str = "stop: Stop packet forwarding",
3557 (void *)&cmd_stop_stop,
3562 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3565 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3566 unsigned int *parsed_items, int check_unique_values)
3568 unsigned int nb_item;
3576 * First parse all items in the list and store their value.
3581 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3583 if ((c >= '0') && (c <= '9')) {
3584 value = (unsigned int) (value * 10 + (c - '0'));
3589 printf("character %c is not a decimal digit\n", c);
3593 printf("No valid value before comma\n");
3596 if (nb_item < max_items) {
3597 parsed_items[nb_item] = value;
3603 if (nb_item >= max_items) {
3604 printf("Number of %s = %u > %u (maximum items)\n",
3605 item_name, nb_item + 1, max_items);
3608 parsed_items[nb_item++] = value;
3609 if (! check_unique_values)
3613 * Then, check that all values in the list are differents.
3614 * No optimization here...
3616 for (i = 0; i < nb_item; i++) {
3617 for (j = i + 1; j < nb_item; j++) {
3618 if (parsed_items[j] == parsed_items[i]) {
3619 printf("duplicated %s %u at index %u and %u\n",
3620 item_name, parsed_items[i], i, j);
3628 struct cmd_set_list_result {
3629 cmdline_fixed_string_t cmd_keyword;
3630 cmdline_fixed_string_t list_name;
3631 cmdline_fixed_string_t list_of_items;
3634 static void cmd_set_list_parsed(void *parsed_result,
3635 __rte_unused struct cmdline *cl,
3636 __rte_unused void *data)
3638 struct cmd_set_list_result *res;
3640 unsigned int lcorelist[RTE_MAX_LCORE];
3641 unsigned int portlist[RTE_MAX_ETHPORTS];
3643 unsigned int nb_item;
3645 if (test_done == 0) {
3646 printf("Please stop forwarding first\n");
3650 res = parsed_result;
3651 if (!strcmp(res->list_name, "corelist")) {
3652 nb_item = parse_item_list(res->list_of_items, "core",
3654 parsed_items.lcorelist, 1);
3656 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3661 if (!strcmp(res->list_name, "portlist")) {
3662 nb_item = parse_item_list(res->list_of_items, "port",
3664 parsed_items.portlist, 1);
3666 set_fwd_ports_list(parsed_items.portlist, nb_item);
3672 cmdline_parse_token_string_t cmd_set_list_keyword =
3673 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3675 cmdline_parse_token_string_t cmd_set_list_name =
3676 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3677 "corelist#portlist");
3678 cmdline_parse_token_string_t cmd_set_list_of_items =
3679 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3682 cmdline_parse_inst_t cmd_set_fwd_list = {
3683 .f = cmd_set_list_parsed,
3685 .help_str = "set corelist|portlist <list0[,list1]*>",
3687 (void *)&cmd_set_list_keyword,
3688 (void *)&cmd_set_list_name,
3689 (void *)&cmd_set_list_of_items,
3694 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3696 struct cmd_setmask_result {
3697 cmdline_fixed_string_t set;
3698 cmdline_fixed_string_t mask;
3702 static void cmd_set_mask_parsed(void *parsed_result,
3703 __rte_unused struct cmdline *cl,
3704 __rte_unused void *data)
3706 struct cmd_setmask_result *res = parsed_result;
3708 if (test_done == 0) {
3709 printf("Please stop forwarding first\n");
3712 if (!strcmp(res->mask, "coremask")) {
3713 set_fwd_lcores_mask(res->hexavalue);
3715 } else if (!strcmp(res->mask, "portmask")) {
3716 set_fwd_ports_mask(res->hexavalue);
3721 cmdline_parse_token_string_t cmd_setmask_set =
3722 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3723 cmdline_parse_token_string_t cmd_setmask_mask =
3724 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3725 "coremask#portmask");
3726 cmdline_parse_token_num_t cmd_setmask_value =
3727 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3729 cmdline_parse_inst_t cmd_set_fwd_mask = {
3730 .f = cmd_set_mask_parsed,
3732 .help_str = "set coremask|portmask <hexadecimal value>",
3734 (void *)&cmd_setmask_set,
3735 (void *)&cmd_setmask_mask,
3736 (void *)&cmd_setmask_value,
3742 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3744 struct cmd_set_result {
3745 cmdline_fixed_string_t set;
3746 cmdline_fixed_string_t what;
3750 static void cmd_set_parsed(void *parsed_result,
3751 __rte_unused struct cmdline *cl,
3752 __rte_unused void *data)
3754 struct cmd_set_result *res = parsed_result;
3755 if (!strcmp(res->what, "nbport")) {
3756 set_fwd_ports_number(res->value);
3758 } else if (!strcmp(res->what, "nbcore")) {
3759 set_fwd_lcores_number(res->value);
3761 } else if (!strcmp(res->what, "burst"))
3762 set_nb_pkt_per_burst(res->value);
3763 else if (!strcmp(res->what, "verbose"))
3764 set_verbose_level(res->value);
3767 cmdline_parse_token_string_t cmd_set_set =
3768 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3769 cmdline_parse_token_string_t cmd_set_what =
3770 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3771 "nbport#nbcore#burst#verbose");
3772 cmdline_parse_token_num_t cmd_set_value =
3773 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3775 cmdline_parse_inst_t cmd_set_numbers = {
3776 .f = cmd_set_parsed,
3778 .help_str = "set nbport|nbcore|burst|verbose <value>",
3780 (void *)&cmd_set_set,
3781 (void *)&cmd_set_what,
3782 (void *)&cmd_set_value,
3787 /* *** SET LOG LEVEL CONFIGURATION *** */
3789 struct cmd_set_log_result {
3790 cmdline_fixed_string_t set;
3791 cmdline_fixed_string_t log;
3792 cmdline_fixed_string_t type;
3797 cmd_set_log_parsed(void *parsed_result,
3798 __rte_unused struct cmdline *cl,
3799 __rte_unused void *data)
3801 struct cmd_set_log_result *res;
3804 res = parsed_result;
3805 if (!strcmp(res->type, "global"))
3806 rte_log_set_global_level(res->level);
3808 ret = rte_log_set_level_regexp(res->type, res->level);
3810 printf("Unable to set log level\n");
3814 cmdline_parse_token_string_t cmd_set_log_set =
3815 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3816 cmdline_parse_token_string_t cmd_set_log_log =
3817 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3818 cmdline_parse_token_string_t cmd_set_log_type =
3819 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3820 cmdline_parse_token_num_t cmd_set_log_level =
3821 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3823 cmdline_parse_inst_t cmd_set_log = {
3824 .f = cmd_set_log_parsed,
3826 .help_str = "set log global|<type> <level>",
3828 (void *)&cmd_set_log_set,
3829 (void *)&cmd_set_log_log,
3830 (void *)&cmd_set_log_type,
3831 (void *)&cmd_set_log_level,
3836 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3838 struct cmd_set_txpkts_result {
3839 cmdline_fixed_string_t cmd_keyword;
3840 cmdline_fixed_string_t txpkts;
3841 cmdline_fixed_string_t seg_lengths;
3845 cmd_set_txpkts_parsed(void *parsed_result,
3846 __rte_unused struct cmdline *cl,
3847 __rte_unused void *data)
3849 struct cmd_set_txpkts_result *res;
3850 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3851 unsigned int nb_segs;
3853 res = parsed_result;
3854 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3855 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3857 set_tx_pkt_segments(seg_lengths, nb_segs);
3860 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3861 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3862 cmd_keyword, "set");
3863 cmdline_parse_token_string_t cmd_set_txpkts_name =
3864 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3866 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3867 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3870 cmdline_parse_inst_t cmd_set_txpkts = {
3871 .f = cmd_set_txpkts_parsed,
3873 .help_str = "set txpkts <len0[,len1]*>",
3875 (void *)&cmd_set_txpkts_keyword,
3876 (void *)&cmd_set_txpkts_name,
3877 (void *)&cmd_set_txpkts_lengths,
3882 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3884 struct cmd_set_txsplit_result {
3885 cmdline_fixed_string_t cmd_keyword;
3886 cmdline_fixed_string_t txsplit;
3887 cmdline_fixed_string_t mode;
3891 cmd_set_txsplit_parsed(void *parsed_result,
3892 __rte_unused struct cmdline *cl,
3893 __rte_unused void *data)
3895 struct cmd_set_txsplit_result *res;
3897 res = parsed_result;
3898 set_tx_pkt_split(res->mode);
3901 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3902 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3903 cmd_keyword, "set");
3904 cmdline_parse_token_string_t cmd_set_txsplit_name =
3905 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3906 txsplit, "txsplit");
3907 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3908 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3911 cmdline_parse_inst_t cmd_set_txsplit = {
3912 .f = cmd_set_txsplit_parsed,
3914 .help_str = "set txsplit on|off|rand",
3916 (void *)&cmd_set_txsplit_keyword,
3917 (void *)&cmd_set_txsplit_name,
3918 (void *)&cmd_set_txsplit_mode,
3923 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3924 struct cmd_rx_vlan_filter_all_result {
3925 cmdline_fixed_string_t rx_vlan;
3926 cmdline_fixed_string_t what;
3927 cmdline_fixed_string_t all;
3932 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3933 __rte_unused struct cmdline *cl,
3934 __rte_unused void *data)
3936 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3938 if (!strcmp(res->what, "add"))
3939 rx_vlan_all_filter_set(res->port_id, 1);
3941 rx_vlan_all_filter_set(res->port_id, 0);
3944 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3945 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3946 rx_vlan, "rx_vlan");
3947 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3948 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3950 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3951 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3953 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3954 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3957 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3958 .f = cmd_rx_vlan_filter_all_parsed,
3960 .help_str = "rx_vlan add|rm all <port_id>: "
3961 "Add/Remove all identifiers to/from the set of VLAN "
3962 "identifiers filtered by a port",
3964 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3965 (void *)&cmd_rx_vlan_filter_all_what,
3966 (void *)&cmd_rx_vlan_filter_all_all,
3967 (void *)&cmd_rx_vlan_filter_all_portid,
3972 /* *** VLAN OFFLOAD SET ON A PORT *** */
3973 struct cmd_vlan_offload_result {
3974 cmdline_fixed_string_t vlan;
3975 cmdline_fixed_string_t set;
3976 cmdline_fixed_string_t vlan_type;
3977 cmdline_fixed_string_t what;
3978 cmdline_fixed_string_t on;
3979 cmdline_fixed_string_t port_id;
3983 cmd_vlan_offload_parsed(void *parsed_result,
3984 __rte_unused struct cmdline *cl,
3985 __rte_unused void *data)
3988 struct cmd_vlan_offload_result *res = parsed_result;
3991 portid_t port_id = 0;
3995 len = strnlen(str, STR_TOKEN_SIZE);
3997 /* Get port_id first */
4005 tmp = strtoul(str, NULL, 0);
4006 /* If port_id greater that what portid_t can represent, return */
4007 if(tmp >= RTE_MAX_ETHPORTS)
4009 port_id = (portid_t)tmp;
4011 if (!strcmp(res->on, "on"))
4016 if (!strcmp(res->what, "strip"))
4017 rx_vlan_strip_set(port_id, on);
4018 else if(!strcmp(res->what, "stripq")){
4019 uint16_t queue_id = 0;
4021 /* No queue_id, return */
4023 printf("must specify (port,queue_id)\n");
4026 tmp = strtoul(str + i + 1, NULL, 0);
4027 /* If queue_id greater that what 16-bits can represent, return */
4031 queue_id = (uint16_t)tmp;
4032 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4034 else if (!strcmp(res->what, "filter"))
4035 rx_vlan_filter_set(port_id, on);
4036 else if (!strcmp(res->what, "qinq_strip"))
4037 rx_vlan_qinq_strip_set(port_id, on);
4039 vlan_extend_set(port_id, on);
4044 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4045 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4047 cmdline_parse_token_string_t cmd_vlan_offload_set =
4048 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4050 cmdline_parse_token_string_t cmd_vlan_offload_what =
4051 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4052 what, "strip#filter#qinq_strip#extend#stripq");
4053 cmdline_parse_token_string_t cmd_vlan_offload_on =
4054 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4056 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4057 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4060 cmdline_parse_inst_t cmd_vlan_offload = {
4061 .f = cmd_vlan_offload_parsed,
4063 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4064 "<port_id[,queue_id]>: "
4065 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4067 (void *)&cmd_vlan_offload_vlan,
4068 (void *)&cmd_vlan_offload_set,
4069 (void *)&cmd_vlan_offload_what,
4070 (void *)&cmd_vlan_offload_on,
4071 (void *)&cmd_vlan_offload_portid,
4076 /* *** VLAN TPID SET ON A PORT *** */
4077 struct cmd_vlan_tpid_result {
4078 cmdline_fixed_string_t vlan;
4079 cmdline_fixed_string_t set;
4080 cmdline_fixed_string_t vlan_type;
4081 cmdline_fixed_string_t what;
4087 cmd_vlan_tpid_parsed(void *parsed_result,
4088 __rte_unused struct cmdline *cl,
4089 __rte_unused void *data)
4091 struct cmd_vlan_tpid_result *res = parsed_result;
4092 enum rte_vlan_type vlan_type;
4094 if (!strcmp(res->vlan_type, "inner"))
4095 vlan_type = ETH_VLAN_TYPE_INNER;
4096 else if (!strcmp(res->vlan_type, "outer"))
4097 vlan_type = ETH_VLAN_TYPE_OUTER;
4099 printf("Unknown vlan type\n");
4102 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4105 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4106 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4108 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4109 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4111 cmdline_parse_token_string_t cmd_vlan_type =
4112 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4113 vlan_type, "inner#outer");
4114 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4115 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4117 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4118 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4120 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4121 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4124 cmdline_parse_inst_t cmd_vlan_tpid = {
4125 .f = cmd_vlan_tpid_parsed,
4127 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4128 "Set the VLAN Ether type",
4130 (void *)&cmd_vlan_tpid_vlan,
4131 (void *)&cmd_vlan_tpid_set,
4132 (void *)&cmd_vlan_type,
4133 (void *)&cmd_vlan_tpid_what,
4134 (void *)&cmd_vlan_tpid_tpid,
4135 (void *)&cmd_vlan_tpid_portid,
4140 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4141 struct cmd_rx_vlan_filter_result {
4142 cmdline_fixed_string_t rx_vlan;
4143 cmdline_fixed_string_t what;
4149 cmd_rx_vlan_filter_parsed(void *parsed_result,
4150 __rte_unused struct cmdline *cl,
4151 __rte_unused void *data)
4153 struct cmd_rx_vlan_filter_result *res = parsed_result;
4155 if (!strcmp(res->what, "add"))
4156 rx_vft_set(res->port_id, res->vlan_id, 1);
4158 rx_vft_set(res->port_id, res->vlan_id, 0);
4161 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4162 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4163 rx_vlan, "rx_vlan");
4164 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4165 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4167 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4168 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4170 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4171 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4174 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4175 .f = cmd_rx_vlan_filter_parsed,
4177 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4178 "Add/Remove a VLAN identifier to/from the set of VLAN "
4179 "identifiers filtered by a port",
4181 (void *)&cmd_rx_vlan_filter_rx_vlan,
4182 (void *)&cmd_rx_vlan_filter_what,
4183 (void *)&cmd_rx_vlan_filter_vlanid,
4184 (void *)&cmd_rx_vlan_filter_portid,
4189 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4190 struct cmd_tx_vlan_set_result {
4191 cmdline_fixed_string_t tx_vlan;
4192 cmdline_fixed_string_t set;
4198 cmd_tx_vlan_set_parsed(void *parsed_result,
4199 __rte_unused struct cmdline *cl,
4200 __rte_unused void *data)
4202 struct cmd_tx_vlan_set_result *res = parsed_result;
4204 if (!port_is_stopped(res->port_id)) {
4205 printf("Please stop port %d first\n", res->port_id);
4209 tx_vlan_set(res->port_id, res->vlan_id);
4211 cmd_reconfig_device_queue(res->port_id, 1, 1);
4214 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4215 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4216 tx_vlan, "tx_vlan");
4217 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4218 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4220 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4221 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4223 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4224 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4227 cmdline_parse_inst_t cmd_tx_vlan_set = {
4228 .f = cmd_tx_vlan_set_parsed,
4230 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4231 "Enable hardware insertion of a single VLAN header "
4232 "with a given TAG Identifier in packets sent on a port",
4234 (void *)&cmd_tx_vlan_set_tx_vlan,
4235 (void *)&cmd_tx_vlan_set_set,
4236 (void *)&cmd_tx_vlan_set_portid,
4237 (void *)&cmd_tx_vlan_set_vlanid,
4242 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4243 struct cmd_tx_vlan_set_qinq_result {
4244 cmdline_fixed_string_t tx_vlan;
4245 cmdline_fixed_string_t set;
4248 uint16_t vlan_id_outer;
4252 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4253 __rte_unused struct cmdline *cl,
4254 __rte_unused void *data)
4256 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4258 if (!port_is_stopped(res->port_id)) {
4259 printf("Please stop port %d first\n", res->port_id);
4263 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4265 cmd_reconfig_device_queue(res->port_id, 1, 1);
4268 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4269 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4270 tx_vlan, "tx_vlan");
4271 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4272 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4274 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4275 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4277 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4278 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4280 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4281 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4282 vlan_id_outer, UINT16);
4284 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4285 .f = cmd_tx_vlan_set_qinq_parsed,
4287 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4288 "Enable hardware insertion of double VLAN header "
4289 "with given TAG Identifiers in packets sent on a port",
4291 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4292 (void *)&cmd_tx_vlan_set_qinq_set,
4293 (void *)&cmd_tx_vlan_set_qinq_portid,
4294 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4295 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4300 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4301 struct cmd_tx_vlan_set_pvid_result {
4302 cmdline_fixed_string_t tx_vlan;
4303 cmdline_fixed_string_t set;
4304 cmdline_fixed_string_t pvid;
4307 cmdline_fixed_string_t mode;
4311 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4312 __rte_unused struct cmdline *cl,
4313 __rte_unused void *data)
4315 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4317 if (strcmp(res->mode, "on") == 0)
4318 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4320 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4323 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4324 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4325 tx_vlan, "tx_vlan");
4326 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4327 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4329 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4330 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4332 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4333 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4335 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4336 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4338 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4339 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4342 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4343 .f = cmd_tx_vlan_set_pvid_parsed,
4345 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4347 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4348 (void *)&cmd_tx_vlan_set_pvid_set,
4349 (void *)&cmd_tx_vlan_set_pvid_pvid,
4350 (void *)&cmd_tx_vlan_set_pvid_port_id,
4351 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4352 (void *)&cmd_tx_vlan_set_pvid_mode,
4357 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4358 struct cmd_tx_vlan_reset_result {
4359 cmdline_fixed_string_t tx_vlan;
4360 cmdline_fixed_string_t reset;
4365 cmd_tx_vlan_reset_parsed(void *parsed_result,
4366 __rte_unused struct cmdline *cl,
4367 __rte_unused void *data)
4369 struct cmd_tx_vlan_reset_result *res = parsed_result;
4371 if (!port_is_stopped(res->port_id)) {
4372 printf("Please stop port %d first\n", res->port_id);
4376 tx_vlan_reset(res->port_id);
4378 cmd_reconfig_device_queue(res->port_id, 1, 1);
4381 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4382 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4383 tx_vlan, "tx_vlan");
4384 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4385 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4387 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4388 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4391 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4392 .f = cmd_tx_vlan_reset_parsed,
4394 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4395 "VLAN header in packets sent on a port",
4397 (void *)&cmd_tx_vlan_reset_tx_vlan,
4398 (void *)&cmd_tx_vlan_reset_reset,
4399 (void *)&cmd_tx_vlan_reset_portid,
4405 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4406 struct cmd_csum_result {
4407 cmdline_fixed_string_t csum;
4408 cmdline_fixed_string_t mode;
4409 cmdline_fixed_string_t proto;
4410 cmdline_fixed_string_t hwsw;
4415 csum_show(int port_id)
4417 struct rte_eth_dev_info dev_info;
4418 uint64_t tx_offloads;
4421 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4422 printf("Parse tunnel is %s\n",
4423 (ports[port_id].parse_tunnel) ? "on" : "off");
4424 printf("IP checksum offload is %s\n",
4425 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4426 printf("UDP checksum offload is %s\n",
4427 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4428 printf("TCP checksum offload is %s\n",
4429 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4430 printf("SCTP checksum offload is %s\n",
4431 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4432 printf("Outer-Ip checksum offload is %s\n",
4433 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4434 printf("Outer-Udp checksum offload is %s\n",
4435 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4437 /* display warnings if configuration is not supported by the NIC */
4438 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4442 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4443 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4444 printf("Warning: hardware IP checksum enabled but not "
4445 "supported by port %d\n", port_id);
4447 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4448 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4449 printf("Warning: hardware UDP checksum enabled but not "
4450 "supported by port %d\n", port_id);
4452 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4453 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4454 printf("Warning: hardware TCP checksum enabled but not "
4455 "supported by port %d\n", port_id);
4457 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4458 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4459 printf("Warning: hardware SCTP checksum enabled but not "
4460 "supported by port %d\n", port_id);
4462 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4463 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4464 printf("Warning: hardware outer IP checksum enabled but not "
4465 "supported by port %d\n", port_id);
4467 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4468 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4470 printf("Warning: hardware outer UDP checksum enabled but not "
4471 "supported by port %d\n", port_id);
4476 cmd_config_queue_tx_offloads(struct rte_port *port)
4480 /* Apply queue tx offloads configuration */
4481 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4482 port->tx_conf[k].offloads =
4483 port->dev_conf.txmode.offloads;
4487 cmd_csum_parsed(void *parsed_result,
4488 __rte_unused struct cmdline *cl,
4489 __rte_unused void *data)
4491 struct cmd_csum_result *res = parsed_result;
4493 uint64_t csum_offloads = 0;
4494 struct rte_eth_dev_info dev_info;
4497 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4498 printf("invalid port %d\n", res->port_id);
4501 if (!port_is_stopped(res->port_id)) {
4502 printf("Please stop port %d first\n", res->port_id);
4506 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4510 if (!strcmp(res->mode, "set")) {
4512 if (!strcmp(res->hwsw, "hw"))
4515 if (!strcmp(res->proto, "ip")) {
4516 if (hw == 0 || (dev_info.tx_offload_capa &
4517 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4518 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4520 printf("IP checksum offload is not supported "
4521 "by port %u\n", res->port_id);
4523 } else if (!strcmp(res->proto, "udp")) {
4524 if (hw == 0 || (dev_info.tx_offload_capa &
4525 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4526 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4528 printf("UDP checksum offload is not supported "
4529 "by port %u\n", res->port_id);
4531 } else if (!strcmp(res->proto, "tcp")) {
4532 if (hw == 0 || (dev_info.tx_offload_capa &
4533 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4534 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4536 printf("TCP checksum offload is not supported "
4537 "by port %u\n", res->port_id);
4539 } else if (!strcmp(res->proto, "sctp")) {
4540 if (hw == 0 || (dev_info.tx_offload_capa &
4541 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4542 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4544 printf("SCTP checksum offload is not supported "
4545 "by port %u\n", res->port_id);
4547 } else if (!strcmp(res->proto, "outer-ip")) {
4548 if (hw == 0 || (dev_info.tx_offload_capa &
4549 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4551 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4553 printf("Outer IP checksum offload is not "
4554 "supported by port %u\n", res->port_id);
4556 } else if (!strcmp(res->proto, "outer-udp")) {
4557 if (hw == 0 || (dev_info.tx_offload_capa &
4558 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4560 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4562 printf("Outer UDP checksum offload is not "
4563 "supported by port %u\n", res->port_id);
4568 ports[res->port_id].dev_conf.txmode.offloads |=
4571 ports[res->port_id].dev_conf.txmode.offloads &=
4574 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4576 csum_show(res->port_id);
4578 cmd_reconfig_device_queue(res->port_id, 1, 1);
4581 cmdline_parse_token_string_t cmd_csum_csum =
4582 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4584 cmdline_parse_token_string_t cmd_csum_mode =
4585 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4587 cmdline_parse_token_string_t cmd_csum_proto =
4588 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4589 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4590 cmdline_parse_token_string_t cmd_csum_hwsw =
4591 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4593 cmdline_parse_token_num_t cmd_csum_portid =
4594 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4597 cmdline_parse_inst_t cmd_csum_set = {
4598 .f = cmd_csum_parsed,
4600 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4601 "Enable/Disable hardware calculation of L3/L4 checksum when "
4602 "using csum forward engine",
4604 (void *)&cmd_csum_csum,
4605 (void *)&cmd_csum_mode,
4606 (void *)&cmd_csum_proto,
4607 (void *)&cmd_csum_hwsw,
4608 (void *)&cmd_csum_portid,
4613 cmdline_parse_token_string_t cmd_csum_mode_show =
4614 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4617 cmdline_parse_inst_t cmd_csum_show = {
4618 .f = cmd_csum_parsed,
4620 .help_str = "csum show <port_id>: Show checksum offload configuration",
4622 (void *)&cmd_csum_csum,
4623 (void *)&cmd_csum_mode_show,
4624 (void *)&cmd_csum_portid,
4629 /* Enable/disable tunnel parsing */
4630 struct cmd_csum_tunnel_result {
4631 cmdline_fixed_string_t csum;
4632 cmdline_fixed_string_t parse;
4633 cmdline_fixed_string_t onoff;
4638 cmd_csum_tunnel_parsed(void *parsed_result,
4639 __rte_unused struct cmdline *cl,
4640 __rte_unused void *data)
4642 struct cmd_csum_tunnel_result *res = parsed_result;
4644 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4647 if (!strcmp(res->onoff, "on"))
4648 ports[res->port_id].parse_tunnel = 1;
4650 ports[res->port_id].parse_tunnel = 0;
4652 csum_show(res->port_id);
4655 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4656 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4658 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4659 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4660 parse, "parse-tunnel");
4661 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4662 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4664 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4665 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4668 cmdline_parse_inst_t cmd_csum_tunnel = {
4669 .f = cmd_csum_tunnel_parsed,
4671 .help_str = "csum parse-tunnel on|off <port_id>: "
4672 "Enable/Disable parsing of tunnels for csum engine",
4674 (void *)&cmd_csum_tunnel_csum,
4675 (void *)&cmd_csum_tunnel_parse,
4676 (void *)&cmd_csum_tunnel_onoff,
4677 (void *)&cmd_csum_tunnel_portid,
4682 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4683 struct cmd_tso_set_result {
4684 cmdline_fixed_string_t tso;
4685 cmdline_fixed_string_t mode;
4691 cmd_tso_set_parsed(void *parsed_result,
4692 __rte_unused struct cmdline *cl,
4693 __rte_unused void *data)
4695 struct cmd_tso_set_result *res = parsed_result;
4696 struct rte_eth_dev_info dev_info;
4699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4701 if (!port_is_stopped(res->port_id)) {
4702 printf("Please stop port %d first\n", res->port_id);
4706 if (!strcmp(res->mode, "set"))
4707 ports[res->port_id].tso_segsz = res->tso_segsz;
4709 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4713 if ((ports[res->port_id].tso_segsz != 0) &&
4714 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4715 printf("Error: TSO is not supported by port %d\n",
4720 if (ports[res->port_id].tso_segsz == 0) {
4721 ports[res->port_id].dev_conf.txmode.offloads &=
4722 ~DEV_TX_OFFLOAD_TCP_TSO;
4723 printf("TSO for non-tunneled packets is disabled\n");
4725 ports[res->port_id].dev_conf.txmode.offloads |=
4726 DEV_TX_OFFLOAD_TCP_TSO;
4727 printf("TSO segment size for non-tunneled packets is %d\n",
4728 ports[res->port_id].tso_segsz);
4730 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4732 /* display warnings if configuration is not supported by the NIC */
4733 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4737 if ((ports[res->port_id].tso_segsz != 0) &&
4738 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4739 printf("Warning: TSO enabled but not "
4740 "supported by port %d\n", res->port_id);
4743 cmd_reconfig_device_queue(res->port_id, 1, 1);
4746 cmdline_parse_token_string_t cmd_tso_set_tso =
4747 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4749 cmdline_parse_token_string_t cmd_tso_set_mode =
4750 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4752 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4753 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4755 cmdline_parse_token_num_t cmd_tso_set_portid =
4756 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4759 cmdline_parse_inst_t cmd_tso_set = {
4760 .f = cmd_tso_set_parsed,
4762 .help_str = "tso set <tso_segsz> <port_id>: "
4763 "Set TSO segment size of non-tunneled packets for csum engine "
4766 (void *)&cmd_tso_set_tso,
4767 (void *)&cmd_tso_set_mode,
4768 (void *)&cmd_tso_set_tso_segsz,
4769 (void *)&cmd_tso_set_portid,
4774 cmdline_parse_token_string_t cmd_tso_show_mode =
4775 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4779 cmdline_parse_inst_t cmd_tso_show = {
4780 .f = cmd_tso_set_parsed,
4782 .help_str = "tso show <port_id>: "
4783 "Show TSO segment size of non-tunneled packets for csum engine",
4785 (void *)&cmd_tso_set_tso,
4786 (void *)&cmd_tso_show_mode,
4787 (void *)&cmd_tso_set_portid,
4792 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4793 struct cmd_tunnel_tso_set_result {
4794 cmdline_fixed_string_t tso;
4795 cmdline_fixed_string_t mode;
4800 static struct rte_eth_dev_info
4801 check_tunnel_tso_nic_support(portid_t port_id)
4803 struct rte_eth_dev_info dev_info;
4805 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4808 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4809 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4810 "not enabled for port %d\n", port_id);
4811 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4812 printf("Warning: GRE TUNNEL TSO not supported therefore "
4813 "not enabled for port %d\n", port_id);
4814 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4815 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4816 "not enabled for port %d\n", port_id);
4817 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4818 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4819 "not enabled for port %d\n", port_id);
4820 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4821 printf("Warning: IP TUNNEL TSO not supported therefore "
4822 "not enabled for port %d\n", port_id);
4823 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4824 printf("Warning: UDP TUNNEL TSO not supported therefore "
4825 "not enabled for port %d\n", port_id);
4830 cmd_tunnel_tso_set_parsed(void *parsed_result,
4831 __rte_unused struct cmdline *cl,
4832 __rte_unused void *data)
4834 struct cmd_tunnel_tso_set_result *res = parsed_result;
4835 struct rte_eth_dev_info dev_info;
4837 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4839 if (!port_is_stopped(res->port_id)) {
4840 printf("Please stop port %d first\n", res->port_id);
4844 if (!strcmp(res->mode, "set"))
4845 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4847 dev_info = check_tunnel_tso_nic_support(res->port_id);
4848 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4849 ports[res->port_id].dev_conf.txmode.offloads &=
4850 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4851 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4852 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4853 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4854 DEV_TX_OFFLOAD_IP_TNL_TSO |
4855 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4856 printf("TSO for tunneled packets is disabled\n");
4858 uint64_t tso_offloads = (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);
4865 ports[res->port_id].dev_conf.txmode.offloads |=
4866 (tso_offloads & dev_info.tx_offload_capa);
4867 printf("TSO segment size for tunneled packets is %d\n",
4868 ports[res->port_id].tunnel_tso_segsz);
4870 /* Below conditions are needed to make it work:
4871 * (1) tunnel TSO is supported by the NIC;
4872 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4874 * (3) for tunneled pkts with outer L3 of IPv4,
4875 * "csum set outer-ip" must be set to hw, because after tso,
4876 * total_len of outer IP header is changed, and the checksum
4877 * of outer IP header calculated by sw should be wrong; that
4878 * is not necessary for IPv6 tunneled pkts because there's no
4879 * checksum in IP header anymore.
4882 if (!ports[res->port_id].parse_tunnel)
4883 printf("Warning: csum parse_tunnel must be set "
4884 "so that tunneled packets are recognized\n");
4885 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4886 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4887 printf("Warning: csum set outer-ip must be set to hw "
4888 "if outer L3 is IPv4; not necessary for IPv6\n");
4891 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4892 cmd_reconfig_device_queue(res->port_id, 1, 1);
4895 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4896 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4898 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4899 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4901 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4902 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4904 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4905 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4908 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4909 .f = cmd_tunnel_tso_set_parsed,
4911 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4912 "Set TSO segment size of tunneled packets for csum engine "
4915 (void *)&cmd_tunnel_tso_set_tso,
4916 (void *)&cmd_tunnel_tso_set_mode,
4917 (void *)&cmd_tunnel_tso_set_tso_segsz,
4918 (void *)&cmd_tunnel_tso_set_portid,
4923 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4924 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4928 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4929 .f = cmd_tunnel_tso_set_parsed,
4931 .help_str = "tunnel_tso show <port_id> "
4932 "Show TSO segment size of tunneled packets for csum engine",
4934 (void *)&cmd_tunnel_tso_set_tso,
4935 (void *)&cmd_tunnel_tso_show_mode,
4936 (void *)&cmd_tunnel_tso_set_portid,
4941 /* *** SET GRO FOR A PORT *** */
4942 struct cmd_gro_enable_result {
4943 cmdline_fixed_string_t cmd_set;
4944 cmdline_fixed_string_t cmd_port;
4945 cmdline_fixed_string_t cmd_keyword;
4946 cmdline_fixed_string_t cmd_onoff;
4951 cmd_gro_enable_parsed(void *parsed_result,
4952 __rte_unused struct cmdline *cl,
4953 __rte_unused void *data)
4955 struct cmd_gro_enable_result *res;
4957 res = parsed_result;
4958 if (!strcmp(res->cmd_keyword, "gro"))
4959 setup_gro(res->cmd_onoff, res->cmd_pid);
4962 cmdline_parse_token_string_t cmd_gro_enable_set =
4963 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4965 cmdline_parse_token_string_t cmd_gro_enable_port =
4966 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4967 cmd_keyword, "port");
4968 cmdline_parse_token_num_t cmd_gro_enable_pid =
4969 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4971 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4972 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4973 cmd_keyword, "gro");
4974 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4975 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4976 cmd_onoff, "on#off");
4978 cmdline_parse_inst_t cmd_gro_enable = {
4979 .f = cmd_gro_enable_parsed,
4981 .help_str = "set port <port_id> gro on|off",
4983 (void *)&cmd_gro_enable_set,
4984 (void *)&cmd_gro_enable_port,
4985 (void *)&cmd_gro_enable_pid,
4986 (void *)&cmd_gro_enable_keyword,
4987 (void *)&cmd_gro_enable_onoff,
4992 /* *** DISPLAY GRO CONFIGURATION *** */
4993 struct cmd_gro_show_result {
4994 cmdline_fixed_string_t cmd_show;
4995 cmdline_fixed_string_t cmd_port;
4996 cmdline_fixed_string_t cmd_keyword;
5001 cmd_gro_show_parsed(void *parsed_result,
5002 __rte_unused struct cmdline *cl,
5003 __rte_unused void *data)
5005 struct cmd_gro_show_result *res;
5007 res = parsed_result;
5008 if (!strcmp(res->cmd_keyword, "gro"))
5009 show_gro(res->cmd_pid);
5012 cmdline_parse_token_string_t cmd_gro_show_show =
5013 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5015 cmdline_parse_token_string_t cmd_gro_show_port =
5016 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5018 cmdline_parse_token_num_t cmd_gro_show_pid =
5019 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5021 cmdline_parse_token_string_t cmd_gro_show_keyword =
5022 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5023 cmd_keyword, "gro");
5025 cmdline_parse_inst_t cmd_gro_show = {
5026 .f = cmd_gro_show_parsed,
5028 .help_str = "show port <port_id> gro",
5030 (void *)&cmd_gro_show_show,
5031 (void *)&cmd_gro_show_port,
5032 (void *)&cmd_gro_show_pid,
5033 (void *)&cmd_gro_show_keyword,
5038 /* *** SET FLUSH CYCLES FOR GRO *** */
5039 struct cmd_gro_flush_result {
5040 cmdline_fixed_string_t cmd_set;
5041 cmdline_fixed_string_t cmd_keyword;
5042 cmdline_fixed_string_t cmd_flush;
5047 cmd_gro_flush_parsed(void *parsed_result,
5048 __rte_unused struct cmdline *cl,
5049 __rte_unused void *data)
5051 struct cmd_gro_flush_result *res;
5053 res = parsed_result;
5054 if ((!strcmp(res->cmd_keyword, "gro")) &&
5055 (!strcmp(res->cmd_flush, "flush")))
5056 setup_gro_flush_cycles(res->cmd_cycles);
5059 cmdline_parse_token_string_t cmd_gro_flush_set =
5060 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5062 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5063 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5064 cmd_keyword, "gro");
5065 cmdline_parse_token_string_t cmd_gro_flush_flush =
5066 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5067 cmd_flush, "flush");
5068 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5069 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5072 cmdline_parse_inst_t cmd_gro_flush = {
5073 .f = cmd_gro_flush_parsed,
5075 .help_str = "set gro flush <cycles>",
5077 (void *)&cmd_gro_flush_set,
5078 (void *)&cmd_gro_flush_keyword,
5079 (void *)&cmd_gro_flush_flush,
5080 (void *)&cmd_gro_flush_cycles,
5085 /* *** ENABLE/DISABLE GSO *** */
5086 struct cmd_gso_enable_result {
5087 cmdline_fixed_string_t cmd_set;
5088 cmdline_fixed_string_t cmd_port;
5089 cmdline_fixed_string_t cmd_keyword;
5090 cmdline_fixed_string_t cmd_mode;
5095 cmd_gso_enable_parsed(void *parsed_result,
5096 __rte_unused struct cmdline *cl,
5097 __rte_unused void *data)
5099 struct cmd_gso_enable_result *res;
5101 res = parsed_result;
5102 if (!strcmp(res->cmd_keyword, "gso"))
5103 setup_gso(res->cmd_mode, res->cmd_pid);
5106 cmdline_parse_token_string_t cmd_gso_enable_set =
5107 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5109 cmdline_parse_token_string_t cmd_gso_enable_port =
5110 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5112 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5113 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5114 cmd_keyword, "gso");
5115 cmdline_parse_token_string_t cmd_gso_enable_mode =
5116 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5117 cmd_mode, "on#off");
5118 cmdline_parse_token_num_t cmd_gso_enable_pid =
5119 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5122 cmdline_parse_inst_t cmd_gso_enable = {
5123 .f = cmd_gso_enable_parsed,
5125 .help_str = "set port <port_id> gso on|off",
5127 (void *)&cmd_gso_enable_set,
5128 (void *)&cmd_gso_enable_port,
5129 (void *)&cmd_gso_enable_pid,
5130 (void *)&cmd_gso_enable_keyword,
5131 (void *)&cmd_gso_enable_mode,
5136 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5137 struct cmd_gso_size_result {
5138 cmdline_fixed_string_t cmd_set;
5139 cmdline_fixed_string_t cmd_keyword;
5140 cmdline_fixed_string_t cmd_segsz;
5145 cmd_gso_size_parsed(void *parsed_result,
5146 __rte_unused struct cmdline *cl,
5147 __rte_unused void *data)
5149 struct cmd_gso_size_result *res = parsed_result;
5151 if (test_done == 0) {
5152 printf("Before setting GSO segsz, please first"
5153 " stop fowarding\n");
5157 if (!strcmp(res->cmd_keyword, "gso") &&
5158 !strcmp(res->cmd_segsz, "segsz")) {
5159 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5160 printf("gso_size should be larger than %zu."
5161 " Please input a legal value\n",
5162 RTE_GSO_SEG_SIZE_MIN);
5164 gso_max_segment_size = res->cmd_size;
5168 cmdline_parse_token_string_t cmd_gso_size_set =
5169 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5171 cmdline_parse_token_string_t cmd_gso_size_keyword =
5172 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5173 cmd_keyword, "gso");
5174 cmdline_parse_token_string_t cmd_gso_size_segsz =
5175 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5176 cmd_segsz, "segsz");
5177 cmdline_parse_token_num_t cmd_gso_size_size =
5178 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5181 cmdline_parse_inst_t cmd_gso_size = {
5182 .f = cmd_gso_size_parsed,
5184 .help_str = "set gso segsz <length>",
5186 (void *)&cmd_gso_size_set,
5187 (void *)&cmd_gso_size_keyword,
5188 (void *)&cmd_gso_size_segsz,
5189 (void *)&cmd_gso_size_size,
5194 /* *** SHOW GSO CONFIGURATION *** */
5195 struct cmd_gso_show_result {
5196 cmdline_fixed_string_t cmd_show;
5197 cmdline_fixed_string_t cmd_port;
5198 cmdline_fixed_string_t cmd_keyword;
5203 cmd_gso_show_parsed(void *parsed_result,
5204 __rte_unused struct cmdline *cl,
5205 __rte_unused void *data)
5207 struct cmd_gso_show_result *res = parsed_result;
5209 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5210 printf("invalid port id %u\n", res->cmd_pid);
5213 if (!strcmp(res->cmd_keyword, "gso")) {
5214 if (gso_ports[res->cmd_pid].enable) {
5215 printf("Max GSO'd packet size: %uB\n"
5216 "Supported GSO types: TCP/IPv4, "
5217 "UDP/IPv4, VxLAN with inner "
5218 "TCP/IPv4 packet, GRE with inner "
5219 "TCP/IPv4 packet\n",
5220 gso_max_segment_size);
5222 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5226 cmdline_parse_token_string_t cmd_gso_show_show =
5227 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5229 cmdline_parse_token_string_t cmd_gso_show_port =
5230 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5232 cmdline_parse_token_string_t cmd_gso_show_keyword =
5233 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5234 cmd_keyword, "gso");
5235 cmdline_parse_token_num_t cmd_gso_show_pid =
5236 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5239 cmdline_parse_inst_t cmd_gso_show = {
5240 .f = cmd_gso_show_parsed,
5242 .help_str = "show port <port_id> gso",
5244 (void *)&cmd_gso_show_show,
5245 (void *)&cmd_gso_show_port,
5246 (void *)&cmd_gso_show_pid,
5247 (void *)&cmd_gso_show_keyword,
5252 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5253 struct cmd_set_flush_rx {
5254 cmdline_fixed_string_t set;
5255 cmdline_fixed_string_t flush_rx;
5256 cmdline_fixed_string_t mode;
5260 cmd_set_flush_rx_parsed(void *parsed_result,
5261 __rte_unused struct cmdline *cl,
5262 __rte_unused void *data)
5264 struct cmd_set_flush_rx *res = parsed_result;
5265 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5268 cmdline_parse_token_string_t cmd_setflushrx_set =
5269 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5271 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5272 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5273 flush_rx, "flush_rx");
5274 cmdline_parse_token_string_t cmd_setflushrx_mode =
5275 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5279 cmdline_parse_inst_t cmd_set_flush_rx = {
5280 .f = cmd_set_flush_rx_parsed,
5281 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5284 (void *)&cmd_setflushrx_set,
5285 (void *)&cmd_setflushrx_flush_rx,
5286 (void *)&cmd_setflushrx_mode,
5291 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5292 struct cmd_set_link_check {
5293 cmdline_fixed_string_t set;
5294 cmdline_fixed_string_t link_check;
5295 cmdline_fixed_string_t mode;
5299 cmd_set_link_check_parsed(void *parsed_result,
5300 __rte_unused struct cmdline *cl,
5301 __rte_unused void *data)
5303 struct cmd_set_link_check *res = parsed_result;
5304 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5307 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5308 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5310 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5311 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5312 link_check, "link_check");
5313 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5314 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5318 cmdline_parse_inst_t cmd_set_link_check = {
5319 .f = cmd_set_link_check_parsed,
5320 .help_str = "set link_check on|off: Enable/Disable link status check "
5321 "when starting/stopping a port",
5324 (void *)&cmd_setlinkcheck_set,
5325 (void *)&cmd_setlinkcheck_link_check,
5326 (void *)&cmd_setlinkcheck_mode,
5331 /* *** SET NIC BYPASS MODE *** */
5332 struct cmd_set_bypass_mode_result {
5333 cmdline_fixed_string_t set;
5334 cmdline_fixed_string_t bypass;
5335 cmdline_fixed_string_t mode;
5336 cmdline_fixed_string_t value;
5341 cmd_set_bypass_mode_parsed(void *parsed_result,
5342 __rte_unused struct cmdline *cl,
5343 __rte_unused void *data)
5345 struct cmd_set_bypass_mode_result *res = parsed_result;
5346 portid_t port_id = res->port_id;
5347 int32_t rc = -EINVAL;
5349 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5350 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5352 if (!strcmp(res->value, "bypass"))
5353 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5354 else if (!strcmp(res->value, "isolate"))
5355 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5357 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5359 /* Set the bypass mode for the relevant port. */
5360 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5363 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5366 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5367 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5369 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5370 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5372 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5373 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5375 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5376 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5377 value, "normal#bypass#isolate");
5378 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5379 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5382 cmdline_parse_inst_t cmd_set_bypass_mode = {
5383 .f = cmd_set_bypass_mode_parsed,
5384 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5385 "Set the NIC bypass mode for port_id",
5388 (void *)&cmd_setbypass_mode_set,
5389 (void *)&cmd_setbypass_mode_bypass,
5390 (void *)&cmd_setbypass_mode_mode,
5391 (void *)&cmd_setbypass_mode_value,
5392 (void *)&cmd_setbypass_mode_port,
5397 /* *** SET NIC BYPASS EVENT *** */
5398 struct cmd_set_bypass_event_result {
5399 cmdline_fixed_string_t set;
5400 cmdline_fixed_string_t bypass;
5401 cmdline_fixed_string_t event;
5402 cmdline_fixed_string_t event_value;
5403 cmdline_fixed_string_t mode;
5404 cmdline_fixed_string_t mode_value;
5409 cmd_set_bypass_event_parsed(void *parsed_result,
5410 __rte_unused struct cmdline *cl,
5411 __rte_unused void *data)
5413 int32_t rc = -EINVAL;
5414 struct cmd_set_bypass_event_result *res = parsed_result;
5415 portid_t port_id = res->port_id;
5417 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5418 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5419 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5421 if (!strcmp(res->event_value, "timeout"))
5422 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5423 else if (!strcmp(res->event_value, "os_on"))
5424 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5425 else if (!strcmp(res->event_value, "os_off"))
5426 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5427 else if (!strcmp(res->event_value, "power_on"))
5428 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5429 else if (!strcmp(res->event_value, "power_off"))
5430 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5432 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5434 if (!strcmp(res->mode_value, "bypass"))
5435 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5436 else if (!strcmp(res->mode_value, "isolate"))
5437 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5439 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5441 /* Set the watchdog timeout. */
5442 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5445 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5446 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5450 printf("Failed to set timeout value %u "
5451 "for port %d, errto code: %d.\n",
5452 bypass_timeout, port_id, rc);
5456 /* Set the bypass event to transition to bypass mode. */
5457 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5462 printf("\t Failed to set bypass event for port = %d.\n",
5466 cmdline_parse_token_string_t cmd_setbypass_event_set =
5467 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5469 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5470 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5472 cmdline_parse_token_string_t cmd_setbypass_event_event =
5473 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5475 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5476 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5477 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5478 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5479 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5481 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5482 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5483 mode_value, "normal#bypass#isolate");
5484 cmdline_parse_token_num_t cmd_setbypass_event_port =
5485 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5488 cmdline_parse_inst_t cmd_set_bypass_event = {
5489 .f = cmd_set_bypass_event_parsed,
5490 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5491 "power_off mode normal|bypass|isolate <port_id>: "
5492 "Set the NIC bypass event mode for port_id",
5495 (void *)&cmd_setbypass_event_set,
5496 (void *)&cmd_setbypass_event_bypass,
5497 (void *)&cmd_setbypass_event_event,
5498 (void *)&cmd_setbypass_event_event_value,
5499 (void *)&cmd_setbypass_event_mode,
5500 (void *)&cmd_setbypass_event_mode_value,
5501 (void *)&cmd_setbypass_event_port,
5507 /* *** SET NIC BYPASS TIMEOUT *** */
5508 struct cmd_set_bypass_timeout_result {
5509 cmdline_fixed_string_t set;
5510 cmdline_fixed_string_t bypass;
5511 cmdline_fixed_string_t timeout;
5512 cmdline_fixed_string_t value;
5516 cmd_set_bypass_timeout_parsed(void *parsed_result,
5517 __rte_unused struct cmdline *cl,
5518 __rte_unused void *data)
5520 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5522 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5523 if (!strcmp(res->value, "1.5"))
5524 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5525 else if (!strcmp(res->value, "2"))
5526 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5527 else if (!strcmp(res->value, "3"))
5528 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5529 else if (!strcmp(res->value, "4"))
5530 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5531 else if (!strcmp(res->value, "8"))
5532 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5533 else if (!strcmp(res->value, "16"))
5534 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5535 else if (!strcmp(res->value, "32"))
5536 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5538 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5542 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5545 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5548 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5550 timeout, "timeout");
5551 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5553 value, "0#1.5#2#3#4#8#16#32");
5555 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5556 .f = cmd_set_bypass_timeout_parsed,
5557 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5558 "Set the NIC bypass watchdog timeout in seconds",
5561 (void *)&cmd_setbypass_timeout_set,
5562 (void *)&cmd_setbypass_timeout_bypass,
5563 (void *)&cmd_setbypass_timeout_timeout,
5564 (void *)&cmd_setbypass_timeout_value,
5569 /* *** SHOW NIC BYPASS MODE *** */
5570 struct cmd_show_bypass_config_result {
5571 cmdline_fixed_string_t show;
5572 cmdline_fixed_string_t bypass;
5573 cmdline_fixed_string_t config;
5578 cmd_show_bypass_config_parsed(void *parsed_result,
5579 __rte_unused struct cmdline *cl,
5580 __rte_unused void *data)
5582 struct cmd_show_bypass_config_result *res = parsed_result;
5583 portid_t port_id = res->port_id;
5585 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5586 uint32_t event_mode;
5587 uint32_t bypass_mode;
5588 uint32_t timeout = bypass_timeout;
5591 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5592 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5593 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5594 {"UNKNOWN", "normal", "bypass", "isolate"};
5595 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5603 /* Display the bypass mode.*/
5604 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5605 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5609 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5610 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5612 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5615 /* Display the bypass timeout.*/
5616 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5617 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5619 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5621 /* Display the bypass events and associated modes. */
5622 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5624 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5625 printf("\tFailed to get bypass mode for event = %s\n",
5628 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5629 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5631 printf("\tbypass event: %-16s = %s\n", events[i],
5637 printf("\tFailed to get bypass configuration for port = %d\n",
5641 cmdline_parse_token_string_t cmd_showbypass_config_show =
5642 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5644 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5645 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5647 cmdline_parse_token_string_t cmd_showbypass_config_config =
5648 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5650 cmdline_parse_token_num_t cmd_showbypass_config_port =
5651 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5654 cmdline_parse_inst_t cmd_show_bypass_config = {
5655 .f = cmd_show_bypass_config_parsed,
5656 .help_str = "show bypass config <port_id>: "
5657 "Show the NIC bypass config for port_id",
5660 (void *)&cmd_showbypass_config_show,
5661 (void *)&cmd_showbypass_config_bypass,
5662 (void *)&cmd_showbypass_config_config,
5663 (void *)&cmd_showbypass_config_port,
5668 #ifdef RTE_LIBRTE_PMD_BOND
5669 /* *** SET BONDING MODE *** */
5670 struct cmd_set_bonding_mode_result {
5671 cmdline_fixed_string_t set;
5672 cmdline_fixed_string_t bonding;
5673 cmdline_fixed_string_t mode;
5678 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5679 __rte_unused struct cmdline *cl,
5680 __rte_unused void *data)
5682 struct cmd_set_bonding_mode_result *res = parsed_result;
5683 portid_t port_id = res->port_id;
5685 /* Set the bonding mode for the relevant port. */
5686 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5687 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5690 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5691 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5693 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5694 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5695 bonding, "bonding");
5696 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5697 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5699 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5700 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5702 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5703 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5706 cmdline_parse_inst_t cmd_set_bonding_mode = {
5707 .f = cmd_set_bonding_mode_parsed,
5708 .help_str = "set bonding mode <mode_value> <port_id>: "
5709 "Set the bonding mode for port_id",
5712 (void *) &cmd_setbonding_mode_set,
5713 (void *) &cmd_setbonding_mode_bonding,
5714 (void *) &cmd_setbonding_mode_mode,
5715 (void *) &cmd_setbonding_mode_value,
5716 (void *) &cmd_setbonding_mode_port,
5721 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5722 struct cmd_set_bonding_lacp_dedicated_queues_result {
5723 cmdline_fixed_string_t set;
5724 cmdline_fixed_string_t bonding;
5725 cmdline_fixed_string_t lacp;
5726 cmdline_fixed_string_t dedicated_queues;
5728 cmdline_fixed_string_t mode;
5731 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5732 __rte_unused struct cmdline *cl,
5733 __rte_unused void *data)
5735 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5736 portid_t port_id = res->port_id;
5737 struct rte_port *port;
5739 port = &ports[port_id];
5741 /** Check if the port is not started **/
5742 if (port->port_status != RTE_PORT_STOPPED) {
5743 printf("Please stop port %d first\n", port_id);
5747 if (!strcmp(res->mode, "enable")) {
5748 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5749 printf("Dedicate queues for LACP control packets"
5752 printf("Enabling dedicate queues for LACP control "
5753 "packets on port %d failed\n", port_id);
5754 } else if (!strcmp(res->mode, "disable")) {
5755 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5756 printf("Dedicated queues for LACP control packets "
5759 printf("Disabling dedicated queues for LACP control "
5760 "traffic on port %d failed\n", port_id);
5764 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5765 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5767 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5768 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5769 bonding, "bonding");
5770 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5771 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5773 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5774 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5775 dedicated_queues, "dedicated_queues");
5776 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5777 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5779 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5780 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5781 mode, "enable#disable");
5783 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5784 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5785 .help_str = "set bonding lacp dedicated_queues <port_id> "
5787 "Enable/disable dedicated queues for LACP control traffic for port_id",
5790 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5791 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5792 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5793 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5794 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5795 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5800 /* *** SET BALANCE XMIT POLICY *** */
5801 struct cmd_set_bonding_balance_xmit_policy_result {
5802 cmdline_fixed_string_t set;
5803 cmdline_fixed_string_t bonding;
5804 cmdline_fixed_string_t balance_xmit_policy;
5806 cmdline_fixed_string_t policy;
5809 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5810 __rte_unused struct cmdline *cl,
5811 __rte_unused void *data)
5813 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5814 portid_t port_id = res->port_id;
5817 if (!strcmp(res->policy, "l2")) {
5818 policy = BALANCE_XMIT_POLICY_LAYER2;
5819 } else if (!strcmp(res->policy, "l23")) {
5820 policy = BALANCE_XMIT_POLICY_LAYER23;
5821 } else if (!strcmp(res->policy, "l34")) {
5822 policy = BALANCE_XMIT_POLICY_LAYER34;
5824 printf("\t Invalid xmit policy selection");
5828 /* Set the bonding mode for the relevant port. */
5829 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5830 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5835 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5836 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5838 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5839 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5840 bonding, "bonding");
5841 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5842 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5843 balance_xmit_policy, "balance_xmit_policy");
5844 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5845 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5847 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5848 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5849 policy, "l2#l23#l34");
5851 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5852 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5853 .help_str = "set bonding balance_xmit_policy <port_id> "
5855 "Set the bonding balance_xmit_policy for port_id",
5858 (void *)&cmd_setbonding_balance_xmit_policy_set,
5859 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5860 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5861 (void *)&cmd_setbonding_balance_xmit_policy_port,
5862 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5867 /* *** SHOW NIC BONDING CONFIGURATION *** */
5868 struct cmd_show_bonding_config_result {
5869 cmdline_fixed_string_t show;
5870 cmdline_fixed_string_t bonding;
5871 cmdline_fixed_string_t config;
5875 static void cmd_show_bonding_config_parsed(void *parsed_result,
5876 __rte_unused struct cmdline *cl,
5877 __rte_unused void *data)
5879 struct cmd_show_bonding_config_result *res = parsed_result;
5880 int bonding_mode, agg_mode;
5881 portid_t slaves[RTE_MAX_ETHPORTS];
5882 int num_slaves, num_active_slaves;
5885 portid_t port_id = res->port_id;
5887 /* Display the bonding mode.*/
5888 bonding_mode = rte_eth_bond_mode_get(port_id);
5889 if (bonding_mode < 0) {
5890 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5893 printf("\tBonding mode: %d\n", bonding_mode);
5895 if (bonding_mode == BONDING_MODE_BALANCE) {
5896 int balance_xmit_policy;
5898 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5899 if (balance_xmit_policy < 0) {
5900 printf("\tFailed to get balance xmit policy for port = %d\n",
5904 printf("\tBalance Xmit Policy: ");
5906 switch (balance_xmit_policy) {
5907 case BALANCE_XMIT_POLICY_LAYER2:
5908 printf("BALANCE_XMIT_POLICY_LAYER2");
5910 case BALANCE_XMIT_POLICY_LAYER23:
5911 printf("BALANCE_XMIT_POLICY_LAYER23");
5913 case BALANCE_XMIT_POLICY_LAYER34:
5914 printf("BALANCE_XMIT_POLICY_LAYER34");
5921 if (bonding_mode == BONDING_MODE_8023AD) {
5922 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5923 printf("\tIEEE802.3AD Aggregator Mode: ");
5926 printf("bandwidth");
5938 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5940 if (num_slaves < 0) {
5941 printf("\tFailed to get slave list for port = %d\n", port_id);
5944 if (num_slaves > 0) {
5945 printf("\tSlaves (%d): [", num_slaves);
5946 for (i = 0; i < num_slaves - 1; i++)
5947 printf("%d ", slaves[i]);
5949 printf("%d]\n", slaves[num_slaves - 1]);
5951 printf("\tSlaves: []\n");
5955 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5958 if (num_active_slaves < 0) {
5959 printf("\tFailed to get active slave list for port = %d\n", port_id);
5962 if (num_active_slaves > 0) {
5963 printf("\tActive Slaves (%d): [", num_active_slaves);
5964 for (i = 0; i < num_active_slaves - 1; i++)
5965 printf("%d ", slaves[i]);
5967 printf("%d]\n", slaves[num_active_slaves - 1]);
5970 printf("\tActive Slaves: []\n");
5974 primary_id = rte_eth_bond_primary_get(port_id);
5975 if (primary_id < 0) {
5976 printf("\tFailed to get primary slave for port = %d\n", port_id);
5979 printf("\tPrimary: [%d]\n", primary_id);
5983 cmdline_parse_token_string_t cmd_showbonding_config_show =
5984 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5986 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5987 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5988 bonding, "bonding");
5989 cmdline_parse_token_string_t cmd_showbonding_config_config =
5990 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5992 cmdline_parse_token_num_t cmd_showbonding_config_port =
5993 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5996 cmdline_parse_inst_t cmd_show_bonding_config = {
5997 .f = cmd_show_bonding_config_parsed,
5998 .help_str = "show bonding config <port_id>: "
5999 "Show the bonding config for port_id",
6002 (void *)&cmd_showbonding_config_show,
6003 (void *)&cmd_showbonding_config_bonding,
6004 (void *)&cmd_showbonding_config_config,
6005 (void *)&cmd_showbonding_config_port,
6010 /* *** SET BONDING PRIMARY *** */
6011 struct cmd_set_bonding_primary_result {
6012 cmdline_fixed_string_t set;
6013 cmdline_fixed_string_t bonding;
6014 cmdline_fixed_string_t primary;
6019 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6020 __rte_unused struct cmdline *cl,
6021 __rte_unused void *data)
6023 struct cmd_set_bonding_primary_result *res = parsed_result;
6024 portid_t master_port_id = res->port_id;
6025 portid_t slave_port_id = res->slave_id;
6027 /* Set the primary slave for a bonded device. */
6028 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6029 printf("\t Failed to set primary slave for port = %d.\n",
6036 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6037 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6039 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6040 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6041 bonding, "bonding");
6042 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6043 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6044 primary, "primary");
6045 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6046 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6048 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6049 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6052 cmdline_parse_inst_t cmd_set_bonding_primary = {
6053 .f = cmd_set_bonding_primary_parsed,
6054 .help_str = "set bonding primary <slave_id> <port_id>: "
6055 "Set the primary slave for port_id",
6058 (void *)&cmd_setbonding_primary_set,
6059 (void *)&cmd_setbonding_primary_bonding,
6060 (void *)&cmd_setbonding_primary_primary,
6061 (void *)&cmd_setbonding_primary_slave,
6062 (void *)&cmd_setbonding_primary_port,
6067 /* *** ADD SLAVE *** */
6068 struct cmd_add_bonding_slave_result {
6069 cmdline_fixed_string_t add;
6070 cmdline_fixed_string_t bonding;
6071 cmdline_fixed_string_t slave;
6076 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6077 __rte_unused struct cmdline *cl,
6078 __rte_unused void *data)
6080 struct cmd_add_bonding_slave_result *res = parsed_result;
6081 portid_t master_port_id = res->port_id;
6082 portid_t slave_port_id = res->slave_id;
6084 /* add the slave for a bonded device. */
6085 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6086 printf("\t Failed to add slave %d to master port = %d.\n",
6087 slave_port_id, master_port_id);
6091 set_port_slave_flag(slave_port_id);
6094 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6095 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6097 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6098 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6099 bonding, "bonding");
6100 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6101 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6103 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6104 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6106 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6107 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6110 cmdline_parse_inst_t cmd_add_bonding_slave = {
6111 .f = cmd_add_bonding_slave_parsed,
6112 .help_str = "add bonding slave <slave_id> <port_id>: "
6113 "Add a slave device to a bonded device",
6116 (void *)&cmd_addbonding_slave_add,
6117 (void *)&cmd_addbonding_slave_bonding,
6118 (void *)&cmd_addbonding_slave_slave,
6119 (void *)&cmd_addbonding_slave_slaveid,
6120 (void *)&cmd_addbonding_slave_port,
6125 /* *** REMOVE SLAVE *** */
6126 struct cmd_remove_bonding_slave_result {
6127 cmdline_fixed_string_t remove;
6128 cmdline_fixed_string_t bonding;
6129 cmdline_fixed_string_t slave;
6134 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6135 __rte_unused struct cmdline *cl,
6136 __rte_unused void *data)
6138 struct cmd_remove_bonding_slave_result *res = parsed_result;
6139 portid_t master_port_id = res->port_id;
6140 portid_t slave_port_id = res->slave_id;
6142 /* remove the slave from a bonded device. */
6143 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6144 printf("\t Failed to remove slave %d from master port = %d.\n",
6145 slave_port_id, master_port_id);
6149 clear_port_slave_flag(slave_port_id);
6152 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6153 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6155 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6156 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6157 bonding, "bonding");
6158 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6159 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6161 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6162 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6164 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6165 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6168 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6169 .f = cmd_remove_bonding_slave_parsed,
6170 .help_str = "remove bonding slave <slave_id> <port_id>: "
6171 "Remove a slave device from a bonded device",
6174 (void *)&cmd_removebonding_slave_remove,
6175 (void *)&cmd_removebonding_slave_bonding,
6176 (void *)&cmd_removebonding_slave_slave,
6177 (void *)&cmd_removebonding_slave_slaveid,
6178 (void *)&cmd_removebonding_slave_port,
6183 /* *** CREATE BONDED DEVICE *** */
6184 struct cmd_create_bonded_device_result {
6185 cmdline_fixed_string_t create;
6186 cmdline_fixed_string_t bonded;
6187 cmdline_fixed_string_t device;
6192 static int bond_dev_num = 0;
6194 static void cmd_create_bonded_device_parsed(void *parsed_result,
6195 __rte_unused struct cmdline *cl,
6196 __rte_unused void *data)
6198 struct cmd_create_bonded_device_result *res = parsed_result;
6199 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6203 if (test_done == 0) {
6204 printf("Please stop forwarding first\n");
6208 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6211 /* Create a new bonded device. */
6212 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6214 printf("\t Failed to create bonded device.\n");
6217 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6220 /* Update number of ports */
6221 nb_ports = rte_eth_dev_count_avail();
6222 reconfig(port_id, res->socket);
6223 ret = rte_eth_promiscuous_enable(port_id);
6225 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6226 port_id, rte_strerror(-ret));
6228 ports[port_id].need_setup = 0;
6229 ports[port_id].port_status = RTE_PORT_STOPPED;
6234 cmdline_parse_token_string_t cmd_createbonded_device_create =
6235 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6237 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6238 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6240 cmdline_parse_token_string_t cmd_createbonded_device_device =
6241 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6243 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6244 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6246 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6247 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6250 cmdline_parse_inst_t cmd_create_bonded_device = {
6251 .f = cmd_create_bonded_device_parsed,
6252 .help_str = "create bonded device <mode> <socket>: "
6253 "Create a new bonded device with specific bonding mode and socket",
6256 (void *)&cmd_createbonded_device_create,
6257 (void *)&cmd_createbonded_device_bonded,
6258 (void *)&cmd_createbonded_device_device,
6259 (void *)&cmd_createbonded_device_mode,
6260 (void *)&cmd_createbonded_device_socket,
6265 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6266 struct cmd_set_bond_mac_addr_result {
6267 cmdline_fixed_string_t set;
6268 cmdline_fixed_string_t bonding;
6269 cmdline_fixed_string_t mac_addr;
6271 struct rte_ether_addr address;
6274 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6275 __rte_unused struct cmdline *cl,
6276 __rte_unused void *data)
6278 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6281 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6284 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6286 /* check the return value and print it if is < 0 */
6288 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6291 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6292 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6293 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6294 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6296 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6297 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6299 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6300 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6302 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6303 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6305 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6306 .f = cmd_set_bond_mac_addr_parsed,
6308 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6310 (void *)&cmd_set_bond_mac_addr_set,
6311 (void *)&cmd_set_bond_mac_addr_bonding,
6312 (void *)&cmd_set_bond_mac_addr_mac,
6313 (void *)&cmd_set_bond_mac_addr_portnum,
6314 (void *)&cmd_set_bond_mac_addr_addr,
6320 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6321 struct cmd_set_bond_mon_period_result {
6322 cmdline_fixed_string_t set;
6323 cmdline_fixed_string_t bonding;
6324 cmdline_fixed_string_t mon_period;
6329 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6330 __rte_unused struct cmdline *cl,
6331 __rte_unused void *data)
6333 struct cmd_set_bond_mon_period_result *res = parsed_result;
6336 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6338 /* check the return value and print it if is < 0 */
6340 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6343 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6344 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6346 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6347 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6348 bonding, "bonding");
6349 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6350 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6351 mon_period, "mon_period");
6352 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6353 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6355 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6356 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6359 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6360 .f = cmd_set_bond_mon_period_parsed,
6362 .help_str = "set bonding mon_period <port_id> <period_ms>",
6364 (void *)&cmd_set_bond_mon_period_set,
6365 (void *)&cmd_set_bond_mon_period_bonding,
6366 (void *)&cmd_set_bond_mon_period_mon_period,
6367 (void *)&cmd_set_bond_mon_period_portnum,
6368 (void *)&cmd_set_bond_mon_period_period_ms,
6375 struct cmd_set_bonding_agg_mode_policy_result {
6376 cmdline_fixed_string_t set;
6377 cmdline_fixed_string_t bonding;
6378 cmdline_fixed_string_t agg_mode;
6380 cmdline_fixed_string_t policy;
6385 cmd_set_bonding_agg_mode(void *parsed_result,
6386 __rte_unused struct cmdline *cl,
6387 __rte_unused void *data)
6389 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6390 uint8_t policy = AGG_BANDWIDTH;
6392 if (!strcmp(res->policy, "bandwidth"))
6393 policy = AGG_BANDWIDTH;
6394 else if (!strcmp(res->policy, "stable"))
6395 policy = AGG_STABLE;
6396 else if (!strcmp(res->policy, "count"))
6399 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6403 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6404 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6406 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6407 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6408 bonding, "bonding");
6410 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6411 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6412 agg_mode, "agg_mode");
6414 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6415 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6418 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6419 TOKEN_STRING_INITIALIZER(
6420 struct cmd_set_bonding_balance_xmit_policy_result,
6421 policy, "stable#bandwidth#count");
6423 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6424 .f = cmd_set_bonding_agg_mode,
6426 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6428 (void *)&cmd_set_bonding_agg_mode_set,
6429 (void *)&cmd_set_bonding_agg_mode_bonding,
6430 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6431 (void *)&cmd_set_bonding_agg_mode_portnum,
6432 (void *)&cmd_set_bonding_agg_mode_policy_string,
6438 #endif /* RTE_LIBRTE_PMD_BOND */
6440 /* *** SET FORWARDING MODE *** */
6441 struct cmd_set_fwd_mode_result {
6442 cmdline_fixed_string_t set;
6443 cmdline_fixed_string_t fwd;
6444 cmdline_fixed_string_t mode;
6447 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6448 __rte_unused struct cmdline *cl,
6449 __rte_unused void *data)
6451 struct cmd_set_fwd_mode_result *res = parsed_result;
6454 set_pkt_forwarding_mode(res->mode);
6457 cmdline_parse_token_string_t cmd_setfwd_set =
6458 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6459 cmdline_parse_token_string_t cmd_setfwd_fwd =
6460 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6461 cmdline_parse_token_string_t cmd_setfwd_mode =
6462 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6463 "" /* defined at init */);
6465 cmdline_parse_inst_t cmd_set_fwd_mode = {
6466 .f = cmd_set_fwd_mode_parsed,
6468 .help_str = NULL, /* defined at init */
6470 (void *)&cmd_setfwd_set,
6471 (void *)&cmd_setfwd_fwd,
6472 (void *)&cmd_setfwd_mode,
6477 static void cmd_set_fwd_mode_init(void)
6480 static char token[128];
6481 static char help[256];
6482 cmdline_parse_token_string_t *token_struct;
6484 modes = list_pkt_forwarding_modes();
6485 snprintf(help, sizeof(help), "set fwd %s: "
6486 "Set packet forwarding mode", modes);
6487 cmd_set_fwd_mode.help_str = help;
6489 /* string token separator is # */
6490 for (c = token; *modes != '\0'; modes++)
6495 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6496 token_struct->string_data.str = token;
6499 /* *** SET RETRY FORWARDING MODE *** */
6500 struct cmd_set_fwd_retry_mode_result {
6501 cmdline_fixed_string_t set;
6502 cmdline_fixed_string_t fwd;
6503 cmdline_fixed_string_t mode;
6504 cmdline_fixed_string_t retry;
6507 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6508 __rte_unused struct cmdline *cl,
6509 __rte_unused void *data)
6511 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6514 set_pkt_forwarding_mode(res->mode);
6517 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6518 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6520 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6521 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6523 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6524 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6526 "" /* defined at init */);
6527 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6528 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6531 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6532 .f = cmd_set_fwd_retry_mode_parsed,
6534 .help_str = NULL, /* defined at init */
6536 (void *)&cmd_setfwd_retry_set,
6537 (void *)&cmd_setfwd_retry_fwd,
6538 (void *)&cmd_setfwd_retry_mode,
6539 (void *)&cmd_setfwd_retry_retry,
6544 static void cmd_set_fwd_retry_mode_init(void)
6547 static char token[128];
6548 static char help[256];
6549 cmdline_parse_token_string_t *token_struct;
6551 modes = list_pkt_forwarding_retry_modes();
6552 snprintf(help, sizeof(help), "set fwd %s retry: "
6553 "Set packet forwarding mode with retry", modes);
6554 cmd_set_fwd_retry_mode.help_str = help;
6556 /* string token separator is # */
6557 for (c = token; *modes != '\0'; modes++)
6562 token_struct = (cmdline_parse_token_string_t *)
6563 cmd_set_fwd_retry_mode.tokens[2];
6564 token_struct->string_data.str = token;
6567 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6568 struct cmd_set_burst_tx_retry_result {
6569 cmdline_fixed_string_t set;
6570 cmdline_fixed_string_t burst;
6571 cmdline_fixed_string_t tx;
6572 cmdline_fixed_string_t delay;
6574 cmdline_fixed_string_t retry;
6578 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6579 __rte_unused struct cmdline *cl,
6580 __rte_unused void *data)
6582 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6584 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6585 && !strcmp(res->tx, "tx")) {
6586 if (!strcmp(res->delay, "delay"))
6587 burst_tx_delay_time = res->time;
6588 if (!strcmp(res->retry, "retry"))
6589 burst_tx_retry_num = res->retry_num;
6594 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6595 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6596 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6597 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6599 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6600 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6601 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6602 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6603 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6604 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6605 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6606 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6607 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6608 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6610 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6611 .f = cmd_set_burst_tx_retry_parsed,
6612 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6614 (void *)&cmd_set_burst_tx_retry_set,
6615 (void *)&cmd_set_burst_tx_retry_burst,
6616 (void *)&cmd_set_burst_tx_retry_tx,
6617 (void *)&cmd_set_burst_tx_retry_delay,
6618 (void *)&cmd_set_burst_tx_retry_time,
6619 (void *)&cmd_set_burst_tx_retry_retry,
6620 (void *)&cmd_set_burst_tx_retry_retry_num,
6625 /* *** SET PROMISC MODE *** */
6626 struct cmd_set_promisc_mode_result {
6627 cmdline_fixed_string_t set;
6628 cmdline_fixed_string_t promisc;
6629 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6630 uint16_t port_num; /* valid if "allports" argument == 0 */
6631 cmdline_fixed_string_t mode;
6634 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6635 __rte_unused struct cmdline *cl,
6638 struct cmd_set_promisc_mode_result *res = parsed_result;
6642 if (!strcmp(res->mode, "on"))
6649 RTE_ETH_FOREACH_DEV(i)
6650 eth_set_promisc_mode(i, enable);
6652 eth_set_promisc_mode(res->port_num, enable);
6656 cmdline_parse_token_string_t cmd_setpromisc_set =
6657 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6658 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6659 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6661 cmdline_parse_token_string_t cmd_setpromisc_portall =
6662 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6664 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6665 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6667 cmdline_parse_token_string_t cmd_setpromisc_mode =
6668 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6671 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6672 .f = cmd_set_promisc_mode_parsed,
6674 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6676 (void *)&cmd_setpromisc_set,
6677 (void *)&cmd_setpromisc_promisc,
6678 (void *)&cmd_setpromisc_portall,
6679 (void *)&cmd_setpromisc_mode,
6684 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6685 .f = cmd_set_promisc_mode_parsed,
6687 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6689 (void *)&cmd_setpromisc_set,
6690 (void *)&cmd_setpromisc_promisc,
6691 (void *)&cmd_setpromisc_portnum,
6692 (void *)&cmd_setpromisc_mode,
6697 /* *** SET ALLMULTI MODE *** */
6698 struct cmd_set_allmulti_mode_result {
6699 cmdline_fixed_string_t set;
6700 cmdline_fixed_string_t allmulti;
6701 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6702 uint16_t port_num; /* valid if "allports" argument == 0 */
6703 cmdline_fixed_string_t mode;
6706 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6707 __rte_unused struct cmdline *cl,
6710 struct cmd_set_allmulti_mode_result *res = parsed_result;
6714 if (!strcmp(res->mode, "on"))
6721 RTE_ETH_FOREACH_DEV(i) {
6722 eth_set_allmulticast_mode(i, enable);
6726 eth_set_allmulticast_mode(res->port_num, enable);
6730 cmdline_parse_token_string_t cmd_setallmulti_set =
6731 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6732 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6733 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6735 cmdline_parse_token_string_t cmd_setallmulti_portall =
6736 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6738 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6739 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6741 cmdline_parse_token_string_t cmd_setallmulti_mode =
6742 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6745 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6746 .f = cmd_set_allmulti_mode_parsed,
6748 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6750 (void *)&cmd_setallmulti_set,
6751 (void *)&cmd_setallmulti_allmulti,
6752 (void *)&cmd_setallmulti_portall,
6753 (void *)&cmd_setallmulti_mode,
6758 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6759 .f = cmd_set_allmulti_mode_parsed,
6761 .help_str = "set allmulti <port_id> on|off: "
6762 "Set allmulti mode on port_id",
6764 (void *)&cmd_setallmulti_set,
6765 (void *)&cmd_setallmulti_allmulti,
6766 (void *)&cmd_setallmulti_portnum,
6767 (void *)&cmd_setallmulti_mode,
6772 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6773 struct cmd_link_flow_ctrl_set_result {
6774 cmdline_fixed_string_t set;
6775 cmdline_fixed_string_t flow_ctrl;
6776 cmdline_fixed_string_t rx;
6777 cmdline_fixed_string_t rx_lfc_mode;
6778 cmdline_fixed_string_t tx;
6779 cmdline_fixed_string_t tx_lfc_mode;
6780 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6781 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6782 cmdline_fixed_string_t autoneg_str;
6783 cmdline_fixed_string_t autoneg;
6784 cmdline_fixed_string_t hw_str;
6785 uint32_t high_water;
6786 cmdline_fixed_string_t lw_str;
6788 cmdline_fixed_string_t pt_str;
6789 uint16_t pause_time;
6790 cmdline_fixed_string_t xon_str;
6795 cmdline_parse_token_string_t cmd_lfc_set_set =
6796 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6798 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6799 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6800 flow_ctrl, "flow_ctrl");
6801 cmdline_parse_token_string_t cmd_lfc_set_rx =
6802 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6804 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6805 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6806 rx_lfc_mode, "on#off");
6807 cmdline_parse_token_string_t cmd_lfc_set_tx =
6808 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6810 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6811 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6812 tx_lfc_mode, "on#off");
6813 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6814 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6815 hw_str, "high_water");
6816 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6817 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6818 high_water, UINT32);
6819 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6820 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6821 lw_str, "low_water");
6822 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6823 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6825 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6826 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6827 pt_str, "pause_time");
6828 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6829 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6830 pause_time, UINT16);
6831 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6832 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6833 xon_str, "send_xon");
6834 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6835 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6837 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6838 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6839 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6840 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6841 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6842 mac_ctrl_frame_fwd_mode, "on#off");
6843 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6844 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6845 autoneg_str, "autoneg");
6846 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6847 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6849 cmdline_parse_token_num_t cmd_lfc_set_portid =
6850 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6853 /* forward declaration */
6855 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6858 cmdline_parse_inst_t cmd_link_flow_control_set = {
6859 .f = cmd_link_flow_ctrl_set_parsed,
6861 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6862 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6863 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6865 (void *)&cmd_lfc_set_set,
6866 (void *)&cmd_lfc_set_flow_ctrl,
6867 (void *)&cmd_lfc_set_rx,
6868 (void *)&cmd_lfc_set_rx_mode,
6869 (void *)&cmd_lfc_set_tx,
6870 (void *)&cmd_lfc_set_tx_mode,
6871 (void *)&cmd_lfc_set_high_water,
6872 (void *)&cmd_lfc_set_low_water,
6873 (void *)&cmd_lfc_set_pause_time,
6874 (void *)&cmd_lfc_set_send_xon,
6875 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6876 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6877 (void *)&cmd_lfc_set_autoneg_str,
6878 (void *)&cmd_lfc_set_autoneg,
6879 (void *)&cmd_lfc_set_portid,
6884 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6885 .f = cmd_link_flow_ctrl_set_parsed,
6886 .data = (void *)&cmd_link_flow_control_set_rx,
6887 .help_str = "set flow_ctrl rx on|off <port_id>: "
6888 "Change rx flow control parameter",
6890 (void *)&cmd_lfc_set_set,
6891 (void *)&cmd_lfc_set_flow_ctrl,
6892 (void *)&cmd_lfc_set_rx,
6893 (void *)&cmd_lfc_set_rx_mode,
6894 (void *)&cmd_lfc_set_portid,
6899 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6900 .f = cmd_link_flow_ctrl_set_parsed,
6901 .data = (void *)&cmd_link_flow_control_set_tx,
6902 .help_str = "set flow_ctrl tx on|off <port_id>: "
6903 "Change tx flow control parameter",
6905 (void *)&cmd_lfc_set_set,
6906 (void *)&cmd_lfc_set_flow_ctrl,
6907 (void *)&cmd_lfc_set_tx,
6908 (void *)&cmd_lfc_set_tx_mode,
6909 (void *)&cmd_lfc_set_portid,
6914 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6915 .f = cmd_link_flow_ctrl_set_parsed,
6916 .data = (void *)&cmd_link_flow_control_set_hw,
6917 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6918 "Change high water flow control parameter",
6920 (void *)&cmd_lfc_set_set,
6921 (void *)&cmd_lfc_set_flow_ctrl,
6922 (void *)&cmd_lfc_set_high_water_str,
6923 (void *)&cmd_lfc_set_high_water,
6924 (void *)&cmd_lfc_set_portid,
6929 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6930 .f = cmd_link_flow_ctrl_set_parsed,
6931 .data = (void *)&cmd_link_flow_control_set_lw,
6932 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6933 "Change low water flow control parameter",
6935 (void *)&cmd_lfc_set_set,
6936 (void *)&cmd_lfc_set_flow_ctrl,
6937 (void *)&cmd_lfc_set_low_water_str,
6938 (void *)&cmd_lfc_set_low_water,
6939 (void *)&cmd_lfc_set_portid,
6944 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6945 .f = cmd_link_flow_ctrl_set_parsed,
6946 .data = (void *)&cmd_link_flow_control_set_pt,
6947 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6948 "Change pause time flow control parameter",
6950 (void *)&cmd_lfc_set_set,
6951 (void *)&cmd_lfc_set_flow_ctrl,
6952 (void *)&cmd_lfc_set_pause_time_str,
6953 (void *)&cmd_lfc_set_pause_time,
6954 (void *)&cmd_lfc_set_portid,
6959 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6960 .f = cmd_link_flow_ctrl_set_parsed,
6961 .data = (void *)&cmd_link_flow_control_set_xon,
6962 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6963 "Change send_xon flow control parameter",
6965 (void *)&cmd_lfc_set_set,
6966 (void *)&cmd_lfc_set_flow_ctrl,
6967 (void *)&cmd_lfc_set_send_xon_str,
6968 (void *)&cmd_lfc_set_send_xon,
6969 (void *)&cmd_lfc_set_portid,
6974 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6975 .f = cmd_link_flow_ctrl_set_parsed,
6976 .data = (void *)&cmd_link_flow_control_set_macfwd,
6977 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6978 "Change mac ctrl fwd flow control parameter",
6980 (void *)&cmd_lfc_set_set,
6981 (void *)&cmd_lfc_set_flow_ctrl,
6982 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6983 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6984 (void *)&cmd_lfc_set_portid,
6989 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6990 .f = cmd_link_flow_ctrl_set_parsed,
6991 .data = (void *)&cmd_link_flow_control_set_autoneg,
6992 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6993 "Change autoneg flow control parameter",
6995 (void *)&cmd_lfc_set_set,
6996 (void *)&cmd_lfc_set_flow_ctrl,
6997 (void *)&cmd_lfc_set_autoneg_str,
6998 (void *)&cmd_lfc_set_autoneg,
6999 (void *)&cmd_lfc_set_portid,
7005 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7006 __rte_unused struct cmdline *cl,
7009 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7010 cmdline_parse_inst_t *cmd = data;
7011 struct rte_eth_fc_conf fc_conf;
7017 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7018 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7019 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7020 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7022 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7023 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7026 /* Partial command line, retrieve current configuration */
7028 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7030 printf("cannot get current flow ctrl parameters, return"
7031 "code = %d\n", ret);
7035 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7036 (fc_conf.mode == RTE_FC_FULL))
7038 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7039 (fc_conf.mode == RTE_FC_FULL))
7043 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7044 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7046 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7047 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7049 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7051 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7052 fc_conf.high_water = res->high_water;
7054 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7055 fc_conf.low_water = res->low_water;
7057 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7058 fc_conf.pause_time = res->pause_time;
7060 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7061 fc_conf.send_xon = res->send_xon;
7063 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7064 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7065 fc_conf.mac_ctrl_frame_fwd = 1;
7067 fc_conf.mac_ctrl_frame_fwd = 0;
7070 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7071 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7073 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7075 printf("bad flow contrl parameter, return code = %d \n", ret);
7078 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7079 struct cmd_priority_flow_ctrl_set_result {
7080 cmdline_fixed_string_t set;
7081 cmdline_fixed_string_t pfc_ctrl;
7082 cmdline_fixed_string_t rx;
7083 cmdline_fixed_string_t rx_pfc_mode;
7084 cmdline_fixed_string_t tx;
7085 cmdline_fixed_string_t tx_pfc_mode;
7086 uint32_t high_water;
7088 uint16_t pause_time;
7094 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7095 __rte_unused struct cmdline *cl,
7096 __rte_unused void *data)
7098 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7099 struct rte_eth_pfc_conf pfc_conf;
7100 int rx_fc_enable, tx_fc_enable;
7104 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7105 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7106 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7107 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7109 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7110 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7113 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7114 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7115 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7116 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7117 pfc_conf.fc.high_water = res->high_water;
7118 pfc_conf.fc.low_water = res->low_water;
7119 pfc_conf.fc.pause_time = res->pause_time;
7120 pfc_conf.priority = res->priority;
7122 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7124 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7127 cmdline_parse_token_string_t cmd_pfc_set_set =
7128 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7130 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7131 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7132 pfc_ctrl, "pfc_ctrl");
7133 cmdline_parse_token_string_t cmd_pfc_set_rx =
7134 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7136 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7137 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7138 rx_pfc_mode, "on#off");
7139 cmdline_parse_token_string_t cmd_pfc_set_tx =
7140 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7142 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7143 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7144 tx_pfc_mode, "on#off");
7145 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7146 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7147 high_water, UINT32);
7148 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7149 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7151 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7152 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7153 pause_time, UINT16);
7154 cmdline_parse_token_num_t cmd_pfc_set_priority =
7155 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7157 cmdline_parse_token_num_t cmd_pfc_set_portid =
7158 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7161 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7162 .f = cmd_priority_flow_ctrl_set_parsed,
7164 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7165 "<pause_time> <priority> <port_id>: "
7166 "Configure the Ethernet priority flow control",
7168 (void *)&cmd_pfc_set_set,
7169 (void *)&cmd_pfc_set_flow_ctrl,
7170 (void *)&cmd_pfc_set_rx,
7171 (void *)&cmd_pfc_set_rx_mode,
7172 (void *)&cmd_pfc_set_tx,
7173 (void *)&cmd_pfc_set_tx_mode,
7174 (void *)&cmd_pfc_set_high_water,
7175 (void *)&cmd_pfc_set_low_water,
7176 (void *)&cmd_pfc_set_pause_time,
7177 (void *)&cmd_pfc_set_priority,
7178 (void *)&cmd_pfc_set_portid,
7183 /* *** RESET CONFIGURATION *** */
7184 struct cmd_reset_result {
7185 cmdline_fixed_string_t reset;
7186 cmdline_fixed_string_t def;
7189 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7191 __rte_unused void *data)
7193 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7194 set_def_fwd_config();
7197 cmdline_parse_token_string_t cmd_reset_set =
7198 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7199 cmdline_parse_token_string_t cmd_reset_def =
7200 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7203 cmdline_parse_inst_t cmd_reset = {
7204 .f = cmd_reset_parsed,
7206 .help_str = "set default: Reset default forwarding configuration",
7208 (void *)&cmd_reset_set,
7209 (void *)&cmd_reset_def,
7214 /* *** START FORWARDING *** */
7215 struct cmd_start_result {
7216 cmdline_fixed_string_t start;
7219 cmdline_parse_token_string_t cmd_start_start =
7220 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7222 static void cmd_start_parsed(__rte_unused void *parsed_result,
7223 __rte_unused struct cmdline *cl,
7224 __rte_unused void *data)
7226 start_packet_forwarding(0);
7229 cmdline_parse_inst_t cmd_start = {
7230 .f = cmd_start_parsed,
7232 .help_str = "start: Start packet forwarding",
7234 (void *)&cmd_start_start,
7239 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7240 struct cmd_start_tx_first_result {
7241 cmdline_fixed_string_t start;
7242 cmdline_fixed_string_t tx_first;
7246 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7247 __rte_unused struct cmdline *cl,
7248 __rte_unused void *data)
7250 start_packet_forwarding(1);
7253 cmdline_parse_token_string_t cmd_start_tx_first_start =
7254 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7256 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7257 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7258 tx_first, "tx_first");
7260 cmdline_parse_inst_t cmd_start_tx_first = {
7261 .f = cmd_start_tx_first_parsed,
7263 .help_str = "start tx_first: Start packet forwarding, "
7264 "after sending 1 burst of packets",
7266 (void *)&cmd_start_tx_first_start,
7267 (void *)&cmd_start_tx_first_tx_first,
7272 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7273 struct cmd_start_tx_first_n_result {
7274 cmdline_fixed_string_t start;
7275 cmdline_fixed_string_t tx_first;
7280 cmd_start_tx_first_n_parsed(void *parsed_result,
7281 __rte_unused struct cmdline *cl,
7282 __rte_unused void *data)
7284 struct cmd_start_tx_first_n_result *res = parsed_result;
7286 start_packet_forwarding(res->tx_num);
7289 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7290 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7292 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7293 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7294 tx_first, "tx_first");
7295 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7296 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7299 cmdline_parse_inst_t cmd_start_tx_first_n = {
7300 .f = cmd_start_tx_first_n_parsed,
7302 .help_str = "start tx_first <num>: "
7303 "packet forwarding, after sending <num> bursts of packets",
7305 (void *)&cmd_start_tx_first_n_start,
7306 (void *)&cmd_start_tx_first_n_tx_first,
7307 (void *)&cmd_start_tx_first_n_tx_num,
7312 /* *** SET LINK UP *** */
7313 struct cmd_set_link_up_result {
7314 cmdline_fixed_string_t set;
7315 cmdline_fixed_string_t link_up;
7316 cmdline_fixed_string_t port;
7320 cmdline_parse_token_string_t cmd_set_link_up_set =
7321 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7322 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7323 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7325 cmdline_parse_token_string_t cmd_set_link_up_port =
7326 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7327 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7328 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7330 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7331 __rte_unused struct cmdline *cl,
7332 __rte_unused void *data)
7334 struct cmd_set_link_up_result *res = parsed_result;
7335 dev_set_link_up(res->port_id);
7338 cmdline_parse_inst_t cmd_set_link_up = {
7339 .f = cmd_set_link_up_parsed,
7341 .help_str = "set link-up port <port id>",
7343 (void *)&cmd_set_link_up_set,
7344 (void *)&cmd_set_link_up_link_up,
7345 (void *)&cmd_set_link_up_port,
7346 (void *)&cmd_set_link_up_port_id,
7351 /* *** SET LINK DOWN *** */
7352 struct cmd_set_link_down_result {
7353 cmdline_fixed_string_t set;
7354 cmdline_fixed_string_t link_down;
7355 cmdline_fixed_string_t port;
7359 cmdline_parse_token_string_t cmd_set_link_down_set =
7360 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7361 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7362 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7364 cmdline_parse_token_string_t cmd_set_link_down_port =
7365 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7366 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7367 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7369 static void cmd_set_link_down_parsed(
7370 __rte_unused void *parsed_result,
7371 __rte_unused struct cmdline *cl,
7372 __rte_unused void *data)
7374 struct cmd_set_link_down_result *res = parsed_result;
7375 dev_set_link_down(res->port_id);
7378 cmdline_parse_inst_t cmd_set_link_down = {
7379 .f = cmd_set_link_down_parsed,
7381 .help_str = "set link-down port <port id>",
7383 (void *)&cmd_set_link_down_set,
7384 (void *)&cmd_set_link_down_link_down,
7385 (void *)&cmd_set_link_down_port,
7386 (void *)&cmd_set_link_down_port_id,
7391 /* *** SHOW CFG *** */
7392 struct cmd_showcfg_result {
7393 cmdline_fixed_string_t show;
7394 cmdline_fixed_string_t cfg;
7395 cmdline_fixed_string_t what;
7398 static void cmd_showcfg_parsed(void *parsed_result,
7399 __rte_unused struct cmdline *cl,
7400 __rte_unused void *data)
7402 struct cmd_showcfg_result *res = parsed_result;
7403 if (!strcmp(res->what, "rxtx"))
7404 rxtx_config_display();
7405 else if (!strcmp(res->what, "cores"))
7406 fwd_lcores_config_display();
7407 else if (!strcmp(res->what, "fwd"))
7408 pkt_fwd_config_display(&cur_fwd_config);
7409 else if (!strcmp(res->what, "txpkts"))
7410 show_tx_pkt_segments();
7413 cmdline_parse_token_string_t cmd_showcfg_show =
7414 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7415 cmdline_parse_token_string_t cmd_showcfg_port =
7416 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7417 cmdline_parse_token_string_t cmd_showcfg_what =
7418 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7419 "rxtx#cores#fwd#txpkts");
7421 cmdline_parse_inst_t cmd_showcfg = {
7422 .f = cmd_showcfg_parsed,
7424 .help_str = "show config rxtx|cores|fwd|txpkts",
7426 (void *)&cmd_showcfg_show,
7427 (void *)&cmd_showcfg_port,
7428 (void *)&cmd_showcfg_what,
7433 /* *** SHOW ALL PORT INFO *** */
7434 struct cmd_showportall_result {
7435 cmdline_fixed_string_t show;
7436 cmdline_fixed_string_t port;
7437 cmdline_fixed_string_t what;
7438 cmdline_fixed_string_t all;
7441 static void cmd_showportall_parsed(void *parsed_result,
7442 __rte_unused struct cmdline *cl,
7443 __rte_unused void *data)
7447 struct cmd_showportall_result *res = parsed_result;
7448 if (!strcmp(res->show, "clear")) {
7449 if (!strcmp(res->what, "stats"))
7450 RTE_ETH_FOREACH_DEV(i)
7452 else if (!strcmp(res->what, "xstats"))
7453 RTE_ETH_FOREACH_DEV(i)
7454 nic_xstats_clear(i);
7455 } else if (!strcmp(res->what, "info"))
7456 RTE_ETH_FOREACH_DEV(i)
7457 port_infos_display(i);
7458 else if (!strcmp(res->what, "summary")) {
7459 port_summary_header_display();
7460 RTE_ETH_FOREACH_DEV(i)
7461 port_summary_display(i);
7463 else if (!strcmp(res->what, "stats"))
7464 RTE_ETH_FOREACH_DEV(i)
7465 nic_stats_display(i);
7466 else if (!strcmp(res->what, "xstats"))
7467 RTE_ETH_FOREACH_DEV(i)
7468 nic_xstats_display(i);
7469 else if (!strcmp(res->what, "fdir"))
7470 RTE_ETH_FOREACH_DEV(i)
7472 else if (!strcmp(res->what, "stat_qmap"))
7473 RTE_ETH_FOREACH_DEV(i)
7474 nic_stats_mapping_display(i);
7475 else if (!strcmp(res->what, "dcb_tc"))
7476 RTE_ETH_FOREACH_DEV(i)
7477 port_dcb_info_display(i);
7478 else if (!strcmp(res->what, "cap"))
7479 RTE_ETH_FOREACH_DEV(i)
7480 port_offload_cap_display(i);
7483 cmdline_parse_token_string_t cmd_showportall_show =
7484 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7486 cmdline_parse_token_string_t cmd_showportall_port =
7487 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7488 cmdline_parse_token_string_t cmd_showportall_what =
7489 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7490 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7491 cmdline_parse_token_string_t cmd_showportall_all =
7492 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7493 cmdline_parse_inst_t cmd_showportall = {
7494 .f = cmd_showportall_parsed,
7496 .help_str = "show|clear port "
7497 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7499 (void *)&cmd_showportall_show,
7500 (void *)&cmd_showportall_port,
7501 (void *)&cmd_showportall_what,
7502 (void *)&cmd_showportall_all,
7507 /* *** SHOW PORT INFO *** */
7508 struct cmd_showport_result {
7509 cmdline_fixed_string_t show;
7510 cmdline_fixed_string_t port;
7511 cmdline_fixed_string_t what;
7515 static void cmd_showport_parsed(void *parsed_result,
7516 __rte_unused struct cmdline *cl,
7517 __rte_unused void *data)
7519 struct cmd_showport_result *res = parsed_result;
7520 if (!strcmp(res->show, "clear")) {
7521 if (!strcmp(res->what, "stats"))
7522 nic_stats_clear(res->portnum);
7523 else if (!strcmp(res->what, "xstats"))
7524 nic_xstats_clear(res->portnum);
7525 } else if (!strcmp(res->what, "info"))
7526 port_infos_display(res->portnum);
7527 else if (!strcmp(res->what, "summary")) {
7528 port_summary_header_display();
7529 port_summary_display(res->portnum);
7531 else if (!strcmp(res->what, "stats"))
7532 nic_stats_display(res->portnum);
7533 else if (!strcmp(res->what, "xstats"))
7534 nic_xstats_display(res->portnum);
7535 else if (!strcmp(res->what, "fdir"))
7536 fdir_get_infos(res->portnum);
7537 else if (!strcmp(res->what, "stat_qmap"))
7538 nic_stats_mapping_display(res->portnum);
7539 else if (!strcmp(res->what, "dcb_tc"))
7540 port_dcb_info_display(res->portnum);
7541 else if (!strcmp(res->what, "cap"))
7542 port_offload_cap_display(res->portnum);
7545 cmdline_parse_token_string_t cmd_showport_show =
7546 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7548 cmdline_parse_token_string_t cmd_showport_port =
7549 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7550 cmdline_parse_token_string_t cmd_showport_what =
7551 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7552 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7553 cmdline_parse_token_num_t cmd_showport_portnum =
7554 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7556 cmdline_parse_inst_t cmd_showport = {
7557 .f = cmd_showport_parsed,
7559 .help_str = "show|clear port "
7560 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7563 (void *)&cmd_showport_show,
7564 (void *)&cmd_showport_port,
7565 (void *)&cmd_showport_what,
7566 (void *)&cmd_showport_portnum,
7571 /* *** SHOW DEVICE INFO *** */
7572 struct cmd_showdevice_result {
7573 cmdline_fixed_string_t show;
7574 cmdline_fixed_string_t device;
7575 cmdline_fixed_string_t what;
7576 cmdline_fixed_string_t identifier;
7579 static void cmd_showdevice_parsed(void *parsed_result,
7580 __rte_unused struct cmdline *cl,
7581 __rte_unused void *data)
7583 struct cmd_showdevice_result *res = parsed_result;
7584 if (!strcmp(res->what, "info")) {
7585 if (!strcmp(res->identifier, "all"))
7586 device_infos_display(NULL);
7588 device_infos_display(res->identifier);
7592 cmdline_parse_token_string_t cmd_showdevice_show =
7593 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7595 cmdline_parse_token_string_t cmd_showdevice_device =
7596 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7597 cmdline_parse_token_string_t cmd_showdevice_what =
7598 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7600 cmdline_parse_token_string_t cmd_showdevice_identifier =
7601 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7604 cmdline_parse_inst_t cmd_showdevice = {
7605 .f = cmd_showdevice_parsed,
7607 .help_str = "show device info <identifier>|all",
7609 (void *)&cmd_showdevice_show,
7610 (void *)&cmd_showdevice_device,
7611 (void *)&cmd_showdevice_what,
7612 (void *)&cmd_showdevice_identifier,
7616 /* *** SHOW QUEUE INFO *** */
7617 struct cmd_showqueue_result {
7618 cmdline_fixed_string_t show;
7619 cmdline_fixed_string_t type;
7620 cmdline_fixed_string_t what;
7626 cmd_showqueue_parsed(void *parsed_result,
7627 __rte_unused struct cmdline *cl,
7628 __rte_unused void *data)
7630 struct cmd_showqueue_result *res = parsed_result;
7632 if (!strcmp(res->type, "rxq"))
7633 rx_queue_infos_display(res->portnum, res->queuenum);
7634 else if (!strcmp(res->type, "txq"))
7635 tx_queue_infos_display(res->portnum, res->queuenum);
7638 cmdline_parse_token_string_t cmd_showqueue_show =
7639 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7640 cmdline_parse_token_string_t cmd_showqueue_type =
7641 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7642 cmdline_parse_token_string_t cmd_showqueue_what =
7643 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7644 cmdline_parse_token_num_t cmd_showqueue_portnum =
7645 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7646 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7647 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7649 cmdline_parse_inst_t cmd_showqueue = {
7650 .f = cmd_showqueue_parsed,
7652 .help_str = "show rxq|txq info <port_id> <queue_id>",
7654 (void *)&cmd_showqueue_show,
7655 (void *)&cmd_showqueue_type,
7656 (void *)&cmd_showqueue_what,
7657 (void *)&cmd_showqueue_portnum,
7658 (void *)&cmd_showqueue_queuenum,
7663 /* show/clear fwd engine statistics */
7665 cmdline_fixed_string_t action;
7666 cmdline_fixed_string_t fwd;
7667 cmdline_fixed_string_t stats;
7668 cmdline_fixed_string_t all;
7671 cmdline_parse_token_string_t cmd_fwd_action =
7672 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7673 cmdline_parse_token_string_t cmd_fwd_fwd =
7674 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7675 cmdline_parse_token_string_t cmd_fwd_stats =
7676 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7677 cmdline_parse_token_string_t cmd_fwd_all =
7678 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7681 cmd_showfwdall_parsed(void *parsed_result,
7682 __rte_unused struct cmdline *cl,
7683 __rte_unused void *data)
7685 struct fwd_result *res = parsed_result;
7687 if (!strcmp(res->action, "show"))
7688 fwd_stats_display();
7693 static cmdline_parse_inst_t cmd_showfwdall = {
7694 .f = cmd_showfwdall_parsed,
7696 .help_str = "show|clear fwd stats all",
7698 (void *)&cmd_fwd_action,
7699 (void *)&cmd_fwd_fwd,
7700 (void *)&cmd_fwd_stats,
7701 (void *)&cmd_fwd_all,
7706 /* *** READ PORT REGISTER *** */
7707 struct cmd_read_reg_result {
7708 cmdline_fixed_string_t read;
7709 cmdline_fixed_string_t reg;
7715 cmd_read_reg_parsed(void *parsed_result,
7716 __rte_unused struct cmdline *cl,
7717 __rte_unused void *data)
7719 struct cmd_read_reg_result *res = parsed_result;
7720 port_reg_display(res->port_id, res->reg_off);
7723 cmdline_parse_token_string_t cmd_read_reg_read =
7724 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7725 cmdline_parse_token_string_t cmd_read_reg_reg =
7726 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7727 cmdline_parse_token_num_t cmd_read_reg_port_id =
7728 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7729 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7730 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7732 cmdline_parse_inst_t cmd_read_reg = {
7733 .f = cmd_read_reg_parsed,
7735 .help_str = "read reg <port_id> <reg_off>",
7737 (void *)&cmd_read_reg_read,
7738 (void *)&cmd_read_reg_reg,
7739 (void *)&cmd_read_reg_port_id,
7740 (void *)&cmd_read_reg_reg_off,
7745 /* *** READ PORT REGISTER BIT FIELD *** */
7746 struct cmd_read_reg_bit_field_result {
7747 cmdline_fixed_string_t read;
7748 cmdline_fixed_string_t regfield;
7756 cmd_read_reg_bit_field_parsed(void *parsed_result,
7757 __rte_unused struct cmdline *cl,
7758 __rte_unused void *data)
7760 struct cmd_read_reg_bit_field_result *res = parsed_result;
7761 port_reg_bit_field_display(res->port_id, res->reg_off,
7762 res->bit1_pos, res->bit2_pos);
7765 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7766 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7768 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7769 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7770 regfield, "regfield");
7771 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7772 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7774 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7775 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7777 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7778 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7780 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7781 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7784 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7785 .f = cmd_read_reg_bit_field_parsed,
7787 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7788 "Read register bit field between bit_x and bit_y included",
7790 (void *)&cmd_read_reg_bit_field_read,
7791 (void *)&cmd_read_reg_bit_field_regfield,
7792 (void *)&cmd_read_reg_bit_field_port_id,
7793 (void *)&cmd_read_reg_bit_field_reg_off,
7794 (void *)&cmd_read_reg_bit_field_bit1_pos,
7795 (void *)&cmd_read_reg_bit_field_bit2_pos,
7800 /* *** READ PORT REGISTER BIT *** */
7801 struct cmd_read_reg_bit_result {
7802 cmdline_fixed_string_t read;
7803 cmdline_fixed_string_t regbit;
7810 cmd_read_reg_bit_parsed(void *parsed_result,
7811 __rte_unused struct cmdline *cl,
7812 __rte_unused void *data)
7814 struct cmd_read_reg_bit_result *res = parsed_result;
7815 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7818 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7819 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7820 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7821 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7823 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7824 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7825 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7826 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7827 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7828 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7830 cmdline_parse_inst_t cmd_read_reg_bit = {
7831 .f = cmd_read_reg_bit_parsed,
7833 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7835 (void *)&cmd_read_reg_bit_read,
7836 (void *)&cmd_read_reg_bit_regbit,
7837 (void *)&cmd_read_reg_bit_port_id,
7838 (void *)&cmd_read_reg_bit_reg_off,
7839 (void *)&cmd_read_reg_bit_bit_pos,
7844 /* *** WRITE PORT REGISTER *** */
7845 struct cmd_write_reg_result {
7846 cmdline_fixed_string_t write;
7847 cmdline_fixed_string_t reg;
7854 cmd_write_reg_parsed(void *parsed_result,
7855 __rte_unused struct cmdline *cl,
7856 __rte_unused void *data)
7858 struct cmd_write_reg_result *res = parsed_result;
7859 port_reg_set(res->port_id, res->reg_off, res->value);
7862 cmdline_parse_token_string_t cmd_write_reg_write =
7863 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7864 cmdline_parse_token_string_t cmd_write_reg_reg =
7865 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7866 cmdline_parse_token_num_t cmd_write_reg_port_id =
7867 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7868 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7869 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7870 cmdline_parse_token_num_t cmd_write_reg_value =
7871 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7873 cmdline_parse_inst_t cmd_write_reg = {
7874 .f = cmd_write_reg_parsed,
7876 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7878 (void *)&cmd_write_reg_write,
7879 (void *)&cmd_write_reg_reg,
7880 (void *)&cmd_write_reg_port_id,
7881 (void *)&cmd_write_reg_reg_off,
7882 (void *)&cmd_write_reg_value,
7887 /* *** WRITE PORT REGISTER BIT FIELD *** */
7888 struct cmd_write_reg_bit_field_result {
7889 cmdline_fixed_string_t write;
7890 cmdline_fixed_string_t regfield;
7899 cmd_write_reg_bit_field_parsed(void *parsed_result,
7900 __rte_unused struct cmdline *cl,
7901 __rte_unused void *data)
7903 struct cmd_write_reg_bit_field_result *res = parsed_result;
7904 port_reg_bit_field_set(res->port_id, res->reg_off,
7905 res->bit1_pos, res->bit2_pos, res->value);
7908 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7909 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7911 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7912 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7913 regfield, "regfield");
7914 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7915 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7917 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7918 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7920 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7921 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7923 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7924 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7926 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7927 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7930 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7931 .f = cmd_write_reg_bit_field_parsed,
7933 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7935 "Set register bit field between bit_x and bit_y included",
7937 (void *)&cmd_write_reg_bit_field_write,
7938 (void *)&cmd_write_reg_bit_field_regfield,
7939 (void *)&cmd_write_reg_bit_field_port_id,
7940 (void *)&cmd_write_reg_bit_field_reg_off,
7941 (void *)&cmd_write_reg_bit_field_bit1_pos,
7942 (void *)&cmd_write_reg_bit_field_bit2_pos,
7943 (void *)&cmd_write_reg_bit_field_value,
7948 /* *** WRITE PORT REGISTER BIT *** */
7949 struct cmd_write_reg_bit_result {
7950 cmdline_fixed_string_t write;
7951 cmdline_fixed_string_t regbit;
7959 cmd_write_reg_bit_parsed(void *parsed_result,
7960 __rte_unused struct cmdline *cl,
7961 __rte_unused void *data)
7963 struct cmd_write_reg_bit_result *res = parsed_result;
7964 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7967 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7968 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7970 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7971 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7973 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7974 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7975 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7976 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7977 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7978 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7979 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7980 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7982 cmdline_parse_inst_t cmd_write_reg_bit = {
7983 .f = cmd_write_reg_bit_parsed,
7985 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7988 (void *)&cmd_write_reg_bit_write,
7989 (void *)&cmd_write_reg_bit_regbit,
7990 (void *)&cmd_write_reg_bit_port_id,
7991 (void *)&cmd_write_reg_bit_reg_off,
7992 (void *)&cmd_write_reg_bit_bit_pos,
7993 (void *)&cmd_write_reg_bit_value,
7998 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7999 struct cmd_read_rxd_txd_result {
8000 cmdline_fixed_string_t read;
8001 cmdline_fixed_string_t rxd_txd;
8008 cmd_read_rxd_txd_parsed(void *parsed_result,
8009 __rte_unused struct cmdline *cl,
8010 __rte_unused void *data)
8012 struct cmd_read_rxd_txd_result *res = parsed_result;
8014 if (!strcmp(res->rxd_txd, "rxd"))
8015 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8016 else if (!strcmp(res->rxd_txd, "txd"))
8017 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8020 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8021 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8022 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8023 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8025 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8026 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8027 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8028 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8029 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8030 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8032 cmdline_parse_inst_t cmd_read_rxd_txd = {
8033 .f = cmd_read_rxd_txd_parsed,
8035 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8037 (void *)&cmd_read_rxd_txd_read,
8038 (void *)&cmd_read_rxd_txd_rxd_txd,
8039 (void *)&cmd_read_rxd_txd_port_id,
8040 (void *)&cmd_read_rxd_txd_queue_id,
8041 (void *)&cmd_read_rxd_txd_desc_id,
8047 struct cmd_quit_result {
8048 cmdline_fixed_string_t quit;
8051 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8053 __rte_unused void *data)
8058 cmdline_parse_token_string_t cmd_quit_quit =
8059 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8061 cmdline_parse_inst_t cmd_quit = {
8062 .f = cmd_quit_parsed,
8064 .help_str = "quit: Exit application",
8066 (void *)&cmd_quit_quit,
8071 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8072 struct cmd_mac_addr_result {
8073 cmdline_fixed_string_t mac_addr_cmd;
8074 cmdline_fixed_string_t what;
8076 struct rte_ether_addr address;
8079 static void cmd_mac_addr_parsed(void *parsed_result,
8080 __rte_unused struct cmdline *cl,
8081 __rte_unused void *data)
8083 struct cmd_mac_addr_result *res = parsed_result;
8086 if (strcmp(res->what, "add") == 0)
8087 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8088 else if (strcmp(res->what, "set") == 0)
8089 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8092 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8094 /* check the return value and print it if is < 0 */
8096 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8100 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8101 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8103 cmdline_parse_token_string_t cmd_mac_addr_what =
8104 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8106 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8107 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8109 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8110 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8112 cmdline_parse_inst_t cmd_mac_addr = {
8113 .f = cmd_mac_addr_parsed,
8115 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8116 "Add/Remove/Set MAC address on port_id",
8118 (void *)&cmd_mac_addr_cmd,
8119 (void *)&cmd_mac_addr_what,
8120 (void *)&cmd_mac_addr_portnum,
8121 (void *)&cmd_mac_addr_addr,
8126 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8127 struct cmd_eth_peer_result {
8128 cmdline_fixed_string_t set;
8129 cmdline_fixed_string_t eth_peer;
8131 cmdline_fixed_string_t peer_addr;
8134 static void cmd_set_eth_peer_parsed(void *parsed_result,
8135 __rte_unused struct cmdline *cl,
8136 __rte_unused void *data)
8138 struct cmd_eth_peer_result *res = parsed_result;
8140 if (test_done == 0) {
8141 printf("Please stop forwarding first\n");
8144 if (!strcmp(res->eth_peer, "eth-peer")) {
8145 set_fwd_eth_peer(res->port_id, res->peer_addr);
8149 cmdline_parse_token_string_t cmd_eth_peer_set =
8150 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8151 cmdline_parse_token_string_t cmd_eth_peer =
8152 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8153 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8154 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8155 cmdline_parse_token_string_t cmd_eth_peer_addr =
8156 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8158 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8159 .f = cmd_set_eth_peer_parsed,
8161 .help_str = "set eth-peer <port_id> <peer_mac>",
8163 (void *)&cmd_eth_peer_set,
8164 (void *)&cmd_eth_peer,
8165 (void *)&cmd_eth_peer_port_id,
8166 (void *)&cmd_eth_peer_addr,
8171 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8172 struct cmd_set_qmap_result {
8173 cmdline_fixed_string_t set;
8174 cmdline_fixed_string_t qmap;
8175 cmdline_fixed_string_t what;
8182 cmd_set_qmap_parsed(void *parsed_result,
8183 __rte_unused struct cmdline *cl,
8184 __rte_unused void *data)
8186 struct cmd_set_qmap_result *res = parsed_result;
8187 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8189 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8192 cmdline_parse_token_string_t cmd_setqmap_set =
8193 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8195 cmdline_parse_token_string_t cmd_setqmap_qmap =
8196 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8198 cmdline_parse_token_string_t cmd_setqmap_what =
8199 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8201 cmdline_parse_token_num_t cmd_setqmap_portid =
8202 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8204 cmdline_parse_token_num_t cmd_setqmap_queueid =
8205 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8207 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8208 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8211 cmdline_parse_inst_t cmd_set_qmap = {
8212 .f = cmd_set_qmap_parsed,
8214 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8215 "Set statistics mapping value on tx|rx queue_id of port_id",
8217 (void *)&cmd_setqmap_set,
8218 (void *)&cmd_setqmap_qmap,
8219 (void *)&cmd_setqmap_what,
8220 (void *)&cmd_setqmap_portid,
8221 (void *)&cmd_setqmap_queueid,
8222 (void *)&cmd_setqmap_mapvalue,
8227 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8228 struct cmd_set_xstats_hide_zero_result {
8229 cmdline_fixed_string_t keyword;
8230 cmdline_fixed_string_t name;
8231 cmdline_fixed_string_t on_off;
8235 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8236 __rte_unused struct cmdline *cl,
8237 __rte_unused void *data)
8239 struct cmd_set_xstats_hide_zero_result *res;
8240 uint16_t on_off = 0;
8242 res = parsed_result;
8243 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8244 set_xstats_hide_zero(on_off);
8247 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8248 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8250 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8251 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8252 name, "xstats-hide-zero");
8253 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8254 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8257 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8258 .f = cmd_set_xstats_hide_zero_parsed,
8260 .help_str = "set xstats-hide-zero on|off",
8262 (void *)&cmd_set_xstats_hide_zero_keyword,
8263 (void *)&cmd_set_xstats_hide_zero_name,
8264 (void *)&cmd_set_xstats_hide_zero_on_off,
8269 /* *** CONFIGURE UNICAST HASH TABLE *** */
8270 struct cmd_set_uc_hash_table {
8271 cmdline_fixed_string_t set;
8272 cmdline_fixed_string_t port;
8274 cmdline_fixed_string_t what;
8275 struct rte_ether_addr address;
8276 cmdline_fixed_string_t mode;
8280 cmd_set_uc_hash_parsed(void *parsed_result,
8281 __rte_unused struct cmdline *cl,
8282 __rte_unused void *data)
8285 struct cmd_set_uc_hash_table *res = parsed_result;
8287 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8289 if (strcmp(res->what, "uta") == 0)
8290 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8291 &res->address,(uint8_t)is_on);
8293 printf("bad unicast hash table parameter, return code = %d \n", ret);
8297 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8298 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8300 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8301 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8303 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8304 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8306 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8307 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8309 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8310 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8312 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8313 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8316 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8317 .f = cmd_set_uc_hash_parsed,
8319 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8321 (void *)&cmd_set_uc_hash_set,
8322 (void *)&cmd_set_uc_hash_port,
8323 (void *)&cmd_set_uc_hash_portid,
8324 (void *)&cmd_set_uc_hash_what,
8325 (void *)&cmd_set_uc_hash_mac,
8326 (void *)&cmd_set_uc_hash_mode,
8331 struct cmd_set_uc_all_hash_table {
8332 cmdline_fixed_string_t set;
8333 cmdline_fixed_string_t port;
8335 cmdline_fixed_string_t what;
8336 cmdline_fixed_string_t value;
8337 cmdline_fixed_string_t mode;
8341 cmd_set_uc_all_hash_parsed(void *parsed_result,
8342 __rte_unused struct cmdline *cl,
8343 __rte_unused void *data)
8346 struct cmd_set_uc_all_hash_table *res = parsed_result;
8348 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8350 if ((strcmp(res->what, "uta") == 0) &&
8351 (strcmp(res->value, "all") == 0))
8352 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8354 printf("bad unicast hash table parameter,"
8355 "return code = %d \n", ret);
8358 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8359 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8361 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8362 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8364 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8365 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8367 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8368 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8370 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8371 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8373 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8374 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8377 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8378 .f = cmd_set_uc_all_hash_parsed,
8380 .help_str = "set port <port_id> uta all on|off",
8382 (void *)&cmd_set_uc_all_hash_set,
8383 (void *)&cmd_set_uc_all_hash_port,
8384 (void *)&cmd_set_uc_all_hash_portid,
8385 (void *)&cmd_set_uc_all_hash_what,
8386 (void *)&cmd_set_uc_all_hash_value,
8387 (void *)&cmd_set_uc_all_hash_mode,
8392 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8393 struct cmd_set_vf_macvlan_filter {
8394 cmdline_fixed_string_t set;
8395 cmdline_fixed_string_t port;
8397 cmdline_fixed_string_t vf;
8399 struct rte_ether_addr address;
8400 cmdline_fixed_string_t filter_type;
8401 cmdline_fixed_string_t mode;
8405 cmd_set_vf_macvlan_parsed(void *parsed_result,
8406 __rte_unused struct cmdline *cl,
8407 __rte_unused void *data)
8410 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8411 struct rte_eth_mac_filter filter;
8413 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8415 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8417 /* set VF MAC filter */
8421 filter.dst_id = res->vf_id;
8423 if (!strcmp(res->filter_type, "exact-mac"))
8424 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8425 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8426 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8427 else if (!strcmp(res->filter_type, "hashmac"))
8428 filter.filter_type = RTE_MAC_HASH_MATCH;
8429 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8430 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8432 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8435 ret = rte_eth_dev_filter_ctrl(res->port_id,
8436 RTE_ETH_FILTER_MACVLAN,
8440 ret = rte_eth_dev_filter_ctrl(res->port_id,
8441 RTE_ETH_FILTER_MACVLAN,
8442 RTE_ETH_FILTER_DELETE,
8446 printf("bad set MAC hash parameter, return code = %d\n", ret);
8450 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8451 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8453 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8454 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8456 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8457 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8459 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8460 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8462 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8463 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8465 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8466 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8468 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8469 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8470 filter_type, "exact-mac#exact-mac-vlan"
8471 "#hashmac#hashmac-vlan");
8472 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8473 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8476 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8477 .f = cmd_set_vf_macvlan_parsed,
8479 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8480 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8481 "Exact match rule: exact match of MAC or MAC and VLAN; "
8482 "hash match rule: hash match of MAC and exact match of VLAN",
8484 (void *)&cmd_set_vf_macvlan_set,
8485 (void *)&cmd_set_vf_macvlan_port,
8486 (void *)&cmd_set_vf_macvlan_portid,
8487 (void *)&cmd_set_vf_macvlan_vf,
8488 (void *)&cmd_set_vf_macvlan_vf_id,
8489 (void *)&cmd_set_vf_macvlan_mac,
8490 (void *)&cmd_set_vf_macvlan_filter_type,
8491 (void *)&cmd_set_vf_macvlan_mode,
8496 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8497 struct cmd_set_vf_traffic {
8498 cmdline_fixed_string_t set;
8499 cmdline_fixed_string_t port;
8501 cmdline_fixed_string_t vf;
8503 cmdline_fixed_string_t what;
8504 cmdline_fixed_string_t mode;
8508 cmd_set_vf_traffic_parsed(void *parsed_result,
8509 __rte_unused struct cmdline *cl,
8510 __rte_unused void *data)
8512 struct cmd_set_vf_traffic *res = parsed_result;
8513 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8514 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8516 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8519 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8520 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8522 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8523 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8525 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8526 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8528 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8529 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8531 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8532 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8534 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8535 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8537 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8538 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8541 cmdline_parse_inst_t cmd_set_vf_traffic = {
8542 .f = cmd_set_vf_traffic_parsed,
8544 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8546 (void *)&cmd_setvf_traffic_set,
8547 (void *)&cmd_setvf_traffic_port,
8548 (void *)&cmd_setvf_traffic_portid,
8549 (void *)&cmd_setvf_traffic_vf,
8550 (void *)&cmd_setvf_traffic_vfid,
8551 (void *)&cmd_setvf_traffic_what,
8552 (void *)&cmd_setvf_traffic_mode,
8557 /* *** CONFIGURE VF RECEIVE MODE *** */
8558 struct cmd_set_vf_rxmode {
8559 cmdline_fixed_string_t set;
8560 cmdline_fixed_string_t port;
8562 cmdline_fixed_string_t vf;
8564 cmdline_fixed_string_t what;
8565 cmdline_fixed_string_t mode;
8566 cmdline_fixed_string_t on;
8570 cmd_set_vf_rxmode_parsed(void *parsed_result,
8571 __rte_unused struct cmdline *cl,
8572 __rte_unused void *data)
8575 uint16_t vf_rxmode = 0;
8576 struct cmd_set_vf_rxmode *res = parsed_result;
8578 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8579 if (!strcmp(res->what,"rxmode")) {
8580 if (!strcmp(res->mode, "AUPE"))
8581 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8582 else if (!strcmp(res->mode, "ROPE"))
8583 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8584 else if (!strcmp(res->mode, "BAM"))
8585 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8586 else if (!strncmp(res->mode, "MPE",3))
8587 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8590 RTE_SET_USED(is_on);
8592 #ifdef RTE_LIBRTE_IXGBE_PMD
8593 if (ret == -ENOTSUP)
8594 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8595 vf_rxmode, (uint8_t)is_on);
8597 #ifdef RTE_LIBRTE_BNXT_PMD
8598 if (ret == -ENOTSUP)
8599 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8600 vf_rxmode, (uint8_t)is_on);
8603 printf("bad VF receive mode parameter, return code = %d \n",
8607 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8608 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8610 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8611 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8613 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8614 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8616 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8617 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8619 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8620 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8622 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8623 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8625 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8626 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8627 mode, "AUPE#ROPE#BAM#MPE");
8628 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8629 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8632 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8633 .f = cmd_set_vf_rxmode_parsed,
8635 .help_str = "set port <port_id> vf <vf_id> rxmode "
8636 "AUPE|ROPE|BAM|MPE on|off",
8638 (void *)&cmd_set_vf_rxmode_set,
8639 (void *)&cmd_set_vf_rxmode_port,
8640 (void *)&cmd_set_vf_rxmode_portid,
8641 (void *)&cmd_set_vf_rxmode_vf,
8642 (void *)&cmd_set_vf_rxmode_vfid,
8643 (void *)&cmd_set_vf_rxmode_what,
8644 (void *)&cmd_set_vf_rxmode_mode,
8645 (void *)&cmd_set_vf_rxmode_on,
8650 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8651 struct cmd_vf_mac_addr_result {
8652 cmdline_fixed_string_t mac_addr_cmd;
8653 cmdline_fixed_string_t what;
8654 cmdline_fixed_string_t port;
8656 cmdline_fixed_string_t vf;
8658 struct rte_ether_addr address;
8661 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8662 __rte_unused struct cmdline *cl,
8663 __rte_unused void *data)
8665 struct cmd_vf_mac_addr_result *res = parsed_result;
8668 if (strcmp(res->what, "add") != 0)
8671 #ifdef RTE_LIBRTE_I40E_PMD
8672 if (ret == -ENOTSUP)
8673 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8676 #ifdef RTE_LIBRTE_BNXT_PMD
8677 if (ret == -ENOTSUP)
8678 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8683 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8687 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8688 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8689 mac_addr_cmd,"mac_addr");
8690 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8691 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8693 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8694 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8696 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8697 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8699 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8700 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8702 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8703 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8705 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8706 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8709 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8710 .f = cmd_vf_mac_addr_parsed,
8712 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8713 "Add MAC address filtering for a VF on port_id",
8715 (void *)&cmd_vf_mac_addr_cmd,
8716 (void *)&cmd_vf_mac_addr_what,
8717 (void *)&cmd_vf_mac_addr_port,
8718 (void *)&cmd_vf_mac_addr_portnum,
8719 (void *)&cmd_vf_mac_addr_vf,
8720 (void *)&cmd_vf_mac_addr_vfnum,
8721 (void *)&cmd_vf_mac_addr_addr,
8726 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8727 struct cmd_vf_rx_vlan_filter {
8728 cmdline_fixed_string_t rx_vlan;
8729 cmdline_fixed_string_t what;
8731 cmdline_fixed_string_t port;
8733 cmdline_fixed_string_t vf;
8738 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8739 __rte_unused struct cmdline *cl,
8740 __rte_unused void *data)
8742 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8745 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8747 #ifdef RTE_LIBRTE_IXGBE_PMD
8748 if (ret == -ENOTSUP)
8749 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8750 res->vlan_id, res->vf_mask, is_add);
8752 #ifdef RTE_LIBRTE_I40E_PMD
8753 if (ret == -ENOTSUP)
8754 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8755 res->vlan_id, res->vf_mask, is_add);
8757 #ifdef RTE_LIBRTE_BNXT_PMD
8758 if (ret == -ENOTSUP)
8759 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8760 res->vlan_id, res->vf_mask, is_add);
8767 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8768 res->vlan_id, res->vf_mask);
8771 printf("invalid port_id %d\n", res->port_id);
8774 printf("function not implemented or supported\n");
8777 printf("programming error: (%s)\n", strerror(-ret));
8781 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8782 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8783 rx_vlan, "rx_vlan");
8784 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8785 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8787 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8788 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8790 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8791 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8793 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8794 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8796 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8797 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8799 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8800 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8803 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8804 .f = cmd_vf_rx_vlan_filter_parsed,
8806 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8807 "(vf_mask = hexadecimal VF mask)",
8809 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8810 (void *)&cmd_vf_rx_vlan_filter_what,
8811 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8812 (void *)&cmd_vf_rx_vlan_filter_port,
8813 (void *)&cmd_vf_rx_vlan_filter_portid,
8814 (void *)&cmd_vf_rx_vlan_filter_vf,
8815 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8820 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8821 struct cmd_queue_rate_limit_result {
8822 cmdline_fixed_string_t set;
8823 cmdline_fixed_string_t port;
8825 cmdline_fixed_string_t queue;
8827 cmdline_fixed_string_t rate;
8831 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8832 __rte_unused struct cmdline *cl,
8833 __rte_unused void *data)
8835 struct cmd_queue_rate_limit_result *res = parsed_result;
8838 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8839 && (strcmp(res->queue, "queue") == 0)
8840 && (strcmp(res->rate, "rate") == 0))
8841 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8844 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8848 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8849 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8851 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8852 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8854 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8855 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8857 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8858 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8860 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8861 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8863 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8864 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8866 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8867 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8870 cmdline_parse_inst_t cmd_queue_rate_limit = {
8871 .f = cmd_queue_rate_limit_parsed,
8873 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8874 "Set rate limit for a queue on port_id",
8876 (void *)&cmd_queue_rate_limit_set,
8877 (void *)&cmd_queue_rate_limit_port,
8878 (void *)&cmd_queue_rate_limit_portnum,
8879 (void *)&cmd_queue_rate_limit_queue,
8880 (void *)&cmd_queue_rate_limit_queuenum,
8881 (void *)&cmd_queue_rate_limit_rate,
8882 (void *)&cmd_queue_rate_limit_ratenum,
8887 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8888 struct cmd_vf_rate_limit_result {
8889 cmdline_fixed_string_t set;
8890 cmdline_fixed_string_t port;
8892 cmdline_fixed_string_t vf;
8894 cmdline_fixed_string_t rate;
8896 cmdline_fixed_string_t q_msk;
8900 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8901 __rte_unused struct cmdline *cl,
8902 __rte_unused void *data)
8904 struct cmd_vf_rate_limit_result *res = parsed_result;
8907 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8908 && (strcmp(res->vf, "vf") == 0)
8909 && (strcmp(res->rate, "rate") == 0)
8910 && (strcmp(res->q_msk, "queue_mask") == 0))
8911 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8912 res->rate_num, res->q_msk_val);
8914 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8918 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8919 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8921 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8922 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8924 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8925 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8927 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8928 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8930 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8931 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8933 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8934 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8936 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8937 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8939 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8940 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8941 q_msk, "queue_mask");
8942 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8943 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8946 cmdline_parse_inst_t cmd_vf_rate_limit = {
8947 .f = cmd_vf_rate_limit_parsed,
8949 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8950 "queue_mask <queue_mask_value>: "
8951 "Set rate limit for queues of VF on port_id",
8953 (void *)&cmd_vf_rate_limit_set,
8954 (void *)&cmd_vf_rate_limit_port,
8955 (void *)&cmd_vf_rate_limit_portnum,
8956 (void *)&cmd_vf_rate_limit_vf,
8957 (void *)&cmd_vf_rate_limit_vfnum,
8958 (void *)&cmd_vf_rate_limit_rate,
8959 (void *)&cmd_vf_rate_limit_ratenum,
8960 (void *)&cmd_vf_rate_limit_q_msk,
8961 (void *)&cmd_vf_rate_limit_q_msk_val,
8966 /* *** ADD TUNNEL FILTER OF A PORT *** */
8967 struct cmd_tunnel_filter_result {
8968 cmdline_fixed_string_t cmd;
8969 cmdline_fixed_string_t what;
8971 struct rte_ether_addr outer_mac;
8972 struct rte_ether_addr inner_mac;
8973 cmdline_ipaddr_t ip_value;
8974 uint16_t inner_vlan;
8975 cmdline_fixed_string_t tunnel_type;
8976 cmdline_fixed_string_t filter_type;
8982 cmd_tunnel_filter_parsed(void *parsed_result,
8983 __rte_unused struct cmdline *cl,
8984 __rte_unused void *data)
8986 struct cmd_tunnel_filter_result *res = parsed_result;
8987 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8990 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8992 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8993 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8994 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8996 if (res->ip_value.family == AF_INET) {
8997 tunnel_filter_conf.ip_addr.ipv4_addr =
8998 res->ip_value.addr.ipv4.s_addr;
8999 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9001 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9002 &(res->ip_value.addr.ipv6),
9003 sizeof(struct in6_addr));
9004 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9007 if (!strcmp(res->filter_type, "imac-ivlan"))
9008 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9009 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9010 tunnel_filter_conf.filter_type =
9011 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9012 else if (!strcmp(res->filter_type, "imac-tenid"))
9013 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9014 else if (!strcmp(res->filter_type, "imac"))
9015 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9016 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9017 tunnel_filter_conf.filter_type =
9018 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9019 else if (!strcmp(res->filter_type, "oip"))
9020 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9021 else if (!strcmp(res->filter_type, "iip"))
9022 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9024 printf("The filter type is not supported");
9028 if (!strcmp(res->tunnel_type, "vxlan"))
9029 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9030 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9031 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9032 else if (!strcmp(res->tunnel_type, "nvgre"))
9033 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9034 else if (!strcmp(res->tunnel_type, "ipingre"))
9035 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9037 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9041 tunnel_filter_conf.tenant_id = res->tenant_id;
9042 tunnel_filter_conf.queue_id = res->queue_num;
9043 if (!strcmp(res->what, "add"))
9044 ret = rte_eth_dev_filter_ctrl(res->port_id,
9045 RTE_ETH_FILTER_TUNNEL,
9047 &tunnel_filter_conf);
9049 ret = rte_eth_dev_filter_ctrl(res->port_id,
9050 RTE_ETH_FILTER_TUNNEL,
9051 RTE_ETH_FILTER_DELETE,
9052 &tunnel_filter_conf);
9054 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9058 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9059 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9060 cmd, "tunnel_filter");
9061 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9062 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9064 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9065 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9067 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9068 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9070 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9071 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9073 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9074 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9075 inner_vlan, UINT16);
9076 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9077 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9079 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9080 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9081 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9083 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9084 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9085 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9086 "imac#omac-imac-tenid");
9087 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9088 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9090 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9091 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9094 cmdline_parse_inst_t cmd_tunnel_filter = {
9095 .f = cmd_tunnel_filter_parsed,
9097 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9098 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9099 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9100 "<queue_id>: Add/Rm tunnel filter of a port",
9102 (void *)&cmd_tunnel_filter_cmd,
9103 (void *)&cmd_tunnel_filter_what,
9104 (void *)&cmd_tunnel_filter_port_id,
9105 (void *)&cmd_tunnel_filter_outer_mac,
9106 (void *)&cmd_tunnel_filter_inner_mac,
9107 (void *)&cmd_tunnel_filter_ip_value,
9108 (void *)&cmd_tunnel_filter_innner_vlan,
9109 (void *)&cmd_tunnel_filter_tunnel_type,
9110 (void *)&cmd_tunnel_filter_filter_type,
9111 (void *)&cmd_tunnel_filter_tenant_id,
9112 (void *)&cmd_tunnel_filter_queue_num,
9117 /* *** CONFIGURE TUNNEL UDP PORT *** */
9118 struct cmd_tunnel_udp_config {
9119 cmdline_fixed_string_t cmd;
9120 cmdline_fixed_string_t what;
9126 cmd_tunnel_udp_config_parsed(void *parsed_result,
9127 __rte_unused struct cmdline *cl,
9128 __rte_unused void *data)
9130 struct cmd_tunnel_udp_config *res = parsed_result;
9131 struct rte_eth_udp_tunnel tunnel_udp;
9134 tunnel_udp.udp_port = res->udp_port;
9136 if (!strcmp(res->cmd, "rx_vxlan_port"))
9137 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9139 if (!strcmp(res->what, "add"))
9140 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9143 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9147 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9150 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9151 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9152 cmd, "rx_vxlan_port");
9153 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9154 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9156 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9157 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9159 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9160 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9163 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9164 .f = cmd_tunnel_udp_config_parsed,
9166 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9167 "Add/Remove a tunneling UDP port filter",
9169 (void *)&cmd_tunnel_udp_config_cmd,
9170 (void *)&cmd_tunnel_udp_config_what,
9171 (void *)&cmd_tunnel_udp_config_udp_port,
9172 (void *)&cmd_tunnel_udp_config_port_id,
9177 struct cmd_config_tunnel_udp_port {
9178 cmdline_fixed_string_t port;
9179 cmdline_fixed_string_t config;
9181 cmdline_fixed_string_t udp_tunnel_port;
9182 cmdline_fixed_string_t action;
9183 cmdline_fixed_string_t tunnel_type;
9188 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9189 __rte_unused struct cmdline *cl,
9190 __rte_unused void *data)
9192 struct cmd_config_tunnel_udp_port *res = parsed_result;
9193 struct rte_eth_udp_tunnel tunnel_udp;
9196 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9199 tunnel_udp.udp_port = res->udp_port;
9201 if (!strcmp(res->tunnel_type, "vxlan")) {
9202 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9203 } else if (!strcmp(res->tunnel_type, "geneve")) {
9204 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9205 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9206 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9208 printf("Invalid tunnel type\n");
9212 if (!strcmp(res->action, "add"))
9213 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9216 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9220 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9223 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9224 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9226 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9227 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9229 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9230 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9232 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9233 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9236 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9237 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9239 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9240 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9241 "vxlan#geneve#vxlan-gpe");
9242 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9243 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9246 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9247 .f = cmd_cfg_tunnel_udp_port_parsed,
9249 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9251 (void *)&cmd_config_tunnel_udp_port_port,
9252 (void *)&cmd_config_tunnel_udp_port_config,
9253 (void *)&cmd_config_tunnel_udp_port_port_id,
9254 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9255 (void *)&cmd_config_tunnel_udp_port_action,
9256 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9257 (void *)&cmd_config_tunnel_udp_port_value,
9262 /* *** GLOBAL CONFIG *** */
9263 struct cmd_global_config_result {
9264 cmdline_fixed_string_t cmd;
9266 cmdline_fixed_string_t cfg_type;
9271 cmd_global_config_parsed(void *parsed_result,
9272 __rte_unused struct cmdline *cl,
9273 __rte_unused void *data)
9275 struct cmd_global_config_result *res = parsed_result;
9276 struct rte_eth_global_cfg conf;
9279 memset(&conf, 0, sizeof(conf));
9280 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9281 conf.cfg.gre_key_len = res->len;
9282 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9283 RTE_ETH_FILTER_SET, &conf);
9285 printf("Global config error\n");
9288 cmdline_parse_token_string_t cmd_global_config_cmd =
9289 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9291 cmdline_parse_token_num_t cmd_global_config_port_id =
9292 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9294 cmdline_parse_token_string_t cmd_global_config_type =
9295 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9296 cfg_type, "gre-key-len");
9297 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9298 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9301 cmdline_parse_inst_t cmd_global_config = {
9302 .f = cmd_global_config_parsed,
9303 .data = (void *)NULL,
9304 .help_str = "global_config <port_id> gre-key-len <key_len>",
9306 (void *)&cmd_global_config_cmd,
9307 (void *)&cmd_global_config_port_id,
9308 (void *)&cmd_global_config_type,
9309 (void *)&cmd_global_config_gre_key_len,
9314 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9315 struct cmd_set_mirror_mask_result {
9316 cmdline_fixed_string_t set;
9317 cmdline_fixed_string_t port;
9319 cmdline_fixed_string_t mirror;
9321 cmdline_fixed_string_t what;
9322 cmdline_fixed_string_t value;
9323 cmdline_fixed_string_t dstpool;
9325 cmdline_fixed_string_t on;
9328 cmdline_parse_token_string_t cmd_mirror_mask_set =
9329 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9331 cmdline_parse_token_string_t cmd_mirror_mask_port =
9332 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9334 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9335 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9337 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9338 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9339 mirror, "mirror-rule");
9340 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9341 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9343 cmdline_parse_token_string_t cmd_mirror_mask_what =
9344 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9345 what, "pool-mirror-up#pool-mirror-down"
9347 cmdline_parse_token_string_t cmd_mirror_mask_value =
9348 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9350 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9351 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9352 dstpool, "dst-pool");
9353 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9354 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9356 cmdline_parse_token_string_t cmd_mirror_mask_on =
9357 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9361 cmd_set_mirror_mask_parsed(void *parsed_result,
9362 __rte_unused struct cmdline *cl,
9363 __rte_unused void *data)
9366 struct cmd_set_mirror_mask_result *res = parsed_result;
9367 struct rte_eth_mirror_conf mr_conf;
9369 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9371 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9373 mr_conf.dst_pool = res->dstpool_id;
9375 if (!strcmp(res->what, "pool-mirror-up")) {
9376 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9377 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9378 } else if (!strcmp(res->what, "pool-mirror-down")) {
9379 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9380 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9381 } else if (!strcmp(res->what, "vlan-mirror")) {
9382 mr_conf.rule_type = ETH_MIRROR_VLAN;
9383 nb_item = parse_item_list(res->value, "vlan",
9384 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9388 for (i = 0; i < nb_item; i++) {
9389 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9390 printf("Invalid vlan_id: must be < 4096\n");
9394 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9395 mr_conf.vlan.vlan_mask |= 1ULL << i;
9399 if (!strcmp(res->on, "on"))
9400 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9403 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9406 printf("mirror rule add error: (%s)\n", strerror(-ret));
9409 cmdline_parse_inst_t cmd_set_mirror_mask = {
9410 .f = cmd_set_mirror_mask_parsed,
9412 .help_str = "set port <port_id> mirror-rule <rule_id> "
9413 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9414 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9416 (void *)&cmd_mirror_mask_set,
9417 (void *)&cmd_mirror_mask_port,
9418 (void *)&cmd_mirror_mask_portid,
9419 (void *)&cmd_mirror_mask_mirror,
9420 (void *)&cmd_mirror_mask_ruleid,
9421 (void *)&cmd_mirror_mask_what,
9422 (void *)&cmd_mirror_mask_value,
9423 (void *)&cmd_mirror_mask_dstpool,
9424 (void *)&cmd_mirror_mask_poolid,
9425 (void *)&cmd_mirror_mask_on,
9430 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9431 struct cmd_set_mirror_link_result {
9432 cmdline_fixed_string_t set;
9433 cmdline_fixed_string_t port;
9435 cmdline_fixed_string_t mirror;
9437 cmdline_fixed_string_t what;
9438 cmdline_fixed_string_t dstpool;
9440 cmdline_fixed_string_t on;
9443 cmdline_parse_token_string_t cmd_mirror_link_set =
9444 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9446 cmdline_parse_token_string_t cmd_mirror_link_port =
9447 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9449 cmdline_parse_token_num_t cmd_mirror_link_portid =
9450 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9452 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9453 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9454 mirror, "mirror-rule");
9455 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9456 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9458 cmdline_parse_token_string_t cmd_mirror_link_what =
9459 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9460 what, "uplink-mirror#downlink-mirror");
9461 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9462 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9463 dstpool, "dst-pool");
9464 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9465 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9467 cmdline_parse_token_string_t cmd_mirror_link_on =
9468 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9472 cmd_set_mirror_link_parsed(void *parsed_result,
9473 __rte_unused struct cmdline *cl,
9474 __rte_unused void *data)
9477 struct cmd_set_mirror_link_result *res = parsed_result;
9478 struct rte_eth_mirror_conf mr_conf;
9480 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9481 if (!strcmp(res->what, "uplink-mirror"))
9482 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9484 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9486 mr_conf.dst_pool = res->dstpool_id;
9488 if (!strcmp(res->on, "on"))
9489 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9492 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9495 /* check the return value and print it if is < 0 */
9497 printf("mirror rule add error: (%s)\n", strerror(-ret));
9501 cmdline_parse_inst_t cmd_set_mirror_link = {
9502 .f = cmd_set_mirror_link_parsed,
9504 .help_str = "set port <port_id> mirror-rule <rule_id> "
9505 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9507 (void *)&cmd_mirror_link_set,
9508 (void *)&cmd_mirror_link_port,
9509 (void *)&cmd_mirror_link_portid,
9510 (void *)&cmd_mirror_link_mirror,
9511 (void *)&cmd_mirror_link_ruleid,
9512 (void *)&cmd_mirror_link_what,
9513 (void *)&cmd_mirror_link_dstpool,
9514 (void *)&cmd_mirror_link_poolid,
9515 (void *)&cmd_mirror_link_on,
9520 /* *** RESET VM MIRROR RULE *** */
9521 struct cmd_rm_mirror_rule_result {
9522 cmdline_fixed_string_t reset;
9523 cmdline_fixed_string_t port;
9525 cmdline_fixed_string_t mirror;
9529 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9530 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9532 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9533 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9535 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9536 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9538 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9539 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9540 mirror, "mirror-rule");
9541 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9542 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9546 cmd_reset_mirror_rule_parsed(void *parsed_result,
9547 __rte_unused struct cmdline *cl,
9548 __rte_unused void *data)
9551 struct cmd_set_mirror_link_result *res = parsed_result;
9553 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9555 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9558 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9559 .f = cmd_reset_mirror_rule_parsed,
9561 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9563 (void *)&cmd_rm_mirror_rule_reset,
9564 (void *)&cmd_rm_mirror_rule_port,
9565 (void *)&cmd_rm_mirror_rule_portid,
9566 (void *)&cmd_rm_mirror_rule_mirror,
9567 (void *)&cmd_rm_mirror_rule_ruleid,
9572 /* ******************************************************************************** */
9574 struct cmd_dump_result {
9575 cmdline_fixed_string_t dump;
9579 dump_struct_sizes(void)
9581 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9582 DUMP_SIZE(struct rte_mbuf);
9583 DUMP_SIZE(struct rte_mempool);
9584 DUMP_SIZE(struct rte_ring);
9589 /* Dump the socket memory statistics on console */
9591 dump_socket_mem(FILE *f)
9593 struct rte_malloc_socket_stats socket_stats;
9598 unsigned int n_alloc = 0;
9599 unsigned int n_free = 0;
9600 static size_t last_allocs;
9601 static size_t last_total;
9604 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9605 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9606 !socket_stats.heap_totalsz_bytes)
9608 total += socket_stats.heap_totalsz_bytes;
9609 alloc += socket_stats.heap_allocsz_bytes;
9610 free += socket_stats.heap_freesz_bytes;
9611 n_alloc += socket_stats.alloc_count;
9612 n_free += socket_stats.free_count;
9614 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9616 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9617 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9618 (double)socket_stats.heap_allocsz_bytes * 100 /
9619 (double)socket_stats.heap_totalsz_bytes,
9620 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9621 socket_stats.alloc_count,
9622 socket_stats.free_count);
9625 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9626 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9627 (double)alloc * 100 / (double)total,
9628 (double)free / (1024 * 1024),
9631 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9632 ((double)total - (double)last_total) / (1024 * 1024),
9633 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9634 last_allocs = alloc;
9638 static void cmd_dump_parsed(void *parsed_result,
9639 __rte_unused struct cmdline *cl,
9640 __rte_unused void *data)
9642 struct cmd_dump_result *res = parsed_result;
9644 if (!strcmp(res->dump, "dump_physmem"))
9645 rte_dump_physmem_layout(stdout);
9646 else if (!strcmp(res->dump, "dump_socket_mem"))
9647 dump_socket_mem(stdout);
9648 else if (!strcmp(res->dump, "dump_memzone"))
9649 rte_memzone_dump(stdout);
9650 else if (!strcmp(res->dump, "dump_struct_sizes"))
9651 dump_struct_sizes();
9652 else if (!strcmp(res->dump, "dump_ring"))
9653 rte_ring_list_dump(stdout);
9654 else if (!strcmp(res->dump, "dump_mempool"))
9655 rte_mempool_list_dump(stdout);
9656 else if (!strcmp(res->dump, "dump_devargs"))
9657 rte_devargs_dump(stdout);
9658 else if (!strcmp(res->dump, "dump_log_types"))
9659 rte_log_dump(stdout);
9662 cmdline_parse_token_string_t cmd_dump_dump =
9663 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9667 "dump_struct_sizes#"
9673 cmdline_parse_inst_t cmd_dump = {
9674 .f = cmd_dump_parsed, /* function to call */
9675 .data = NULL, /* 2nd arg of func */
9676 .help_str = "Dump status",
9677 .tokens = { /* token list, NULL terminated */
9678 (void *)&cmd_dump_dump,
9683 /* ******************************************************************************** */
9685 struct cmd_dump_one_result {
9686 cmdline_fixed_string_t dump;
9687 cmdline_fixed_string_t name;
9690 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9691 __rte_unused void *data)
9693 struct cmd_dump_one_result *res = parsed_result;
9695 if (!strcmp(res->dump, "dump_ring")) {
9697 r = rte_ring_lookup(res->name);
9699 cmdline_printf(cl, "Cannot find ring\n");
9702 rte_ring_dump(stdout, r);
9703 } else if (!strcmp(res->dump, "dump_mempool")) {
9704 struct rte_mempool *mp;
9705 mp = rte_mempool_lookup(res->name);
9707 cmdline_printf(cl, "Cannot find mempool\n");
9710 rte_mempool_dump(stdout, mp);
9714 cmdline_parse_token_string_t cmd_dump_one_dump =
9715 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9716 "dump_ring#dump_mempool");
9718 cmdline_parse_token_string_t cmd_dump_one_name =
9719 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9721 cmdline_parse_inst_t cmd_dump_one = {
9722 .f = cmd_dump_one_parsed, /* function to call */
9723 .data = NULL, /* 2nd arg of func */
9724 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9725 .tokens = { /* token list, NULL terminated */
9726 (void *)&cmd_dump_one_dump,
9727 (void *)&cmd_dump_one_name,
9732 /* *** Add/Del syn filter *** */
9733 struct cmd_syn_filter_result {
9734 cmdline_fixed_string_t filter;
9736 cmdline_fixed_string_t ops;
9737 cmdline_fixed_string_t priority;
9738 cmdline_fixed_string_t high;
9739 cmdline_fixed_string_t queue;
9744 cmd_syn_filter_parsed(void *parsed_result,
9745 __rte_unused struct cmdline *cl,
9746 __rte_unused void *data)
9748 struct cmd_syn_filter_result *res = parsed_result;
9749 struct rte_eth_syn_filter syn_filter;
9752 ret = rte_eth_dev_filter_supported(res->port_id,
9753 RTE_ETH_FILTER_SYN);
9755 printf("syn filter is not supported on port %u.\n",
9760 memset(&syn_filter, 0, sizeof(syn_filter));
9762 if (!strcmp(res->ops, "add")) {
9763 if (!strcmp(res->high, "high"))
9764 syn_filter.hig_pri = 1;
9766 syn_filter.hig_pri = 0;
9768 syn_filter.queue = res->queue_id;
9769 ret = rte_eth_dev_filter_ctrl(res->port_id,
9774 ret = rte_eth_dev_filter_ctrl(res->port_id,
9776 RTE_ETH_FILTER_DELETE,
9780 printf("syn filter programming error: (%s)\n",
9784 cmdline_parse_token_string_t cmd_syn_filter_filter =
9785 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9786 filter, "syn_filter");
9787 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9788 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9790 cmdline_parse_token_string_t cmd_syn_filter_ops =
9791 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9793 cmdline_parse_token_string_t cmd_syn_filter_priority =
9794 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9795 priority, "priority");
9796 cmdline_parse_token_string_t cmd_syn_filter_high =
9797 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9799 cmdline_parse_token_string_t cmd_syn_filter_queue =
9800 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9802 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9803 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9806 cmdline_parse_inst_t cmd_syn_filter = {
9807 .f = cmd_syn_filter_parsed,
9809 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9810 "<queue_id>: Add/Delete syn filter",
9812 (void *)&cmd_syn_filter_filter,
9813 (void *)&cmd_syn_filter_port_id,
9814 (void *)&cmd_syn_filter_ops,
9815 (void *)&cmd_syn_filter_priority,
9816 (void *)&cmd_syn_filter_high,
9817 (void *)&cmd_syn_filter_queue,
9818 (void *)&cmd_syn_filter_queue_id,
9823 /* *** queue region set *** */
9824 struct cmd_queue_region_result {
9825 cmdline_fixed_string_t set;
9826 cmdline_fixed_string_t port;
9828 cmdline_fixed_string_t cmd;
9829 cmdline_fixed_string_t region;
9831 cmdline_fixed_string_t queue_start_index;
9833 cmdline_fixed_string_t queue_num;
9834 uint8_t queue_num_value;
9838 cmd_queue_region_parsed(void *parsed_result,
9839 __rte_unused struct cmdline *cl,
9840 __rte_unused void *data)
9842 struct cmd_queue_region_result *res = parsed_result;
9844 #ifdef RTE_LIBRTE_I40E_PMD
9845 struct rte_pmd_i40e_queue_region_conf region_conf;
9846 enum rte_pmd_i40e_queue_region_op op_type;
9849 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9852 #ifdef RTE_LIBRTE_I40E_PMD
9853 memset(®ion_conf, 0, sizeof(region_conf));
9854 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9855 region_conf.region_id = res->region_id;
9856 region_conf.queue_num = res->queue_num_value;
9857 region_conf.queue_start_index = res->queue_id;
9859 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9860 op_type, ®ion_conf);
9867 printf("function not implemented or supported\n");
9870 printf("queue region config error: (%s)\n", strerror(-ret));
9874 cmdline_parse_token_string_t cmd_queue_region_set =
9875 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9877 cmdline_parse_token_string_t cmd_queue_region_port =
9878 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9879 cmdline_parse_token_num_t cmd_queue_region_port_id =
9880 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9882 cmdline_parse_token_string_t cmd_queue_region_cmd =
9883 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9884 cmd, "queue-region");
9885 cmdline_parse_token_string_t cmd_queue_region_id =
9886 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9887 region, "region_id");
9888 cmdline_parse_token_num_t cmd_queue_region_index =
9889 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9891 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9892 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9893 queue_start_index, "queue_start_index");
9894 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9895 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9897 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9898 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9899 queue_num, "queue_num");
9900 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9901 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9902 queue_num_value, UINT8);
9904 cmdline_parse_inst_t cmd_queue_region = {
9905 .f = cmd_queue_region_parsed,
9907 .help_str = "set port <port_id> queue-region region_id <value> "
9908 "queue_start_index <value> queue_num <value>: Set a queue region",
9910 (void *)&cmd_queue_region_set,
9911 (void *)&cmd_queue_region_port,
9912 (void *)&cmd_queue_region_port_id,
9913 (void *)&cmd_queue_region_cmd,
9914 (void *)&cmd_queue_region_id,
9915 (void *)&cmd_queue_region_index,
9916 (void *)&cmd_queue_region_queue_start_index,
9917 (void *)&cmd_queue_region_queue_id,
9918 (void *)&cmd_queue_region_queue_num,
9919 (void *)&cmd_queue_region_queue_num_value,
9924 /* *** queue region and flowtype set *** */
9925 struct cmd_region_flowtype_result {
9926 cmdline_fixed_string_t set;
9927 cmdline_fixed_string_t port;
9929 cmdline_fixed_string_t cmd;
9930 cmdline_fixed_string_t region;
9932 cmdline_fixed_string_t flowtype;
9933 uint8_t flowtype_id;
9937 cmd_region_flowtype_parsed(void *parsed_result,
9938 __rte_unused struct cmdline *cl,
9939 __rte_unused void *data)
9941 struct cmd_region_flowtype_result *res = parsed_result;
9943 #ifdef RTE_LIBRTE_I40E_PMD
9944 struct rte_pmd_i40e_queue_region_conf region_conf;
9945 enum rte_pmd_i40e_queue_region_op op_type;
9948 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9951 #ifdef RTE_LIBRTE_I40E_PMD
9952 memset(®ion_conf, 0, sizeof(region_conf));
9954 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9955 region_conf.region_id = res->region_id;
9956 region_conf.hw_flowtype = res->flowtype_id;
9958 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9959 op_type, ®ion_conf);
9966 printf("function not implemented or supported\n");
9969 printf("region flowtype config error: (%s)\n", strerror(-ret));
9973 cmdline_parse_token_string_t cmd_region_flowtype_set =
9974 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9976 cmdline_parse_token_string_t cmd_region_flowtype_port =
9977 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9979 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9980 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9982 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9983 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9984 cmd, "queue-region");
9985 cmdline_parse_token_string_t cmd_region_flowtype_index =
9986 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9987 region, "region_id");
9988 cmdline_parse_token_num_t cmd_region_flowtype_id =
9989 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9991 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9992 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9993 flowtype, "flowtype");
9994 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9995 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9996 flowtype_id, UINT8);
9997 cmdline_parse_inst_t cmd_region_flowtype = {
9998 .f = cmd_region_flowtype_parsed,
10000 .help_str = "set port <port_id> queue-region region_id <value> "
10001 "flowtype <value>: Set a flowtype region index",
10003 (void *)&cmd_region_flowtype_set,
10004 (void *)&cmd_region_flowtype_port,
10005 (void *)&cmd_region_flowtype_port_index,
10006 (void *)&cmd_region_flowtype_cmd,
10007 (void *)&cmd_region_flowtype_index,
10008 (void *)&cmd_region_flowtype_id,
10009 (void *)&cmd_region_flowtype_flow_index,
10010 (void *)&cmd_region_flowtype_flow_id,
10015 /* *** User Priority (UP) to queue region (region_id) set *** */
10016 struct cmd_user_priority_region_result {
10017 cmdline_fixed_string_t set;
10018 cmdline_fixed_string_t port;
10020 cmdline_fixed_string_t cmd;
10021 cmdline_fixed_string_t user_priority;
10022 uint8_t user_priority_id;
10023 cmdline_fixed_string_t region;
10028 cmd_user_priority_region_parsed(void *parsed_result,
10029 __rte_unused struct cmdline *cl,
10030 __rte_unused void *data)
10032 struct cmd_user_priority_region_result *res = parsed_result;
10033 int ret = -ENOTSUP;
10034 #ifdef RTE_LIBRTE_I40E_PMD
10035 struct rte_pmd_i40e_queue_region_conf region_conf;
10036 enum rte_pmd_i40e_queue_region_op op_type;
10039 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10042 #ifdef RTE_LIBRTE_I40E_PMD
10043 memset(®ion_conf, 0, sizeof(region_conf));
10044 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10045 region_conf.user_priority = res->user_priority_id;
10046 region_conf.region_id = res->region_id;
10048 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10049 op_type, ®ion_conf);
10056 printf("function not implemented or supported\n");
10059 printf("user_priority region config error: (%s)\n",
10064 cmdline_parse_token_string_t cmd_user_priority_region_set =
10065 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10067 cmdline_parse_token_string_t cmd_user_priority_region_port =
10068 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10070 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10071 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10073 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10074 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10075 cmd, "queue-region");
10076 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10077 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10078 user_priority, "UP");
10079 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10080 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10081 user_priority_id, UINT8);
10082 cmdline_parse_token_string_t cmd_user_priority_region_region =
10083 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10084 region, "region_id");
10085 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10086 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10089 cmdline_parse_inst_t cmd_user_priority_region = {
10090 .f = cmd_user_priority_region_parsed,
10092 .help_str = "set port <port_id> queue-region UP <value> "
10093 "region_id <value>: Set the mapping of User Priority (UP) "
10094 "to queue region (region_id) ",
10096 (void *)&cmd_user_priority_region_set,
10097 (void *)&cmd_user_priority_region_port,
10098 (void *)&cmd_user_priority_region_port_index,
10099 (void *)&cmd_user_priority_region_cmd,
10100 (void *)&cmd_user_priority_region_UP,
10101 (void *)&cmd_user_priority_region_UP_id,
10102 (void *)&cmd_user_priority_region_region,
10103 (void *)&cmd_user_priority_region_region_id,
10108 /* *** flush all queue region related configuration *** */
10109 struct cmd_flush_queue_region_result {
10110 cmdline_fixed_string_t set;
10111 cmdline_fixed_string_t port;
10113 cmdline_fixed_string_t cmd;
10114 cmdline_fixed_string_t flush;
10115 cmdline_fixed_string_t what;
10119 cmd_flush_queue_region_parsed(void *parsed_result,
10120 __rte_unused struct cmdline *cl,
10121 __rte_unused void *data)
10123 struct cmd_flush_queue_region_result *res = parsed_result;
10124 int ret = -ENOTSUP;
10125 #ifdef RTE_LIBRTE_I40E_PMD
10126 struct rte_pmd_i40e_queue_region_conf region_conf;
10127 enum rte_pmd_i40e_queue_region_op op_type;
10130 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10133 #ifdef RTE_LIBRTE_I40E_PMD
10134 memset(®ion_conf, 0, sizeof(region_conf));
10136 if (strcmp(res->what, "on") == 0)
10137 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10139 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10141 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10142 op_type, ®ion_conf);
10149 printf("function not implemented or supported\n");
10152 printf("queue region config flush error: (%s)\n",
10157 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10158 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10160 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10161 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10163 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10164 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10166 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10167 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10168 cmd, "queue-region");
10169 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10170 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10172 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10173 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10176 cmdline_parse_inst_t cmd_flush_queue_region = {
10177 .f = cmd_flush_queue_region_parsed,
10179 .help_str = "set port <port_id> queue-region flush on|off"
10180 ": flush all queue region related configuration",
10182 (void *)&cmd_flush_queue_region_set,
10183 (void *)&cmd_flush_queue_region_port,
10184 (void *)&cmd_flush_queue_region_port_index,
10185 (void *)&cmd_flush_queue_region_cmd,
10186 (void *)&cmd_flush_queue_region_flush,
10187 (void *)&cmd_flush_queue_region_what,
10192 /* *** get all queue region related configuration info *** */
10193 struct cmd_show_queue_region_info {
10194 cmdline_fixed_string_t show;
10195 cmdline_fixed_string_t port;
10197 cmdline_fixed_string_t cmd;
10201 cmd_show_queue_region_info_parsed(void *parsed_result,
10202 __rte_unused struct cmdline *cl,
10203 __rte_unused void *data)
10205 struct cmd_show_queue_region_info *res = parsed_result;
10206 int ret = -ENOTSUP;
10207 #ifdef RTE_LIBRTE_I40E_PMD
10208 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10209 enum rte_pmd_i40e_queue_region_op op_type;
10212 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10215 #ifdef RTE_LIBRTE_I40E_PMD
10216 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10218 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10220 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10221 op_type, &rte_pmd_regions);
10223 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10230 printf("function not implemented or supported\n");
10233 printf("queue region config info show error: (%s)\n",
10238 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10239 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10241 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10242 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10244 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10245 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10247 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10248 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10249 cmd, "queue-region");
10251 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10252 .f = cmd_show_queue_region_info_parsed,
10254 .help_str = "show port <port_id> queue-region"
10255 ": show all queue region related configuration info",
10257 (void *)&cmd_show_queue_region_info_get,
10258 (void *)&cmd_show_queue_region_info_port,
10259 (void *)&cmd_show_queue_region_info_port_index,
10260 (void *)&cmd_show_queue_region_info_cmd,
10265 /* *** ADD/REMOVE A 2tuple FILTER *** */
10266 struct cmd_2tuple_filter_result {
10267 cmdline_fixed_string_t filter;
10269 cmdline_fixed_string_t ops;
10270 cmdline_fixed_string_t dst_port;
10271 uint16_t dst_port_value;
10272 cmdline_fixed_string_t protocol;
10273 uint8_t protocol_value;
10274 cmdline_fixed_string_t mask;
10275 uint8_t mask_value;
10276 cmdline_fixed_string_t tcp_flags;
10277 uint8_t tcp_flags_value;
10278 cmdline_fixed_string_t priority;
10279 uint8_t priority_value;
10280 cmdline_fixed_string_t queue;
10285 cmd_2tuple_filter_parsed(void *parsed_result,
10286 __rte_unused struct cmdline *cl,
10287 __rte_unused void *data)
10289 struct rte_eth_ntuple_filter filter;
10290 struct cmd_2tuple_filter_result *res = parsed_result;
10293 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10295 printf("ntuple filter is not supported on port %u.\n",
10300 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10302 filter.flags = RTE_2TUPLE_FLAGS;
10303 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10304 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10305 filter.proto = res->protocol_value;
10306 filter.priority = res->priority_value;
10307 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10308 printf("nonzero tcp_flags is only meaningful"
10309 " when protocol is TCP.\n");
10312 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10313 printf("invalid TCP flags.\n");
10317 if (res->tcp_flags_value != 0) {
10318 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10319 filter.tcp_flags = res->tcp_flags_value;
10322 /* need convert to big endian. */
10323 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10324 filter.queue = res->queue_id;
10326 if (!strcmp(res->ops, "add"))
10327 ret = rte_eth_dev_filter_ctrl(res->port_id,
10328 RTE_ETH_FILTER_NTUPLE,
10329 RTE_ETH_FILTER_ADD,
10332 ret = rte_eth_dev_filter_ctrl(res->port_id,
10333 RTE_ETH_FILTER_NTUPLE,
10334 RTE_ETH_FILTER_DELETE,
10337 printf("2tuple filter programming error: (%s)\n",
10342 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10343 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10344 filter, "2tuple_filter");
10345 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10346 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10348 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10349 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10351 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10352 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10353 dst_port, "dst_port");
10354 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10355 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10356 dst_port_value, UINT16);
10357 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10358 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10359 protocol, "protocol");
10360 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10361 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10362 protocol_value, UINT8);
10363 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10364 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10366 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10367 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10369 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10370 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10371 tcp_flags, "tcp_flags");
10372 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10373 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10374 tcp_flags_value, UINT8);
10375 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10376 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10377 priority, "priority");
10378 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10379 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10380 priority_value, UINT8);
10381 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10382 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10384 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10385 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10388 cmdline_parse_inst_t cmd_2tuple_filter = {
10389 .f = cmd_2tuple_filter_parsed,
10391 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10392 "<value> mask <value> tcp_flags <value> priority <value> queue "
10393 "<queue_id>: Add a 2tuple filter",
10395 (void *)&cmd_2tuple_filter_filter,
10396 (void *)&cmd_2tuple_filter_port_id,
10397 (void *)&cmd_2tuple_filter_ops,
10398 (void *)&cmd_2tuple_filter_dst_port,
10399 (void *)&cmd_2tuple_filter_dst_port_value,
10400 (void *)&cmd_2tuple_filter_protocol,
10401 (void *)&cmd_2tuple_filter_protocol_value,
10402 (void *)&cmd_2tuple_filter_mask,
10403 (void *)&cmd_2tuple_filter_mask_value,
10404 (void *)&cmd_2tuple_filter_tcp_flags,
10405 (void *)&cmd_2tuple_filter_tcp_flags_value,
10406 (void *)&cmd_2tuple_filter_priority,
10407 (void *)&cmd_2tuple_filter_priority_value,
10408 (void *)&cmd_2tuple_filter_queue,
10409 (void *)&cmd_2tuple_filter_queue_id,
10414 /* *** ADD/REMOVE A 5tuple FILTER *** */
10415 struct cmd_5tuple_filter_result {
10416 cmdline_fixed_string_t filter;
10418 cmdline_fixed_string_t ops;
10419 cmdline_fixed_string_t dst_ip;
10420 cmdline_ipaddr_t dst_ip_value;
10421 cmdline_fixed_string_t src_ip;
10422 cmdline_ipaddr_t src_ip_value;
10423 cmdline_fixed_string_t dst_port;
10424 uint16_t dst_port_value;
10425 cmdline_fixed_string_t src_port;
10426 uint16_t src_port_value;
10427 cmdline_fixed_string_t protocol;
10428 uint8_t protocol_value;
10429 cmdline_fixed_string_t mask;
10430 uint8_t mask_value;
10431 cmdline_fixed_string_t tcp_flags;
10432 uint8_t tcp_flags_value;
10433 cmdline_fixed_string_t priority;
10434 uint8_t priority_value;
10435 cmdline_fixed_string_t queue;
10440 cmd_5tuple_filter_parsed(void *parsed_result,
10441 __rte_unused struct cmdline *cl,
10442 __rte_unused void *data)
10444 struct rte_eth_ntuple_filter filter;
10445 struct cmd_5tuple_filter_result *res = parsed_result;
10448 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10450 printf("ntuple filter is not supported on port %u.\n",
10455 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10457 filter.flags = RTE_5TUPLE_FLAGS;
10458 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10459 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10460 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10461 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10462 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10463 filter.proto = res->protocol_value;
10464 filter.priority = res->priority_value;
10465 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10466 printf("nonzero tcp_flags is only meaningful"
10467 " when protocol is TCP.\n");
10470 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10471 printf("invalid TCP flags.\n");
10475 if (res->tcp_flags_value != 0) {
10476 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10477 filter.tcp_flags = res->tcp_flags_value;
10480 if (res->dst_ip_value.family == AF_INET)
10481 /* no need to convert, already big endian. */
10482 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10484 if (filter.dst_ip_mask == 0) {
10485 printf("can not support ipv6 involved compare.\n");
10491 if (res->src_ip_value.family == AF_INET)
10492 /* no need to convert, already big endian. */
10493 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10495 if (filter.src_ip_mask == 0) {
10496 printf("can not support ipv6 involved compare.\n");
10501 /* need convert to big endian. */
10502 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10503 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10504 filter.queue = res->queue_id;
10506 if (!strcmp(res->ops, "add"))
10507 ret = rte_eth_dev_filter_ctrl(res->port_id,
10508 RTE_ETH_FILTER_NTUPLE,
10509 RTE_ETH_FILTER_ADD,
10512 ret = rte_eth_dev_filter_ctrl(res->port_id,
10513 RTE_ETH_FILTER_NTUPLE,
10514 RTE_ETH_FILTER_DELETE,
10517 printf("5tuple filter programming error: (%s)\n",
10521 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10522 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10523 filter, "5tuple_filter");
10524 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10525 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10527 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10528 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10530 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10531 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10533 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10534 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10536 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10537 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10539 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10540 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10542 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10543 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10544 dst_port, "dst_port");
10545 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10546 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10547 dst_port_value, UINT16);
10548 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10549 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10550 src_port, "src_port");
10551 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10552 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10553 src_port_value, UINT16);
10554 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10555 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10556 protocol, "protocol");
10557 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10558 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10559 protocol_value, UINT8);
10560 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10561 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10563 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10564 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10566 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10567 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10568 tcp_flags, "tcp_flags");
10569 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10570 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10571 tcp_flags_value, UINT8);
10572 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10573 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10574 priority, "priority");
10575 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10576 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10577 priority_value, UINT8);
10578 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10579 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10581 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10582 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10585 cmdline_parse_inst_t cmd_5tuple_filter = {
10586 .f = cmd_5tuple_filter_parsed,
10588 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10589 "src_ip <value> dst_port <value> src_port <value> "
10590 "protocol <value> mask <value> tcp_flags <value> "
10591 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10593 (void *)&cmd_5tuple_filter_filter,
10594 (void *)&cmd_5tuple_filter_port_id,
10595 (void *)&cmd_5tuple_filter_ops,
10596 (void *)&cmd_5tuple_filter_dst_ip,
10597 (void *)&cmd_5tuple_filter_dst_ip_value,
10598 (void *)&cmd_5tuple_filter_src_ip,
10599 (void *)&cmd_5tuple_filter_src_ip_value,
10600 (void *)&cmd_5tuple_filter_dst_port,
10601 (void *)&cmd_5tuple_filter_dst_port_value,
10602 (void *)&cmd_5tuple_filter_src_port,
10603 (void *)&cmd_5tuple_filter_src_port_value,
10604 (void *)&cmd_5tuple_filter_protocol,
10605 (void *)&cmd_5tuple_filter_protocol_value,
10606 (void *)&cmd_5tuple_filter_mask,
10607 (void *)&cmd_5tuple_filter_mask_value,
10608 (void *)&cmd_5tuple_filter_tcp_flags,
10609 (void *)&cmd_5tuple_filter_tcp_flags_value,
10610 (void *)&cmd_5tuple_filter_priority,
10611 (void *)&cmd_5tuple_filter_priority_value,
10612 (void *)&cmd_5tuple_filter_queue,
10613 (void *)&cmd_5tuple_filter_queue_id,
10618 /* *** ADD/REMOVE A flex FILTER *** */
10619 struct cmd_flex_filter_result {
10620 cmdline_fixed_string_t filter;
10621 cmdline_fixed_string_t ops;
10623 cmdline_fixed_string_t len;
10625 cmdline_fixed_string_t bytes;
10626 cmdline_fixed_string_t bytes_value;
10627 cmdline_fixed_string_t mask;
10628 cmdline_fixed_string_t mask_value;
10629 cmdline_fixed_string_t priority;
10630 uint8_t priority_value;
10631 cmdline_fixed_string_t queue;
10635 static int xdigit2val(unsigned char c)
10640 else if (isupper(c))
10641 val = c - 'A' + 10;
10643 val = c - 'a' + 10;
10648 cmd_flex_filter_parsed(void *parsed_result,
10649 __rte_unused struct cmdline *cl,
10650 __rte_unused void *data)
10653 struct rte_eth_flex_filter filter;
10654 struct cmd_flex_filter_result *res = parsed_result;
10655 char *bytes_ptr, *mask_ptr;
10656 uint16_t len, i, j = 0;
10661 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10662 printf("the len exceed the max length 128\n");
10665 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10666 filter.len = res->len_value;
10667 filter.priority = res->priority_value;
10668 filter.queue = res->queue_id;
10669 bytes_ptr = res->bytes_value;
10670 mask_ptr = res->mask_value;
10672 /* translate bytes string to array. */
10673 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10674 (bytes_ptr[1] == 'X')))
10676 len = strnlen(bytes_ptr, res->len_value * 2);
10677 if (len == 0 || (len % 8 != 0)) {
10678 printf("please check len and bytes input\n");
10681 for (i = 0; i < len; i++) {
10683 if (isxdigit(c) == 0) {
10684 /* invalid characters. */
10685 printf("invalid input\n");
10688 val = xdigit2val(c);
10691 filter.bytes[j] = byte;
10692 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10699 /* translate mask string to uint8_t array. */
10700 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10701 (mask_ptr[1] == 'X')))
10703 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10705 printf("invalid input\n");
10710 for (i = 0; i < len; i++) {
10712 if (isxdigit(c) == 0) {
10713 /* invalid characters. */
10714 printf("invalid input\n");
10717 val = xdigit2val(c);
10720 filter.mask[j] = byte;
10721 printf("mask[%d]:%02x ", j, filter.mask[j]);
10729 if (!strcmp(res->ops, "add"))
10730 ret = rte_eth_dev_filter_ctrl(res->port_id,
10731 RTE_ETH_FILTER_FLEXIBLE,
10732 RTE_ETH_FILTER_ADD,
10735 ret = rte_eth_dev_filter_ctrl(res->port_id,
10736 RTE_ETH_FILTER_FLEXIBLE,
10737 RTE_ETH_FILTER_DELETE,
10741 printf("flex filter setting error: (%s)\n", strerror(-ret));
10744 cmdline_parse_token_string_t cmd_flex_filter_filter =
10745 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10746 filter, "flex_filter");
10747 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10748 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10750 cmdline_parse_token_string_t cmd_flex_filter_ops =
10751 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10753 cmdline_parse_token_string_t cmd_flex_filter_len =
10754 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10756 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10757 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10759 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10760 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10762 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10763 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10764 bytes_value, NULL);
10765 cmdline_parse_token_string_t cmd_flex_filter_mask =
10766 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10768 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10769 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10771 cmdline_parse_token_string_t cmd_flex_filter_priority =
10772 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10773 priority, "priority");
10774 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10775 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10776 priority_value, UINT8);
10777 cmdline_parse_token_string_t cmd_flex_filter_queue =
10778 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10780 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10781 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10783 cmdline_parse_inst_t cmd_flex_filter = {
10784 .f = cmd_flex_filter_parsed,
10786 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10787 "<value> mask <value> priority <value> queue <queue_id>: "
10788 "Add/Del a flex filter",
10790 (void *)&cmd_flex_filter_filter,
10791 (void *)&cmd_flex_filter_port_id,
10792 (void *)&cmd_flex_filter_ops,
10793 (void *)&cmd_flex_filter_len,
10794 (void *)&cmd_flex_filter_len_value,
10795 (void *)&cmd_flex_filter_bytes,
10796 (void *)&cmd_flex_filter_bytes_value,
10797 (void *)&cmd_flex_filter_mask,
10798 (void *)&cmd_flex_filter_mask_value,
10799 (void *)&cmd_flex_filter_priority,
10800 (void *)&cmd_flex_filter_priority_value,
10801 (void *)&cmd_flex_filter_queue,
10802 (void *)&cmd_flex_filter_queue_id,
10807 /* *** Filters Control *** */
10809 /* *** deal with ethertype filter *** */
10810 struct cmd_ethertype_filter_result {
10811 cmdline_fixed_string_t filter;
10813 cmdline_fixed_string_t ops;
10814 cmdline_fixed_string_t mac;
10815 struct rte_ether_addr mac_addr;
10816 cmdline_fixed_string_t ethertype;
10817 uint16_t ethertype_value;
10818 cmdline_fixed_string_t drop;
10819 cmdline_fixed_string_t queue;
10823 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10824 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10825 filter, "ethertype_filter");
10826 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10827 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10829 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10830 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10832 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10833 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10834 mac, "mac_addr#mac_ignr");
10835 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10836 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10838 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10839 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10840 ethertype, "ethertype");
10841 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10842 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10843 ethertype_value, UINT16);
10844 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10845 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10847 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10848 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10850 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10851 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10855 cmd_ethertype_filter_parsed(void *parsed_result,
10856 __rte_unused struct cmdline *cl,
10857 __rte_unused void *data)
10859 struct cmd_ethertype_filter_result *res = parsed_result;
10860 struct rte_eth_ethertype_filter filter;
10863 ret = rte_eth_dev_filter_supported(res->port_id,
10864 RTE_ETH_FILTER_ETHERTYPE);
10866 printf("ethertype filter is not supported on port %u.\n",
10871 memset(&filter, 0, sizeof(filter));
10872 if (!strcmp(res->mac, "mac_addr")) {
10873 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10874 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10875 sizeof(struct rte_ether_addr));
10877 if (!strcmp(res->drop, "drop"))
10878 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10879 filter.ether_type = res->ethertype_value;
10880 filter.queue = res->queue_id;
10882 if (!strcmp(res->ops, "add"))
10883 ret = rte_eth_dev_filter_ctrl(res->port_id,
10884 RTE_ETH_FILTER_ETHERTYPE,
10885 RTE_ETH_FILTER_ADD,
10888 ret = rte_eth_dev_filter_ctrl(res->port_id,
10889 RTE_ETH_FILTER_ETHERTYPE,
10890 RTE_ETH_FILTER_DELETE,
10893 printf("ethertype filter programming error: (%s)\n",
10897 cmdline_parse_inst_t cmd_ethertype_filter = {
10898 .f = cmd_ethertype_filter_parsed,
10900 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10901 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10902 "Add or delete an ethertype filter entry",
10904 (void *)&cmd_ethertype_filter_filter,
10905 (void *)&cmd_ethertype_filter_port_id,
10906 (void *)&cmd_ethertype_filter_ops,
10907 (void *)&cmd_ethertype_filter_mac,
10908 (void *)&cmd_ethertype_filter_mac_addr,
10909 (void *)&cmd_ethertype_filter_ethertype,
10910 (void *)&cmd_ethertype_filter_ethertype_value,
10911 (void *)&cmd_ethertype_filter_drop,
10912 (void *)&cmd_ethertype_filter_queue,
10913 (void *)&cmd_ethertype_filter_queue_id,
10918 /* *** deal with flow director filter *** */
10919 struct cmd_flow_director_result {
10920 cmdline_fixed_string_t flow_director_filter;
10922 cmdline_fixed_string_t mode;
10923 cmdline_fixed_string_t mode_value;
10924 cmdline_fixed_string_t ops;
10925 cmdline_fixed_string_t flow;
10926 cmdline_fixed_string_t flow_type;
10927 cmdline_fixed_string_t ether;
10928 uint16_t ether_type;
10929 cmdline_fixed_string_t src;
10930 cmdline_ipaddr_t ip_src;
10932 cmdline_fixed_string_t dst;
10933 cmdline_ipaddr_t ip_dst;
10935 cmdline_fixed_string_t verify_tag;
10936 uint32_t verify_tag_value;
10937 cmdline_fixed_string_t tos;
10939 cmdline_fixed_string_t proto;
10940 uint8_t proto_value;
10941 cmdline_fixed_string_t ttl;
10943 cmdline_fixed_string_t vlan;
10944 uint16_t vlan_value;
10945 cmdline_fixed_string_t flexbytes;
10946 cmdline_fixed_string_t flexbytes_value;
10947 cmdline_fixed_string_t pf_vf;
10948 cmdline_fixed_string_t drop;
10949 cmdline_fixed_string_t queue;
10951 cmdline_fixed_string_t fd_id;
10952 uint32_t fd_id_value;
10953 cmdline_fixed_string_t mac;
10954 struct rte_ether_addr mac_addr;
10955 cmdline_fixed_string_t tunnel;
10956 cmdline_fixed_string_t tunnel_type;
10957 cmdline_fixed_string_t tunnel_id;
10958 uint32_t tunnel_id_value;
10959 cmdline_fixed_string_t packet;
10964 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10967 const char *p, *p0 = q_arg;
10969 unsigned long int_fld;
10970 char *str_fld[max_num];
10975 p = strchr(p0, '(');
10979 p0 = strchr(p, ')');
10984 if (size >= sizeof(s))
10987 snprintf(s, sizeof(s), "%.*s", size, p);
10988 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10989 if (ret < 0 || ret > max_num)
10991 for (i = 0; i < ret; i++) {
10993 int_fld = strtoul(str_fld[i], &end, 0);
10994 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10996 flexbytes[i] = (uint8_t)int_fld;
11002 str2flowtype(char *string)
11005 static const struct {
11008 } flowtype_str[] = {
11009 {"raw", RTE_ETH_FLOW_RAW},
11010 {"ipv4", RTE_ETH_FLOW_IPV4},
11011 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11012 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11013 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11014 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11015 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11016 {"ipv6", RTE_ETH_FLOW_IPV6},
11017 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11018 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11019 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11020 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11021 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11022 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11025 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11026 if (!strcmp(flowtype_str[i].str, string))
11027 return flowtype_str[i].type;
11030 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11031 return (uint16_t)atoi(string);
11033 return RTE_ETH_FLOW_UNKNOWN;
11036 static enum rte_eth_fdir_tunnel_type
11037 str2fdir_tunneltype(char *string)
11041 static const struct {
11043 enum rte_eth_fdir_tunnel_type type;
11044 } tunneltype_str[] = {
11045 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11046 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11049 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11050 if (!strcmp(tunneltype_str[i].str, string))
11051 return tunneltype_str[i].type;
11053 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11056 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11058 if ((ip_addr).family == AF_INET) \
11059 (ip) = (ip_addr).addr.ipv4.s_addr; \
11061 printf("invalid parameter.\n"); \
11066 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11068 if ((ip_addr).family == AF_INET6) \
11069 rte_memcpy(&(ip), \
11070 &((ip_addr).addr.ipv6), \
11071 sizeof(struct in6_addr)); \
11073 printf("invalid parameter.\n"); \
11079 cmd_flow_director_filter_parsed(void *parsed_result,
11080 __rte_unused struct cmdline *cl,
11081 __rte_unused void *data)
11083 struct cmd_flow_director_result *res = parsed_result;
11084 struct rte_eth_fdir_filter entry;
11085 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11087 unsigned long vf_id;
11090 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11092 printf("flow director is not supported on port %u.\n",
11096 memset(flexbytes, 0, sizeof(flexbytes));
11097 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11099 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11100 if (strcmp(res->mode_value, "MAC-VLAN")) {
11101 printf("Please set mode to MAC-VLAN.\n");
11104 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11105 if (strcmp(res->mode_value, "Tunnel")) {
11106 printf("Please set mode to Tunnel.\n");
11110 if (!strcmp(res->mode_value, "raw")) {
11111 #ifdef RTE_LIBRTE_I40E_PMD
11112 struct rte_pmd_i40e_flow_type_mapping
11113 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11114 struct rte_pmd_i40e_pkt_template_conf conf;
11115 uint16_t flow_type = str2flowtype(res->flow_type);
11116 uint16_t i, port = res->port_id;
11119 memset(&conf, 0, sizeof(conf));
11121 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11122 printf("Invalid flow type specified.\n");
11125 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11129 if (mapping[flow_type].pctype == 0ULL) {
11130 printf("Invalid flow type specified.\n");
11133 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11134 if (mapping[flow_type].pctype & (1ULL << i)) {
11135 conf.input.pctype = i;
11140 conf.input.packet = open_file(res->filepath,
11141 &conf.input.length);
11142 if (!conf.input.packet)
11144 if (!strcmp(res->drop, "drop"))
11145 conf.action.behavior =
11146 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11148 conf.action.behavior =
11149 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11150 conf.action.report_status =
11151 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11152 conf.action.rx_queue = res->queue_id;
11153 conf.soft_id = res->fd_id_value;
11154 add = strcmp(res->ops, "del") ? 1 : 0;
11155 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11159 printf("flow director config error: (%s)\n",
11161 close_file(conf.input.packet);
11164 } else if (strcmp(res->mode_value, "IP")) {
11165 printf("Please set mode to IP or raw.\n");
11168 entry.input.flow_type = str2flowtype(res->flow_type);
11171 ret = parse_flexbytes(res->flexbytes_value,
11173 RTE_ETH_FDIR_MAX_FLEXLEN);
11175 printf("error: Cannot parse flexbytes input.\n");
11179 switch (entry.input.flow_type) {
11180 case RTE_ETH_FLOW_FRAG_IPV4:
11181 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11182 entry.input.flow.ip4_flow.proto = res->proto_value;
11184 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11185 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11186 IPV4_ADDR_TO_UINT(res->ip_dst,
11187 entry.input.flow.ip4_flow.dst_ip);
11188 IPV4_ADDR_TO_UINT(res->ip_src,
11189 entry.input.flow.ip4_flow.src_ip);
11190 entry.input.flow.ip4_flow.tos = res->tos_value;
11191 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11192 /* need convert to big endian. */
11193 entry.input.flow.udp4_flow.dst_port =
11194 rte_cpu_to_be_16(res->port_dst);
11195 entry.input.flow.udp4_flow.src_port =
11196 rte_cpu_to_be_16(res->port_src);
11198 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11199 IPV4_ADDR_TO_UINT(res->ip_dst,
11200 entry.input.flow.sctp4_flow.ip.dst_ip);
11201 IPV4_ADDR_TO_UINT(res->ip_src,
11202 entry.input.flow.sctp4_flow.ip.src_ip);
11203 entry.input.flow.ip4_flow.tos = res->tos_value;
11204 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11205 /* need convert to big endian. */
11206 entry.input.flow.sctp4_flow.dst_port =
11207 rte_cpu_to_be_16(res->port_dst);
11208 entry.input.flow.sctp4_flow.src_port =
11209 rte_cpu_to_be_16(res->port_src);
11210 entry.input.flow.sctp4_flow.verify_tag =
11211 rte_cpu_to_be_32(res->verify_tag_value);
11213 case RTE_ETH_FLOW_FRAG_IPV6:
11214 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11215 entry.input.flow.ipv6_flow.proto = res->proto_value;
11217 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11218 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11219 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11220 entry.input.flow.ipv6_flow.dst_ip);
11221 IPV6_ADDR_TO_ARRAY(res->ip_src,
11222 entry.input.flow.ipv6_flow.src_ip);
11223 entry.input.flow.ipv6_flow.tc = res->tos_value;
11224 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11225 /* need convert to big endian. */
11226 entry.input.flow.udp6_flow.dst_port =
11227 rte_cpu_to_be_16(res->port_dst);
11228 entry.input.flow.udp6_flow.src_port =
11229 rte_cpu_to_be_16(res->port_src);
11231 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11232 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11233 entry.input.flow.sctp6_flow.ip.dst_ip);
11234 IPV6_ADDR_TO_ARRAY(res->ip_src,
11235 entry.input.flow.sctp6_flow.ip.src_ip);
11236 entry.input.flow.ipv6_flow.tc = res->tos_value;
11237 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11238 /* need convert to big endian. */
11239 entry.input.flow.sctp6_flow.dst_port =
11240 rte_cpu_to_be_16(res->port_dst);
11241 entry.input.flow.sctp6_flow.src_port =
11242 rte_cpu_to_be_16(res->port_src);
11243 entry.input.flow.sctp6_flow.verify_tag =
11244 rte_cpu_to_be_32(res->verify_tag_value);
11246 case RTE_ETH_FLOW_L2_PAYLOAD:
11247 entry.input.flow.l2_flow.ether_type =
11248 rte_cpu_to_be_16(res->ether_type);
11254 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11255 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11257 sizeof(struct rte_ether_addr));
11259 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11260 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11262 sizeof(struct rte_ether_addr));
11263 entry.input.flow.tunnel_flow.tunnel_type =
11264 str2fdir_tunneltype(res->tunnel_type);
11265 entry.input.flow.tunnel_flow.tunnel_id =
11266 rte_cpu_to_be_32(res->tunnel_id_value);
11269 rte_memcpy(entry.input.flow_ext.flexbytes,
11271 RTE_ETH_FDIR_MAX_FLEXLEN);
11273 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11275 entry.action.flex_off = 0; /*use 0 by default */
11276 if (!strcmp(res->drop, "drop"))
11277 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11279 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11281 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11282 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11283 if (!strcmp(res->pf_vf, "pf"))
11284 entry.input.flow_ext.is_vf = 0;
11285 else if (!strncmp(res->pf_vf, "vf", 2)) {
11286 struct rte_eth_dev_info dev_info;
11288 ret = eth_dev_info_get_print_err(res->port_id,
11294 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11295 if (errno != 0 || *end != '\0' ||
11296 vf_id >= dev_info.max_vfs) {
11297 printf("invalid parameter %s.\n", res->pf_vf);
11300 entry.input.flow_ext.is_vf = 1;
11301 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11303 printf("invalid parameter %s.\n", res->pf_vf);
11308 /* set to report FD ID by default */
11309 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11310 entry.action.rx_queue = res->queue_id;
11311 entry.soft_id = res->fd_id_value;
11312 if (!strcmp(res->ops, "add"))
11313 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11314 RTE_ETH_FILTER_ADD, &entry);
11315 else if (!strcmp(res->ops, "del"))
11316 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11317 RTE_ETH_FILTER_DELETE, &entry);
11319 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11320 RTE_ETH_FILTER_UPDATE, &entry);
11322 printf("flow director programming error: (%s)\n",
11326 cmdline_parse_token_string_t cmd_flow_director_filter =
11327 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11328 flow_director_filter, "flow_director_filter");
11329 cmdline_parse_token_num_t cmd_flow_director_port_id =
11330 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11332 cmdline_parse_token_string_t cmd_flow_director_ops =
11333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11334 ops, "add#del#update");
11335 cmdline_parse_token_string_t cmd_flow_director_flow =
11336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11338 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11341 cmdline_parse_token_string_t cmd_flow_director_ether =
11342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11344 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11345 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11346 ether_type, UINT16);
11347 cmdline_parse_token_string_t cmd_flow_director_src =
11348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11350 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11351 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11353 cmdline_parse_token_num_t cmd_flow_director_port_src =
11354 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11356 cmdline_parse_token_string_t cmd_flow_director_dst =
11357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11359 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11360 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11362 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11363 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11365 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11366 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11367 verify_tag, "verify_tag");
11368 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11369 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11370 verify_tag_value, UINT32);
11371 cmdline_parse_token_string_t cmd_flow_director_tos =
11372 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11374 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11375 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11377 cmdline_parse_token_string_t cmd_flow_director_proto =
11378 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11380 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11381 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11382 proto_value, UINT8);
11383 cmdline_parse_token_string_t cmd_flow_director_ttl =
11384 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11386 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11387 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11389 cmdline_parse_token_string_t cmd_flow_director_vlan =
11390 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11392 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11393 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11394 vlan_value, UINT16);
11395 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11396 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11397 flexbytes, "flexbytes");
11398 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11400 flexbytes_value, NULL);
11401 cmdline_parse_token_string_t cmd_flow_director_drop =
11402 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11404 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11407 cmdline_parse_token_string_t cmd_flow_director_queue =
11408 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11410 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11411 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11413 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11414 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11416 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11417 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11418 fd_id_value, UINT32);
11420 cmdline_parse_token_string_t cmd_flow_director_mode =
11421 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11423 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11426 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11427 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11428 mode_value, "MAC-VLAN");
11429 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11431 mode_value, "Tunnel");
11432 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11433 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11434 mode_value, "raw");
11435 cmdline_parse_token_string_t cmd_flow_director_mac =
11436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11438 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11439 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11441 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11444 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11445 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11446 tunnel_type, "NVGRE#VxLAN");
11447 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11448 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11449 tunnel_id, "tunnel-id");
11450 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11451 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11452 tunnel_id_value, UINT32);
11453 cmdline_parse_token_string_t cmd_flow_director_packet =
11454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11456 cmdline_parse_token_string_t cmd_flow_director_filepath =
11457 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11460 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11461 .f = cmd_flow_director_filter_parsed,
11463 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11464 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11465 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11466 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11467 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11468 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11469 "fd_id <fd_id_value>: "
11470 "Add or delete an ip flow director entry on NIC",
11472 (void *)&cmd_flow_director_filter,
11473 (void *)&cmd_flow_director_port_id,
11474 (void *)&cmd_flow_director_mode,
11475 (void *)&cmd_flow_director_mode_ip,
11476 (void *)&cmd_flow_director_ops,
11477 (void *)&cmd_flow_director_flow,
11478 (void *)&cmd_flow_director_flow_type,
11479 (void *)&cmd_flow_director_src,
11480 (void *)&cmd_flow_director_ip_src,
11481 (void *)&cmd_flow_director_dst,
11482 (void *)&cmd_flow_director_ip_dst,
11483 (void *)&cmd_flow_director_tos,
11484 (void *)&cmd_flow_director_tos_value,
11485 (void *)&cmd_flow_director_proto,
11486 (void *)&cmd_flow_director_proto_value,
11487 (void *)&cmd_flow_director_ttl,
11488 (void *)&cmd_flow_director_ttl_value,
11489 (void *)&cmd_flow_director_vlan,
11490 (void *)&cmd_flow_director_vlan_value,
11491 (void *)&cmd_flow_director_flexbytes,
11492 (void *)&cmd_flow_director_flexbytes_value,
11493 (void *)&cmd_flow_director_drop,
11494 (void *)&cmd_flow_director_pf_vf,
11495 (void *)&cmd_flow_director_queue,
11496 (void *)&cmd_flow_director_queue_id,
11497 (void *)&cmd_flow_director_fd_id,
11498 (void *)&cmd_flow_director_fd_id_value,
11503 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11504 .f = cmd_flow_director_filter_parsed,
11506 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11507 "director entry on NIC",
11509 (void *)&cmd_flow_director_filter,
11510 (void *)&cmd_flow_director_port_id,
11511 (void *)&cmd_flow_director_mode,
11512 (void *)&cmd_flow_director_mode_ip,
11513 (void *)&cmd_flow_director_ops,
11514 (void *)&cmd_flow_director_flow,
11515 (void *)&cmd_flow_director_flow_type,
11516 (void *)&cmd_flow_director_src,
11517 (void *)&cmd_flow_director_ip_src,
11518 (void *)&cmd_flow_director_port_src,
11519 (void *)&cmd_flow_director_dst,
11520 (void *)&cmd_flow_director_ip_dst,
11521 (void *)&cmd_flow_director_port_dst,
11522 (void *)&cmd_flow_director_tos,
11523 (void *)&cmd_flow_director_tos_value,
11524 (void *)&cmd_flow_director_ttl,
11525 (void *)&cmd_flow_director_ttl_value,
11526 (void *)&cmd_flow_director_vlan,
11527 (void *)&cmd_flow_director_vlan_value,
11528 (void *)&cmd_flow_director_flexbytes,
11529 (void *)&cmd_flow_director_flexbytes_value,
11530 (void *)&cmd_flow_director_drop,
11531 (void *)&cmd_flow_director_pf_vf,
11532 (void *)&cmd_flow_director_queue,
11533 (void *)&cmd_flow_director_queue_id,
11534 (void *)&cmd_flow_director_fd_id,
11535 (void *)&cmd_flow_director_fd_id_value,
11540 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11541 .f = cmd_flow_director_filter_parsed,
11543 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11544 "director entry on NIC",
11546 (void *)&cmd_flow_director_filter,
11547 (void *)&cmd_flow_director_port_id,
11548 (void *)&cmd_flow_director_mode,
11549 (void *)&cmd_flow_director_mode_ip,
11550 (void *)&cmd_flow_director_ops,
11551 (void *)&cmd_flow_director_flow,
11552 (void *)&cmd_flow_director_flow_type,
11553 (void *)&cmd_flow_director_src,
11554 (void *)&cmd_flow_director_ip_src,
11555 (void *)&cmd_flow_director_port_src,
11556 (void *)&cmd_flow_director_dst,
11557 (void *)&cmd_flow_director_ip_dst,
11558 (void *)&cmd_flow_director_port_dst,
11559 (void *)&cmd_flow_director_verify_tag,
11560 (void *)&cmd_flow_director_verify_tag_value,
11561 (void *)&cmd_flow_director_tos,
11562 (void *)&cmd_flow_director_tos_value,
11563 (void *)&cmd_flow_director_ttl,
11564 (void *)&cmd_flow_director_ttl_value,
11565 (void *)&cmd_flow_director_vlan,
11566 (void *)&cmd_flow_director_vlan_value,
11567 (void *)&cmd_flow_director_flexbytes,
11568 (void *)&cmd_flow_director_flexbytes_value,
11569 (void *)&cmd_flow_director_drop,
11570 (void *)&cmd_flow_director_pf_vf,
11571 (void *)&cmd_flow_director_queue,
11572 (void *)&cmd_flow_director_queue_id,
11573 (void *)&cmd_flow_director_fd_id,
11574 (void *)&cmd_flow_director_fd_id_value,
11579 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11580 .f = cmd_flow_director_filter_parsed,
11582 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11583 "director entry on NIC",
11585 (void *)&cmd_flow_director_filter,
11586 (void *)&cmd_flow_director_port_id,
11587 (void *)&cmd_flow_director_mode,
11588 (void *)&cmd_flow_director_mode_ip,
11589 (void *)&cmd_flow_director_ops,
11590 (void *)&cmd_flow_director_flow,
11591 (void *)&cmd_flow_director_flow_type,
11592 (void *)&cmd_flow_director_ether,
11593 (void *)&cmd_flow_director_ether_type,
11594 (void *)&cmd_flow_director_flexbytes,
11595 (void *)&cmd_flow_director_flexbytes_value,
11596 (void *)&cmd_flow_director_drop,
11597 (void *)&cmd_flow_director_pf_vf,
11598 (void *)&cmd_flow_director_queue,
11599 (void *)&cmd_flow_director_queue_id,
11600 (void *)&cmd_flow_director_fd_id,
11601 (void *)&cmd_flow_director_fd_id_value,
11606 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11607 .f = cmd_flow_director_filter_parsed,
11609 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11610 "director entry on NIC",
11612 (void *)&cmd_flow_director_filter,
11613 (void *)&cmd_flow_director_port_id,
11614 (void *)&cmd_flow_director_mode,
11615 (void *)&cmd_flow_director_mode_mac_vlan,
11616 (void *)&cmd_flow_director_ops,
11617 (void *)&cmd_flow_director_mac,
11618 (void *)&cmd_flow_director_mac_addr,
11619 (void *)&cmd_flow_director_vlan,
11620 (void *)&cmd_flow_director_vlan_value,
11621 (void *)&cmd_flow_director_flexbytes,
11622 (void *)&cmd_flow_director_flexbytes_value,
11623 (void *)&cmd_flow_director_drop,
11624 (void *)&cmd_flow_director_queue,
11625 (void *)&cmd_flow_director_queue_id,
11626 (void *)&cmd_flow_director_fd_id,
11627 (void *)&cmd_flow_director_fd_id_value,
11632 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11633 .f = cmd_flow_director_filter_parsed,
11635 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11636 "director entry on NIC",
11638 (void *)&cmd_flow_director_filter,
11639 (void *)&cmd_flow_director_port_id,
11640 (void *)&cmd_flow_director_mode,
11641 (void *)&cmd_flow_director_mode_tunnel,
11642 (void *)&cmd_flow_director_ops,
11643 (void *)&cmd_flow_director_mac,
11644 (void *)&cmd_flow_director_mac_addr,
11645 (void *)&cmd_flow_director_vlan,
11646 (void *)&cmd_flow_director_vlan_value,
11647 (void *)&cmd_flow_director_tunnel,
11648 (void *)&cmd_flow_director_tunnel_type,
11649 (void *)&cmd_flow_director_tunnel_id,
11650 (void *)&cmd_flow_director_tunnel_id_value,
11651 (void *)&cmd_flow_director_flexbytes,
11652 (void *)&cmd_flow_director_flexbytes_value,
11653 (void *)&cmd_flow_director_drop,
11654 (void *)&cmd_flow_director_queue,
11655 (void *)&cmd_flow_director_queue_id,
11656 (void *)&cmd_flow_director_fd_id,
11657 (void *)&cmd_flow_director_fd_id_value,
11662 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11663 .f = cmd_flow_director_filter_parsed,
11665 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11666 "director entry on NIC",
11668 (void *)&cmd_flow_director_filter,
11669 (void *)&cmd_flow_director_port_id,
11670 (void *)&cmd_flow_director_mode,
11671 (void *)&cmd_flow_director_mode_raw,
11672 (void *)&cmd_flow_director_ops,
11673 (void *)&cmd_flow_director_flow,
11674 (void *)&cmd_flow_director_flow_type,
11675 (void *)&cmd_flow_director_drop,
11676 (void *)&cmd_flow_director_queue,
11677 (void *)&cmd_flow_director_queue_id,
11678 (void *)&cmd_flow_director_fd_id,
11679 (void *)&cmd_flow_director_fd_id_value,
11680 (void *)&cmd_flow_director_packet,
11681 (void *)&cmd_flow_director_filepath,
11686 struct cmd_flush_flow_director_result {
11687 cmdline_fixed_string_t flush_flow_director;
11691 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11692 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11693 flush_flow_director, "flush_flow_director");
11694 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11695 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11699 cmd_flush_flow_director_parsed(void *parsed_result,
11700 __rte_unused struct cmdline *cl,
11701 __rte_unused void *data)
11703 struct cmd_flow_director_result *res = parsed_result;
11706 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11708 printf("flow director is not supported on port %u.\n",
11713 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11714 RTE_ETH_FILTER_FLUSH, NULL);
11716 printf("flow director table flushing error: (%s)\n",
11720 cmdline_parse_inst_t cmd_flush_flow_director = {
11721 .f = cmd_flush_flow_director_parsed,
11723 .help_str = "flush_flow_director <port_id>: "
11724 "Flush all flow director entries of a device on NIC",
11726 (void *)&cmd_flush_flow_director_flush,
11727 (void *)&cmd_flush_flow_director_port_id,
11732 /* *** deal with flow director mask *** */
11733 struct cmd_flow_director_mask_result {
11734 cmdline_fixed_string_t flow_director_mask;
11736 cmdline_fixed_string_t mode;
11737 cmdline_fixed_string_t mode_value;
11738 cmdline_fixed_string_t vlan;
11739 uint16_t vlan_mask;
11740 cmdline_fixed_string_t src_mask;
11741 cmdline_ipaddr_t ipv4_src;
11742 cmdline_ipaddr_t ipv6_src;
11744 cmdline_fixed_string_t dst_mask;
11745 cmdline_ipaddr_t ipv4_dst;
11746 cmdline_ipaddr_t ipv6_dst;
11748 cmdline_fixed_string_t mac;
11749 uint8_t mac_addr_byte_mask;
11750 cmdline_fixed_string_t tunnel_id;
11751 uint32_t tunnel_id_mask;
11752 cmdline_fixed_string_t tunnel_type;
11753 uint8_t tunnel_type_mask;
11757 cmd_flow_director_mask_parsed(void *parsed_result,
11758 __rte_unused struct cmdline *cl,
11759 __rte_unused void *data)
11761 struct cmd_flow_director_mask_result *res = parsed_result;
11762 struct rte_eth_fdir_masks *mask;
11763 struct rte_port *port;
11765 port = &ports[res->port_id];
11766 /** Check if the port is not started **/
11767 if (port->port_status != RTE_PORT_STOPPED) {
11768 printf("Please stop port %d first\n", res->port_id);
11772 mask = &port->dev_conf.fdir_conf.mask;
11774 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11775 if (strcmp(res->mode_value, "MAC-VLAN")) {
11776 printf("Please set mode to MAC-VLAN.\n");
11780 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11781 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11782 if (strcmp(res->mode_value, "Tunnel")) {
11783 printf("Please set mode to Tunnel.\n");
11787 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11788 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11789 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11790 mask->tunnel_type_mask = res->tunnel_type_mask;
11792 if (strcmp(res->mode_value, "IP")) {
11793 printf("Please set mode to IP.\n");
11797 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11798 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11799 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11800 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11801 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11802 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11803 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11806 cmd_reconfig_device_queue(res->port_id, 1, 1);
11809 cmdline_parse_token_string_t cmd_flow_director_mask =
11810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11811 flow_director_mask, "flow_director_mask");
11812 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11813 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11815 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11816 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11818 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11819 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11820 vlan_mask, UINT16);
11821 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11822 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11823 src_mask, "src_mask");
11824 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11825 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11827 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11828 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11830 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11831 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11833 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11835 dst_mask, "dst_mask");
11836 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11837 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11839 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11840 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11842 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11843 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11846 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11847 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11849 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11850 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11852 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11854 mode_value, "MAC-VLAN");
11855 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11857 mode_value, "Tunnel");
11858 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11859 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11861 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11862 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11863 mac_addr_byte_mask, UINT8);
11864 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11866 tunnel_type, "tunnel-type");
11867 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11868 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11869 tunnel_type_mask, UINT8);
11870 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11872 tunnel_id, "tunnel-id");
11873 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11874 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11875 tunnel_id_mask, UINT32);
11877 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11878 .f = cmd_flow_director_mask_parsed,
11880 .help_str = "flow_director_mask ... : "
11881 "Set IP mode flow director's mask on NIC",
11883 (void *)&cmd_flow_director_mask,
11884 (void *)&cmd_flow_director_mask_port_id,
11885 (void *)&cmd_flow_director_mask_mode,
11886 (void *)&cmd_flow_director_mask_mode_ip,
11887 (void *)&cmd_flow_director_mask_vlan,
11888 (void *)&cmd_flow_director_mask_vlan_value,
11889 (void *)&cmd_flow_director_mask_src,
11890 (void *)&cmd_flow_director_mask_ipv4_src,
11891 (void *)&cmd_flow_director_mask_ipv6_src,
11892 (void *)&cmd_flow_director_mask_port_src,
11893 (void *)&cmd_flow_director_mask_dst,
11894 (void *)&cmd_flow_director_mask_ipv4_dst,
11895 (void *)&cmd_flow_director_mask_ipv6_dst,
11896 (void *)&cmd_flow_director_mask_port_dst,
11901 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11902 .f = cmd_flow_director_mask_parsed,
11904 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11905 "flow director's mask on NIC",
11907 (void *)&cmd_flow_director_mask,
11908 (void *)&cmd_flow_director_mask_port_id,
11909 (void *)&cmd_flow_director_mask_mode,
11910 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11911 (void *)&cmd_flow_director_mask_vlan,
11912 (void *)&cmd_flow_director_mask_vlan_value,
11917 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11918 .f = cmd_flow_director_mask_parsed,
11920 .help_str = "flow_director_mask ... : Set tunnel mode "
11921 "flow director's mask on NIC",
11923 (void *)&cmd_flow_director_mask,
11924 (void *)&cmd_flow_director_mask_port_id,
11925 (void *)&cmd_flow_director_mask_mode,
11926 (void *)&cmd_flow_director_mask_mode_tunnel,
11927 (void *)&cmd_flow_director_mask_vlan,
11928 (void *)&cmd_flow_director_mask_vlan_value,
11929 (void *)&cmd_flow_director_mask_mac,
11930 (void *)&cmd_flow_director_mask_mac_value,
11931 (void *)&cmd_flow_director_mask_tunnel_type,
11932 (void *)&cmd_flow_director_mask_tunnel_type_value,
11933 (void *)&cmd_flow_director_mask_tunnel_id,
11934 (void *)&cmd_flow_director_mask_tunnel_id_value,
11939 /* *** deal with flow director mask on flexible payload *** */
11940 struct cmd_flow_director_flex_mask_result {
11941 cmdline_fixed_string_t flow_director_flexmask;
11943 cmdline_fixed_string_t flow;
11944 cmdline_fixed_string_t flow_type;
11945 cmdline_fixed_string_t mask;
11949 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11950 __rte_unused struct cmdline *cl,
11951 __rte_unused void *data)
11953 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11954 struct rte_eth_fdir_info fdir_info;
11955 struct rte_eth_fdir_flex_mask flex_mask;
11956 struct rte_port *port;
11957 uint64_t flow_type_mask;
11961 port = &ports[res->port_id];
11962 /** Check if the port is not started **/
11963 if (port->port_status != RTE_PORT_STOPPED) {
11964 printf("Please stop port %d first\n", res->port_id);
11968 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11969 ret = parse_flexbytes(res->mask,
11971 RTE_ETH_FDIR_MAX_FLEXLEN);
11973 printf("error: Cannot parse mask input.\n");
11977 memset(&fdir_info, 0, sizeof(fdir_info));
11978 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11979 RTE_ETH_FILTER_INFO, &fdir_info);
11981 printf("Cannot get FDir filter info\n");
11985 if (!strcmp(res->flow_type, "none")) {
11986 /* means don't specify the flow type */
11987 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11988 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11989 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11990 0, sizeof(struct rte_eth_fdir_flex_mask));
11991 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11992 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11994 sizeof(struct rte_eth_fdir_flex_mask));
11995 cmd_reconfig_device_queue(res->port_id, 1, 1);
11998 flow_type_mask = fdir_info.flow_types_mask[0];
11999 if (!strcmp(res->flow_type, "all")) {
12000 if (!flow_type_mask) {
12001 printf("No flow type supported\n");
12004 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12005 if (flow_type_mask & (1ULL << i)) {
12006 flex_mask.flow_type = i;
12007 fdir_set_flex_mask(res->port_id, &flex_mask);
12010 cmd_reconfig_device_queue(res->port_id, 1, 1);
12013 flex_mask.flow_type = str2flowtype(res->flow_type);
12014 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12015 printf("Flow type %s not supported on port %d\n",
12016 res->flow_type, res->port_id);
12019 fdir_set_flex_mask(res->port_id, &flex_mask);
12020 cmd_reconfig_device_queue(res->port_id, 1, 1);
12023 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12024 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12025 flow_director_flexmask,
12026 "flow_director_flex_mask");
12027 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12028 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12030 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12031 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12033 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12034 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12035 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12036 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12037 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12038 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12041 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12042 .f = cmd_flow_director_flex_mask_parsed,
12044 .help_str = "flow_director_flex_mask ... : "
12045 "Set flow director's flex mask on NIC",
12047 (void *)&cmd_flow_director_flexmask,
12048 (void *)&cmd_flow_director_flexmask_port_id,
12049 (void *)&cmd_flow_director_flexmask_flow,
12050 (void *)&cmd_flow_director_flexmask_flow_type,
12051 (void *)&cmd_flow_director_flexmask_mask,
12056 /* *** deal with flow director flexible payload configuration *** */
12057 struct cmd_flow_director_flexpayload_result {
12058 cmdline_fixed_string_t flow_director_flexpayload;
12060 cmdline_fixed_string_t payload_layer;
12061 cmdline_fixed_string_t payload_cfg;
12065 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12068 const char *p, *p0 = q_arg;
12070 unsigned long int_fld;
12071 char *str_fld[max_num];
12076 p = strchr(p0, '(');
12080 p0 = strchr(p, ')');
12085 if (size >= sizeof(s))
12088 snprintf(s, sizeof(s), "%.*s", size, p);
12089 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12090 if (ret < 0 || ret > max_num)
12092 for (i = 0; i < ret; i++) {
12094 int_fld = strtoul(str_fld[i], &end, 0);
12095 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12097 offsets[i] = (uint16_t)int_fld;
12103 cmd_flow_director_flxpld_parsed(void *parsed_result,
12104 __rte_unused struct cmdline *cl,
12105 __rte_unused void *data)
12107 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12108 struct rte_eth_flex_payload_cfg flex_cfg;
12109 struct rte_port *port;
12112 port = &ports[res->port_id];
12113 /** Check if the port is not started **/
12114 if (port->port_status != RTE_PORT_STOPPED) {
12115 printf("Please stop port %d first\n", res->port_id);
12119 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12121 if (!strcmp(res->payload_layer, "raw"))
12122 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12123 else if (!strcmp(res->payload_layer, "l2"))
12124 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12125 else if (!strcmp(res->payload_layer, "l3"))
12126 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12127 else if (!strcmp(res->payload_layer, "l4"))
12128 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12130 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12131 RTE_ETH_FDIR_MAX_FLEXLEN);
12133 printf("error: Cannot parse flex payload input.\n");
12137 fdir_set_flex_payload(res->port_id, &flex_cfg);
12138 cmd_reconfig_device_queue(res->port_id, 1, 1);
12141 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12142 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12143 flow_director_flexpayload,
12144 "flow_director_flex_payload");
12145 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12146 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12148 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12150 payload_layer, "raw#l2#l3#l4");
12151 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12153 payload_cfg, NULL);
12155 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12156 .f = cmd_flow_director_flxpld_parsed,
12158 .help_str = "flow_director_flexpayload ... : "
12159 "Set flow director's flex payload on NIC",
12161 (void *)&cmd_flow_director_flexpayload,
12162 (void *)&cmd_flow_director_flexpayload_port_id,
12163 (void *)&cmd_flow_director_flexpayload_payload_layer,
12164 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12169 /* Generic flow interface command. */
12170 extern cmdline_parse_inst_t cmd_flow;
12172 /* *** Classification Filters Control *** */
12173 /* *** Get symmetric hash enable per port *** */
12174 struct cmd_get_sym_hash_ena_per_port_result {
12175 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12180 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12181 __rte_unused struct cmdline *cl,
12182 __rte_unused void *data)
12184 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12185 struct rte_eth_hash_filter_info info;
12188 if (rte_eth_dev_filter_supported(res->port_id,
12189 RTE_ETH_FILTER_HASH) < 0) {
12190 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12195 memset(&info, 0, sizeof(info));
12196 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12197 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12198 RTE_ETH_FILTER_GET, &info);
12201 printf("Cannot get symmetric hash enable per port "
12202 "on port %u\n", res->port_id);
12206 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12207 "enabled" : "disabled", res->port_id);
12210 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12211 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12212 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12213 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12214 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12217 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12218 .f = cmd_get_sym_hash_per_port_parsed,
12220 .help_str = "get_sym_hash_ena_per_port <port_id>",
12222 (void *)&cmd_get_sym_hash_ena_per_port_all,
12223 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12228 /* *** Set symmetric hash enable per port *** */
12229 struct cmd_set_sym_hash_ena_per_port_result {
12230 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12231 cmdline_fixed_string_t enable;
12236 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12237 __rte_unused struct cmdline *cl,
12238 __rte_unused void *data)
12240 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12241 struct rte_eth_hash_filter_info info;
12244 if (rte_eth_dev_filter_supported(res->port_id,
12245 RTE_ETH_FILTER_HASH) < 0) {
12246 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12251 memset(&info, 0, sizeof(info));
12252 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12253 if (!strcmp(res->enable, "enable"))
12254 info.info.enable = 1;
12255 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12256 RTE_ETH_FILTER_SET, &info);
12258 printf("Cannot set symmetric hash enable per port on "
12259 "port %u\n", res->port_id);
12262 printf("Symmetric hash has been set to %s on port %u\n",
12263 res->enable, res->port_id);
12266 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12267 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12268 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12269 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12270 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12272 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12273 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12274 enable, "enable#disable");
12276 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12277 .f = cmd_set_sym_hash_per_port_parsed,
12279 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12281 (void *)&cmd_set_sym_hash_ena_per_port_all,
12282 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12283 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12288 /* Get global config of hash function */
12289 struct cmd_get_hash_global_config_result {
12290 cmdline_fixed_string_t get_hash_global_config;
12295 flowtype_to_str(uint16_t ftype)
12301 } ftype_table[] = {
12302 {"ipv4", RTE_ETH_FLOW_IPV4},
12303 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12304 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12305 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12306 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12307 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12308 {"ipv6", RTE_ETH_FLOW_IPV6},
12309 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12310 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12311 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12312 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12313 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12314 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12315 {"port", RTE_ETH_FLOW_PORT},
12316 {"vxlan", RTE_ETH_FLOW_VXLAN},
12317 {"geneve", RTE_ETH_FLOW_GENEVE},
12318 {"nvgre", RTE_ETH_FLOW_NVGRE},
12319 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12322 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12323 if (ftype_table[i].ftype == ftype)
12324 return ftype_table[i].str;
12331 cmd_get_hash_global_config_parsed(void *parsed_result,
12332 __rte_unused struct cmdline *cl,
12333 __rte_unused void *data)
12335 struct cmd_get_hash_global_config_result *res = parsed_result;
12336 struct rte_eth_hash_filter_info info;
12337 uint32_t idx, offset;
12342 if (rte_eth_dev_filter_supported(res->port_id,
12343 RTE_ETH_FILTER_HASH) < 0) {
12344 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12349 memset(&info, 0, sizeof(info));
12350 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12351 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12352 RTE_ETH_FILTER_GET, &info);
12354 printf("Cannot get hash global configurations by port %d\n",
12359 switch (info.info.global_conf.hash_func) {
12360 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12361 printf("Hash function is Toeplitz\n");
12363 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12364 printf("Hash function is Simple XOR\n");
12366 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12367 printf("Hash function is Symmetric Toeplitz\n");
12370 printf("Unknown hash function\n");
12374 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12375 idx = i / UINT64_BIT;
12376 offset = i % UINT64_BIT;
12377 if (!(info.info.global_conf.valid_bit_mask[idx] &
12380 str = flowtype_to_str(i);
12383 printf("Symmetric hash is %s globally for flow type %s "
12385 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12386 (1ULL << offset)) ? "enabled" : "disabled"), str,
12391 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12392 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12393 get_hash_global_config, "get_hash_global_config");
12394 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12395 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12398 cmdline_parse_inst_t cmd_get_hash_global_config = {
12399 .f = cmd_get_hash_global_config_parsed,
12401 .help_str = "get_hash_global_config <port_id>",
12403 (void *)&cmd_get_hash_global_config_all,
12404 (void *)&cmd_get_hash_global_config_port_id,
12409 /* Set global config of hash function */
12410 struct cmd_set_hash_global_config_result {
12411 cmdline_fixed_string_t set_hash_global_config;
12413 cmdline_fixed_string_t hash_func;
12414 cmdline_fixed_string_t flow_type;
12415 cmdline_fixed_string_t enable;
12419 cmd_set_hash_global_config_parsed(void *parsed_result,
12420 __rte_unused struct cmdline *cl,
12421 __rte_unused void *data)
12423 struct cmd_set_hash_global_config_result *res = parsed_result;
12424 struct rte_eth_hash_filter_info info;
12425 uint32_t ftype, idx, offset;
12428 if (rte_eth_dev_filter_supported(res->port_id,
12429 RTE_ETH_FILTER_HASH) < 0) {
12430 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12434 memset(&info, 0, sizeof(info));
12435 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12436 if (!strcmp(res->hash_func, "toeplitz"))
12437 info.info.global_conf.hash_func =
12438 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12439 else if (!strcmp(res->hash_func, "simple_xor"))
12440 info.info.global_conf.hash_func =
12441 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12442 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12443 info.info.global_conf.hash_func =
12444 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12445 else if (!strcmp(res->hash_func, "default"))
12446 info.info.global_conf.hash_func =
12447 RTE_ETH_HASH_FUNCTION_DEFAULT;
12449 ftype = str2flowtype(res->flow_type);
12450 idx = ftype / UINT64_BIT;
12451 offset = ftype % UINT64_BIT;
12452 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12453 if (!strcmp(res->enable, "enable"))
12454 info.info.global_conf.sym_hash_enable_mask[idx] |=
12456 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12457 RTE_ETH_FILTER_SET, &info);
12459 printf("Cannot set global hash configurations by port %d\n",
12462 printf("Global hash configurations have been set "
12463 "successfully by port %d\n", res->port_id);
12466 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12467 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12468 set_hash_global_config, "set_hash_global_config");
12469 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12470 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12472 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12473 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12474 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12475 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12476 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12478 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12479 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12480 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12481 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12482 enable, "enable#disable");
12484 cmdline_parse_inst_t cmd_set_hash_global_config = {
12485 .f = cmd_set_hash_global_config_parsed,
12487 .help_str = "set_hash_global_config <port_id> "
12488 "toeplitz|simple_xor|symmetric_toeplitz|default "
12489 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12490 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12491 "l2_payload enable|disable",
12493 (void *)&cmd_set_hash_global_config_all,
12494 (void *)&cmd_set_hash_global_config_port_id,
12495 (void *)&cmd_set_hash_global_config_hash_func,
12496 (void *)&cmd_set_hash_global_config_flow_type,
12497 (void *)&cmd_set_hash_global_config_enable,
12502 /* Set hash input set */
12503 struct cmd_set_hash_input_set_result {
12504 cmdline_fixed_string_t set_hash_input_set;
12506 cmdline_fixed_string_t flow_type;
12507 cmdline_fixed_string_t inset_field;
12508 cmdline_fixed_string_t select;
12511 static enum rte_eth_input_set_field
12512 str2inset(char *string)
12516 static const struct {
12518 enum rte_eth_input_set_field inset;
12519 } inset_table[] = {
12520 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12521 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12522 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12523 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12524 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12525 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12526 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12527 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12528 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12529 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12530 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12531 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12532 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12533 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12534 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12535 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12536 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12537 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12538 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12539 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12540 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12541 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12542 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12543 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12544 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12545 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12546 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12547 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12548 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12549 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12550 {"none", RTE_ETH_INPUT_SET_NONE},
12553 for (i = 0; i < RTE_DIM(inset_table); i++) {
12554 if (!strcmp(string, inset_table[i].str))
12555 return inset_table[i].inset;
12558 return RTE_ETH_INPUT_SET_UNKNOWN;
12562 cmd_set_hash_input_set_parsed(void *parsed_result,
12563 __rte_unused struct cmdline *cl,
12564 __rte_unused void *data)
12566 struct cmd_set_hash_input_set_result *res = parsed_result;
12567 struct rte_eth_hash_filter_info info;
12569 memset(&info, 0, sizeof(info));
12570 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12571 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12572 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12573 info.info.input_set_conf.inset_size = 1;
12574 if (!strcmp(res->select, "select"))
12575 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12576 else if (!strcmp(res->select, "add"))
12577 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12578 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12579 RTE_ETH_FILTER_SET, &info);
12582 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12583 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12584 set_hash_input_set, "set_hash_input_set");
12585 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12586 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12588 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12589 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12591 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12592 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12594 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12595 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12596 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12597 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12598 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12600 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12601 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12602 select, "select#add");
12604 cmdline_parse_inst_t cmd_set_hash_input_set = {
12605 .f = cmd_set_hash_input_set_parsed,
12607 .help_str = "set_hash_input_set <port_id> "
12608 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12609 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12610 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12611 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12612 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12613 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12614 "fld-7th|fld-8th|none select|add",
12616 (void *)&cmd_set_hash_input_set_cmd,
12617 (void *)&cmd_set_hash_input_set_port_id,
12618 (void *)&cmd_set_hash_input_set_flow_type,
12619 (void *)&cmd_set_hash_input_set_field,
12620 (void *)&cmd_set_hash_input_set_select,
12625 /* Set flow director input set */
12626 struct cmd_set_fdir_input_set_result {
12627 cmdline_fixed_string_t set_fdir_input_set;
12629 cmdline_fixed_string_t flow_type;
12630 cmdline_fixed_string_t inset_field;
12631 cmdline_fixed_string_t select;
12635 cmd_set_fdir_input_set_parsed(void *parsed_result,
12636 __rte_unused struct cmdline *cl,
12637 __rte_unused void *data)
12639 struct cmd_set_fdir_input_set_result *res = parsed_result;
12640 struct rte_eth_fdir_filter_info info;
12642 memset(&info, 0, sizeof(info));
12643 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12644 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12645 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12646 info.info.input_set_conf.inset_size = 1;
12647 if (!strcmp(res->select, "select"))
12648 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12649 else if (!strcmp(res->select, "add"))
12650 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12651 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12652 RTE_ETH_FILTER_SET, &info);
12655 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12656 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12657 set_fdir_input_set, "set_fdir_input_set");
12658 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12659 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12661 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12662 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12664 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12665 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12666 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12667 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12669 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12670 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12671 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12672 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12673 "sctp-veri-tag#none");
12674 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12675 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12676 select, "select#add");
12678 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12679 .f = cmd_set_fdir_input_set_parsed,
12681 .help_str = "set_fdir_input_set <port_id> "
12682 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12683 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12684 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12685 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12686 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12687 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12688 "sctp-veri-tag|none select|add",
12690 (void *)&cmd_set_fdir_input_set_cmd,
12691 (void *)&cmd_set_fdir_input_set_port_id,
12692 (void *)&cmd_set_fdir_input_set_flow_type,
12693 (void *)&cmd_set_fdir_input_set_field,
12694 (void *)&cmd_set_fdir_input_set_select,
12699 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12700 struct cmd_mcast_addr_result {
12701 cmdline_fixed_string_t mcast_addr_cmd;
12702 cmdline_fixed_string_t what;
12704 struct rte_ether_addr mc_addr;
12707 static void cmd_mcast_addr_parsed(void *parsed_result,
12708 __rte_unused struct cmdline *cl,
12709 __rte_unused void *data)
12711 struct cmd_mcast_addr_result *res = parsed_result;
12713 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12714 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12715 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12716 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12717 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12720 if (strcmp(res->what, "add") == 0)
12721 mcast_addr_add(res->port_num, &res->mc_addr);
12723 mcast_addr_remove(res->port_num, &res->mc_addr);
12726 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12727 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12728 mcast_addr_cmd, "mcast_addr");
12729 cmdline_parse_token_string_t cmd_mcast_addr_what =
12730 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12732 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12733 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12734 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12735 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12737 cmdline_parse_inst_t cmd_mcast_addr = {
12738 .f = cmd_mcast_addr_parsed,
12740 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12741 "Add/Remove multicast MAC address on port_id",
12743 (void *)&cmd_mcast_addr_cmd,
12744 (void *)&cmd_mcast_addr_what,
12745 (void *)&cmd_mcast_addr_portnum,
12746 (void *)&cmd_mcast_addr_addr,
12751 /* l2 tunnel config
12752 * only support E-tag now.
12755 /* Ether type config */
12756 struct cmd_config_l2_tunnel_eth_type_result {
12757 cmdline_fixed_string_t port;
12758 cmdline_fixed_string_t config;
12759 cmdline_fixed_string_t all;
12761 cmdline_fixed_string_t l2_tunnel;
12762 cmdline_fixed_string_t l2_tunnel_type;
12763 cmdline_fixed_string_t eth_type;
12764 uint16_t eth_type_val;
12767 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12768 TOKEN_STRING_INITIALIZER
12769 (struct cmd_config_l2_tunnel_eth_type_result,
12771 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12772 TOKEN_STRING_INITIALIZER
12773 (struct cmd_config_l2_tunnel_eth_type_result,
12775 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12776 TOKEN_STRING_INITIALIZER
12777 (struct cmd_config_l2_tunnel_eth_type_result,
12779 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12780 TOKEN_NUM_INITIALIZER
12781 (struct cmd_config_l2_tunnel_eth_type_result,
12783 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12784 TOKEN_STRING_INITIALIZER
12785 (struct cmd_config_l2_tunnel_eth_type_result,
12786 l2_tunnel, "l2-tunnel");
12787 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12788 TOKEN_STRING_INITIALIZER
12789 (struct cmd_config_l2_tunnel_eth_type_result,
12790 l2_tunnel_type, "E-tag");
12791 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12792 TOKEN_STRING_INITIALIZER
12793 (struct cmd_config_l2_tunnel_eth_type_result,
12794 eth_type, "ether-type");
12795 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12796 TOKEN_NUM_INITIALIZER
12797 (struct cmd_config_l2_tunnel_eth_type_result,
12798 eth_type_val, UINT16);
12800 static enum rte_eth_tunnel_type
12801 str2fdir_l2_tunnel_type(char *string)
12805 static const struct {
12807 enum rte_eth_tunnel_type type;
12808 } l2_tunnel_type_str[] = {
12809 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12812 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12813 if (!strcmp(l2_tunnel_type_str[i].str, string))
12814 return l2_tunnel_type_str[i].type;
12816 return RTE_TUNNEL_TYPE_NONE;
12819 /* ether type config for all ports */
12821 cmd_config_l2_tunnel_eth_type_all_parsed
12822 (void *parsed_result,
12823 __rte_unused struct cmdline *cl,
12824 __rte_unused void *data)
12826 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12827 struct rte_eth_l2_tunnel_conf entry;
12830 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12831 entry.ether_type = res->eth_type_val;
12833 RTE_ETH_FOREACH_DEV(pid) {
12834 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12838 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12839 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12841 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12843 (void *)&cmd_config_l2_tunnel_eth_type_port,
12844 (void *)&cmd_config_l2_tunnel_eth_type_config,
12845 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12846 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12847 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12848 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12849 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12854 /* ether type config for a specific port */
12856 cmd_config_l2_tunnel_eth_type_specific_parsed(
12857 void *parsed_result,
12858 __rte_unused struct cmdline *cl,
12859 __rte_unused void *data)
12861 struct cmd_config_l2_tunnel_eth_type_result *res =
12863 struct rte_eth_l2_tunnel_conf entry;
12865 if (port_id_is_invalid(res->id, ENABLED_WARN))
12868 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12869 entry.ether_type = res->eth_type_val;
12871 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12874 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12875 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12877 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12879 (void *)&cmd_config_l2_tunnel_eth_type_port,
12880 (void *)&cmd_config_l2_tunnel_eth_type_config,
12881 (void *)&cmd_config_l2_tunnel_eth_type_id,
12882 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12883 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12884 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12885 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12890 /* Enable/disable l2 tunnel */
12891 struct cmd_config_l2_tunnel_en_dis_result {
12892 cmdline_fixed_string_t port;
12893 cmdline_fixed_string_t config;
12894 cmdline_fixed_string_t all;
12896 cmdline_fixed_string_t l2_tunnel;
12897 cmdline_fixed_string_t l2_tunnel_type;
12898 cmdline_fixed_string_t en_dis;
12901 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12902 TOKEN_STRING_INITIALIZER
12903 (struct cmd_config_l2_tunnel_en_dis_result,
12905 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12906 TOKEN_STRING_INITIALIZER
12907 (struct cmd_config_l2_tunnel_en_dis_result,
12909 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12910 TOKEN_STRING_INITIALIZER
12911 (struct cmd_config_l2_tunnel_en_dis_result,
12913 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12914 TOKEN_NUM_INITIALIZER
12915 (struct cmd_config_l2_tunnel_en_dis_result,
12917 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12918 TOKEN_STRING_INITIALIZER
12919 (struct cmd_config_l2_tunnel_en_dis_result,
12920 l2_tunnel, "l2-tunnel");
12921 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12922 TOKEN_STRING_INITIALIZER
12923 (struct cmd_config_l2_tunnel_en_dis_result,
12924 l2_tunnel_type, "E-tag");
12925 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12926 TOKEN_STRING_INITIALIZER
12927 (struct cmd_config_l2_tunnel_en_dis_result,
12928 en_dis, "enable#disable");
12930 /* enable/disable l2 tunnel for all ports */
12932 cmd_config_l2_tunnel_en_dis_all_parsed(
12933 void *parsed_result,
12934 __rte_unused struct cmdline *cl,
12935 __rte_unused void *data)
12937 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12938 struct rte_eth_l2_tunnel_conf entry;
12942 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12944 if (!strcmp("enable", res->en_dis))
12949 RTE_ETH_FOREACH_DEV(pid) {
12950 rte_eth_dev_l2_tunnel_offload_set(pid,
12952 ETH_L2_TUNNEL_ENABLE_MASK,
12957 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12958 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12960 .help_str = "port config all l2-tunnel E-tag enable|disable",
12962 (void *)&cmd_config_l2_tunnel_en_dis_port,
12963 (void *)&cmd_config_l2_tunnel_en_dis_config,
12964 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12965 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12966 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12967 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12972 /* enable/disable l2 tunnel for a port */
12974 cmd_config_l2_tunnel_en_dis_specific_parsed(
12975 void *parsed_result,
12976 __rte_unused struct cmdline *cl,
12977 __rte_unused void *data)
12979 struct cmd_config_l2_tunnel_en_dis_result *res =
12981 struct rte_eth_l2_tunnel_conf entry;
12983 if (port_id_is_invalid(res->id, ENABLED_WARN))
12986 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12988 if (!strcmp("enable", res->en_dis))
12989 rte_eth_dev_l2_tunnel_offload_set(res->id,
12991 ETH_L2_TUNNEL_ENABLE_MASK,
12994 rte_eth_dev_l2_tunnel_offload_set(res->id,
12996 ETH_L2_TUNNEL_ENABLE_MASK,
13000 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13001 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13003 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13005 (void *)&cmd_config_l2_tunnel_en_dis_port,
13006 (void *)&cmd_config_l2_tunnel_en_dis_config,
13007 (void *)&cmd_config_l2_tunnel_en_dis_id,
13008 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13009 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13010 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13015 /* E-tag configuration */
13017 /* Common result structure for all E-tag configuration */
13018 struct cmd_config_e_tag_result {
13019 cmdline_fixed_string_t e_tag;
13020 cmdline_fixed_string_t set;
13021 cmdline_fixed_string_t insertion;
13022 cmdline_fixed_string_t stripping;
13023 cmdline_fixed_string_t forwarding;
13024 cmdline_fixed_string_t filter;
13025 cmdline_fixed_string_t add;
13026 cmdline_fixed_string_t del;
13027 cmdline_fixed_string_t on;
13028 cmdline_fixed_string_t off;
13029 cmdline_fixed_string_t on_off;
13030 cmdline_fixed_string_t port_tag_id;
13031 uint32_t port_tag_id_val;
13032 cmdline_fixed_string_t e_tag_id;
13033 uint16_t e_tag_id_val;
13034 cmdline_fixed_string_t dst_pool;
13035 uint8_t dst_pool_val;
13036 cmdline_fixed_string_t port;
13038 cmdline_fixed_string_t vf;
13042 /* Common CLI fields for all E-tag configuration */
13043 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13044 TOKEN_STRING_INITIALIZER
13045 (struct cmd_config_e_tag_result,
13047 cmdline_parse_token_string_t cmd_config_e_tag_set =
13048 TOKEN_STRING_INITIALIZER
13049 (struct cmd_config_e_tag_result,
13051 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13052 TOKEN_STRING_INITIALIZER
13053 (struct cmd_config_e_tag_result,
13054 insertion, "insertion");
13055 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13056 TOKEN_STRING_INITIALIZER
13057 (struct cmd_config_e_tag_result,
13058 stripping, "stripping");
13059 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13060 TOKEN_STRING_INITIALIZER
13061 (struct cmd_config_e_tag_result,
13062 forwarding, "forwarding");
13063 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13064 TOKEN_STRING_INITIALIZER
13065 (struct cmd_config_e_tag_result,
13067 cmdline_parse_token_string_t cmd_config_e_tag_add =
13068 TOKEN_STRING_INITIALIZER
13069 (struct cmd_config_e_tag_result,
13071 cmdline_parse_token_string_t cmd_config_e_tag_del =
13072 TOKEN_STRING_INITIALIZER
13073 (struct cmd_config_e_tag_result,
13075 cmdline_parse_token_string_t cmd_config_e_tag_on =
13076 TOKEN_STRING_INITIALIZER
13077 (struct cmd_config_e_tag_result,
13079 cmdline_parse_token_string_t cmd_config_e_tag_off =
13080 TOKEN_STRING_INITIALIZER
13081 (struct cmd_config_e_tag_result,
13083 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13084 TOKEN_STRING_INITIALIZER
13085 (struct cmd_config_e_tag_result,
13087 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13088 TOKEN_STRING_INITIALIZER
13089 (struct cmd_config_e_tag_result,
13090 port_tag_id, "port-tag-id");
13091 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13092 TOKEN_NUM_INITIALIZER
13093 (struct cmd_config_e_tag_result,
13094 port_tag_id_val, UINT32);
13095 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13096 TOKEN_STRING_INITIALIZER
13097 (struct cmd_config_e_tag_result,
13098 e_tag_id, "e-tag-id");
13099 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13100 TOKEN_NUM_INITIALIZER
13101 (struct cmd_config_e_tag_result,
13102 e_tag_id_val, UINT16);
13103 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13104 TOKEN_STRING_INITIALIZER
13105 (struct cmd_config_e_tag_result,
13106 dst_pool, "dst-pool");
13107 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13108 TOKEN_NUM_INITIALIZER
13109 (struct cmd_config_e_tag_result,
13110 dst_pool_val, UINT8);
13111 cmdline_parse_token_string_t cmd_config_e_tag_port =
13112 TOKEN_STRING_INITIALIZER
13113 (struct cmd_config_e_tag_result,
13115 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13116 TOKEN_NUM_INITIALIZER
13117 (struct cmd_config_e_tag_result,
13119 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13120 TOKEN_STRING_INITIALIZER
13121 (struct cmd_config_e_tag_result,
13123 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13124 TOKEN_NUM_INITIALIZER
13125 (struct cmd_config_e_tag_result,
13128 /* E-tag insertion configuration */
13130 cmd_config_e_tag_insertion_en_parsed(
13131 void *parsed_result,
13132 __rte_unused struct cmdline *cl,
13133 __rte_unused void *data)
13135 struct cmd_config_e_tag_result *res =
13137 struct rte_eth_l2_tunnel_conf entry;
13139 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13142 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13143 entry.tunnel_id = res->port_tag_id_val;
13144 entry.vf_id = res->vf_id;
13145 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13147 ETH_L2_TUNNEL_INSERTION_MASK,
13152 cmd_config_e_tag_insertion_dis_parsed(
13153 void *parsed_result,
13154 __rte_unused struct cmdline *cl,
13155 __rte_unused void *data)
13157 struct cmd_config_e_tag_result *res =
13159 struct rte_eth_l2_tunnel_conf entry;
13161 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13164 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13165 entry.vf_id = res->vf_id;
13167 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13169 ETH_L2_TUNNEL_INSERTION_MASK,
13173 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13174 .f = cmd_config_e_tag_insertion_en_parsed,
13176 .help_str = "E-tag ... : E-tag insertion enable",
13178 (void *)&cmd_config_e_tag_e_tag,
13179 (void *)&cmd_config_e_tag_set,
13180 (void *)&cmd_config_e_tag_insertion,
13181 (void *)&cmd_config_e_tag_on,
13182 (void *)&cmd_config_e_tag_port_tag_id,
13183 (void *)&cmd_config_e_tag_port_tag_id_val,
13184 (void *)&cmd_config_e_tag_port,
13185 (void *)&cmd_config_e_tag_port_id,
13186 (void *)&cmd_config_e_tag_vf,
13187 (void *)&cmd_config_e_tag_vf_id,
13192 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13193 .f = cmd_config_e_tag_insertion_dis_parsed,
13195 .help_str = "E-tag ... : E-tag insertion disable",
13197 (void *)&cmd_config_e_tag_e_tag,
13198 (void *)&cmd_config_e_tag_set,
13199 (void *)&cmd_config_e_tag_insertion,
13200 (void *)&cmd_config_e_tag_off,
13201 (void *)&cmd_config_e_tag_port,
13202 (void *)&cmd_config_e_tag_port_id,
13203 (void *)&cmd_config_e_tag_vf,
13204 (void *)&cmd_config_e_tag_vf_id,
13209 /* E-tag stripping configuration */
13211 cmd_config_e_tag_stripping_parsed(
13212 void *parsed_result,
13213 __rte_unused struct cmdline *cl,
13214 __rte_unused void *data)
13216 struct cmd_config_e_tag_result *res =
13218 struct rte_eth_l2_tunnel_conf entry;
13220 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13223 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13225 if (!strcmp(res->on_off, "on"))
13226 rte_eth_dev_l2_tunnel_offload_set
13229 ETH_L2_TUNNEL_STRIPPING_MASK,
13232 rte_eth_dev_l2_tunnel_offload_set
13235 ETH_L2_TUNNEL_STRIPPING_MASK,
13239 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13240 .f = cmd_config_e_tag_stripping_parsed,
13242 .help_str = "E-tag ... : E-tag stripping enable/disable",
13244 (void *)&cmd_config_e_tag_e_tag,
13245 (void *)&cmd_config_e_tag_set,
13246 (void *)&cmd_config_e_tag_stripping,
13247 (void *)&cmd_config_e_tag_on_off,
13248 (void *)&cmd_config_e_tag_port,
13249 (void *)&cmd_config_e_tag_port_id,
13254 /* E-tag forwarding configuration */
13256 cmd_config_e_tag_forwarding_parsed(
13257 void *parsed_result,
13258 __rte_unused struct cmdline *cl,
13259 __rte_unused void *data)
13261 struct cmd_config_e_tag_result *res = parsed_result;
13262 struct rte_eth_l2_tunnel_conf entry;
13264 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13267 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13269 if (!strcmp(res->on_off, "on"))
13270 rte_eth_dev_l2_tunnel_offload_set
13273 ETH_L2_TUNNEL_FORWARDING_MASK,
13276 rte_eth_dev_l2_tunnel_offload_set
13279 ETH_L2_TUNNEL_FORWARDING_MASK,
13283 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13284 .f = cmd_config_e_tag_forwarding_parsed,
13286 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13288 (void *)&cmd_config_e_tag_e_tag,
13289 (void *)&cmd_config_e_tag_set,
13290 (void *)&cmd_config_e_tag_forwarding,
13291 (void *)&cmd_config_e_tag_on_off,
13292 (void *)&cmd_config_e_tag_port,
13293 (void *)&cmd_config_e_tag_port_id,
13298 /* E-tag filter configuration */
13300 cmd_config_e_tag_filter_add_parsed(
13301 void *parsed_result,
13302 __rte_unused struct cmdline *cl,
13303 __rte_unused void *data)
13305 struct cmd_config_e_tag_result *res = parsed_result;
13306 struct rte_eth_l2_tunnel_conf entry;
13309 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13312 if (res->e_tag_id_val > 0x3fff) {
13313 printf("e-tag-id must be equal or less than 0x3fff.\n");
13317 ret = rte_eth_dev_filter_supported(res->port_id,
13318 RTE_ETH_FILTER_L2_TUNNEL);
13320 printf("E-tag filter is not supported on port %u.\n",
13325 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13326 entry.tunnel_id = res->e_tag_id_val;
13327 entry.pool = res->dst_pool_val;
13329 ret = rte_eth_dev_filter_ctrl(res->port_id,
13330 RTE_ETH_FILTER_L2_TUNNEL,
13331 RTE_ETH_FILTER_ADD,
13334 printf("E-tag filter programming error: (%s)\n",
13338 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13339 .f = cmd_config_e_tag_filter_add_parsed,
13341 .help_str = "E-tag ... : E-tag filter add",
13343 (void *)&cmd_config_e_tag_e_tag,
13344 (void *)&cmd_config_e_tag_set,
13345 (void *)&cmd_config_e_tag_filter,
13346 (void *)&cmd_config_e_tag_add,
13347 (void *)&cmd_config_e_tag_e_tag_id,
13348 (void *)&cmd_config_e_tag_e_tag_id_val,
13349 (void *)&cmd_config_e_tag_dst_pool,
13350 (void *)&cmd_config_e_tag_dst_pool_val,
13351 (void *)&cmd_config_e_tag_port,
13352 (void *)&cmd_config_e_tag_port_id,
13358 cmd_config_e_tag_filter_del_parsed(
13359 void *parsed_result,
13360 __rte_unused struct cmdline *cl,
13361 __rte_unused void *data)
13363 struct cmd_config_e_tag_result *res = parsed_result;
13364 struct rte_eth_l2_tunnel_conf entry;
13367 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13370 if (res->e_tag_id_val > 0x3fff) {
13371 printf("e-tag-id must be less than 0x3fff.\n");
13375 ret = rte_eth_dev_filter_supported(res->port_id,
13376 RTE_ETH_FILTER_L2_TUNNEL);
13378 printf("E-tag filter is not supported on port %u.\n",
13383 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13384 entry.tunnel_id = res->e_tag_id_val;
13386 ret = rte_eth_dev_filter_ctrl(res->port_id,
13387 RTE_ETH_FILTER_L2_TUNNEL,
13388 RTE_ETH_FILTER_DELETE,
13391 printf("E-tag filter programming error: (%s)\n",
13395 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13396 .f = cmd_config_e_tag_filter_del_parsed,
13398 .help_str = "E-tag ... : E-tag filter delete",
13400 (void *)&cmd_config_e_tag_e_tag,
13401 (void *)&cmd_config_e_tag_set,
13402 (void *)&cmd_config_e_tag_filter,
13403 (void *)&cmd_config_e_tag_del,
13404 (void *)&cmd_config_e_tag_e_tag_id,
13405 (void *)&cmd_config_e_tag_e_tag_id_val,
13406 (void *)&cmd_config_e_tag_port,
13407 (void *)&cmd_config_e_tag_port_id,
13412 /* vf vlan anti spoof configuration */
13414 /* Common result structure for vf vlan anti spoof */
13415 struct cmd_vf_vlan_anti_spoof_result {
13416 cmdline_fixed_string_t set;
13417 cmdline_fixed_string_t vf;
13418 cmdline_fixed_string_t vlan;
13419 cmdline_fixed_string_t antispoof;
13422 cmdline_fixed_string_t on_off;
13425 /* Common CLI fields for vf vlan anti spoof enable disable */
13426 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13427 TOKEN_STRING_INITIALIZER
13428 (struct cmd_vf_vlan_anti_spoof_result,
13430 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13431 TOKEN_STRING_INITIALIZER
13432 (struct cmd_vf_vlan_anti_spoof_result,
13434 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13435 TOKEN_STRING_INITIALIZER
13436 (struct cmd_vf_vlan_anti_spoof_result,
13438 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13439 TOKEN_STRING_INITIALIZER
13440 (struct cmd_vf_vlan_anti_spoof_result,
13441 antispoof, "antispoof");
13442 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13443 TOKEN_NUM_INITIALIZER
13444 (struct cmd_vf_vlan_anti_spoof_result,
13446 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13447 TOKEN_NUM_INITIALIZER
13448 (struct cmd_vf_vlan_anti_spoof_result,
13450 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13451 TOKEN_STRING_INITIALIZER
13452 (struct cmd_vf_vlan_anti_spoof_result,
13456 cmd_set_vf_vlan_anti_spoof_parsed(
13457 void *parsed_result,
13458 __rte_unused struct cmdline *cl,
13459 __rte_unused void *data)
13461 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13462 int ret = -ENOTSUP;
13464 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13466 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13469 #ifdef RTE_LIBRTE_IXGBE_PMD
13470 if (ret == -ENOTSUP)
13471 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13472 res->vf_id, is_on);
13474 #ifdef RTE_LIBRTE_I40E_PMD
13475 if (ret == -ENOTSUP)
13476 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13477 res->vf_id, is_on);
13479 #ifdef RTE_LIBRTE_BNXT_PMD
13480 if (ret == -ENOTSUP)
13481 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13482 res->vf_id, is_on);
13489 printf("invalid vf_id %d\n", res->vf_id);
13492 printf("invalid port_id %d\n", res->port_id);
13495 printf("function not implemented\n");
13498 printf("programming error: (%s)\n", strerror(-ret));
13502 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13503 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13505 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13507 (void *)&cmd_vf_vlan_anti_spoof_set,
13508 (void *)&cmd_vf_vlan_anti_spoof_vf,
13509 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13510 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13511 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13512 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13513 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13518 /* vf mac anti spoof configuration */
13520 /* Common result structure for vf mac anti spoof */
13521 struct cmd_vf_mac_anti_spoof_result {
13522 cmdline_fixed_string_t set;
13523 cmdline_fixed_string_t vf;
13524 cmdline_fixed_string_t mac;
13525 cmdline_fixed_string_t antispoof;
13528 cmdline_fixed_string_t on_off;
13531 /* Common CLI fields for vf mac anti spoof enable disable */
13532 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13533 TOKEN_STRING_INITIALIZER
13534 (struct cmd_vf_mac_anti_spoof_result,
13536 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13537 TOKEN_STRING_INITIALIZER
13538 (struct cmd_vf_mac_anti_spoof_result,
13540 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13541 TOKEN_STRING_INITIALIZER
13542 (struct cmd_vf_mac_anti_spoof_result,
13544 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13545 TOKEN_STRING_INITIALIZER
13546 (struct cmd_vf_mac_anti_spoof_result,
13547 antispoof, "antispoof");
13548 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13549 TOKEN_NUM_INITIALIZER
13550 (struct cmd_vf_mac_anti_spoof_result,
13552 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13553 TOKEN_NUM_INITIALIZER
13554 (struct cmd_vf_mac_anti_spoof_result,
13556 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13557 TOKEN_STRING_INITIALIZER
13558 (struct cmd_vf_mac_anti_spoof_result,
13562 cmd_set_vf_mac_anti_spoof_parsed(
13563 void *parsed_result,
13564 __rte_unused struct cmdline *cl,
13565 __rte_unused void *data)
13567 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13568 int ret = -ENOTSUP;
13570 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13572 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13575 #ifdef RTE_LIBRTE_IXGBE_PMD
13576 if (ret == -ENOTSUP)
13577 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13578 res->vf_id, is_on);
13580 #ifdef RTE_LIBRTE_I40E_PMD
13581 if (ret == -ENOTSUP)
13582 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13583 res->vf_id, is_on);
13585 #ifdef RTE_LIBRTE_BNXT_PMD
13586 if (ret == -ENOTSUP)
13587 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13588 res->vf_id, is_on);
13595 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13598 printf("invalid port_id %d\n", res->port_id);
13601 printf("function not implemented\n");
13604 printf("programming error: (%s)\n", strerror(-ret));
13608 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13609 .f = cmd_set_vf_mac_anti_spoof_parsed,
13611 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13613 (void *)&cmd_vf_mac_anti_spoof_set,
13614 (void *)&cmd_vf_mac_anti_spoof_vf,
13615 (void *)&cmd_vf_mac_anti_spoof_mac,
13616 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13617 (void *)&cmd_vf_mac_anti_spoof_port_id,
13618 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13619 (void *)&cmd_vf_mac_anti_spoof_on_off,
13624 /* vf vlan strip queue configuration */
13626 /* Common result structure for vf mac anti spoof */
13627 struct cmd_vf_vlan_stripq_result {
13628 cmdline_fixed_string_t set;
13629 cmdline_fixed_string_t vf;
13630 cmdline_fixed_string_t vlan;
13631 cmdline_fixed_string_t stripq;
13634 cmdline_fixed_string_t on_off;
13637 /* Common CLI fields for vf vlan strip enable disable */
13638 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13639 TOKEN_STRING_INITIALIZER
13640 (struct cmd_vf_vlan_stripq_result,
13642 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13643 TOKEN_STRING_INITIALIZER
13644 (struct cmd_vf_vlan_stripq_result,
13646 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13647 TOKEN_STRING_INITIALIZER
13648 (struct cmd_vf_vlan_stripq_result,
13650 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13651 TOKEN_STRING_INITIALIZER
13652 (struct cmd_vf_vlan_stripq_result,
13654 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13655 TOKEN_NUM_INITIALIZER
13656 (struct cmd_vf_vlan_stripq_result,
13658 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13659 TOKEN_NUM_INITIALIZER
13660 (struct cmd_vf_vlan_stripq_result,
13662 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13663 TOKEN_STRING_INITIALIZER
13664 (struct cmd_vf_vlan_stripq_result,
13668 cmd_set_vf_vlan_stripq_parsed(
13669 void *parsed_result,
13670 __rte_unused struct cmdline *cl,
13671 __rte_unused void *data)
13673 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13674 int ret = -ENOTSUP;
13676 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13678 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13681 #ifdef RTE_LIBRTE_IXGBE_PMD
13682 if (ret == -ENOTSUP)
13683 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13684 res->vf_id, is_on);
13686 #ifdef RTE_LIBRTE_I40E_PMD
13687 if (ret == -ENOTSUP)
13688 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13689 res->vf_id, is_on);
13691 #ifdef RTE_LIBRTE_BNXT_PMD
13692 if (ret == -ENOTSUP)
13693 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13694 res->vf_id, is_on);
13701 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13704 printf("invalid port_id %d\n", res->port_id);
13707 printf("function not implemented\n");
13710 printf("programming error: (%s)\n", strerror(-ret));
13714 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13715 .f = cmd_set_vf_vlan_stripq_parsed,
13717 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13719 (void *)&cmd_vf_vlan_stripq_set,
13720 (void *)&cmd_vf_vlan_stripq_vf,
13721 (void *)&cmd_vf_vlan_stripq_vlan,
13722 (void *)&cmd_vf_vlan_stripq_stripq,
13723 (void *)&cmd_vf_vlan_stripq_port_id,
13724 (void *)&cmd_vf_vlan_stripq_vf_id,
13725 (void *)&cmd_vf_vlan_stripq_on_off,
13730 /* vf vlan insert configuration */
13732 /* Common result structure for vf vlan insert */
13733 struct cmd_vf_vlan_insert_result {
13734 cmdline_fixed_string_t set;
13735 cmdline_fixed_string_t vf;
13736 cmdline_fixed_string_t vlan;
13737 cmdline_fixed_string_t insert;
13743 /* Common CLI fields for vf vlan insert enable disable */
13744 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13745 TOKEN_STRING_INITIALIZER
13746 (struct cmd_vf_vlan_insert_result,
13748 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13749 TOKEN_STRING_INITIALIZER
13750 (struct cmd_vf_vlan_insert_result,
13752 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13753 TOKEN_STRING_INITIALIZER
13754 (struct cmd_vf_vlan_insert_result,
13756 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13757 TOKEN_STRING_INITIALIZER
13758 (struct cmd_vf_vlan_insert_result,
13760 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13761 TOKEN_NUM_INITIALIZER
13762 (struct cmd_vf_vlan_insert_result,
13764 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13765 TOKEN_NUM_INITIALIZER
13766 (struct cmd_vf_vlan_insert_result,
13768 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13769 TOKEN_NUM_INITIALIZER
13770 (struct cmd_vf_vlan_insert_result,
13774 cmd_set_vf_vlan_insert_parsed(
13775 void *parsed_result,
13776 __rte_unused struct cmdline *cl,
13777 __rte_unused void *data)
13779 struct cmd_vf_vlan_insert_result *res = parsed_result;
13780 int ret = -ENOTSUP;
13782 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13785 #ifdef RTE_LIBRTE_IXGBE_PMD
13786 if (ret == -ENOTSUP)
13787 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13790 #ifdef RTE_LIBRTE_I40E_PMD
13791 if (ret == -ENOTSUP)
13792 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13795 #ifdef RTE_LIBRTE_BNXT_PMD
13796 if (ret == -ENOTSUP)
13797 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13805 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13808 printf("invalid port_id %d\n", res->port_id);
13811 printf("function not implemented\n");
13814 printf("programming error: (%s)\n", strerror(-ret));
13818 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13819 .f = cmd_set_vf_vlan_insert_parsed,
13821 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13823 (void *)&cmd_vf_vlan_insert_set,
13824 (void *)&cmd_vf_vlan_insert_vf,
13825 (void *)&cmd_vf_vlan_insert_vlan,
13826 (void *)&cmd_vf_vlan_insert_insert,
13827 (void *)&cmd_vf_vlan_insert_port_id,
13828 (void *)&cmd_vf_vlan_insert_vf_id,
13829 (void *)&cmd_vf_vlan_insert_vlan_id,
13834 /* tx loopback configuration */
13836 /* Common result structure for tx loopback */
13837 struct cmd_tx_loopback_result {
13838 cmdline_fixed_string_t set;
13839 cmdline_fixed_string_t tx;
13840 cmdline_fixed_string_t loopback;
13842 cmdline_fixed_string_t on_off;
13845 /* Common CLI fields for tx loopback enable disable */
13846 cmdline_parse_token_string_t cmd_tx_loopback_set =
13847 TOKEN_STRING_INITIALIZER
13848 (struct cmd_tx_loopback_result,
13850 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13851 TOKEN_STRING_INITIALIZER
13852 (struct cmd_tx_loopback_result,
13854 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13855 TOKEN_STRING_INITIALIZER
13856 (struct cmd_tx_loopback_result,
13857 loopback, "loopback");
13858 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13859 TOKEN_NUM_INITIALIZER
13860 (struct cmd_tx_loopback_result,
13862 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13863 TOKEN_STRING_INITIALIZER
13864 (struct cmd_tx_loopback_result,
13868 cmd_set_tx_loopback_parsed(
13869 void *parsed_result,
13870 __rte_unused struct cmdline *cl,
13871 __rte_unused void *data)
13873 struct cmd_tx_loopback_result *res = parsed_result;
13874 int ret = -ENOTSUP;
13876 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13878 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13881 #ifdef RTE_LIBRTE_IXGBE_PMD
13882 if (ret == -ENOTSUP)
13883 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13885 #ifdef RTE_LIBRTE_I40E_PMD
13886 if (ret == -ENOTSUP)
13887 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13889 #ifdef RTE_LIBRTE_BNXT_PMD
13890 if (ret == -ENOTSUP)
13891 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13893 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13894 if (ret == -ENOTSUP)
13895 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13902 printf("invalid is_on %d\n", is_on);
13905 printf("invalid port_id %d\n", res->port_id);
13908 printf("function not implemented\n");
13911 printf("programming error: (%s)\n", strerror(-ret));
13915 cmdline_parse_inst_t cmd_set_tx_loopback = {
13916 .f = cmd_set_tx_loopback_parsed,
13918 .help_str = "set tx loopback <port_id> on|off",
13920 (void *)&cmd_tx_loopback_set,
13921 (void *)&cmd_tx_loopback_tx,
13922 (void *)&cmd_tx_loopback_loopback,
13923 (void *)&cmd_tx_loopback_port_id,
13924 (void *)&cmd_tx_loopback_on_off,
13929 /* all queues drop enable configuration */
13931 /* Common result structure for all queues drop enable */
13932 struct cmd_all_queues_drop_en_result {
13933 cmdline_fixed_string_t set;
13934 cmdline_fixed_string_t all;
13935 cmdline_fixed_string_t queues;
13936 cmdline_fixed_string_t drop;
13938 cmdline_fixed_string_t on_off;
13941 /* Common CLI fields for tx loopback enable disable */
13942 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13943 TOKEN_STRING_INITIALIZER
13944 (struct cmd_all_queues_drop_en_result,
13946 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13947 TOKEN_STRING_INITIALIZER
13948 (struct cmd_all_queues_drop_en_result,
13950 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13951 TOKEN_STRING_INITIALIZER
13952 (struct cmd_all_queues_drop_en_result,
13954 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13955 TOKEN_STRING_INITIALIZER
13956 (struct cmd_all_queues_drop_en_result,
13958 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13959 TOKEN_NUM_INITIALIZER
13960 (struct cmd_all_queues_drop_en_result,
13962 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13963 TOKEN_STRING_INITIALIZER
13964 (struct cmd_all_queues_drop_en_result,
13968 cmd_set_all_queues_drop_en_parsed(
13969 void *parsed_result,
13970 __rte_unused struct cmdline *cl,
13971 __rte_unused void *data)
13973 struct cmd_all_queues_drop_en_result *res = parsed_result;
13974 int ret = -ENOTSUP;
13975 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13977 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13980 #ifdef RTE_LIBRTE_IXGBE_PMD
13981 if (ret == -ENOTSUP)
13982 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13984 #ifdef RTE_LIBRTE_BNXT_PMD
13985 if (ret == -ENOTSUP)
13986 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13992 printf("invalid is_on %d\n", is_on);
13995 printf("invalid port_id %d\n", res->port_id);
13998 printf("function not implemented\n");
14001 printf("programming error: (%s)\n", strerror(-ret));
14005 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14006 .f = cmd_set_all_queues_drop_en_parsed,
14008 .help_str = "set all queues drop <port_id> on|off",
14010 (void *)&cmd_all_queues_drop_en_set,
14011 (void *)&cmd_all_queues_drop_en_all,
14012 (void *)&cmd_all_queues_drop_en_queues,
14013 (void *)&cmd_all_queues_drop_en_drop,
14014 (void *)&cmd_all_queues_drop_en_port_id,
14015 (void *)&cmd_all_queues_drop_en_on_off,
14020 /* vf split drop enable configuration */
14022 /* Common result structure for vf split drop enable */
14023 struct cmd_vf_split_drop_en_result {
14024 cmdline_fixed_string_t set;
14025 cmdline_fixed_string_t vf;
14026 cmdline_fixed_string_t split;
14027 cmdline_fixed_string_t drop;
14030 cmdline_fixed_string_t on_off;
14033 /* Common CLI fields for vf split drop enable disable */
14034 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14035 TOKEN_STRING_INITIALIZER
14036 (struct cmd_vf_split_drop_en_result,
14038 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14039 TOKEN_STRING_INITIALIZER
14040 (struct cmd_vf_split_drop_en_result,
14042 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14043 TOKEN_STRING_INITIALIZER
14044 (struct cmd_vf_split_drop_en_result,
14046 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14047 TOKEN_STRING_INITIALIZER
14048 (struct cmd_vf_split_drop_en_result,
14050 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14051 TOKEN_NUM_INITIALIZER
14052 (struct cmd_vf_split_drop_en_result,
14054 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14055 TOKEN_NUM_INITIALIZER
14056 (struct cmd_vf_split_drop_en_result,
14058 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14059 TOKEN_STRING_INITIALIZER
14060 (struct cmd_vf_split_drop_en_result,
14064 cmd_set_vf_split_drop_en_parsed(
14065 void *parsed_result,
14066 __rte_unused struct cmdline *cl,
14067 __rte_unused void *data)
14069 struct cmd_vf_split_drop_en_result *res = parsed_result;
14070 int ret = -ENOTSUP;
14071 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14073 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14076 #ifdef RTE_LIBRTE_IXGBE_PMD
14077 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14084 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14087 printf("invalid port_id %d\n", res->port_id);
14090 printf("not supported on port %d\n", res->port_id);
14093 printf("programming error: (%s)\n", strerror(-ret));
14097 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14098 .f = cmd_set_vf_split_drop_en_parsed,
14100 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14102 (void *)&cmd_vf_split_drop_en_set,
14103 (void *)&cmd_vf_split_drop_en_vf,
14104 (void *)&cmd_vf_split_drop_en_split,
14105 (void *)&cmd_vf_split_drop_en_drop,
14106 (void *)&cmd_vf_split_drop_en_port_id,
14107 (void *)&cmd_vf_split_drop_en_vf_id,
14108 (void *)&cmd_vf_split_drop_en_on_off,
14113 /* vf mac address configuration */
14115 /* Common result structure for vf mac address */
14116 struct cmd_set_vf_mac_addr_result {
14117 cmdline_fixed_string_t set;
14118 cmdline_fixed_string_t vf;
14119 cmdline_fixed_string_t mac;
14120 cmdline_fixed_string_t addr;
14123 struct rte_ether_addr mac_addr;
14127 /* Common CLI fields for vf split drop enable disable */
14128 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14129 TOKEN_STRING_INITIALIZER
14130 (struct cmd_set_vf_mac_addr_result,
14132 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14133 TOKEN_STRING_INITIALIZER
14134 (struct cmd_set_vf_mac_addr_result,
14136 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14137 TOKEN_STRING_INITIALIZER
14138 (struct cmd_set_vf_mac_addr_result,
14140 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14141 TOKEN_STRING_INITIALIZER
14142 (struct cmd_set_vf_mac_addr_result,
14144 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14145 TOKEN_NUM_INITIALIZER
14146 (struct cmd_set_vf_mac_addr_result,
14148 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14149 TOKEN_NUM_INITIALIZER
14150 (struct cmd_set_vf_mac_addr_result,
14152 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14153 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14157 cmd_set_vf_mac_addr_parsed(
14158 void *parsed_result,
14159 __rte_unused struct cmdline *cl,
14160 __rte_unused void *data)
14162 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14163 int ret = -ENOTSUP;
14165 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14168 #ifdef RTE_LIBRTE_IXGBE_PMD
14169 if (ret == -ENOTSUP)
14170 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14173 #ifdef RTE_LIBRTE_I40E_PMD
14174 if (ret == -ENOTSUP)
14175 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14178 #ifdef RTE_LIBRTE_BNXT_PMD
14179 if (ret == -ENOTSUP)
14180 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14188 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14191 printf("invalid port_id %d\n", res->port_id);
14194 printf("function not implemented\n");
14197 printf("programming error: (%s)\n", strerror(-ret));
14201 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14202 .f = cmd_set_vf_mac_addr_parsed,
14204 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14206 (void *)&cmd_set_vf_mac_addr_set,
14207 (void *)&cmd_set_vf_mac_addr_vf,
14208 (void *)&cmd_set_vf_mac_addr_mac,
14209 (void *)&cmd_set_vf_mac_addr_addr,
14210 (void *)&cmd_set_vf_mac_addr_port_id,
14211 (void *)&cmd_set_vf_mac_addr_vf_id,
14212 (void *)&cmd_set_vf_mac_addr_mac_addr,
14217 /* MACsec configuration */
14219 /* Common result structure for MACsec offload enable */
14220 struct cmd_macsec_offload_on_result {
14221 cmdline_fixed_string_t set;
14222 cmdline_fixed_string_t macsec;
14223 cmdline_fixed_string_t offload;
14225 cmdline_fixed_string_t on;
14226 cmdline_fixed_string_t encrypt;
14227 cmdline_fixed_string_t en_on_off;
14228 cmdline_fixed_string_t replay_protect;
14229 cmdline_fixed_string_t rp_on_off;
14232 /* Common CLI fields for MACsec offload disable */
14233 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14234 TOKEN_STRING_INITIALIZER
14235 (struct cmd_macsec_offload_on_result,
14237 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14238 TOKEN_STRING_INITIALIZER
14239 (struct cmd_macsec_offload_on_result,
14241 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14242 TOKEN_STRING_INITIALIZER
14243 (struct cmd_macsec_offload_on_result,
14244 offload, "offload");
14245 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14246 TOKEN_NUM_INITIALIZER
14247 (struct cmd_macsec_offload_on_result,
14249 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14250 TOKEN_STRING_INITIALIZER
14251 (struct cmd_macsec_offload_on_result,
14253 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14254 TOKEN_STRING_INITIALIZER
14255 (struct cmd_macsec_offload_on_result,
14256 encrypt, "encrypt");
14257 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14258 TOKEN_STRING_INITIALIZER
14259 (struct cmd_macsec_offload_on_result,
14260 en_on_off, "on#off");
14261 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14262 TOKEN_STRING_INITIALIZER
14263 (struct cmd_macsec_offload_on_result,
14264 replay_protect, "replay-protect");
14265 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14266 TOKEN_STRING_INITIALIZER
14267 (struct cmd_macsec_offload_on_result,
14268 rp_on_off, "on#off");
14271 cmd_set_macsec_offload_on_parsed(
14272 void *parsed_result,
14273 __rte_unused struct cmdline *cl,
14274 __rte_unused void *data)
14276 struct cmd_macsec_offload_on_result *res = parsed_result;
14277 int ret = -ENOTSUP;
14278 portid_t port_id = res->port_id;
14279 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14280 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14281 struct rte_eth_dev_info dev_info;
14283 if (port_id_is_invalid(port_id, ENABLED_WARN))
14285 if (!port_is_stopped(port_id)) {
14286 printf("Please stop port %d first\n", port_id);
14290 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14294 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14295 #ifdef RTE_LIBRTE_IXGBE_PMD
14296 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14304 ports[port_id].dev_conf.txmode.offloads |=
14305 DEV_TX_OFFLOAD_MACSEC_INSERT;
14306 cmd_reconfig_device_queue(port_id, 1, 1);
14309 printf("invalid port_id %d\n", port_id);
14312 printf("not supported on port %d\n", port_id);
14315 printf("programming error: (%s)\n", strerror(-ret));
14319 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14320 .f = cmd_set_macsec_offload_on_parsed,
14322 .help_str = "set macsec offload <port_id> on "
14323 "encrypt on|off replay-protect on|off",
14325 (void *)&cmd_macsec_offload_on_set,
14326 (void *)&cmd_macsec_offload_on_macsec,
14327 (void *)&cmd_macsec_offload_on_offload,
14328 (void *)&cmd_macsec_offload_on_port_id,
14329 (void *)&cmd_macsec_offload_on_on,
14330 (void *)&cmd_macsec_offload_on_encrypt,
14331 (void *)&cmd_macsec_offload_on_en_on_off,
14332 (void *)&cmd_macsec_offload_on_replay_protect,
14333 (void *)&cmd_macsec_offload_on_rp_on_off,
14338 /* Common result structure for MACsec offload disable */
14339 struct cmd_macsec_offload_off_result {
14340 cmdline_fixed_string_t set;
14341 cmdline_fixed_string_t macsec;
14342 cmdline_fixed_string_t offload;
14344 cmdline_fixed_string_t off;
14347 /* Common CLI fields for MACsec offload disable */
14348 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14349 TOKEN_STRING_INITIALIZER
14350 (struct cmd_macsec_offload_off_result,
14352 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14353 TOKEN_STRING_INITIALIZER
14354 (struct cmd_macsec_offload_off_result,
14356 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14357 TOKEN_STRING_INITIALIZER
14358 (struct cmd_macsec_offload_off_result,
14359 offload, "offload");
14360 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14361 TOKEN_NUM_INITIALIZER
14362 (struct cmd_macsec_offload_off_result,
14364 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14365 TOKEN_STRING_INITIALIZER
14366 (struct cmd_macsec_offload_off_result,
14370 cmd_set_macsec_offload_off_parsed(
14371 void *parsed_result,
14372 __rte_unused struct cmdline *cl,
14373 __rte_unused void *data)
14375 struct cmd_macsec_offload_off_result *res = parsed_result;
14376 int ret = -ENOTSUP;
14377 struct rte_eth_dev_info dev_info;
14378 portid_t port_id = res->port_id;
14380 if (port_id_is_invalid(port_id, ENABLED_WARN))
14382 if (!port_is_stopped(port_id)) {
14383 printf("Please stop port %d first\n", port_id);
14387 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14391 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14392 #ifdef RTE_LIBRTE_IXGBE_PMD
14393 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14398 ports[port_id].dev_conf.txmode.offloads &=
14399 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14400 cmd_reconfig_device_queue(port_id, 1, 1);
14403 printf("invalid port_id %d\n", port_id);
14406 printf("not supported on port %d\n", port_id);
14409 printf("programming error: (%s)\n", strerror(-ret));
14413 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14414 .f = cmd_set_macsec_offload_off_parsed,
14416 .help_str = "set macsec offload <port_id> off",
14418 (void *)&cmd_macsec_offload_off_set,
14419 (void *)&cmd_macsec_offload_off_macsec,
14420 (void *)&cmd_macsec_offload_off_offload,
14421 (void *)&cmd_macsec_offload_off_port_id,
14422 (void *)&cmd_macsec_offload_off_off,
14427 /* Common result structure for MACsec secure connection configure */
14428 struct cmd_macsec_sc_result {
14429 cmdline_fixed_string_t set;
14430 cmdline_fixed_string_t macsec;
14431 cmdline_fixed_string_t sc;
14432 cmdline_fixed_string_t tx_rx;
14434 struct rte_ether_addr mac;
14438 /* Common CLI fields for MACsec secure connection configure */
14439 cmdline_parse_token_string_t cmd_macsec_sc_set =
14440 TOKEN_STRING_INITIALIZER
14441 (struct cmd_macsec_sc_result,
14443 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14444 TOKEN_STRING_INITIALIZER
14445 (struct cmd_macsec_sc_result,
14447 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14448 TOKEN_STRING_INITIALIZER
14449 (struct cmd_macsec_sc_result,
14451 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14452 TOKEN_STRING_INITIALIZER
14453 (struct cmd_macsec_sc_result,
14455 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14456 TOKEN_NUM_INITIALIZER
14457 (struct cmd_macsec_sc_result,
14459 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14460 TOKEN_ETHERADDR_INITIALIZER
14461 (struct cmd_macsec_sc_result,
14463 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14464 TOKEN_NUM_INITIALIZER
14465 (struct cmd_macsec_sc_result,
14469 cmd_set_macsec_sc_parsed(
14470 void *parsed_result,
14471 __rte_unused struct cmdline *cl,
14472 __rte_unused void *data)
14474 struct cmd_macsec_sc_result *res = parsed_result;
14475 int ret = -ENOTSUP;
14476 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14478 #ifdef RTE_LIBRTE_IXGBE_PMD
14480 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14481 res->mac.addr_bytes) :
14482 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14483 res->mac.addr_bytes, res->pi);
14485 RTE_SET_USED(is_tx);
14491 printf("invalid port_id %d\n", res->port_id);
14494 printf("not supported on port %d\n", res->port_id);
14497 printf("programming error: (%s)\n", strerror(-ret));
14501 cmdline_parse_inst_t cmd_set_macsec_sc = {
14502 .f = cmd_set_macsec_sc_parsed,
14504 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14506 (void *)&cmd_macsec_sc_set,
14507 (void *)&cmd_macsec_sc_macsec,
14508 (void *)&cmd_macsec_sc_sc,
14509 (void *)&cmd_macsec_sc_tx_rx,
14510 (void *)&cmd_macsec_sc_port_id,
14511 (void *)&cmd_macsec_sc_mac,
14512 (void *)&cmd_macsec_sc_pi,
14517 /* Common result structure for MACsec secure connection configure */
14518 struct cmd_macsec_sa_result {
14519 cmdline_fixed_string_t set;
14520 cmdline_fixed_string_t macsec;
14521 cmdline_fixed_string_t sa;
14522 cmdline_fixed_string_t tx_rx;
14527 cmdline_fixed_string_t key;
14530 /* Common CLI fields for MACsec secure connection configure */
14531 cmdline_parse_token_string_t cmd_macsec_sa_set =
14532 TOKEN_STRING_INITIALIZER
14533 (struct cmd_macsec_sa_result,
14535 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14536 TOKEN_STRING_INITIALIZER
14537 (struct cmd_macsec_sa_result,
14539 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14540 TOKEN_STRING_INITIALIZER
14541 (struct cmd_macsec_sa_result,
14543 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14544 TOKEN_STRING_INITIALIZER
14545 (struct cmd_macsec_sa_result,
14547 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14548 TOKEN_NUM_INITIALIZER
14549 (struct cmd_macsec_sa_result,
14551 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14552 TOKEN_NUM_INITIALIZER
14553 (struct cmd_macsec_sa_result,
14555 cmdline_parse_token_num_t cmd_macsec_sa_an =
14556 TOKEN_NUM_INITIALIZER
14557 (struct cmd_macsec_sa_result,
14559 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14560 TOKEN_NUM_INITIALIZER
14561 (struct cmd_macsec_sa_result,
14563 cmdline_parse_token_string_t cmd_macsec_sa_key =
14564 TOKEN_STRING_INITIALIZER
14565 (struct cmd_macsec_sa_result,
14569 cmd_set_macsec_sa_parsed(
14570 void *parsed_result,
14571 __rte_unused struct cmdline *cl,
14572 __rte_unused void *data)
14574 struct cmd_macsec_sa_result *res = parsed_result;
14575 int ret = -ENOTSUP;
14576 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14577 uint8_t key[16] = { 0 };
14583 key_len = strlen(res->key) / 2;
14587 for (i = 0; i < key_len; i++) {
14588 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14591 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14594 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14597 #ifdef RTE_LIBRTE_IXGBE_PMD
14599 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14600 res->idx, res->an, res->pn, key) :
14601 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14602 res->idx, res->an, res->pn, key);
14604 RTE_SET_USED(is_tx);
14611 printf("invalid idx %d or an %d\n", res->idx, res->an);
14614 printf("invalid port_id %d\n", res->port_id);
14617 printf("not supported on port %d\n", res->port_id);
14620 printf("programming error: (%s)\n", strerror(-ret));
14624 cmdline_parse_inst_t cmd_set_macsec_sa = {
14625 .f = cmd_set_macsec_sa_parsed,
14627 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14629 (void *)&cmd_macsec_sa_set,
14630 (void *)&cmd_macsec_sa_macsec,
14631 (void *)&cmd_macsec_sa_sa,
14632 (void *)&cmd_macsec_sa_tx_rx,
14633 (void *)&cmd_macsec_sa_port_id,
14634 (void *)&cmd_macsec_sa_idx,
14635 (void *)&cmd_macsec_sa_an,
14636 (void *)&cmd_macsec_sa_pn,
14637 (void *)&cmd_macsec_sa_key,
14642 /* VF unicast promiscuous mode configuration */
14644 /* Common result structure for VF unicast promiscuous mode */
14645 struct cmd_vf_promisc_result {
14646 cmdline_fixed_string_t set;
14647 cmdline_fixed_string_t vf;
14648 cmdline_fixed_string_t promisc;
14651 cmdline_fixed_string_t on_off;
14654 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14655 cmdline_parse_token_string_t cmd_vf_promisc_set =
14656 TOKEN_STRING_INITIALIZER
14657 (struct cmd_vf_promisc_result,
14659 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14660 TOKEN_STRING_INITIALIZER
14661 (struct cmd_vf_promisc_result,
14663 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14664 TOKEN_STRING_INITIALIZER
14665 (struct cmd_vf_promisc_result,
14666 promisc, "promisc");
14667 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14668 TOKEN_NUM_INITIALIZER
14669 (struct cmd_vf_promisc_result,
14671 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14672 TOKEN_NUM_INITIALIZER
14673 (struct cmd_vf_promisc_result,
14675 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14676 TOKEN_STRING_INITIALIZER
14677 (struct cmd_vf_promisc_result,
14681 cmd_set_vf_promisc_parsed(
14682 void *parsed_result,
14683 __rte_unused struct cmdline *cl,
14684 __rte_unused void *data)
14686 struct cmd_vf_promisc_result *res = parsed_result;
14687 int ret = -ENOTSUP;
14689 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14691 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14694 #ifdef RTE_LIBRTE_I40E_PMD
14695 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14696 res->vf_id, is_on);
14703 printf("invalid vf_id %d\n", res->vf_id);
14706 printf("invalid port_id %d\n", res->port_id);
14709 printf("function not implemented\n");
14712 printf("programming error: (%s)\n", strerror(-ret));
14716 cmdline_parse_inst_t cmd_set_vf_promisc = {
14717 .f = cmd_set_vf_promisc_parsed,
14719 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14720 "Set unicast promiscuous mode for a VF from the PF",
14722 (void *)&cmd_vf_promisc_set,
14723 (void *)&cmd_vf_promisc_vf,
14724 (void *)&cmd_vf_promisc_promisc,
14725 (void *)&cmd_vf_promisc_port_id,
14726 (void *)&cmd_vf_promisc_vf_id,
14727 (void *)&cmd_vf_promisc_on_off,
14732 /* VF multicast promiscuous mode configuration */
14734 /* Common result structure for VF multicast promiscuous mode */
14735 struct cmd_vf_allmulti_result {
14736 cmdline_fixed_string_t set;
14737 cmdline_fixed_string_t vf;
14738 cmdline_fixed_string_t allmulti;
14741 cmdline_fixed_string_t on_off;
14744 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14745 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14746 TOKEN_STRING_INITIALIZER
14747 (struct cmd_vf_allmulti_result,
14749 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14750 TOKEN_STRING_INITIALIZER
14751 (struct cmd_vf_allmulti_result,
14753 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14754 TOKEN_STRING_INITIALIZER
14755 (struct cmd_vf_allmulti_result,
14756 allmulti, "allmulti");
14757 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14758 TOKEN_NUM_INITIALIZER
14759 (struct cmd_vf_allmulti_result,
14761 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14762 TOKEN_NUM_INITIALIZER
14763 (struct cmd_vf_allmulti_result,
14765 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14766 TOKEN_STRING_INITIALIZER
14767 (struct cmd_vf_allmulti_result,
14771 cmd_set_vf_allmulti_parsed(
14772 void *parsed_result,
14773 __rte_unused struct cmdline *cl,
14774 __rte_unused void *data)
14776 struct cmd_vf_allmulti_result *res = parsed_result;
14777 int ret = -ENOTSUP;
14779 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14781 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14784 #ifdef RTE_LIBRTE_I40E_PMD
14785 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14786 res->vf_id, is_on);
14793 printf("invalid vf_id %d\n", res->vf_id);
14796 printf("invalid port_id %d\n", res->port_id);
14799 printf("function not implemented\n");
14802 printf("programming error: (%s)\n", strerror(-ret));
14806 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14807 .f = cmd_set_vf_allmulti_parsed,
14809 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14810 "Set multicast promiscuous mode for a VF from the PF",
14812 (void *)&cmd_vf_allmulti_set,
14813 (void *)&cmd_vf_allmulti_vf,
14814 (void *)&cmd_vf_allmulti_allmulti,
14815 (void *)&cmd_vf_allmulti_port_id,
14816 (void *)&cmd_vf_allmulti_vf_id,
14817 (void *)&cmd_vf_allmulti_on_off,
14822 /* vf broadcast mode configuration */
14824 /* Common result structure for vf broadcast */
14825 struct cmd_set_vf_broadcast_result {
14826 cmdline_fixed_string_t set;
14827 cmdline_fixed_string_t vf;
14828 cmdline_fixed_string_t broadcast;
14831 cmdline_fixed_string_t on_off;
14834 /* Common CLI fields for vf broadcast enable disable */
14835 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14836 TOKEN_STRING_INITIALIZER
14837 (struct cmd_set_vf_broadcast_result,
14839 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14840 TOKEN_STRING_INITIALIZER
14841 (struct cmd_set_vf_broadcast_result,
14843 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14844 TOKEN_STRING_INITIALIZER
14845 (struct cmd_set_vf_broadcast_result,
14846 broadcast, "broadcast");
14847 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14848 TOKEN_NUM_INITIALIZER
14849 (struct cmd_set_vf_broadcast_result,
14851 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14852 TOKEN_NUM_INITIALIZER
14853 (struct cmd_set_vf_broadcast_result,
14855 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14856 TOKEN_STRING_INITIALIZER
14857 (struct cmd_set_vf_broadcast_result,
14861 cmd_set_vf_broadcast_parsed(
14862 void *parsed_result,
14863 __rte_unused struct cmdline *cl,
14864 __rte_unused void *data)
14866 struct cmd_set_vf_broadcast_result *res = parsed_result;
14867 int ret = -ENOTSUP;
14869 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14871 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14874 #ifdef RTE_LIBRTE_I40E_PMD
14875 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14876 res->vf_id, is_on);
14883 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14886 printf("invalid port_id %d\n", res->port_id);
14889 printf("function not implemented\n");
14892 printf("programming error: (%s)\n", strerror(-ret));
14896 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14897 .f = cmd_set_vf_broadcast_parsed,
14899 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14901 (void *)&cmd_set_vf_broadcast_set,
14902 (void *)&cmd_set_vf_broadcast_vf,
14903 (void *)&cmd_set_vf_broadcast_broadcast,
14904 (void *)&cmd_set_vf_broadcast_port_id,
14905 (void *)&cmd_set_vf_broadcast_vf_id,
14906 (void *)&cmd_set_vf_broadcast_on_off,
14911 /* vf vlan tag configuration */
14913 /* Common result structure for vf vlan tag */
14914 struct cmd_set_vf_vlan_tag_result {
14915 cmdline_fixed_string_t set;
14916 cmdline_fixed_string_t vf;
14917 cmdline_fixed_string_t vlan;
14918 cmdline_fixed_string_t tag;
14921 cmdline_fixed_string_t on_off;
14924 /* Common CLI fields for vf vlan tag enable disable */
14925 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14926 TOKEN_STRING_INITIALIZER
14927 (struct cmd_set_vf_vlan_tag_result,
14929 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14930 TOKEN_STRING_INITIALIZER
14931 (struct cmd_set_vf_vlan_tag_result,
14933 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14934 TOKEN_STRING_INITIALIZER
14935 (struct cmd_set_vf_vlan_tag_result,
14937 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14938 TOKEN_STRING_INITIALIZER
14939 (struct cmd_set_vf_vlan_tag_result,
14941 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14942 TOKEN_NUM_INITIALIZER
14943 (struct cmd_set_vf_vlan_tag_result,
14945 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14946 TOKEN_NUM_INITIALIZER
14947 (struct cmd_set_vf_vlan_tag_result,
14949 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14950 TOKEN_STRING_INITIALIZER
14951 (struct cmd_set_vf_vlan_tag_result,
14955 cmd_set_vf_vlan_tag_parsed(
14956 void *parsed_result,
14957 __rte_unused struct cmdline *cl,
14958 __rte_unused void *data)
14960 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14961 int ret = -ENOTSUP;
14963 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14965 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14968 #ifdef RTE_LIBRTE_I40E_PMD
14969 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14970 res->vf_id, is_on);
14977 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14980 printf("invalid port_id %d\n", res->port_id);
14983 printf("function not implemented\n");
14986 printf("programming error: (%s)\n", strerror(-ret));
14990 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14991 .f = cmd_set_vf_vlan_tag_parsed,
14993 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14995 (void *)&cmd_set_vf_vlan_tag_set,
14996 (void *)&cmd_set_vf_vlan_tag_vf,
14997 (void *)&cmd_set_vf_vlan_tag_vlan,
14998 (void *)&cmd_set_vf_vlan_tag_tag,
14999 (void *)&cmd_set_vf_vlan_tag_port_id,
15000 (void *)&cmd_set_vf_vlan_tag_vf_id,
15001 (void *)&cmd_set_vf_vlan_tag_on_off,
15006 /* Common definition of VF and TC TX bandwidth configuration */
15007 struct cmd_vf_tc_bw_result {
15008 cmdline_fixed_string_t set;
15009 cmdline_fixed_string_t vf;
15010 cmdline_fixed_string_t tc;
15011 cmdline_fixed_string_t tx;
15012 cmdline_fixed_string_t min_bw;
15013 cmdline_fixed_string_t max_bw;
15014 cmdline_fixed_string_t strict_link_prio;
15019 cmdline_fixed_string_t bw_list;
15023 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15024 TOKEN_STRING_INITIALIZER
15025 (struct cmd_vf_tc_bw_result,
15027 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15028 TOKEN_STRING_INITIALIZER
15029 (struct cmd_vf_tc_bw_result,
15031 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15032 TOKEN_STRING_INITIALIZER
15033 (struct cmd_vf_tc_bw_result,
15035 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15036 TOKEN_STRING_INITIALIZER
15037 (struct cmd_vf_tc_bw_result,
15039 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15040 TOKEN_STRING_INITIALIZER
15041 (struct cmd_vf_tc_bw_result,
15042 strict_link_prio, "strict-link-priority");
15043 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15044 TOKEN_STRING_INITIALIZER
15045 (struct cmd_vf_tc_bw_result,
15046 min_bw, "min-bandwidth");
15047 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15048 TOKEN_STRING_INITIALIZER
15049 (struct cmd_vf_tc_bw_result,
15050 max_bw, "max-bandwidth");
15051 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15052 TOKEN_NUM_INITIALIZER
15053 (struct cmd_vf_tc_bw_result,
15055 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15056 TOKEN_NUM_INITIALIZER
15057 (struct cmd_vf_tc_bw_result,
15059 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15060 TOKEN_NUM_INITIALIZER
15061 (struct cmd_vf_tc_bw_result,
15063 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15064 TOKEN_NUM_INITIALIZER
15065 (struct cmd_vf_tc_bw_result,
15067 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15068 TOKEN_STRING_INITIALIZER
15069 (struct cmd_vf_tc_bw_result,
15071 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15072 TOKEN_NUM_INITIALIZER
15073 (struct cmd_vf_tc_bw_result,
15076 /* VF max bandwidth setting */
15078 cmd_vf_max_bw_parsed(
15079 void *parsed_result,
15080 __rte_unused struct cmdline *cl,
15081 __rte_unused void *data)
15083 struct cmd_vf_tc_bw_result *res = parsed_result;
15084 int ret = -ENOTSUP;
15086 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15089 #ifdef RTE_LIBRTE_I40E_PMD
15090 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15091 res->vf_id, res->bw);
15098 printf("invalid vf_id %d or bandwidth %d\n",
15099 res->vf_id, res->bw);
15102 printf("invalid port_id %d\n", res->port_id);
15105 printf("function not implemented\n");
15108 printf("programming error: (%s)\n", strerror(-ret));
15112 cmdline_parse_inst_t cmd_vf_max_bw = {
15113 .f = cmd_vf_max_bw_parsed,
15115 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15117 (void *)&cmd_vf_tc_bw_set,
15118 (void *)&cmd_vf_tc_bw_vf,
15119 (void *)&cmd_vf_tc_bw_tx,
15120 (void *)&cmd_vf_tc_bw_max_bw,
15121 (void *)&cmd_vf_tc_bw_port_id,
15122 (void *)&cmd_vf_tc_bw_vf_id,
15123 (void *)&cmd_vf_tc_bw_bw,
15129 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15134 const char *p, *p0 = str;
15141 p = strchr(p0, '(');
15143 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15147 p0 = strchr(p, ')');
15149 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15153 if (size >= sizeof(s)) {
15154 printf("The string size exceeds the internal buffer size\n");
15157 snprintf(s, sizeof(s), "%.*s", size, p);
15158 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15160 printf("Failed to get the bandwidth list. ");
15164 for (i = 0; i < ret; i++)
15165 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15170 /* TC min bandwidth setting */
15172 cmd_vf_tc_min_bw_parsed(
15173 void *parsed_result,
15174 __rte_unused struct cmdline *cl,
15175 __rte_unused void *data)
15177 struct cmd_vf_tc_bw_result *res = parsed_result;
15180 int ret = -ENOTSUP;
15182 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15185 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15189 #ifdef RTE_LIBRTE_I40E_PMD
15190 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15198 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15201 printf("invalid port_id %d\n", res->port_id);
15204 printf("function not implemented\n");
15207 printf("programming error: (%s)\n", strerror(-ret));
15211 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15212 .f = cmd_vf_tc_min_bw_parsed,
15214 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15215 " <bw1, bw2, ...>",
15217 (void *)&cmd_vf_tc_bw_set,
15218 (void *)&cmd_vf_tc_bw_vf,
15219 (void *)&cmd_vf_tc_bw_tc,
15220 (void *)&cmd_vf_tc_bw_tx,
15221 (void *)&cmd_vf_tc_bw_min_bw,
15222 (void *)&cmd_vf_tc_bw_port_id,
15223 (void *)&cmd_vf_tc_bw_vf_id,
15224 (void *)&cmd_vf_tc_bw_bw_list,
15230 cmd_tc_min_bw_parsed(
15231 void *parsed_result,
15232 __rte_unused struct cmdline *cl,
15233 __rte_unused void *data)
15235 struct cmd_vf_tc_bw_result *res = parsed_result;
15236 struct rte_port *port;
15239 int ret = -ENOTSUP;
15241 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15244 port = &ports[res->port_id];
15245 /** Check if the port is not started **/
15246 if (port->port_status != RTE_PORT_STOPPED) {
15247 printf("Please stop port %d first\n", res->port_id);
15251 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15255 #ifdef RTE_LIBRTE_IXGBE_PMD
15256 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15263 printf("invalid bandwidth\n");
15266 printf("invalid port_id %d\n", res->port_id);
15269 printf("function not implemented\n");
15272 printf("programming error: (%s)\n", strerror(-ret));
15276 cmdline_parse_inst_t cmd_tc_min_bw = {
15277 .f = cmd_tc_min_bw_parsed,
15279 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15281 (void *)&cmd_vf_tc_bw_set,
15282 (void *)&cmd_vf_tc_bw_tc,
15283 (void *)&cmd_vf_tc_bw_tx,
15284 (void *)&cmd_vf_tc_bw_min_bw,
15285 (void *)&cmd_vf_tc_bw_port_id,
15286 (void *)&cmd_vf_tc_bw_bw_list,
15291 /* TC max bandwidth setting */
15293 cmd_vf_tc_max_bw_parsed(
15294 void *parsed_result,
15295 __rte_unused struct cmdline *cl,
15296 __rte_unused void *data)
15298 struct cmd_vf_tc_bw_result *res = parsed_result;
15299 int ret = -ENOTSUP;
15301 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15304 #ifdef RTE_LIBRTE_I40E_PMD
15305 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15306 res->tc_no, res->bw);
15313 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15314 res->vf_id, res->tc_no, res->bw);
15317 printf("invalid port_id %d\n", res->port_id);
15320 printf("function not implemented\n");
15323 printf("programming error: (%s)\n", strerror(-ret));
15327 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15328 .f = cmd_vf_tc_max_bw_parsed,
15330 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15333 (void *)&cmd_vf_tc_bw_set,
15334 (void *)&cmd_vf_tc_bw_vf,
15335 (void *)&cmd_vf_tc_bw_tc,
15336 (void *)&cmd_vf_tc_bw_tx,
15337 (void *)&cmd_vf_tc_bw_max_bw,
15338 (void *)&cmd_vf_tc_bw_port_id,
15339 (void *)&cmd_vf_tc_bw_vf_id,
15340 (void *)&cmd_vf_tc_bw_tc_no,
15341 (void *)&cmd_vf_tc_bw_bw,
15347 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15349 /* *** Set Port default Traffic Management Hierarchy *** */
15350 struct cmd_set_port_tm_hierarchy_default_result {
15351 cmdline_fixed_string_t set;
15352 cmdline_fixed_string_t port;
15353 cmdline_fixed_string_t tm;
15354 cmdline_fixed_string_t hierarchy;
15355 cmdline_fixed_string_t def;
15359 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15360 TOKEN_STRING_INITIALIZER(
15361 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15362 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15363 TOKEN_STRING_INITIALIZER(
15364 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15365 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15366 TOKEN_STRING_INITIALIZER(
15367 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15368 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15369 TOKEN_STRING_INITIALIZER(
15370 struct cmd_set_port_tm_hierarchy_default_result,
15371 hierarchy, "hierarchy");
15372 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15373 TOKEN_STRING_INITIALIZER(
15374 struct cmd_set_port_tm_hierarchy_default_result,
15376 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15377 TOKEN_NUM_INITIALIZER(
15378 struct cmd_set_port_tm_hierarchy_default_result,
15381 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15382 __rte_unused struct cmdline *cl,
15383 __rte_unused void *data)
15385 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15386 struct rte_port *p;
15387 portid_t port_id = res->port_id;
15389 if (port_id_is_invalid(port_id, ENABLED_WARN))
15392 p = &ports[port_id];
15394 /* Forward mode: tm */
15395 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15396 printf(" softnicfwd mode not enabled(error)\n");
15400 /* Set the default tm hierarchy */
15401 p->softport.default_tm_hierarchy_enable = 1;
15404 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15405 .f = cmd_set_port_tm_hierarchy_default_parsed,
15407 .help_str = "set port tm hierarchy default <port_id>",
15409 (void *)&cmd_set_port_tm_hierarchy_default_set,
15410 (void *)&cmd_set_port_tm_hierarchy_default_port,
15411 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15412 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15413 (void *)&cmd_set_port_tm_hierarchy_default_default,
15414 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15420 /** Set VXLAN encapsulation details */
15421 struct cmd_set_vxlan_result {
15422 cmdline_fixed_string_t set;
15423 cmdline_fixed_string_t vxlan;
15424 cmdline_fixed_string_t pos_token;
15425 cmdline_fixed_string_t ip_version;
15426 uint32_t vlan_present:1;
15430 cmdline_ipaddr_t ip_src;
15431 cmdline_ipaddr_t ip_dst;
15435 struct rte_ether_addr eth_src;
15436 struct rte_ether_addr eth_dst;
15439 cmdline_parse_token_string_t cmd_set_vxlan_set =
15440 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15441 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15442 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15443 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15444 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15446 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15447 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15448 "vxlan-with-vlan");
15449 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15450 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15452 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15453 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15455 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15456 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15458 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15459 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15460 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15461 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15463 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15464 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15465 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15466 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15468 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15469 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15470 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15471 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15473 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15474 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15475 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15476 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15478 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15479 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15480 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15481 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15483 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15484 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15485 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15486 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15488 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15489 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15490 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15491 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15493 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15494 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15495 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15496 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15498 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15499 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15500 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15501 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15503 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15504 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15506 static void cmd_set_vxlan_parsed(void *parsed_result,
15507 __rte_unused struct cmdline *cl,
15508 __rte_unused void *data)
15510 struct cmd_set_vxlan_result *res = parsed_result;
15515 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15518 vxlan_encap_conf.select_tos_ttl = 0;
15519 if (strcmp(res->vxlan, "vxlan") == 0)
15520 vxlan_encap_conf.select_vlan = 0;
15521 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15522 vxlan_encap_conf.select_vlan = 1;
15523 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15524 vxlan_encap_conf.select_vlan = 0;
15525 vxlan_encap_conf.select_tos_ttl = 1;
15527 if (strcmp(res->ip_version, "ipv4") == 0)
15528 vxlan_encap_conf.select_ipv4 = 1;
15529 else if (strcmp(res->ip_version, "ipv6") == 0)
15530 vxlan_encap_conf.select_ipv4 = 0;
15533 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15534 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15535 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15536 vxlan_encap_conf.ip_tos = res->tos;
15537 vxlan_encap_conf.ip_ttl = res->ttl;
15538 if (vxlan_encap_conf.select_ipv4) {
15539 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15540 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15542 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15543 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15545 if (vxlan_encap_conf.select_vlan)
15546 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15547 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15548 RTE_ETHER_ADDR_LEN);
15549 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15550 RTE_ETHER_ADDR_LEN);
15553 cmdline_parse_inst_t cmd_set_vxlan = {
15554 .f = cmd_set_vxlan_parsed,
15556 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15557 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15558 " eth-src <eth-src> eth-dst <eth-dst>",
15560 (void *)&cmd_set_vxlan_set,
15561 (void *)&cmd_set_vxlan_vxlan,
15562 (void *)&cmd_set_vxlan_ip_version,
15563 (void *)&cmd_set_vxlan_ip_version_value,
15564 (void *)&cmd_set_vxlan_vni,
15565 (void *)&cmd_set_vxlan_vni_value,
15566 (void *)&cmd_set_vxlan_udp_src,
15567 (void *)&cmd_set_vxlan_udp_src_value,
15568 (void *)&cmd_set_vxlan_udp_dst,
15569 (void *)&cmd_set_vxlan_udp_dst_value,
15570 (void *)&cmd_set_vxlan_ip_src,
15571 (void *)&cmd_set_vxlan_ip_src_value,
15572 (void *)&cmd_set_vxlan_ip_dst,
15573 (void *)&cmd_set_vxlan_ip_dst_value,
15574 (void *)&cmd_set_vxlan_eth_src,
15575 (void *)&cmd_set_vxlan_eth_src_value,
15576 (void *)&cmd_set_vxlan_eth_dst,
15577 (void *)&cmd_set_vxlan_eth_dst_value,
15582 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15583 .f = cmd_set_vxlan_parsed,
15585 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15586 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15587 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15588 " eth-dst <eth-dst>",
15590 (void *)&cmd_set_vxlan_set,
15591 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15592 (void *)&cmd_set_vxlan_ip_version,
15593 (void *)&cmd_set_vxlan_ip_version_value,
15594 (void *)&cmd_set_vxlan_vni,
15595 (void *)&cmd_set_vxlan_vni_value,
15596 (void *)&cmd_set_vxlan_udp_src,
15597 (void *)&cmd_set_vxlan_udp_src_value,
15598 (void *)&cmd_set_vxlan_udp_dst,
15599 (void *)&cmd_set_vxlan_udp_dst_value,
15600 (void *)&cmd_set_vxlan_ip_tos,
15601 (void *)&cmd_set_vxlan_ip_tos_value,
15602 (void *)&cmd_set_vxlan_ip_ttl,
15603 (void *)&cmd_set_vxlan_ip_ttl_value,
15604 (void *)&cmd_set_vxlan_ip_src,
15605 (void *)&cmd_set_vxlan_ip_src_value,
15606 (void *)&cmd_set_vxlan_ip_dst,
15607 (void *)&cmd_set_vxlan_ip_dst_value,
15608 (void *)&cmd_set_vxlan_eth_src,
15609 (void *)&cmd_set_vxlan_eth_src_value,
15610 (void *)&cmd_set_vxlan_eth_dst,
15611 (void *)&cmd_set_vxlan_eth_dst_value,
15616 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15617 .f = cmd_set_vxlan_parsed,
15619 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15620 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15621 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15624 (void *)&cmd_set_vxlan_set,
15625 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15626 (void *)&cmd_set_vxlan_ip_version,
15627 (void *)&cmd_set_vxlan_ip_version_value,
15628 (void *)&cmd_set_vxlan_vni,
15629 (void *)&cmd_set_vxlan_vni_value,
15630 (void *)&cmd_set_vxlan_udp_src,
15631 (void *)&cmd_set_vxlan_udp_src_value,
15632 (void *)&cmd_set_vxlan_udp_dst,
15633 (void *)&cmd_set_vxlan_udp_dst_value,
15634 (void *)&cmd_set_vxlan_ip_src,
15635 (void *)&cmd_set_vxlan_ip_src_value,
15636 (void *)&cmd_set_vxlan_ip_dst,
15637 (void *)&cmd_set_vxlan_ip_dst_value,
15638 (void *)&cmd_set_vxlan_vlan,
15639 (void *)&cmd_set_vxlan_vlan_value,
15640 (void *)&cmd_set_vxlan_eth_src,
15641 (void *)&cmd_set_vxlan_eth_src_value,
15642 (void *)&cmd_set_vxlan_eth_dst,
15643 (void *)&cmd_set_vxlan_eth_dst_value,
15648 /** Set NVGRE encapsulation details */
15649 struct cmd_set_nvgre_result {
15650 cmdline_fixed_string_t set;
15651 cmdline_fixed_string_t nvgre;
15652 cmdline_fixed_string_t pos_token;
15653 cmdline_fixed_string_t ip_version;
15655 cmdline_ipaddr_t ip_src;
15656 cmdline_ipaddr_t ip_dst;
15658 struct rte_ether_addr eth_src;
15659 struct rte_ether_addr eth_dst;
15662 cmdline_parse_token_string_t cmd_set_nvgre_set =
15663 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15664 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15665 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15666 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15667 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15668 "nvgre-with-vlan");
15669 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15670 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15672 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15673 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15675 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15676 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15678 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15679 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15680 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15681 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15683 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15684 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15685 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15686 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15688 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15689 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15690 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15691 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15693 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15694 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15695 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15696 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15698 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15699 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15700 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15701 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15703 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15704 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15706 static void cmd_set_nvgre_parsed(void *parsed_result,
15707 __rte_unused struct cmdline *cl,
15708 __rte_unused void *data)
15710 struct cmd_set_nvgre_result *res = parsed_result;
15712 uint32_t nvgre_tni;
15715 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15718 if (strcmp(res->nvgre, "nvgre") == 0)
15719 nvgre_encap_conf.select_vlan = 0;
15720 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15721 nvgre_encap_conf.select_vlan = 1;
15722 if (strcmp(res->ip_version, "ipv4") == 0)
15723 nvgre_encap_conf.select_ipv4 = 1;
15724 else if (strcmp(res->ip_version, "ipv6") == 0)
15725 nvgre_encap_conf.select_ipv4 = 0;
15728 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15729 if (nvgre_encap_conf.select_ipv4) {
15730 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15731 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15733 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15734 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15736 if (nvgre_encap_conf.select_vlan)
15737 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15738 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15739 RTE_ETHER_ADDR_LEN);
15740 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15741 RTE_ETHER_ADDR_LEN);
15744 cmdline_parse_inst_t cmd_set_nvgre = {
15745 .f = cmd_set_nvgre_parsed,
15747 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15748 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15749 " eth-dst <eth-dst>",
15751 (void *)&cmd_set_nvgre_set,
15752 (void *)&cmd_set_nvgre_nvgre,
15753 (void *)&cmd_set_nvgre_ip_version,
15754 (void *)&cmd_set_nvgre_ip_version_value,
15755 (void *)&cmd_set_nvgre_tni,
15756 (void *)&cmd_set_nvgre_tni_value,
15757 (void *)&cmd_set_nvgre_ip_src,
15758 (void *)&cmd_set_nvgre_ip_src_value,
15759 (void *)&cmd_set_nvgre_ip_dst,
15760 (void *)&cmd_set_nvgre_ip_dst_value,
15761 (void *)&cmd_set_nvgre_eth_src,
15762 (void *)&cmd_set_nvgre_eth_src_value,
15763 (void *)&cmd_set_nvgre_eth_dst,
15764 (void *)&cmd_set_nvgre_eth_dst_value,
15769 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15770 .f = cmd_set_nvgre_parsed,
15772 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15773 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15774 " eth-src <eth-src> eth-dst <eth-dst>",
15776 (void *)&cmd_set_nvgre_set,
15777 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15778 (void *)&cmd_set_nvgre_ip_version,
15779 (void *)&cmd_set_nvgre_ip_version_value,
15780 (void *)&cmd_set_nvgre_tni,
15781 (void *)&cmd_set_nvgre_tni_value,
15782 (void *)&cmd_set_nvgre_ip_src,
15783 (void *)&cmd_set_nvgre_ip_src_value,
15784 (void *)&cmd_set_nvgre_ip_dst,
15785 (void *)&cmd_set_nvgre_ip_dst_value,
15786 (void *)&cmd_set_nvgre_vlan,
15787 (void *)&cmd_set_nvgre_vlan_value,
15788 (void *)&cmd_set_nvgre_eth_src,
15789 (void *)&cmd_set_nvgre_eth_src_value,
15790 (void *)&cmd_set_nvgre_eth_dst,
15791 (void *)&cmd_set_nvgre_eth_dst_value,
15796 /** Set L2 encapsulation details */
15797 struct cmd_set_l2_encap_result {
15798 cmdline_fixed_string_t set;
15799 cmdline_fixed_string_t l2_encap;
15800 cmdline_fixed_string_t pos_token;
15801 cmdline_fixed_string_t ip_version;
15802 uint32_t vlan_present:1;
15804 struct rte_ether_addr eth_src;
15805 struct rte_ether_addr eth_dst;
15808 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15809 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15810 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15811 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15812 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15813 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15814 "l2_encap-with-vlan");
15815 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15816 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15818 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15819 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15821 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15822 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15824 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15825 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15826 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15827 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15829 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15830 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15831 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15832 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15834 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15835 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15837 static void cmd_set_l2_encap_parsed(void *parsed_result,
15838 __rte_unused struct cmdline *cl,
15839 __rte_unused void *data)
15841 struct cmd_set_l2_encap_result *res = parsed_result;
15843 if (strcmp(res->l2_encap, "l2_encap") == 0)
15844 l2_encap_conf.select_vlan = 0;
15845 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15846 l2_encap_conf.select_vlan = 1;
15847 if (strcmp(res->ip_version, "ipv4") == 0)
15848 l2_encap_conf.select_ipv4 = 1;
15849 else if (strcmp(res->ip_version, "ipv6") == 0)
15850 l2_encap_conf.select_ipv4 = 0;
15853 if (l2_encap_conf.select_vlan)
15854 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15855 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15856 RTE_ETHER_ADDR_LEN);
15857 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15858 RTE_ETHER_ADDR_LEN);
15861 cmdline_parse_inst_t cmd_set_l2_encap = {
15862 .f = cmd_set_l2_encap_parsed,
15864 .help_str = "set l2_encap ip-version ipv4|ipv6"
15865 " eth-src <eth-src> eth-dst <eth-dst>",
15867 (void *)&cmd_set_l2_encap_set,
15868 (void *)&cmd_set_l2_encap_l2_encap,
15869 (void *)&cmd_set_l2_encap_ip_version,
15870 (void *)&cmd_set_l2_encap_ip_version_value,
15871 (void *)&cmd_set_l2_encap_eth_src,
15872 (void *)&cmd_set_l2_encap_eth_src_value,
15873 (void *)&cmd_set_l2_encap_eth_dst,
15874 (void *)&cmd_set_l2_encap_eth_dst_value,
15879 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15880 .f = cmd_set_l2_encap_parsed,
15882 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15883 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15885 (void *)&cmd_set_l2_encap_set,
15886 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15887 (void *)&cmd_set_l2_encap_ip_version,
15888 (void *)&cmd_set_l2_encap_ip_version_value,
15889 (void *)&cmd_set_l2_encap_vlan,
15890 (void *)&cmd_set_l2_encap_vlan_value,
15891 (void *)&cmd_set_l2_encap_eth_src,
15892 (void *)&cmd_set_l2_encap_eth_src_value,
15893 (void *)&cmd_set_l2_encap_eth_dst,
15894 (void *)&cmd_set_l2_encap_eth_dst_value,
15899 /** Set L2 decapsulation details */
15900 struct cmd_set_l2_decap_result {
15901 cmdline_fixed_string_t set;
15902 cmdline_fixed_string_t l2_decap;
15903 cmdline_fixed_string_t pos_token;
15904 uint32_t vlan_present:1;
15907 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15908 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15909 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15910 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15912 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15913 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15914 "l2_decap-with-vlan");
15916 static void cmd_set_l2_decap_parsed(void *parsed_result,
15917 __rte_unused struct cmdline *cl,
15918 __rte_unused void *data)
15920 struct cmd_set_l2_decap_result *res = parsed_result;
15922 if (strcmp(res->l2_decap, "l2_decap") == 0)
15923 l2_decap_conf.select_vlan = 0;
15924 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15925 l2_decap_conf.select_vlan = 1;
15928 cmdline_parse_inst_t cmd_set_l2_decap = {
15929 .f = cmd_set_l2_decap_parsed,
15931 .help_str = "set l2_decap",
15933 (void *)&cmd_set_l2_decap_set,
15934 (void *)&cmd_set_l2_decap_l2_decap,
15939 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15940 .f = cmd_set_l2_decap_parsed,
15942 .help_str = "set l2_decap-with-vlan",
15944 (void *)&cmd_set_l2_decap_set,
15945 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15950 /** Set MPLSoGRE encapsulation details */
15951 struct cmd_set_mplsogre_encap_result {
15952 cmdline_fixed_string_t set;
15953 cmdline_fixed_string_t mplsogre;
15954 cmdline_fixed_string_t pos_token;
15955 cmdline_fixed_string_t ip_version;
15956 uint32_t vlan_present:1;
15958 cmdline_ipaddr_t ip_src;
15959 cmdline_ipaddr_t ip_dst;
15961 struct rte_ether_addr eth_src;
15962 struct rte_ether_addr eth_dst;
15965 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15966 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15968 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15969 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15971 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15972 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15973 mplsogre, "mplsogre_encap-with-vlan");
15974 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15975 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15976 pos_token, "ip-version");
15977 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15978 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15979 ip_version, "ipv4#ipv6");
15980 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15981 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15982 pos_token, "label");
15983 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15984 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15986 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15987 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15988 pos_token, "ip-src");
15989 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15990 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15991 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15992 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15993 pos_token, "ip-dst");
15994 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15995 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15996 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15997 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15998 pos_token, "vlan-tci");
15999 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16000 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16002 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16003 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16004 pos_token, "eth-src");
16005 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16006 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16008 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16009 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16010 pos_token, "eth-dst");
16011 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16012 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16015 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16016 __rte_unused struct cmdline *cl,
16017 __rte_unused void *data)
16019 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16021 uint32_t mplsogre_label;
16024 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16027 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16028 mplsogre_encap_conf.select_vlan = 0;
16029 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16030 mplsogre_encap_conf.select_vlan = 1;
16031 if (strcmp(res->ip_version, "ipv4") == 0)
16032 mplsogre_encap_conf.select_ipv4 = 1;
16033 else if (strcmp(res->ip_version, "ipv6") == 0)
16034 mplsogre_encap_conf.select_ipv4 = 0;
16037 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16038 if (mplsogre_encap_conf.select_ipv4) {
16039 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16040 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16042 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16043 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16045 if (mplsogre_encap_conf.select_vlan)
16046 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16047 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16048 RTE_ETHER_ADDR_LEN);
16049 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16050 RTE_ETHER_ADDR_LEN);
16053 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16054 .f = cmd_set_mplsogre_encap_parsed,
16056 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16057 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16058 " eth-dst <eth-dst>",
16060 (void *)&cmd_set_mplsogre_encap_set,
16061 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16062 (void *)&cmd_set_mplsogre_encap_ip_version,
16063 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16064 (void *)&cmd_set_mplsogre_encap_label,
16065 (void *)&cmd_set_mplsogre_encap_label_value,
16066 (void *)&cmd_set_mplsogre_encap_ip_src,
16067 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16068 (void *)&cmd_set_mplsogre_encap_ip_dst,
16069 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16070 (void *)&cmd_set_mplsogre_encap_eth_src,
16071 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16072 (void *)&cmd_set_mplsogre_encap_eth_dst,
16073 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16078 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16079 .f = cmd_set_mplsogre_encap_parsed,
16081 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16082 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16083 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16085 (void *)&cmd_set_mplsogre_encap_set,
16086 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16087 (void *)&cmd_set_mplsogre_encap_ip_version,
16088 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16089 (void *)&cmd_set_mplsogre_encap_label,
16090 (void *)&cmd_set_mplsogre_encap_label_value,
16091 (void *)&cmd_set_mplsogre_encap_ip_src,
16092 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16093 (void *)&cmd_set_mplsogre_encap_ip_dst,
16094 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16095 (void *)&cmd_set_mplsogre_encap_vlan,
16096 (void *)&cmd_set_mplsogre_encap_vlan_value,
16097 (void *)&cmd_set_mplsogre_encap_eth_src,
16098 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16099 (void *)&cmd_set_mplsogre_encap_eth_dst,
16100 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16105 /** Set MPLSoGRE decapsulation details */
16106 struct cmd_set_mplsogre_decap_result {
16107 cmdline_fixed_string_t set;
16108 cmdline_fixed_string_t mplsogre;
16109 cmdline_fixed_string_t pos_token;
16110 cmdline_fixed_string_t ip_version;
16111 uint32_t vlan_present:1;
16114 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16115 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16117 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16118 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16120 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16121 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16122 mplsogre, "mplsogre_decap-with-vlan");
16123 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16124 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16125 pos_token, "ip-version");
16126 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16127 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16128 ip_version, "ipv4#ipv6");
16130 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16131 __rte_unused struct cmdline *cl,
16132 __rte_unused void *data)
16134 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16136 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16137 mplsogre_decap_conf.select_vlan = 0;
16138 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16139 mplsogre_decap_conf.select_vlan = 1;
16140 if (strcmp(res->ip_version, "ipv4") == 0)
16141 mplsogre_decap_conf.select_ipv4 = 1;
16142 else if (strcmp(res->ip_version, "ipv6") == 0)
16143 mplsogre_decap_conf.select_ipv4 = 0;
16146 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16147 .f = cmd_set_mplsogre_decap_parsed,
16149 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16151 (void *)&cmd_set_mplsogre_decap_set,
16152 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16153 (void *)&cmd_set_mplsogre_decap_ip_version,
16154 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16159 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16160 .f = cmd_set_mplsogre_decap_parsed,
16162 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16164 (void *)&cmd_set_mplsogre_decap_set,
16165 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16166 (void *)&cmd_set_mplsogre_decap_ip_version,
16167 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16172 /** Set MPLSoUDP encapsulation details */
16173 struct cmd_set_mplsoudp_encap_result {
16174 cmdline_fixed_string_t set;
16175 cmdline_fixed_string_t mplsoudp;
16176 cmdline_fixed_string_t pos_token;
16177 cmdline_fixed_string_t ip_version;
16178 uint32_t vlan_present:1;
16182 cmdline_ipaddr_t ip_src;
16183 cmdline_ipaddr_t ip_dst;
16185 struct rte_ether_addr eth_src;
16186 struct rte_ether_addr eth_dst;
16189 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16190 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16192 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16193 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16195 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16196 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16197 mplsoudp, "mplsoudp_encap-with-vlan");
16198 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16199 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16200 pos_token, "ip-version");
16201 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16202 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16203 ip_version, "ipv4#ipv6");
16204 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16205 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16206 pos_token, "label");
16207 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16208 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16210 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16211 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16212 pos_token, "udp-src");
16213 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16214 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16216 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16217 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16218 pos_token, "udp-dst");
16219 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16220 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16222 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16223 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16224 pos_token, "ip-src");
16225 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16226 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16227 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16228 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16229 pos_token, "ip-dst");
16230 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16231 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16232 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16233 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16234 pos_token, "vlan-tci");
16235 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16236 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16238 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16239 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16240 pos_token, "eth-src");
16241 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16242 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16244 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16245 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16246 pos_token, "eth-dst");
16247 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16248 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16251 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16252 __rte_unused struct cmdline *cl,
16253 __rte_unused void *data)
16255 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16257 uint32_t mplsoudp_label;
16260 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16263 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16264 mplsoudp_encap_conf.select_vlan = 0;
16265 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16266 mplsoudp_encap_conf.select_vlan = 1;
16267 if (strcmp(res->ip_version, "ipv4") == 0)
16268 mplsoudp_encap_conf.select_ipv4 = 1;
16269 else if (strcmp(res->ip_version, "ipv6") == 0)
16270 mplsoudp_encap_conf.select_ipv4 = 0;
16273 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16274 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16275 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16276 if (mplsoudp_encap_conf.select_ipv4) {
16277 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16278 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16280 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16281 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16283 if (mplsoudp_encap_conf.select_vlan)
16284 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16285 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16286 RTE_ETHER_ADDR_LEN);
16287 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16288 RTE_ETHER_ADDR_LEN);
16291 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16292 .f = cmd_set_mplsoudp_encap_parsed,
16294 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16295 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16296 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16298 (void *)&cmd_set_mplsoudp_encap_set,
16299 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16300 (void *)&cmd_set_mplsoudp_encap_ip_version,
16301 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16302 (void *)&cmd_set_mplsoudp_encap_label,
16303 (void *)&cmd_set_mplsoudp_encap_label_value,
16304 (void *)&cmd_set_mplsoudp_encap_udp_src,
16305 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16306 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16307 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16308 (void *)&cmd_set_mplsoudp_encap_ip_src,
16309 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16310 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16311 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16312 (void *)&cmd_set_mplsoudp_encap_eth_src,
16313 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16314 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16315 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16320 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16321 .f = cmd_set_mplsoudp_encap_parsed,
16323 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16324 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16325 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16326 " eth-src <eth-src> eth-dst <eth-dst>",
16328 (void *)&cmd_set_mplsoudp_encap_set,
16329 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16330 (void *)&cmd_set_mplsoudp_encap_ip_version,
16331 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16332 (void *)&cmd_set_mplsoudp_encap_label,
16333 (void *)&cmd_set_mplsoudp_encap_label_value,
16334 (void *)&cmd_set_mplsoudp_encap_udp_src,
16335 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16336 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16337 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16338 (void *)&cmd_set_mplsoudp_encap_ip_src,
16339 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16340 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16341 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16342 (void *)&cmd_set_mplsoudp_encap_vlan,
16343 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16344 (void *)&cmd_set_mplsoudp_encap_eth_src,
16345 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16346 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16347 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16352 /** Set MPLSoUDP decapsulation details */
16353 struct cmd_set_mplsoudp_decap_result {
16354 cmdline_fixed_string_t set;
16355 cmdline_fixed_string_t mplsoudp;
16356 cmdline_fixed_string_t pos_token;
16357 cmdline_fixed_string_t ip_version;
16358 uint32_t vlan_present:1;
16361 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16362 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16364 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16365 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16367 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16368 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16369 mplsoudp, "mplsoudp_decap-with-vlan");
16370 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16371 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16372 pos_token, "ip-version");
16373 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16374 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16375 ip_version, "ipv4#ipv6");
16377 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16378 __rte_unused struct cmdline *cl,
16379 __rte_unused void *data)
16381 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16383 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16384 mplsoudp_decap_conf.select_vlan = 0;
16385 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16386 mplsoudp_decap_conf.select_vlan = 1;
16387 if (strcmp(res->ip_version, "ipv4") == 0)
16388 mplsoudp_decap_conf.select_ipv4 = 1;
16389 else if (strcmp(res->ip_version, "ipv6") == 0)
16390 mplsoudp_decap_conf.select_ipv4 = 0;
16393 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16394 .f = cmd_set_mplsoudp_decap_parsed,
16396 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16398 (void *)&cmd_set_mplsoudp_decap_set,
16399 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16400 (void *)&cmd_set_mplsoudp_decap_ip_version,
16401 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16406 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16407 .f = cmd_set_mplsoudp_decap_parsed,
16409 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16411 (void *)&cmd_set_mplsoudp_decap_set,
16412 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16413 (void *)&cmd_set_mplsoudp_decap_ip_version,
16414 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16419 /* Strict link priority scheduling mode setting */
16421 cmd_strict_link_prio_parsed(
16422 void *parsed_result,
16423 __rte_unused struct cmdline *cl,
16424 __rte_unused void *data)
16426 struct cmd_vf_tc_bw_result *res = parsed_result;
16427 int ret = -ENOTSUP;
16429 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16432 #ifdef RTE_LIBRTE_I40E_PMD
16433 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16440 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16443 printf("invalid port_id %d\n", res->port_id);
16446 printf("function not implemented\n");
16449 printf("programming error: (%s)\n", strerror(-ret));
16453 cmdline_parse_inst_t cmd_strict_link_prio = {
16454 .f = cmd_strict_link_prio_parsed,
16456 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16458 (void *)&cmd_vf_tc_bw_set,
16459 (void *)&cmd_vf_tc_bw_tx,
16460 (void *)&cmd_vf_tc_bw_strict_link_prio,
16461 (void *)&cmd_vf_tc_bw_port_id,
16462 (void *)&cmd_vf_tc_bw_tc_map,
16467 /* Load dynamic device personalization*/
16468 struct cmd_ddp_add_result {
16469 cmdline_fixed_string_t ddp;
16470 cmdline_fixed_string_t add;
16475 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16476 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16477 cmdline_parse_token_string_t cmd_ddp_add_add =
16478 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16479 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16480 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16481 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16482 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16485 cmd_ddp_add_parsed(
16486 void *parsed_result,
16487 __rte_unused struct cmdline *cl,
16488 __rte_unused void *data)
16490 struct cmd_ddp_add_result *res = parsed_result;
16496 int ret = -ENOTSUP;
16498 if (!all_ports_stopped()) {
16499 printf("Please stop all ports first\n");
16503 filepath = strdup(res->filepath);
16504 if (filepath == NULL) {
16505 printf("Failed to allocate memory\n");
16508 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16510 buff = open_file(file_fld[0], &size);
16512 free((void *)filepath);
16516 #ifdef RTE_LIBRTE_I40E_PMD
16517 if (ret == -ENOTSUP)
16518 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16520 RTE_PMD_I40E_PKG_OP_WR_ADD);
16523 if (ret == -EEXIST)
16524 printf("Profile has already existed.\n");
16526 printf("Failed to load profile.\n");
16527 else if (file_num == 2)
16528 save_file(file_fld[1], buff, size);
16531 free((void *)filepath);
16534 cmdline_parse_inst_t cmd_ddp_add = {
16535 .f = cmd_ddp_add_parsed,
16537 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16539 (void *)&cmd_ddp_add_ddp,
16540 (void *)&cmd_ddp_add_add,
16541 (void *)&cmd_ddp_add_port_id,
16542 (void *)&cmd_ddp_add_filepath,
16547 /* Delete dynamic device personalization*/
16548 struct cmd_ddp_del_result {
16549 cmdline_fixed_string_t ddp;
16550 cmdline_fixed_string_t del;
16555 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16556 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16557 cmdline_parse_token_string_t cmd_ddp_del_del =
16558 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16559 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16560 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16561 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16562 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16565 cmd_ddp_del_parsed(
16566 void *parsed_result,
16567 __rte_unused struct cmdline *cl,
16568 __rte_unused void *data)
16570 struct cmd_ddp_del_result *res = parsed_result;
16573 int ret = -ENOTSUP;
16575 if (!all_ports_stopped()) {
16576 printf("Please stop all ports first\n");
16580 buff = open_file(res->filepath, &size);
16584 #ifdef RTE_LIBRTE_I40E_PMD
16585 if (ret == -ENOTSUP)
16586 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16588 RTE_PMD_I40E_PKG_OP_WR_DEL);
16591 if (ret == -EACCES)
16592 printf("Profile does not exist.\n");
16594 printf("Failed to delete profile.\n");
16599 cmdline_parse_inst_t cmd_ddp_del = {
16600 .f = cmd_ddp_del_parsed,
16602 .help_str = "ddp del <port_id> <backup_profile_path>",
16604 (void *)&cmd_ddp_del_ddp,
16605 (void *)&cmd_ddp_del_del,
16606 (void *)&cmd_ddp_del_port_id,
16607 (void *)&cmd_ddp_del_filepath,
16612 /* Get dynamic device personalization profile info */
16613 struct cmd_ddp_info_result {
16614 cmdline_fixed_string_t ddp;
16615 cmdline_fixed_string_t get;
16616 cmdline_fixed_string_t info;
16620 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16621 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16622 cmdline_parse_token_string_t cmd_ddp_info_get =
16623 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16624 cmdline_parse_token_string_t cmd_ddp_info_info =
16625 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16626 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16627 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16630 cmd_ddp_info_parsed(
16631 void *parsed_result,
16632 __rte_unused struct cmdline *cl,
16633 __rte_unused void *data)
16635 struct cmd_ddp_info_result *res = parsed_result;
16638 int ret = -ENOTSUP;
16639 #ifdef RTE_LIBRTE_I40E_PMD
16642 uint32_t buff_size = 0;
16643 struct rte_pmd_i40e_profile_info info;
16644 uint32_t dev_num = 0;
16645 struct rte_pmd_i40e_ddp_device_id *devs;
16646 uint32_t proto_num = 0;
16647 struct rte_pmd_i40e_proto_info *proto = NULL;
16648 uint32_t pctype_num = 0;
16649 struct rte_pmd_i40e_ptype_info *pctype;
16650 uint32_t ptype_num = 0;
16651 struct rte_pmd_i40e_ptype_info *ptype;
16656 pkg = open_file(res->filepath, &pkg_size);
16660 #ifdef RTE_LIBRTE_I40E_PMD
16661 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16662 (uint8_t *)&info, sizeof(info),
16663 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16665 printf("Global Track id: 0x%x\n", info.track_id);
16666 printf("Global Version: %d.%d.%d.%d\n",
16667 info.version.major,
16668 info.version.minor,
16669 info.version.update,
16670 info.version.draft);
16671 printf("Global Package name: %s\n\n", info.name);
16674 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16675 (uint8_t *)&info, sizeof(info),
16676 RTE_PMD_I40E_PKG_INFO_HEADER);
16678 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16679 printf("i40e Profile Version: %d.%d.%d.%d\n",
16680 info.version.major,
16681 info.version.minor,
16682 info.version.update,
16683 info.version.draft);
16684 printf("i40e Profile name: %s\n\n", info.name);
16687 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16688 (uint8_t *)&buff_size, sizeof(buff_size),
16689 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16690 if (!ret && buff_size) {
16691 buff = (uint8_t *)malloc(buff_size);
16693 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16695 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16697 printf("Package Notes:\n%s\n\n", buff);
16702 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16703 (uint8_t *)&dev_num, sizeof(dev_num),
16704 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16705 if (!ret && dev_num) {
16706 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16707 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16709 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16710 (uint8_t *)devs, buff_size,
16711 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16713 printf("List of supported devices:\n");
16714 for (i = 0; i < dev_num; i++) {
16715 printf(" %04X:%04X %04X:%04X\n",
16716 devs[i].vendor_dev_id >> 16,
16717 devs[i].vendor_dev_id & 0xFFFF,
16718 devs[i].sub_vendor_dev_id >> 16,
16719 devs[i].sub_vendor_dev_id & 0xFFFF);
16727 /* get information about protocols and packet types */
16728 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16729 (uint8_t *)&proto_num, sizeof(proto_num),
16730 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16731 if (ret || !proto_num)
16732 goto no_print_return;
16734 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16735 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16737 goto no_print_return;
16739 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16741 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16743 printf("List of used protocols:\n");
16744 for (i = 0; i < proto_num; i++)
16745 printf(" %2u: %s\n", proto[i].proto_id,
16749 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16750 (uint8_t *)&pctype_num, sizeof(pctype_num),
16751 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16752 if (ret || !pctype_num)
16753 goto no_print_pctypes;
16755 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16756 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16758 goto no_print_pctypes;
16760 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16762 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16765 goto no_print_pctypes;
16768 printf("List of defined packet classification types:\n");
16769 for (i = 0; i < pctype_num; i++) {
16770 printf(" %2u:", pctype[i].ptype_id);
16771 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16772 proto_id = pctype[i].protocols[j];
16773 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16774 for (n = 0; n < proto_num; n++) {
16775 if (proto[n].proto_id == proto_id) {
16776 printf(" %s", proto[n].name);
16789 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16791 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16792 if (ret || !ptype_num)
16793 goto no_print_return;
16795 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16796 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16798 goto no_print_return;
16800 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16802 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16805 goto no_print_return;
16807 printf("List of defined packet types:\n");
16808 for (i = 0; i < ptype_num; i++) {
16809 printf(" %2u:", ptype[i].ptype_id);
16810 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16811 proto_id = ptype[i].protocols[j];
16812 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16813 for (n = 0; n < proto_num; n++) {
16814 if (proto[n].proto_id == proto_id) {
16815 printf(" %s", proto[n].name);
16831 if (ret == -ENOTSUP)
16832 printf("Function not supported in PMD driver\n");
16836 cmdline_parse_inst_t cmd_ddp_get_info = {
16837 .f = cmd_ddp_info_parsed,
16839 .help_str = "ddp get info <profile_path>",
16841 (void *)&cmd_ddp_info_ddp,
16842 (void *)&cmd_ddp_info_get,
16843 (void *)&cmd_ddp_info_info,
16844 (void *)&cmd_ddp_info_filepath,
16849 /* Get dynamic device personalization profile info list*/
16850 #define PROFILE_INFO_SIZE 48
16851 #define MAX_PROFILE_NUM 16
16853 struct cmd_ddp_get_list_result {
16854 cmdline_fixed_string_t ddp;
16855 cmdline_fixed_string_t get;
16856 cmdline_fixed_string_t list;
16860 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16861 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16862 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16863 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16864 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16865 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16866 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16867 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16870 cmd_ddp_get_list_parsed(
16871 __rte_unused void *parsed_result,
16872 __rte_unused struct cmdline *cl,
16873 __rte_unused void *data)
16875 #ifdef RTE_LIBRTE_I40E_PMD
16876 struct cmd_ddp_get_list_result *res = parsed_result;
16877 struct rte_pmd_i40e_profile_list *p_list;
16878 struct rte_pmd_i40e_profile_info *p_info;
16883 int ret = -ENOTSUP;
16885 #ifdef RTE_LIBRTE_I40E_PMD
16886 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16887 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16889 printf("%s: Failed to malloc buffer\n", __func__);
16891 if (ret == -ENOTSUP)
16892 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16893 (uint8_t *)p_list, size);
16896 p_num = p_list->p_count;
16897 printf("Profile number is: %d\n\n", p_num);
16899 for (i = 0; i < p_num; i++) {
16900 p_info = &p_list->p_info[i];
16901 printf("Profile %d:\n", i);
16902 printf("Track id: 0x%x\n", p_info->track_id);
16903 printf("Version: %d.%d.%d.%d\n",
16904 p_info->version.major,
16905 p_info->version.minor,
16906 p_info->version.update,
16907 p_info->version.draft);
16908 printf("Profile name: %s\n\n", p_info->name);
16916 printf("Failed to get ddp list\n");
16919 cmdline_parse_inst_t cmd_ddp_get_list = {
16920 .f = cmd_ddp_get_list_parsed,
16922 .help_str = "ddp get list <port_id>",
16924 (void *)&cmd_ddp_get_list_ddp,
16925 (void *)&cmd_ddp_get_list_get,
16926 (void *)&cmd_ddp_get_list_list,
16927 (void *)&cmd_ddp_get_list_port_id,
16932 /* Configure input set */
16933 struct cmd_cfg_input_set_result {
16934 cmdline_fixed_string_t port;
16935 cmdline_fixed_string_t cfg;
16937 cmdline_fixed_string_t pctype;
16939 cmdline_fixed_string_t inset_type;
16940 cmdline_fixed_string_t opt;
16941 cmdline_fixed_string_t field;
16946 cmd_cfg_input_set_parsed(
16947 __rte_unused void *parsed_result,
16948 __rte_unused struct cmdline *cl,
16949 __rte_unused void *data)
16951 #ifdef RTE_LIBRTE_I40E_PMD
16952 struct cmd_cfg_input_set_result *res = parsed_result;
16953 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16954 struct rte_pmd_i40e_inset inset;
16956 int ret = -ENOTSUP;
16958 if (!all_ports_stopped()) {
16959 printf("Please stop all ports first\n");
16963 #ifdef RTE_LIBRTE_I40E_PMD
16964 if (!strcmp(res->inset_type, "hash_inset"))
16965 inset_type = INSET_HASH;
16966 else if (!strcmp(res->inset_type, "fdir_inset"))
16967 inset_type = INSET_FDIR;
16968 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16969 inset_type = INSET_FDIR_FLX;
16970 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16971 &inset, inset_type);
16973 printf("Failed to get input set.\n");
16977 if (!strcmp(res->opt, "get")) {
16978 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16981 printf("Field index %d is enabled.\n", res->field_idx);
16983 printf("Field index %d is disabled.\n", res->field_idx);
16985 } else if (!strcmp(res->opt, "set"))
16986 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16988 else if (!strcmp(res->opt, "clear"))
16989 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16992 printf("Failed to configure input set field.\n");
16996 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16997 &inset, inset_type);
16999 printf("Failed to set input set.\n");
17004 if (ret == -ENOTSUP)
17005 printf("Function not supported\n");
17008 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17009 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17011 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17012 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17014 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17015 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17017 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17018 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17020 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17021 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17023 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17024 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17026 "hash_inset#fdir_inset#fdir_flx_inset");
17027 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17028 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17029 opt, "get#set#clear");
17030 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17031 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17033 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17034 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17037 cmdline_parse_inst_t cmd_cfg_input_set = {
17038 .f = cmd_cfg_input_set_parsed,
17040 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17041 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17043 (void *)&cmd_cfg_input_set_port,
17044 (void *)&cmd_cfg_input_set_cfg,
17045 (void *)&cmd_cfg_input_set_port_id,
17046 (void *)&cmd_cfg_input_set_pctype,
17047 (void *)&cmd_cfg_input_set_pctype_id,
17048 (void *)&cmd_cfg_input_set_inset_type,
17049 (void *)&cmd_cfg_input_set_opt,
17050 (void *)&cmd_cfg_input_set_field,
17051 (void *)&cmd_cfg_input_set_field_idx,
17056 /* Clear input set */
17057 struct cmd_clear_input_set_result {
17058 cmdline_fixed_string_t port;
17059 cmdline_fixed_string_t cfg;
17061 cmdline_fixed_string_t pctype;
17063 cmdline_fixed_string_t inset_type;
17064 cmdline_fixed_string_t clear;
17065 cmdline_fixed_string_t all;
17069 cmd_clear_input_set_parsed(
17070 __rte_unused void *parsed_result,
17071 __rte_unused struct cmdline *cl,
17072 __rte_unused void *data)
17074 #ifdef RTE_LIBRTE_I40E_PMD
17075 struct cmd_clear_input_set_result *res = parsed_result;
17076 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17077 struct rte_pmd_i40e_inset inset;
17079 int ret = -ENOTSUP;
17081 if (!all_ports_stopped()) {
17082 printf("Please stop all ports first\n");
17086 #ifdef RTE_LIBRTE_I40E_PMD
17087 if (!strcmp(res->inset_type, "hash_inset"))
17088 inset_type = INSET_HASH;
17089 else if (!strcmp(res->inset_type, "fdir_inset"))
17090 inset_type = INSET_FDIR;
17091 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17092 inset_type = INSET_FDIR_FLX;
17094 memset(&inset, 0, sizeof(inset));
17096 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17097 &inset, inset_type);
17099 printf("Failed to clear input set.\n");
17105 if (ret == -ENOTSUP)
17106 printf("Function not supported\n");
17109 cmdline_parse_token_string_t cmd_clear_input_set_port =
17110 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17112 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17113 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17115 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17116 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17118 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17119 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17121 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17122 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17124 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17125 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17127 "hash_inset#fdir_inset#fdir_flx_inset");
17128 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17129 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17131 cmdline_parse_token_string_t cmd_clear_input_set_all =
17132 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17135 cmdline_parse_inst_t cmd_clear_input_set = {
17136 .f = cmd_clear_input_set_parsed,
17138 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17139 "fdir_inset|fdir_flx_inset clear all",
17141 (void *)&cmd_clear_input_set_port,
17142 (void *)&cmd_clear_input_set_cfg,
17143 (void *)&cmd_clear_input_set_port_id,
17144 (void *)&cmd_clear_input_set_pctype,
17145 (void *)&cmd_clear_input_set_pctype_id,
17146 (void *)&cmd_clear_input_set_inset_type,
17147 (void *)&cmd_clear_input_set_clear,
17148 (void *)&cmd_clear_input_set_all,
17153 /* show vf stats */
17155 /* Common result structure for show vf stats */
17156 struct cmd_show_vf_stats_result {
17157 cmdline_fixed_string_t show;
17158 cmdline_fixed_string_t vf;
17159 cmdline_fixed_string_t stats;
17164 /* Common CLI fields show vf stats*/
17165 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17166 TOKEN_STRING_INITIALIZER
17167 (struct cmd_show_vf_stats_result,
17169 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17170 TOKEN_STRING_INITIALIZER
17171 (struct cmd_show_vf_stats_result,
17173 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17174 TOKEN_STRING_INITIALIZER
17175 (struct cmd_show_vf_stats_result,
17177 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17178 TOKEN_NUM_INITIALIZER
17179 (struct cmd_show_vf_stats_result,
17181 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17182 TOKEN_NUM_INITIALIZER
17183 (struct cmd_show_vf_stats_result,
17187 cmd_show_vf_stats_parsed(
17188 void *parsed_result,
17189 __rte_unused struct cmdline *cl,
17190 __rte_unused void *data)
17192 struct cmd_show_vf_stats_result *res = parsed_result;
17193 struct rte_eth_stats stats;
17194 int ret = -ENOTSUP;
17195 static const char *nic_stats_border = "########################";
17197 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17200 memset(&stats, 0, sizeof(stats));
17202 #ifdef RTE_LIBRTE_I40E_PMD
17203 if (ret == -ENOTSUP)
17204 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17208 #ifdef RTE_LIBRTE_BNXT_PMD
17209 if (ret == -ENOTSUP)
17210 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17219 printf("invalid vf_id %d\n", res->vf_id);
17222 printf("invalid port_id %d\n", res->port_id);
17225 printf("function not implemented\n");
17228 printf("programming error: (%s)\n", strerror(-ret));
17231 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17232 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17234 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17236 stats.ipackets, stats.imissed, stats.ibytes);
17237 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17238 printf(" RX-nombuf: %-10"PRIu64"\n",
17240 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17242 stats.opackets, stats.oerrors, stats.obytes);
17244 printf(" %s############################%s\n",
17245 nic_stats_border, nic_stats_border);
17248 cmdline_parse_inst_t cmd_show_vf_stats = {
17249 .f = cmd_show_vf_stats_parsed,
17251 .help_str = "show vf stats <port_id> <vf_id>",
17253 (void *)&cmd_show_vf_stats_show,
17254 (void *)&cmd_show_vf_stats_vf,
17255 (void *)&cmd_show_vf_stats_stats,
17256 (void *)&cmd_show_vf_stats_port_id,
17257 (void *)&cmd_show_vf_stats_vf_id,
17262 /* clear vf stats */
17264 /* Common result structure for clear vf stats */
17265 struct cmd_clear_vf_stats_result {
17266 cmdline_fixed_string_t clear;
17267 cmdline_fixed_string_t vf;
17268 cmdline_fixed_string_t stats;
17273 /* Common CLI fields clear vf stats*/
17274 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17275 TOKEN_STRING_INITIALIZER
17276 (struct cmd_clear_vf_stats_result,
17278 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17279 TOKEN_STRING_INITIALIZER
17280 (struct cmd_clear_vf_stats_result,
17282 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17283 TOKEN_STRING_INITIALIZER
17284 (struct cmd_clear_vf_stats_result,
17286 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17287 TOKEN_NUM_INITIALIZER
17288 (struct cmd_clear_vf_stats_result,
17290 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17291 TOKEN_NUM_INITIALIZER
17292 (struct cmd_clear_vf_stats_result,
17296 cmd_clear_vf_stats_parsed(
17297 void *parsed_result,
17298 __rte_unused struct cmdline *cl,
17299 __rte_unused void *data)
17301 struct cmd_clear_vf_stats_result *res = parsed_result;
17302 int ret = -ENOTSUP;
17304 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17307 #ifdef RTE_LIBRTE_I40E_PMD
17308 if (ret == -ENOTSUP)
17309 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17312 #ifdef RTE_LIBRTE_BNXT_PMD
17313 if (ret == -ENOTSUP)
17314 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17322 printf("invalid vf_id %d\n", res->vf_id);
17325 printf("invalid port_id %d\n", res->port_id);
17328 printf("function not implemented\n");
17331 printf("programming error: (%s)\n", strerror(-ret));
17335 cmdline_parse_inst_t cmd_clear_vf_stats = {
17336 .f = cmd_clear_vf_stats_parsed,
17338 .help_str = "clear vf stats <port_id> <vf_id>",
17340 (void *)&cmd_clear_vf_stats_clear,
17341 (void *)&cmd_clear_vf_stats_vf,
17342 (void *)&cmd_clear_vf_stats_stats,
17343 (void *)&cmd_clear_vf_stats_port_id,
17344 (void *)&cmd_clear_vf_stats_vf_id,
17349 /* port config pctype mapping reset */
17351 /* Common result structure for port config pctype mapping reset */
17352 struct cmd_pctype_mapping_reset_result {
17353 cmdline_fixed_string_t port;
17354 cmdline_fixed_string_t config;
17356 cmdline_fixed_string_t pctype;
17357 cmdline_fixed_string_t mapping;
17358 cmdline_fixed_string_t reset;
17361 /* Common CLI fields for port config pctype mapping reset*/
17362 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17363 TOKEN_STRING_INITIALIZER
17364 (struct cmd_pctype_mapping_reset_result,
17366 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17367 TOKEN_STRING_INITIALIZER
17368 (struct cmd_pctype_mapping_reset_result,
17370 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17371 TOKEN_NUM_INITIALIZER
17372 (struct cmd_pctype_mapping_reset_result,
17374 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17375 TOKEN_STRING_INITIALIZER
17376 (struct cmd_pctype_mapping_reset_result,
17378 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17379 TOKEN_STRING_INITIALIZER
17380 (struct cmd_pctype_mapping_reset_result,
17381 mapping, "mapping");
17382 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17383 TOKEN_STRING_INITIALIZER
17384 (struct cmd_pctype_mapping_reset_result,
17388 cmd_pctype_mapping_reset_parsed(
17389 void *parsed_result,
17390 __rte_unused struct cmdline *cl,
17391 __rte_unused void *data)
17393 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17394 int ret = -ENOTSUP;
17396 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17399 #ifdef RTE_LIBRTE_I40E_PMD
17400 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17407 printf("invalid port_id %d\n", res->port_id);
17410 printf("function not implemented\n");
17413 printf("programming error: (%s)\n", strerror(-ret));
17417 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17418 .f = cmd_pctype_mapping_reset_parsed,
17420 .help_str = "port config <port_id> pctype mapping reset",
17422 (void *)&cmd_pctype_mapping_reset_port,
17423 (void *)&cmd_pctype_mapping_reset_config,
17424 (void *)&cmd_pctype_mapping_reset_port_id,
17425 (void *)&cmd_pctype_mapping_reset_pctype,
17426 (void *)&cmd_pctype_mapping_reset_mapping,
17427 (void *)&cmd_pctype_mapping_reset_reset,
17432 /* show port pctype mapping */
17434 /* Common result structure for show port pctype mapping */
17435 struct cmd_pctype_mapping_get_result {
17436 cmdline_fixed_string_t show;
17437 cmdline_fixed_string_t port;
17439 cmdline_fixed_string_t pctype;
17440 cmdline_fixed_string_t mapping;
17443 /* Common CLI fields for pctype mapping get */
17444 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17445 TOKEN_STRING_INITIALIZER
17446 (struct cmd_pctype_mapping_get_result,
17448 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17449 TOKEN_STRING_INITIALIZER
17450 (struct cmd_pctype_mapping_get_result,
17452 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17453 TOKEN_NUM_INITIALIZER
17454 (struct cmd_pctype_mapping_get_result,
17456 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17457 TOKEN_STRING_INITIALIZER
17458 (struct cmd_pctype_mapping_get_result,
17460 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17461 TOKEN_STRING_INITIALIZER
17462 (struct cmd_pctype_mapping_get_result,
17463 mapping, "mapping");
17466 cmd_pctype_mapping_get_parsed(
17467 void *parsed_result,
17468 __rte_unused struct cmdline *cl,
17469 __rte_unused void *data)
17471 struct cmd_pctype_mapping_get_result *res = parsed_result;
17472 int ret = -ENOTSUP;
17473 #ifdef RTE_LIBRTE_I40E_PMD
17474 struct rte_pmd_i40e_flow_type_mapping
17475 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17476 int i, j, first_pctype;
17479 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17482 #ifdef RTE_LIBRTE_I40E_PMD
17483 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17490 printf("invalid port_id %d\n", res->port_id);
17493 printf("function not implemented\n");
17496 printf("programming error: (%s)\n", strerror(-ret));
17500 #ifdef RTE_LIBRTE_I40E_PMD
17501 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17502 if (mapping[i].pctype != 0ULL) {
17505 printf("pctype: ");
17506 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17507 if (mapping[i].pctype & (1ULL << j)) {
17508 printf(first_pctype ?
17509 "%02d" : ",%02d", j);
17513 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17519 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17520 .f = cmd_pctype_mapping_get_parsed,
17522 .help_str = "show port <port_id> pctype mapping",
17524 (void *)&cmd_pctype_mapping_get_show,
17525 (void *)&cmd_pctype_mapping_get_port,
17526 (void *)&cmd_pctype_mapping_get_port_id,
17527 (void *)&cmd_pctype_mapping_get_pctype,
17528 (void *)&cmd_pctype_mapping_get_mapping,
17533 /* port config pctype mapping update */
17535 /* Common result structure for port config pctype mapping update */
17536 struct cmd_pctype_mapping_update_result {
17537 cmdline_fixed_string_t port;
17538 cmdline_fixed_string_t config;
17540 cmdline_fixed_string_t pctype;
17541 cmdline_fixed_string_t mapping;
17542 cmdline_fixed_string_t update;
17543 cmdline_fixed_string_t pctype_list;
17544 uint16_t flow_type;
17547 /* Common CLI fields for pctype mapping update*/
17548 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17549 TOKEN_STRING_INITIALIZER
17550 (struct cmd_pctype_mapping_update_result,
17552 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17553 TOKEN_STRING_INITIALIZER
17554 (struct cmd_pctype_mapping_update_result,
17556 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17557 TOKEN_NUM_INITIALIZER
17558 (struct cmd_pctype_mapping_update_result,
17560 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17561 TOKEN_STRING_INITIALIZER
17562 (struct cmd_pctype_mapping_update_result,
17564 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17565 TOKEN_STRING_INITIALIZER
17566 (struct cmd_pctype_mapping_update_result,
17567 mapping, "mapping");
17568 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17569 TOKEN_STRING_INITIALIZER
17570 (struct cmd_pctype_mapping_update_result,
17572 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17573 TOKEN_STRING_INITIALIZER
17574 (struct cmd_pctype_mapping_update_result,
17575 pctype_list, NULL);
17576 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17577 TOKEN_NUM_INITIALIZER
17578 (struct cmd_pctype_mapping_update_result,
17579 flow_type, UINT16);
17582 cmd_pctype_mapping_update_parsed(
17583 void *parsed_result,
17584 __rte_unused struct cmdline *cl,
17585 __rte_unused void *data)
17587 struct cmd_pctype_mapping_update_result *res = parsed_result;
17588 int ret = -ENOTSUP;
17589 #ifdef RTE_LIBRTE_I40E_PMD
17590 struct rte_pmd_i40e_flow_type_mapping mapping;
17592 unsigned int nb_item;
17593 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17596 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17599 #ifdef RTE_LIBRTE_I40E_PMD
17600 nb_item = parse_item_list(res->pctype_list, "pctypes",
17601 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17602 mapping.flow_type = res->flow_type;
17603 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17604 mapping.pctype |= (1ULL << pctype_list[i]);
17605 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17615 printf("invalid pctype or flow type\n");
17618 printf("invalid port_id %d\n", res->port_id);
17621 printf("function not implemented\n");
17624 printf("programming error: (%s)\n", strerror(-ret));
17628 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17629 .f = cmd_pctype_mapping_update_parsed,
17631 .help_str = "port config <port_id> pctype mapping update"
17632 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17634 (void *)&cmd_pctype_mapping_update_port,
17635 (void *)&cmd_pctype_mapping_update_config,
17636 (void *)&cmd_pctype_mapping_update_port_id,
17637 (void *)&cmd_pctype_mapping_update_pctype,
17638 (void *)&cmd_pctype_mapping_update_mapping,
17639 (void *)&cmd_pctype_mapping_update_update,
17640 (void *)&cmd_pctype_mapping_update_pc_type,
17641 (void *)&cmd_pctype_mapping_update_flow_type,
17646 /* ptype mapping get */
17648 /* Common result structure for ptype mapping get */
17649 struct cmd_ptype_mapping_get_result {
17650 cmdline_fixed_string_t ptype;
17651 cmdline_fixed_string_t mapping;
17652 cmdline_fixed_string_t get;
17654 uint8_t valid_only;
17657 /* Common CLI fields for ptype mapping get */
17658 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17659 TOKEN_STRING_INITIALIZER
17660 (struct cmd_ptype_mapping_get_result,
17662 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17663 TOKEN_STRING_INITIALIZER
17664 (struct cmd_ptype_mapping_get_result,
17665 mapping, "mapping");
17666 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17667 TOKEN_STRING_INITIALIZER
17668 (struct cmd_ptype_mapping_get_result,
17670 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17671 TOKEN_NUM_INITIALIZER
17672 (struct cmd_ptype_mapping_get_result,
17674 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17675 TOKEN_NUM_INITIALIZER
17676 (struct cmd_ptype_mapping_get_result,
17677 valid_only, UINT8);
17680 cmd_ptype_mapping_get_parsed(
17681 void *parsed_result,
17682 __rte_unused struct cmdline *cl,
17683 __rte_unused void *data)
17685 struct cmd_ptype_mapping_get_result *res = parsed_result;
17686 int ret = -ENOTSUP;
17687 #ifdef RTE_LIBRTE_I40E_PMD
17688 int max_ptype_num = 256;
17689 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17694 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17697 #ifdef RTE_LIBRTE_I40E_PMD
17698 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17709 printf("invalid port_id %d\n", res->port_id);
17712 printf("function not implemented\n");
17715 printf("programming error: (%s)\n", strerror(-ret));
17718 #ifdef RTE_LIBRTE_I40E_PMD
17720 for (i = 0; i < count; i++)
17721 printf("%3d\t0x%08x\n",
17722 mapping[i].hw_ptype, mapping[i].sw_ptype);
17727 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17728 .f = cmd_ptype_mapping_get_parsed,
17730 .help_str = "ptype mapping get <port_id> <valid_only>",
17732 (void *)&cmd_ptype_mapping_get_ptype,
17733 (void *)&cmd_ptype_mapping_get_mapping,
17734 (void *)&cmd_ptype_mapping_get_get,
17735 (void *)&cmd_ptype_mapping_get_port_id,
17736 (void *)&cmd_ptype_mapping_get_valid_only,
17741 /* ptype mapping replace */
17743 /* Common result structure for ptype mapping replace */
17744 struct cmd_ptype_mapping_replace_result {
17745 cmdline_fixed_string_t ptype;
17746 cmdline_fixed_string_t mapping;
17747 cmdline_fixed_string_t replace;
17754 /* Common CLI fields for ptype mapping replace */
17755 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17756 TOKEN_STRING_INITIALIZER
17757 (struct cmd_ptype_mapping_replace_result,
17759 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17760 TOKEN_STRING_INITIALIZER
17761 (struct cmd_ptype_mapping_replace_result,
17762 mapping, "mapping");
17763 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17764 TOKEN_STRING_INITIALIZER
17765 (struct cmd_ptype_mapping_replace_result,
17766 replace, "replace");
17767 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17768 TOKEN_NUM_INITIALIZER
17769 (struct cmd_ptype_mapping_replace_result,
17771 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17772 TOKEN_NUM_INITIALIZER
17773 (struct cmd_ptype_mapping_replace_result,
17775 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17776 TOKEN_NUM_INITIALIZER
17777 (struct cmd_ptype_mapping_replace_result,
17779 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17780 TOKEN_NUM_INITIALIZER
17781 (struct cmd_ptype_mapping_replace_result,
17785 cmd_ptype_mapping_replace_parsed(
17786 void *parsed_result,
17787 __rte_unused struct cmdline *cl,
17788 __rte_unused void *data)
17790 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17791 int ret = -ENOTSUP;
17793 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17796 #ifdef RTE_LIBRTE_I40E_PMD
17797 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17807 printf("invalid ptype 0x%8x or 0x%8x\n",
17808 res->target, res->pkt_type);
17811 printf("invalid port_id %d\n", res->port_id);
17814 printf("function not implemented\n");
17817 printf("programming error: (%s)\n", strerror(-ret));
17821 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17822 .f = cmd_ptype_mapping_replace_parsed,
17825 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17827 (void *)&cmd_ptype_mapping_replace_ptype,
17828 (void *)&cmd_ptype_mapping_replace_mapping,
17829 (void *)&cmd_ptype_mapping_replace_replace,
17830 (void *)&cmd_ptype_mapping_replace_port_id,
17831 (void *)&cmd_ptype_mapping_replace_target,
17832 (void *)&cmd_ptype_mapping_replace_mask,
17833 (void *)&cmd_ptype_mapping_replace_pkt_type,
17838 /* ptype mapping reset */
17840 /* Common result structure for ptype mapping reset */
17841 struct cmd_ptype_mapping_reset_result {
17842 cmdline_fixed_string_t ptype;
17843 cmdline_fixed_string_t mapping;
17844 cmdline_fixed_string_t reset;
17848 /* Common CLI fields for ptype mapping reset*/
17849 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17850 TOKEN_STRING_INITIALIZER
17851 (struct cmd_ptype_mapping_reset_result,
17853 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17854 TOKEN_STRING_INITIALIZER
17855 (struct cmd_ptype_mapping_reset_result,
17856 mapping, "mapping");
17857 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17858 TOKEN_STRING_INITIALIZER
17859 (struct cmd_ptype_mapping_reset_result,
17861 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17862 TOKEN_NUM_INITIALIZER
17863 (struct cmd_ptype_mapping_reset_result,
17867 cmd_ptype_mapping_reset_parsed(
17868 void *parsed_result,
17869 __rte_unused struct cmdline *cl,
17870 __rte_unused void *data)
17872 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17873 int ret = -ENOTSUP;
17875 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17878 #ifdef RTE_LIBRTE_I40E_PMD
17879 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17886 printf("invalid port_id %d\n", res->port_id);
17889 printf("function not implemented\n");
17892 printf("programming error: (%s)\n", strerror(-ret));
17896 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17897 .f = cmd_ptype_mapping_reset_parsed,
17899 .help_str = "ptype mapping reset <port_id>",
17901 (void *)&cmd_ptype_mapping_reset_ptype,
17902 (void *)&cmd_ptype_mapping_reset_mapping,
17903 (void *)&cmd_ptype_mapping_reset_reset,
17904 (void *)&cmd_ptype_mapping_reset_port_id,
17909 /* ptype mapping update */
17911 /* Common result structure for ptype mapping update */
17912 struct cmd_ptype_mapping_update_result {
17913 cmdline_fixed_string_t ptype;
17914 cmdline_fixed_string_t mapping;
17915 cmdline_fixed_string_t reset;
17921 /* Common CLI fields for ptype mapping update*/
17922 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17923 TOKEN_STRING_INITIALIZER
17924 (struct cmd_ptype_mapping_update_result,
17926 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17927 TOKEN_STRING_INITIALIZER
17928 (struct cmd_ptype_mapping_update_result,
17929 mapping, "mapping");
17930 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17931 TOKEN_STRING_INITIALIZER
17932 (struct cmd_ptype_mapping_update_result,
17934 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17935 TOKEN_NUM_INITIALIZER
17936 (struct cmd_ptype_mapping_update_result,
17938 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17939 TOKEN_NUM_INITIALIZER
17940 (struct cmd_ptype_mapping_update_result,
17942 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17943 TOKEN_NUM_INITIALIZER
17944 (struct cmd_ptype_mapping_update_result,
17948 cmd_ptype_mapping_update_parsed(
17949 void *parsed_result,
17950 __rte_unused struct cmdline *cl,
17951 __rte_unused void *data)
17953 struct cmd_ptype_mapping_update_result *res = parsed_result;
17954 int ret = -ENOTSUP;
17955 #ifdef RTE_LIBRTE_I40E_PMD
17956 struct rte_pmd_i40e_ptype_mapping mapping;
17958 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17961 #ifdef RTE_LIBRTE_I40E_PMD
17962 mapping.hw_ptype = res->hw_ptype;
17963 mapping.sw_ptype = res->sw_ptype;
17964 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17974 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17977 printf("invalid port_id %d\n", res->port_id);
17980 printf("function not implemented\n");
17983 printf("programming error: (%s)\n", strerror(-ret));
17987 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17988 .f = cmd_ptype_mapping_update_parsed,
17990 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17992 (void *)&cmd_ptype_mapping_update_ptype,
17993 (void *)&cmd_ptype_mapping_update_mapping,
17994 (void *)&cmd_ptype_mapping_update_update,
17995 (void *)&cmd_ptype_mapping_update_port_id,
17996 (void *)&cmd_ptype_mapping_update_hw_ptype,
17997 (void *)&cmd_ptype_mapping_update_sw_ptype,
18002 /* Common result structure for file commands */
18003 struct cmd_cmdfile_result {
18004 cmdline_fixed_string_t load;
18005 cmdline_fixed_string_t filename;
18008 /* Common CLI fields for file commands */
18009 cmdline_parse_token_string_t cmd_load_cmdfile =
18010 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18011 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18012 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18015 cmd_load_from_file_parsed(
18016 void *parsed_result,
18017 __rte_unused struct cmdline *cl,
18018 __rte_unused void *data)
18020 struct cmd_cmdfile_result *res = parsed_result;
18022 cmdline_read_from_file(res->filename);
18025 cmdline_parse_inst_t cmd_load_from_file = {
18026 .f = cmd_load_from_file_parsed,
18028 .help_str = "load <filename>",
18030 (void *)&cmd_load_cmdfile,
18031 (void *)&cmd_load_cmdfile_filename,
18036 /* Get Rx offloads capabilities */
18037 struct cmd_rx_offload_get_capa_result {
18038 cmdline_fixed_string_t show;
18039 cmdline_fixed_string_t port;
18041 cmdline_fixed_string_t rx_offload;
18042 cmdline_fixed_string_t capabilities;
18045 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18046 TOKEN_STRING_INITIALIZER
18047 (struct cmd_rx_offload_get_capa_result,
18049 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18050 TOKEN_STRING_INITIALIZER
18051 (struct cmd_rx_offload_get_capa_result,
18053 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18054 TOKEN_NUM_INITIALIZER
18055 (struct cmd_rx_offload_get_capa_result,
18057 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18058 TOKEN_STRING_INITIALIZER
18059 (struct cmd_rx_offload_get_capa_result,
18060 rx_offload, "rx_offload");
18061 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18062 TOKEN_STRING_INITIALIZER
18063 (struct cmd_rx_offload_get_capa_result,
18064 capabilities, "capabilities");
18067 print_rx_offloads(uint64_t offloads)
18069 uint64_t single_offload;
18077 begin = __builtin_ctzll(offloads);
18078 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18080 single_offload = 1ULL << begin;
18081 for (bit = begin; bit < end; bit++) {
18082 if (offloads & single_offload)
18084 rte_eth_dev_rx_offload_name(single_offload));
18085 single_offload <<= 1;
18090 cmd_rx_offload_get_capa_parsed(
18091 void *parsed_result,
18092 __rte_unused struct cmdline *cl,
18093 __rte_unused void *data)
18095 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18096 struct rte_eth_dev_info dev_info;
18097 portid_t port_id = res->port_id;
18098 uint64_t queue_offloads;
18099 uint64_t port_offloads;
18102 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18106 queue_offloads = dev_info.rx_queue_offload_capa;
18107 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18109 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18110 printf(" Per Queue :");
18111 print_rx_offloads(queue_offloads);
18114 printf(" Per Port :");
18115 print_rx_offloads(port_offloads);
18119 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18120 .f = cmd_rx_offload_get_capa_parsed,
18122 .help_str = "show port <port_id> rx_offload capabilities",
18124 (void *)&cmd_rx_offload_get_capa_show,
18125 (void *)&cmd_rx_offload_get_capa_port,
18126 (void *)&cmd_rx_offload_get_capa_port_id,
18127 (void *)&cmd_rx_offload_get_capa_rx_offload,
18128 (void *)&cmd_rx_offload_get_capa_capabilities,
18133 /* Get Rx offloads configuration */
18134 struct cmd_rx_offload_get_configuration_result {
18135 cmdline_fixed_string_t show;
18136 cmdline_fixed_string_t port;
18138 cmdline_fixed_string_t rx_offload;
18139 cmdline_fixed_string_t configuration;
18142 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18143 TOKEN_STRING_INITIALIZER
18144 (struct cmd_rx_offload_get_configuration_result,
18146 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18147 TOKEN_STRING_INITIALIZER
18148 (struct cmd_rx_offload_get_configuration_result,
18150 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18151 TOKEN_NUM_INITIALIZER
18152 (struct cmd_rx_offload_get_configuration_result,
18154 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18155 TOKEN_STRING_INITIALIZER
18156 (struct cmd_rx_offload_get_configuration_result,
18157 rx_offload, "rx_offload");
18158 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18159 TOKEN_STRING_INITIALIZER
18160 (struct cmd_rx_offload_get_configuration_result,
18161 configuration, "configuration");
18164 cmd_rx_offload_get_configuration_parsed(
18165 void *parsed_result,
18166 __rte_unused struct cmdline *cl,
18167 __rte_unused void *data)
18169 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18170 struct rte_eth_dev_info dev_info;
18171 portid_t port_id = res->port_id;
18172 struct rte_port *port = &ports[port_id];
18173 uint64_t port_offloads;
18174 uint64_t queue_offloads;
18175 uint16_t nb_rx_queues;
18179 printf("Rx Offloading Configuration of port %d :\n", port_id);
18181 port_offloads = port->dev_conf.rxmode.offloads;
18183 print_rx_offloads(port_offloads);
18186 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18190 nb_rx_queues = dev_info.nb_rx_queues;
18191 for (q = 0; q < nb_rx_queues; q++) {
18192 queue_offloads = port->rx_conf[q].offloads;
18193 printf(" Queue[%2d] :", q);
18194 print_rx_offloads(queue_offloads);
18200 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18201 .f = cmd_rx_offload_get_configuration_parsed,
18203 .help_str = "show port <port_id> rx_offload configuration",
18205 (void *)&cmd_rx_offload_get_configuration_show,
18206 (void *)&cmd_rx_offload_get_configuration_port,
18207 (void *)&cmd_rx_offload_get_configuration_port_id,
18208 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18209 (void *)&cmd_rx_offload_get_configuration_configuration,
18214 /* Enable/Disable a per port offloading */
18215 struct cmd_config_per_port_rx_offload_result {
18216 cmdline_fixed_string_t port;
18217 cmdline_fixed_string_t config;
18219 cmdline_fixed_string_t rx_offload;
18220 cmdline_fixed_string_t offload;
18221 cmdline_fixed_string_t on_off;
18224 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18225 TOKEN_STRING_INITIALIZER
18226 (struct cmd_config_per_port_rx_offload_result,
18228 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18229 TOKEN_STRING_INITIALIZER
18230 (struct cmd_config_per_port_rx_offload_result,
18232 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18233 TOKEN_NUM_INITIALIZER
18234 (struct cmd_config_per_port_rx_offload_result,
18236 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18237 TOKEN_STRING_INITIALIZER
18238 (struct cmd_config_per_port_rx_offload_result,
18239 rx_offload, "rx_offload");
18240 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18241 TOKEN_STRING_INITIALIZER
18242 (struct cmd_config_per_port_rx_offload_result,
18243 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18244 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18245 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18246 "scatter#timestamp#security#keep_crc#rss_hash");
18247 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18248 TOKEN_STRING_INITIALIZER
18249 (struct cmd_config_per_port_rx_offload_result,
18253 search_rx_offload(const char *name)
18255 uint64_t single_offload;
18256 const char *single_name;
18260 single_offload = 1;
18261 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18262 single_name = rte_eth_dev_rx_offload_name(single_offload);
18263 if (!strcasecmp(single_name, name)) {
18267 single_offload <<= 1;
18271 return single_offload;
18277 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18278 __rte_unused struct cmdline *cl,
18279 __rte_unused void *data)
18281 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18282 portid_t port_id = res->port_id;
18283 struct rte_eth_dev_info dev_info;
18284 struct rte_port *port = &ports[port_id];
18285 uint64_t single_offload;
18286 uint16_t nb_rx_queues;
18290 if (port->port_status != RTE_PORT_STOPPED) {
18291 printf("Error: Can't config offload when Port %d "
18292 "is not stopped\n", port_id);
18296 single_offload = search_rx_offload(res->offload);
18297 if (single_offload == 0) {
18298 printf("Unknown offload name: %s\n", res->offload);
18302 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18306 nb_rx_queues = dev_info.nb_rx_queues;
18307 if (!strcmp(res->on_off, "on")) {
18308 port->dev_conf.rxmode.offloads |= single_offload;
18309 for (q = 0; q < nb_rx_queues; q++)
18310 port->rx_conf[q].offloads |= single_offload;
18312 port->dev_conf.rxmode.offloads &= ~single_offload;
18313 for (q = 0; q < nb_rx_queues; q++)
18314 port->rx_conf[q].offloads &= ~single_offload;
18317 cmd_reconfig_device_queue(port_id, 1, 1);
18320 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18321 .f = cmd_config_per_port_rx_offload_parsed,
18323 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18324 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18325 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18326 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18329 (void *)&cmd_config_per_port_rx_offload_result_port,
18330 (void *)&cmd_config_per_port_rx_offload_result_config,
18331 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18332 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18333 (void *)&cmd_config_per_port_rx_offload_result_offload,
18334 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18339 /* Enable/Disable a per queue offloading */
18340 struct cmd_config_per_queue_rx_offload_result {
18341 cmdline_fixed_string_t port;
18343 cmdline_fixed_string_t rxq;
18345 cmdline_fixed_string_t rx_offload;
18346 cmdline_fixed_string_t offload;
18347 cmdline_fixed_string_t on_off;
18350 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18351 TOKEN_STRING_INITIALIZER
18352 (struct cmd_config_per_queue_rx_offload_result,
18354 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18355 TOKEN_NUM_INITIALIZER
18356 (struct cmd_config_per_queue_rx_offload_result,
18358 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18359 TOKEN_STRING_INITIALIZER
18360 (struct cmd_config_per_queue_rx_offload_result,
18362 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18363 TOKEN_NUM_INITIALIZER
18364 (struct cmd_config_per_queue_rx_offload_result,
18366 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18367 TOKEN_STRING_INITIALIZER
18368 (struct cmd_config_per_queue_rx_offload_result,
18369 rx_offload, "rx_offload");
18370 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18371 TOKEN_STRING_INITIALIZER
18372 (struct cmd_config_per_queue_rx_offload_result,
18373 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18374 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18375 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18376 "scatter#timestamp#security#keep_crc");
18377 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18378 TOKEN_STRING_INITIALIZER
18379 (struct cmd_config_per_queue_rx_offload_result,
18383 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18384 __rte_unused struct cmdline *cl,
18385 __rte_unused void *data)
18387 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18388 struct rte_eth_dev_info dev_info;
18389 portid_t port_id = res->port_id;
18390 uint16_t queue_id = res->queue_id;
18391 struct rte_port *port = &ports[port_id];
18392 uint64_t single_offload;
18395 if (port->port_status != RTE_PORT_STOPPED) {
18396 printf("Error: Can't config offload when Port %d "
18397 "is not stopped\n", port_id);
18401 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18405 if (queue_id >= dev_info.nb_rx_queues) {
18406 printf("Error: input queue_id should be 0 ... "
18407 "%d\n", dev_info.nb_rx_queues - 1);
18411 single_offload = search_rx_offload(res->offload);
18412 if (single_offload == 0) {
18413 printf("Unknown offload name: %s\n", res->offload);
18417 if (!strcmp(res->on_off, "on"))
18418 port->rx_conf[queue_id].offloads |= single_offload;
18420 port->rx_conf[queue_id].offloads &= ~single_offload;
18422 cmd_reconfig_device_queue(port_id, 1, 1);
18425 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18426 .f = cmd_config_per_queue_rx_offload_parsed,
18428 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18429 "vlan_strip|ipv4_cksum|"
18430 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18431 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18432 "jumbo_frame|scatter|timestamp|security|keep_crc "
18435 (void *)&cmd_config_per_queue_rx_offload_result_port,
18436 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18437 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18438 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18439 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18440 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18441 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18446 /* Get Tx offloads capabilities */
18447 struct cmd_tx_offload_get_capa_result {
18448 cmdline_fixed_string_t show;
18449 cmdline_fixed_string_t port;
18451 cmdline_fixed_string_t tx_offload;
18452 cmdline_fixed_string_t capabilities;
18455 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18456 TOKEN_STRING_INITIALIZER
18457 (struct cmd_tx_offload_get_capa_result,
18459 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18460 TOKEN_STRING_INITIALIZER
18461 (struct cmd_tx_offload_get_capa_result,
18463 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18464 TOKEN_NUM_INITIALIZER
18465 (struct cmd_tx_offload_get_capa_result,
18467 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18468 TOKEN_STRING_INITIALIZER
18469 (struct cmd_tx_offload_get_capa_result,
18470 tx_offload, "tx_offload");
18471 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18472 TOKEN_STRING_INITIALIZER
18473 (struct cmd_tx_offload_get_capa_result,
18474 capabilities, "capabilities");
18477 print_tx_offloads(uint64_t offloads)
18479 uint64_t single_offload;
18487 begin = __builtin_ctzll(offloads);
18488 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18490 single_offload = 1ULL << begin;
18491 for (bit = begin; bit < end; bit++) {
18492 if (offloads & single_offload)
18494 rte_eth_dev_tx_offload_name(single_offload));
18495 single_offload <<= 1;
18500 cmd_tx_offload_get_capa_parsed(
18501 void *parsed_result,
18502 __rte_unused struct cmdline *cl,
18503 __rte_unused void *data)
18505 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18506 struct rte_eth_dev_info dev_info;
18507 portid_t port_id = res->port_id;
18508 uint64_t queue_offloads;
18509 uint64_t port_offloads;
18512 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18516 queue_offloads = dev_info.tx_queue_offload_capa;
18517 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18519 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18520 printf(" Per Queue :");
18521 print_tx_offloads(queue_offloads);
18524 printf(" Per Port :");
18525 print_tx_offloads(port_offloads);
18529 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18530 .f = cmd_tx_offload_get_capa_parsed,
18532 .help_str = "show port <port_id> tx_offload capabilities",
18534 (void *)&cmd_tx_offload_get_capa_show,
18535 (void *)&cmd_tx_offload_get_capa_port,
18536 (void *)&cmd_tx_offload_get_capa_port_id,
18537 (void *)&cmd_tx_offload_get_capa_tx_offload,
18538 (void *)&cmd_tx_offload_get_capa_capabilities,
18543 /* Get Tx offloads configuration */
18544 struct cmd_tx_offload_get_configuration_result {
18545 cmdline_fixed_string_t show;
18546 cmdline_fixed_string_t port;
18548 cmdline_fixed_string_t tx_offload;
18549 cmdline_fixed_string_t configuration;
18552 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18553 TOKEN_STRING_INITIALIZER
18554 (struct cmd_tx_offload_get_configuration_result,
18556 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18557 TOKEN_STRING_INITIALIZER
18558 (struct cmd_tx_offload_get_configuration_result,
18560 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18561 TOKEN_NUM_INITIALIZER
18562 (struct cmd_tx_offload_get_configuration_result,
18564 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18565 TOKEN_STRING_INITIALIZER
18566 (struct cmd_tx_offload_get_configuration_result,
18567 tx_offload, "tx_offload");
18568 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18569 TOKEN_STRING_INITIALIZER
18570 (struct cmd_tx_offload_get_configuration_result,
18571 configuration, "configuration");
18574 cmd_tx_offload_get_configuration_parsed(
18575 void *parsed_result,
18576 __rte_unused struct cmdline *cl,
18577 __rte_unused void *data)
18579 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18580 struct rte_eth_dev_info dev_info;
18581 portid_t port_id = res->port_id;
18582 struct rte_port *port = &ports[port_id];
18583 uint64_t port_offloads;
18584 uint64_t queue_offloads;
18585 uint16_t nb_tx_queues;
18589 printf("Tx Offloading Configuration of port %d :\n", port_id);
18591 port_offloads = port->dev_conf.txmode.offloads;
18593 print_tx_offloads(port_offloads);
18596 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18600 nb_tx_queues = dev_info.nb_tx_queues;
18601 for (q = 0; q < nb_tx_queues; q++) {
18602 queue_offloads = port->tx_conf[q].offloads;
18603 printf(" Queue[%2d] :", q);
18604 print_tx_offloads(queue_offloads);
18610 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18611 .f = cmd_tx_offload_get_configuration_parsed,
18613 .help_str = "show port <port_id> tx_offload configuration",
18615 (void *)&cmd_tx_offload_get_configuration_show,
18616 (void *)&cmd_tx_offload_get_configuration_port,
18617 (void *)&cmd_tx_offload_get_configuration_port_id,
18618 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18619 (void *)&cmd_tx_offload_get_configuration_configuration,
18624 /* Enable/Disable a per port offloading */
18625 struct cmd_config_per_port_tx_offload_result {
18626 cmdline_fixed_string_t port;
18627 cmdline_fixed_string_t config;
18629 cmdline_fixed_string_t tx_offload;
18630 cmdline_fixed_string_t offload;
18631 cmdline_fixed_string_t on_off;
18634 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18635 TOKEN_STRING_INITIALIZER
18636 (struct cmd_config_per_port_tx_offload_result,
18638 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18639 TOKEN_STRING_INITIALIZER
18640 (struct cmd_config_per_port_tx_offload_result,
18642 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18643 TOKEN_NUM_INITIALIZER
18644 (struct cmd_config_per_port_tx_offload_result,
18646 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18647 TOKEN_STRING_INITIALIZER
18648 (struct cmd_config_per_port_tx_offload_result,
18649 tx_offload, "tx_offload");
18650 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18651 TOKEN_STRING_INITIALIZER
18652 (struct cmd_config_per_port_tx_offload_result,
18653 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18654 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18655 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18656 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18657 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18658 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18659 TOKEN_STRING_INITIALIZER
18660 (struct cmd_config_per_port_tx_offload_result,
18664 search_tx_offload(const char *name)
18666 uint64_t single_offload;
18667 const char *single_name;
18671 single_offload = 1;
18672 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18673 single_name = rte_eth_dev_tx_offload_name(single_offload);
18674 if (single_name == NULL)
18676 if (!strcasecmp(single_name, name)) {
18679 } else if (!strcasecmp(single_name, "UNKNOWN"))
18681 single_offload <<= 1;
18685 return single_offload;
18691 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18692 __rte_unused struct cmdline *cl,
18693 __rte_unused void *data)
18695 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18696 portid_t port_id = res->port_id;
18697 struct rte_eth_dev_info dev_info;
18698 struct rte_port *port = &ports[port_id];
18699 uint64_t single_offload;
18700 uint16_t nb_tx_queues;
18704 if (port->port_status != RTE_PORT_STOPPED) {
18705 printf("Error: Can't config offload when Port %d "
18706 "is not stopped\n", port_id);
18710 single_offload = search_tx_offload(res->offload);
18711 if (single_offload == 0) {
18712 printf("Unknown offload name: %s\n", res->offload);
18716 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18720 nb_tx_queues = dev_info.nb_tx_queues;
18721 if (!strcmp(res->on_off, "on")) {
18722 port->dev_conf.txmode.offloads |= single_offload;
18723 for (q = 0; q < nb_tx_queues; q++)
18724 port->tx_conf[q].offloads |= single_offload;
18726 port->dev_conf.txmode.offloads &= ~single_offload;
18727 for (q = 0; q < nb_tx_queues; q++)
18728 port->tx_conf[q].offloads &= ~single_offload;
18731 cmd_reconfig_device_queue(port_id, 1, 1);
18734 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18735 .f = cmd_config_per_port_tx_offload_parsed,
18737 .help_str = "port config <port_id> tx_offload "
18738 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18739 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18740 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18741 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18742 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18744 (void *)&cmd_config_per_port_tx_offload_result_port,
18745 (void *)&cmd_config_per_port_tx_offload_result_config,
18746 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18747 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18748 (void *)&cmd_config_per_port_tx_offload_result_offload,
18749 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18754 /* Enable/Disable a per queue offloading */
18755 struct cmd_config_per_queue_tx_offload_result {
18756 cmdline_fixed_string_t port;
18758 cmdline_fixed_string_t txq;
18760 cmdline_fixed_string_t tx_offload;
18761 cmdline_fixed_string_t offload;
18762 cmdline_fixed_string_t on_off;
18765 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18766 TOKEN_STRING_INITIALIZER
18767 (struct cmd_config_per_queue_tx_offload_result,
18769 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18770 TOKEN_NUM_INITIALIZER
18771 (struct cmd_config_per_queue_tx_offload_result,
18773 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18774 TOKEN_STRING_INITIALIZER
18775 (struct cmd_config_per_queue_tx_offload_result,
18777 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18778 TOKEN_NUM_INITIALIZER
18779 (struct cmd_config_per_queue_tx_offload_result,
18781 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18782 TOKEN_STRING_INITIALIZER
18783 (struct cmd_config_per_queue_tx_offload_result,
18784 tx_offload, "tx_offload");
18785 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18786 TOKEN_STRING_INITIALIZER
18787 (struct cmd_config_per_queue_tx_offload_result,
18788 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18789 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18790 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18791 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18792 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18793 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18794 TOKEN_STRING_INITIALIZER
18795 (struct cmd_config_per_queue_tx_offload_result,
18799 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18800 __rte_unused struct cmdline *cl,
18801 __rte_unused void *data)
18803 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18804 struct rte_eth_dev_info dev_info;
18805 portid_t port_id = res->port_id;
18806 uint16_t queue_id = res->queue_id;
18807 struct rte_port *port = &ports[port_id];
18808 uint64_t single_offload;
18811 if (port->port_status != RTE_PORT_STOPPED) {
18812 printf("Error: Can't config offload when Port %d "
18813 "is not stopped\n", port_id);
18817 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18821 if (queue_id >= dev_info.nb_tx_queues) {
18822 printf("Error: input queue_id should be 0 ... "
18823 "%d\n", dev_info.nb_tx_queues - 1);
18827 single_offload = search_tx_offload(res->offload);
18828 if (single_offload == 0) {
18829 printf("Unknown offload name: %s\n", res->offload);
18833 if (!strcmp(res->on_off, "on"))
18834 port->tx_conf[queue_id].offloads |= single_offload;
18836 port->tx_conf[queue_id].offloads &= ~single_offload;
18838 cmd_reconfig_device_queue(port_id, 1, 1);
18841 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18842 .f = cmd_config_per_queue_tx_offload_parsed,
18844 .help_str = "port <port_id> txq <queue_id> tx_offload "
18845 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18846 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18847 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18848 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18849 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18852 (void *)&cmd_config_per_queue_tx_offload_result_port,
18853 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18854 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18855 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18856 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18857 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18858 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18863 /* *** configure tx_metadata for specific port *** */
18864 struct cmd_config_tx_metadata_specific_result {
18865 cmdline_fixed_string_t port;
18866 cmdline_fixed_string_t keyword;
18868 cmdline_fixed_string_t item;
18873 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18874 __rte_unused struct cmdline *cl,
18875 __rte_unused void *data)
18877 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18879 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18881 ports[res->port_id].tx_metadata = res->value;
18882 /* Add/remove callback to insert valid metadata in every Tx packet. */
18883 if (ports[res->port_id].tx_metadata)
18884 add_tx_md_callback(res->port_id);
18886 remove_tx_md_callback(res->port_id);
18887 rte_flow_dynf_metadata_register();
18890 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18891 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18893 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18894 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18895 keyword, "config");
18896 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18897 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18899 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18900 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18901 item, "tx_metadata");
18902 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18903 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18906 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18907 .f = cmd_config_tx_metadata_specific_parsed,
18909 .help_str = "port config <port_id> tx_metadata <value>",
18911 (void *)&cmd_config_tx_metadata_specific_port,
18912 (void *)&cmd_config_tx_metadata_specific_keyword,
18913 (void *)&cmd_config_tx_metadata_specific_id,
18914 (void *)&cmd_config_tx_metadata_specific_item,
18915 (void *)&cmd_config_tx_metadata_specific_value,
18920 /* *** set dynf *** */
18921 struct cmd_config_tx_dynf_specific_result {
18922 cmdline_fixed_string_t port;
18923 cmdline_fixed_string_t keyword;
18925 cmdline_fixed_string_t item;
18926 cmdline_fixed_string_t name;
18927 cmdline_fixed_string_t value;
18931 cmd_config_dynf_specific_parsed(void *parsed_result,
18932 __rte_unused struct cmdline *cl,
18933 __rte_unused void *data)
18935 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18936 struct rte_mbuf_dynflag desc_flag;
18938 uint64_t old_port_flags;
18940 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18942 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18944 if (strlcpy(desc_flag.name, res->name,
18945 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18946 printf("Flag name too long\n");
18949 desc_flag.flags = 0;
18950 flag = rte_mbuf_dynflag_register(&desc_flag);
18952 printf("Can't register flag\n");
18955 strcpy(dynf_names[flag], desc_flag.name);
18957 old_port_flags = ports[res->port_id].mbuf_dynf;
18958 if (!strcmp(res->value, "set")) {
18959 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18960 if (old_port_flags == 0)
18961 add_tx_dynf_callback(res->port_id);
18963 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18964 if (ports[res->port_id].mbuf_dynf == 0)
18965 remove_tx_dynf_callback(res->port_id);
18969 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18970 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18972 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18973 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18974 keyword, "config");
18975 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18976 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18978 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18979 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18981 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18982 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18984 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18985 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18986 value, "set#clear");
18988 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18989 .f = cmd_config_dynf_specific_parsed,
18991 .help_str = "port config <port id> dynf <name> set|clear",
18993 (void *)&cmd_config_tx_dynf_specific_port,
18994 (void *)&cmd_config_tx_dynf_specific_keyword,
18995 (void *)&cmd_config_tx_dynf_specific_port_id,
18996 (void *)&cmd_config_tx_dynf_specific_item,
18997 (void *)&cmd_config_tx_dynf_specific_name,
18998 (void *)&cmd_config_tx_dynf_specific_value,
19003 /* *** display tx_metadata per port configuration *** */
19004 struct cmd_show_tx_metadata_result {
19005 cmdline_fixed_string_t cmd_show;
19006 cmdline_fixed_string_t cmd_port;
19007 cmdline_fixed_string_t cmd_keyword;
19012 cmd_show_tx_metadata_parsed(void *parsed_result,
19013 __rte_unused struct cmdline *cl,
19014 __rte_unused void *data)
19016 struct cmd_show_tx_metadata_result *res = parsed_result;
19018 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19019 printf("invalid port id %u\n", res->cmd_pid);
19022 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19023 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19024 ports[res->cmd_pid].tx_metadata);
19028 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19029 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19031 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19032 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19034 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19035 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19037 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19038 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19039 cmd_keyword, "tx_metadata");
19041 cmdline_parse_inst_t cmd_show_tx_metadata = {
19042 .f = cmd_show_tx_metadata_parsed,
19044 .help_str = "show port <port_id> tx_metadata",
19046 (void *)&cmd_show_tx_metadata_show,
19047 (void *)&cmd_show_tx_metadata_port,
19048 (void *)&cmd_show_tx_metadata_pid,
19049 (void *)&cmd_show_tx_metadata_keyword,
19054 /* show port supported ptypes */
19056 /* Common result structure for show port ptypes */
19057 struct cmd_show_port_supported_ptypes_result {
19058 cmdline_fixed_string_t show;
19059 cmdline_fixed_string_t port;
19061 cmdline_fixed_string_t ptypes;
19064 /* Common CLI fields for show port ptypes */
19065 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19066 TOKEN_STRING_INITIALIZER
19067 (struct cmd_show_port_supported_ptypes_result,
19069 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19070 TOKEN_STRING_INITIALIZER
19071 (struct cmd_show_port_supported_ptypes_result,
19073 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19074 TOKEN_NUM_INITIALIZER
19075 (struct cmd_show_port_supported_ptypes_result,
19077 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19078 TOKEN_STRING_INITIALIZER
19079 (struct cmd_show_port_supported_ptypes_result,
19083 cmd_show_port_supported_ptypes_parsed(
19084 void *parsed_result,
19085 __rte_unused struct cmdline *cl,
19086 __rte_unused void *data)
19088 #define RSVD_PTYPE_MASK 0xf0000000
19089 #define MAX_PTYPES_PER_LAYER 16
19090 #define LTYPE_NAMESIZE 32
19091 #define PTYPE_NAMESIZE 256
19092 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19093 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19094 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19095 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19096 uint16_t port_id = res->port_id;
19099 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19103 while (ptype_mask != RSVD_PTYPE_MASK) {
19105 switch (ptype_mask) {
19106 case RTE_PTYPE_L2_MASK:
19107 strlcpy(ltype, "L2", sizeof(ltype));
19109 case RTE_PTYPE_L3_MASK:
19110 strlcpy(ltype, "L3", sizeof(ltype));
19112 case RTE_PTYPE_L4_MASK:
19113 strlcpy(ltype, "L4", sizeof(ltype));
19115 case RTE_PTYPE_TUNNEL_MASK:
19116 strlcpy(ltype, "Tunnel", sizeof(ltype));
19118 case RTE_PTYPE_INNER_L2_MASK:
19119 strlcpy(ltype, "Inner L2", sizeof(ltype));
19121 case RTE_PTYPE_INNER_L3_MASK:
19122 strlcpy(ltype, "Inner L3", sizeof(ltype));
19124 case RTE_PTYPE_INNER_L4_MASK:
19125 strlcpy(ltype, "Inner L4", sizeof(ltype));
19131 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19132 ptype_mask, ptypes,
19133 MAX_PTYPES_PER_LAYER);
19136 printf("Supported %s ptypes:\n", ltype);
19138 printf("%s ptypes unsupported\n", ltype);
19140 for (i = 0; i < ret; ++i) {
19141 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19142 printf("%s\n", buf);
19149 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19150 .f = cmd_show_port_supported_ptypes_parsed,
19152 .help_str = "show port <port_id> ptypes",
19154 (void *)&cmd_show_port_supported_ptypes_show,
19155 (void *)&cmd_show_port_supported_ptypes_port,
19156 (void *)&cmd_show_port_supported_ptypes_port_id,
19157 (void *)&cmd_show_port_supported_ptypes_ptypes,
19162 /* *** display rx/tx descriptor status *** */
19163 struct cmd_show_rx_tx_desc_status_result {
19164 cmdline_fixed_string_t cmd_show;
19165 cmdline_fixed_string_t cmd_port;
19166 cmdline_fixed_string_t cmd_keyword;
19167 cmdline_fixed_string_t cmd_desc;
19168 cmdline_fixed_string_t cmd_status;
19175 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19176 __rte_unused struct cmdline *cl,
19177 __rte_unused void *data)
19179 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19182 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19183 printf("invalid port id %u\n", res->cmd_pid);
19187 if (!strcmp(res->cmd_keyword, "rxq")) {
19188 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19191 printf("Invalid queueid = %d\n", res->cmd_qid);
19194 if (rc == RTE_ETH_RX_DESC_AVAIL)
19195 printf("Desc status = AVAILABLE\n");
19196 else if (rc == RTE_ETH_RX_DESC_DONE)
19197 printf("Desc status = DONE\n");
19199 printf("Desc status = UNAVAILABLE\n");
19200 } else if (!strcmp(res->cmd_keyword, "txq")) {
19201 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19204 printf("Invalid queueid = %d\n", res->cmd_qid);
19207 if (rc == RTE_ETH_TX_DESC_FULL)
19208 printf("Desc status = FULL\n");
19209 else if (rc == RTE_ETH_TX_DESC_DONE)
19210 printf("Desc status = DONE\n");
19212 printf("Desc status = UNAVAILABLE\n");
19216 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19217 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19219 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19220 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19222 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19223 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19225 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19226 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19227 cmd_keyword, "rxq#txq");
19228 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19229 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19231 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19232 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19234 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19235 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19237 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19238 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19239 cmd_status, "status");
19240 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19241 .f = cmd_show_rx_tx_desc_status_parsed,
19243 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19246 (void *)&cmd_show_rx_tx_desc_status_show,
19247 (void *)&cmd_show_rx_tx_desc_status_port,
19248 (void *)&cmd_show_rx_tx_desc_status_pid,
19249 (void *)&cmd_show_rx_tx_desc_status_keyword,
19250 (void *)&cmd_show_rx_tx_desc_status_qid,
19251 (void *)&cmd_show_rx_tx_desc_status_desc,
19252 (void *)&cmd_show_rx_tx_desc_status_did,
19253 (void *)&cmd_show_rx_tx_desc_status_status,
19258 /* Common result structure for set port ptypes */
19259 struct cmd_set_port_ptypes_result {
19260 cmdline_fixed_string_t set;
19261 cmdline_fixed_string_t port;
19263 cmdline_fixed_string_t ptype_mask;
19267 /* Common CLI fields for set port ptypes */
19268 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19269 TOKEN_STRING_INITIALIZER
19270 (struct cmd_set_port_ptypes_result,
19272 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19273 TOKEN_STRING_INITIALIZER
19274 (struct cmd_set_port_ptypes_result,
19276 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19277 TOKEN_NUM_INITIALIZER
19278 (struct cmd_set_port_ptypes_result,
19280 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19281 TOKEN_STRING_INITIALIZER
19282 (struct cmd_set_port_ptypes_result,
19283 ptype_mask, "ptype_mask");
19284 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19285 TOKEN_NUM_INITIALIZER
19286 (struct cmd_set_port_ptypes_result,
19290 cmd_set_port_ptypes_parsed(
19291 void *parsed_result,
19292 __rte_unused struct cmdline *cl,
19293 __rte_unused void *data)
19295 struct cmd_set_port_ptypes_result *res = parsed_result;
19296 #define PTYPE_NAMESIZE 256
19297 char ptype_name[PTYPE_NAMESIZE];
19298 uint16_t port_id = res->port_id;
19299 uint32_t ptype_mask = res->mask;
19302 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19305 printf("Port %d doesn't support any ptypes.\n", port_id);
19309 uint32_t ptypes[ret];
19311 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19313 printf("Unable to set requested ptypes for Port %d\n", port_id);
19317 printf("Successfully set following ptypes for Port %d\n", port_id);
19318 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19319 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19320 printf("%s\n", ptype_name);
19323 clear_ptypes = false;
19326 cmdline_parse_inst_t cmd_set_port_ptypes = {
19327 .f = cmd_set_port_ptypes_parsed,
19329 .help_str = "set port <port_id> ptype_mask <mask>",
19331 (void *)&cmd_set_port_ptypes_set,
19332 (void *)&cmd_set_port_ptypes_port,
19333 (void *)&cmd_set_port_ptypes_port_id,
19334 (void *)&cmd_set_port_ptypes_mask_str,
19335 (void *)&cmd_set_port_ptypes_mask_u32,
19340 /* *** display mac addresses added to a port *** */
19341 struct cmd_showport_macs_result {
19342 cmdline_fixed_string_t cmd_show;
19343 cmdline_fixed_string_t cmd_port;
19344 cmdline_fixed_string_t cmd_keyword;
19349 cmd_showport_macs_parsed(void *parsed_result,
19350 __rte_unused struct cmdline *cl,
19351 __rte_unused void *data)
19353 struct cmd_showport_macs_result *res = parsed_result;
19355 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19358 if (!strcmp(res->cmd_keyword, "macs"))
19359 show_macs(res->cmd_pid);
19360 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19361 show_mcast_macs(res->cmd_pid);
19364 cmdline_parse_token_string_t cmd_showport_macs_show =
19365 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19367 cmdline_parse_token_string_t cmd_showport_macs_port =
19368 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19370 cmdline_parse_token_num_t cmd_showport_macs_pid =
19371 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19373 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19374 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19375 cmd_keyword, "macs#mcast_macs");
19377 cmdline_parse_inst_t cmd_showport_macs = {
19378 .f = cmd_showport_macs_parsed,
19380 .help_str = "show port <port_id> macs|mcast_macs",
19382 (void *)&cmd_showport_macs_show,
19383 (void *)&cmd_showport_macs_port,
19384 (void *)&cmd_showport_macs_pid,
19385 (void *)&cmd_showport_macs_keyword,
19390 /* ******************************************************************************** */
19392 /* list of instructions */
19393 cmdline_parse_ctx_t main_ctx[] = {
19394 (cmdline_parse_inst_t *)&cmd_help_brief,
19395 (cmdline_parse_inst_t *)&cmd_help_long,
19396 (cmdline_parse_inst_t *)&cmd_quit,
19397 (cmdline_parse_inst_t *)&cmd_load_from_file,
19398 (cmdline_parse_inst_t *)&cmd_showport,
19399 (cmdline_parse_inst_t *)&cmd_showqueue,
19400 (cmdline_parse_inst_t *)&cmd_showportall,
19401 (cmdline_parse_inst_t *)&cmd_showdevice,
19402 (cmdline_parse_inst_t *)&cmd_showcfg,
19403 (cmdline_parse_inst_t *)&cmd_showfwdall,
19404 (cmdline_parse_inst_t *)&cmd_start,
19405 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19406 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19407 (cmdline_parse_inst_t *)&cmd_set_link_up,
19408 (cmdline_parse_inst_t *)&cmd_set_link_down,
19409 (cmdline_parse_inst_t *)&cmd_reset,
19410 (cmdline_parse_inst_t *)&cmd_set_numbers,
19411 (cmdline_parse_inst_t *)&cmd_set_log,
19412 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19413 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19414 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19415 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19416 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19417 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19418 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19419 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19420 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19421 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19422 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19423 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19424 (cmdline_parse_inst_t *)&cmd_set_link_check,
19425 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19426 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19427 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19428 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19429 #ifdef RTE_LIBRTE_PMD_BOND
19430 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19431 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19432 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19433 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19434 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19435 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19436 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19437 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19438 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19439 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19440 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19442 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19443 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19444 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19445 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19446 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19447 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19448 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19449 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19450 (cmdline_parse_inst_t *)&cmd_csum_set,
19451 (cmdline_parse_inst_t *)&cmd_csum_show,
19452 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19453 (cmdline_parse_inst_t *)&cmd_tso_set,
19454 (cmdline_parse_inst_t *)&cmd_tso_show,
19455 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19456 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19457 (cmdline_parse_inst_t *)&cmd_gro_enable,
19458 (cmdline_parse_inst_t *)&cmd_gro_flush,
19459 (cmdline_parse_inst_t *)&cmd_gro_show,
19460 (cmdline_parse_inst_t *)&cmd_gso_enable,
19461 (cmdline_parse_inst_t *)&cmd_gso_size,
19462 (cmdline_parse_inst_t *)&cmd_gso_show,
19463 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19464 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19465 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19466 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19467 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19468 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19469 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19470 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19471 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19472 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19473 (cmdline_parse_inst_t *)&cmd_config_dcb,
19474 (cmdline_parse_inst_t *)&cmd_read_reg,
19475 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19476 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19477 (cmdline_parse_inst_t *)&cmd_write_reg,
19478 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19479 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19480 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19481 (cmdline_parse_inst_t *)&cmd_stop,
19482 (cmdline_parse_inst_t *)&cmd_mac_addr,
19483 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19484 (cmdline_parse_inst_t *)&cmd_set_qmap,
19485 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19486 (cmdline_parse_inst_t *)&cmd_operate_port,
19487 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19488 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19489 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19490 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19491 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19492 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19493 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19494 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19495 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19496 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19497 (cmdline_parse_inst_t *)&cmd_config_mtu,
19498 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19499 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19500 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19501 (cmdline_parse_inst_t *)&cmd_config_rss,
19502 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19503 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19504 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19505 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19506 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19507 (cmdline_parse_inst_t *)&cmd_showport_reta,
19508 (cmdline_parse_inst_t *)&cmd_showport_macs,
19509 (cmdline_parse_inst_t *)&cmd_config_burst,
19510 (cmdline_parse_inst_t *)&cmd_config_thresh,
19511 (cmdline_parse_inst_t *)&cmd_config_threshold,
19512 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19513 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19514 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19515 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19516 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19517 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19518 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19519 (cmdline_parse_inst_t *)&cmd_global_config,
19520 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19521 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19522 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19523 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19524 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19525 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19526 (cmdline_parse_inst_t *)&cmd_dump,
19527 (cmdline_parse_inst_t *)&cmd_dump_one,
19528 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19529 (cmdline_parse_inst_t *)&cmd_syn_filter,
19530 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19531 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19532 (cmdline_parse_inst_t *)&cmd_flex_filter,
19533 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19534 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19535 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19536 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19537 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19538 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19539 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19540 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19541 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19542 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19543 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19544 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19545 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19546 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19547 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19548 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19549 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19550 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19551 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19552 (cmdline_parse_inst_t *)&cmd_flow,
19553 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19554 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19555 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19556 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19557 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19558 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19559 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19560 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19561 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19562 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19563 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19564 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19565 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19566 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19567 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19568 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19569 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19570 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19571 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19572 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19573 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19574 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19575 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19576 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19577 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19578 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19579 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19580 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19581 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19582 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19583 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19584 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19585 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19586 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19587 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19588 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19589 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19590 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19591 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19592 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19593 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19594 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19595 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19596 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19597 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19598 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19599 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19600 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19601 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19602 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19603 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19605 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19606 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19607 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19608 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19609 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19610 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19611 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19612 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19613 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19614 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19615 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19616 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19617 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19618 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19619 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19620 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19621 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19622 (cmdline_parse_inst_t *)&cmd_ddp_add,
19623 (cmdline_parse_inst_t *)&cmd_ddp_del,
19624 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19625 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19626 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19627 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19628 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19629 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19630 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19631 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19632 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19633 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19634 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19635 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19637 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19638 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19639 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19640 (cmdline_parse_inst_t *)&cmd_queue_region,
19641 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19642 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19643 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19644 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19645 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19646 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19647 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19648 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19649 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19650 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19651 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19652 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19653 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19654 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19655 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19656 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19657 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19658 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19659 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19660 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19661 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19662 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19663 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19664 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19665 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19666 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19667 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19668 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19669 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19670 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19671 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19672 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19673 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19674 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19675 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19676 #ifdef RTE_LIBRTE_BPF
19677 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19678 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19680 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19681 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19682 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19683 (cmdline_parse_inst_t *)&cmd_set_raw,
19684 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19685 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19686 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19690 /* read cmdline commands from file */
19692 cmdline_read_from_file(const char *filename)
19694 struct cmdline *cl;
19696 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19698 printf("Failed to create file based cmdline context: %s\n",
19703 cmdline_interact(cl);
19708 printf("Read CLI commands from %s\n", filename);
19711 /* prompt function, called from main on MASTER lcore */
19715 /* initialize non-constant commands */
19716 cmd_set_fwd_mode_init();
19717 cmd_set_fwd_retry_mode_init();
19719 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19720 if (testpmd_cl == NULL)
19722 cmdline_interact(testpmd_cl);
19723 cmdline_stdin_exit(testpmd_cl);
19729 if (testpmd_cl != NULL)
19730 cmdline_quit(testpmd_cl);
19734 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19736 if (id == (portid_t)RTE_PORT_ALL) {
19739 RTE_ETH_FOREACH_DEV(pid) {
19740 /* check if need_reconfig has been set to 1 */
19741 if (ports[pid].need_reconfig == 0)
19742 ports[pid].need_reconfig = dev;
19743 /* check if need_reconfig_queues has been set to 1 */
19744 if (ports[pid].need_reconfig_queues == 0)
19745 ports[pid].need_reconfig_queues = queue;
19747 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19748 /* check if need_reconfig has been set to 1 */
19749 if (ports[id].need_reconfig == 0)
19750 ports[id].need_reconfig = dev;
19751 /* check if need_reconfig_queues has been set to 1 */
19752 if (ports[id].need_reconfig_queues == 0)
19753 ports[id].need_reconfig_queues = queue;