1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
53 #ifdef RTE_LIBRTE_PMD_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
58 #include <rte_pmd_dpaa.h>
60 #ifdef RTE_LIBRTE_IXGBE_PMD
61 #include <rte_pmd_ixgbe.h>
63 #ifdef RTE_LIBRTE_I40E_PMD
64 #include <rte_pmd_i40e.h>
66 #ifdef RTE_LIBRTE_BNXT_PMD
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
85 __rte_unused void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port X rss reta (size) (mask0,mask1,...)\n"
170 " Display the rss redirection table entry indicated"
171 " by masks on port X. size is used to indicate the"
172 " hardware supported reta size\n\n"
174 "show port (port_id) rss-hash [key]\n"
175 " Display the RSS hash functions and RSS hash key of port\n\n"
177 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
178 " Clear information for port_id, or all.\n\n"
180 "show (rxq|txq) info (port_id) (queue_id)\n"
181 " Display information for configured RX/TX queue.\n\n"
183 "show config (rxtx|cores|fwd|txpkts)\n"
184 " Display the given configuration.\n\n"
186 "read rxd (port_id) (queue_id) (rxd_id)\n"
187 " Display an RX descriptor of a port RX queue.\n\n"
189 "read txd (port_id) (queue_id) (txd_id)\n"
190 " Display a TX descriptor of a port TX queue.\n\n"
192 "ddp get list (port_id)\n"
193 " Get ddp profile info list\n\n"
195 "ddp get info (profile_path)\n"
196 " Get ddp profile information.\n\n"
198 "show vf stats (port_id) (vf_id)\n"
199 " Display a VF's statistics.\n\n"
201 "clear vf stats (port_id) (vf_id)\n"
202 " Reset a VF's statistics.\n\n"
204 "show port (port_id) pctype mapping\n"
205 " Get flow ptype to pctype mapping on a port\n\n"
207 "show port meter stats (port_id) (meter_id) (clear)\n"
208 " Get meter stats on a port\n\n"
210 "show fwd stats all\n"
211 " Display statistics for all fwd engines.\n\n"
213 "clear fwd stats all\n"
214 " Clear statistics for all fwd engines.\n\n"
216 "show port (port_id) rx_offload capabilities\n"
217 " List all per queue and per port Rx offloading"
218 " capabilities of a port\n\n"
220 "show port (port_id) rx_offload configuration\n"
221 " List port level and all queue level"
222 " Rx offloading configuration\n\n"
224 "show port (port_id) tx_offload capabilities\n"
225 " List all per queue and per port"
226 " Tx offloading capabilities of a port\n\n"
228 "show port (port_id) tx_offload configuration\n"
229 " List port level and all queue level"
230 " Tx offloading configuration\n\n"
232 "show port (port_id) tx_metadata\n"
233 " Show Tx metadata value set"
234 " for a specific port\n\n"
236 "show port (port_id) ptypes\n"
237 " Show port supported ptypes"
238 " for a specific port\n\n"
240 "show device info (<identifier>|all)"
241 " Show general information about devices probed.\n\n"
243 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
244 " Show status of rx|tx descriptor.\n\n"
246 "show port (port_id) macs|mcast_macs"
247 " Display list of mac addresses added to port.\n\n"
251 if (show_all || !strcmp(res->section, "config")) {
257 "Configuration changes only become active when"
258 " forwarding is started/restarted.\n\n"
261 " Reset forwarding to the default configuration.\n\n"
263 "set verbose (level)\n"
264 " Set the debug verbosity level X.\n\n"
266 "set log global|(type) (level)\n"
267 " Set the log level.\n\n"
270 " Set number of ports.\n\n"
273 " Set number of cores.\n\n"
275 "set coremask (mask)\n"
276 " Set the forwarding cores hexadecimal mask.\n\n"
278 "set portmask (mask)\n"
279 " Set the forwarding ports hexadecimal mask.\n\n"
282 " Set number of packets per burst.\n\n"
284 "set burst tx delay (microseconds) retry (num)\n"
285 " Set the transmit delay time and number of retries,"
286 " effective when retry is enabled.\n\n"
288 "set txpkts (x[,y]*)\n"
289 " Set the length of each segment of TXONLY"
290 " and optionally CSUM packets.\n\n"
292 "set txsplit (off|on|rand)\n"
293 " Set the split policy for the TX packets."
294 " Right now only applicable for CSUM and TXONLY"
297 "set corelist (x[,y]*)\n"
298 " Set the list of forwarding cores.\n\n"
300 "set portlist (x[,y]*)\n"
301 " Set the list of forwarding ports.\n\n"
303 "set port setup on (iterator|event)\n"
304 " Select how attached port is retrieved for setup.\n\n"
306 "set tx loopback (port_id) (on|off)\n"
307 " Enable or disable tx loopback.\n\n"
309 "set all queues drop (port_id) (on|off)\n"
310 " Set drop enable bit for all queues.\n\n"
312 "set vf split drop (port_id) (vf_id) (on|off)\n"
313 " Set split drop enable bit for a VF from the PF.\n\n"
315 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
316 " Set MAC antispoof for a VF from the PF.\n\n"
318 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
319 " Enable MACsec offload.\n\n"
321 "set macsec offload (port_id) off\n"
322 " Disable MACsec offload.\n\n"
324 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
325 " Configure MACsec secure connection (SC).\n\n"
327 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
328 " Configure MACsec secure association (SA).\n\n"
330 "set vf broadcast (port_id) (vf_id) (on|off)\n"
331 " Set VF broadcast for a VF from the PF.\n\n"
333 "vlan set stripq (on|off) (port_id,queue_id)\n"
334 " Set the VLAN strip for a queue on a port.\n\n"
336 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
337 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
339 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
340 " Set VLAN insert for a VF from the PF.\n\n"
342 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
343 " Set VLAN antispoof for a VF from the PF.\n\n"
345 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
346 " Set VLAN tag for a VF from the PF.\n\n"
348 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
349 " Set a VF's max bandwidth(Mbps).\n\n"
351 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
352 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
354 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
355 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
357 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
358 " Set some TCs' strict link priority mode on a physical port.\n\n"
360 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
361 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
363 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
364 " Set the VLAN strip or filter or qinq strip or extend\n\n"
366 "vlan set (inner|outer) tpid (value) (port_id)\n"
367 " Set the VLAN TPID for Packet Filtering on"
370 "rx_vlan add (vlan_id|all) (port_id)\n"
371 " Add a vlan_id, or all identifiers, to the set"
372 " of VLAN identifiers filtered by port_id.\n\n"
374 "rx_vlan rm (vlan_id|all) (port_id)\n"
375 " Remove a vlan_id, or all identifiers, from the set"
376 " of VLAN identifiers filtered by port_id.\n\n"
378 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
379 " Add a vlan_id, to the set of VLAN identifiers"
380 "filtered for VF(s) from port_id.\n\n"
382 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
383 " Remove a vlan_id, to the set of VLAN identifiers"
384 "filtered for VF(s) from port_id.\n\n"
386 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
387 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
388 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
389 " add a tunnel filter of a port.\n\n"
391 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
392 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
393 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
394 " remove a tunnel filter of a port.\n\n"
396 "rx_vxlan_port add (udp_port) (port_id)\n"
397 " Add an UDP port for VXLAN packet filter on a port\n\n"
399 "rx_vxlan_port rm (udp_port) (port_id)\n"
400 " Remove an UDP port for VXLAN packet filter on a port\n\n"
402 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
403 " Set hardware insertion of VLAN IDs (single or double VLAN "
404 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
406 "tx_vlan set pvid port_id vlan_id (on|off)\n"
407 " Set port based TX VLAN insertion.\n\n"
409 "tx_vlan reset (port_id)\n"
410 " Disable hardware insertion of a VLAN header in"
411 " packets sent on a port.\n\n"
413 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
414 " Select hardware or software calculation of the"
415 " checksum when transmitting a packet using the"
416 " csum forward engine.\n"
417 " ip|udp|tcp|sctp always concern the inner layer.\n"
418 " outer-ip concerns the outer IP layer in"
419 " outer-udp concerns the outer UDP layer in"
420 " case the packet is recognized as a tunnel packet by"
421 " the forward engine (vxlan, gre and ipip are supported)\n"
422 " Please check the NIC datasheet for HW limits.\n\n"
424 "csum parse-tunnel (on|off) (tx_port_id)\n"
425 " If disabled, treat tunnel packets as non-tunneled"
426 " packets (treat inner headers as payload). The port\n"
427 " argument is the port used for TX in csum forward"
430 "csum show (port_id)\n"
431 " Display tx checksum offload configuration\n\n"
433 "tso set (segsize) (portid)\n"
434 " Enable TCP Segmentation Offload in csum forward"
436 " Please check the NIC datasheet for HW limits.\n\n"
439 " Display the status of TCP Segmentation Offload.\n\n"
441 "set port (port_id) gro on|off\n"
442 " Enable or disable Generic Receive Offload in"
443 " csum forwarding engine.\n\n"
445 "show port (port_id) gro\n"
446 " Display GRO configuration.\n\n"
448 "set gro flush (cycles)\n"
449 " Set the cycle to flush GROed packets from"
450 " reassembly tables.\n\n"
452 "set port (port_id) gso (on|off)"
453 " Enable or disable Generic Segmentation Offload in"
454 " csum forwarding engine.\n\n"
456 "set gso segsz (length)\n"
457 " Set max packet length for output GSO segments,"
458 " including packet header and payload.\n\n"
460 "show port (port_id) gso\n"
461 " Show GSO configuration.\n\n"
464 " Set packet forwarding mode.\n\n"
466 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
467 " Add a MAC address on port_id.\n\n"
469 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
470 " Remove a MAC address from port_id.\n\n"
472 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
473 " Set the default MAC address for port_id.\n\n"
475 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
476 " Add a MAC address for a VF on the port.\n\n"
478 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
479 " Set the MAC address for a VF from the PF.\n\n"
481 "set eth-peer (port_id) (peer_addr)\n"
482 " set the peer address for certain port.\n\n"
484 "set port (port_id) uta (mac_address|all) (on|off)\n"
485 " Add/Remove a or all unicast hash filter(s)"
488 "set promisc (port_id|all) (on|off)\n"
489 " Set the promiscuous mode on port_id, or all.\n\n"
491 "set allmulti (port_id|all) (on|off)\n"
492 " Set the allmulti mode on port_id, or all.\n\n"
494 "set vf promisc (port_id) (vf_id) (on|off)\n"
495 " Set unicast promiscuous mode for a VF from the PF.\n\n"
497 "set vf allmulti (port_id) (vf_id) (on|off)\n"
498 " Set multicast promiscuous mode for a VF from the PF.\n\n"
500 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
501 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
502 " (on|off) autoneg (on|off) (port_id)\n"
503 "set flow_ctrl rx (on|off) (portid)\n"
504 "set flow_ctrl tx (on|off) (portid)\n"
505 "set flow_ctrl high_water (high_water) (portid)\n"
506 "set flow_ctrl low_water (low_water) (portid)\n"
507 "set flow_ctrl pause_time (pause_time) (portid)\n"
508 "set flow_ctrl send_xon (send_xon) (portid)\n"
509 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
510 "set flow_ctrl autoneg (on|off) (port_id)\n"
511 " Set the link flow control parameter on a port.\n\n"
513 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
514 " (low_water) (pause_time) (priority) (port_id)\n"
515 " Set the priority flow control parameter on a"
518 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
519 " Set statistics mapping (qmapping 0..15) for RX/TX"
521 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
522 " on port 0 to mapping 5.\n\n"
524 "set xstats-hide-zero on|off\n"
525 " Set the option to hide the zero values"
526 " for xstats display.\n"
528 "set port (port_id) vf (vf_id) rx|tx on|off\n"
529 " Enable/Disable a VF receive/tranmit from a port\n\n"
531 "set port (port_id) vf (vf_id) (mac_addr)"
532 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
533 " Add/Remove unicast or multicast MAC addr filter"
536 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
538 " AUPE:accepts untagged VLAN;"
539 "ROPE:accept unicast hash\n\n"
540 " BAM:accepts broadcast packets;"
541 "MPE:accepts all multicast packets\n\n"
542 " Enable/Disable a VF receive mode of a port\n\n"
544 "set port (port_id) queue (queue_id) rate (rate_num)\n"
545 " Set rate limit for a queue of a port\n\n"
547 "set port (port_id) vf (vf_id) rate (rate_num) "
548 "queue_mask (queue_mask_value)\n"
549 " Set rate limit for queues in VF of a port\n\n"
551 "set port (port_id) mirror-rule (rule_id)"
552 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
553 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
554 " Set pool or vlan type mirror rule on a port.\n"
555 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
556 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
559 "set port (port_id) mirror-rule (rule_id)"
560 " (uplink-mirror|downlink-mirror) dst-pool"
561 " (pool_id) (on|off)\n"
562 " Set uplink or downlink type mirror rule on a port.\n"
563 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
564 " 0 on' enable mirror income traffic to pool 0.\n\n"
566 "reset port (port_id) mirror-rule (rule_id)\n"
567 " Reset a mirror rule.\n\n"
569 "set flush_rx (on|off)\n"
570 " Flush (default) or don't flush RX streams before"
571 " forwarding. Mainly used with PCAP drivers.\n\n"
573 "set bypass mode (normal|bypass|isolate) (port_id)\n"
574 " Set the bypass mode for the lowest port on bypass enabled"
577 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
578 "mode (normal|bypass|isolate) (port_id)\n"
579 " Set the event required to initiate specified bypass mode for"
580 " the lowest port on a bypass enabled NIC where:\n"
581 " timeout = enable bypass after watchdog timeout.\n"
582 " os_on = enable bypass when OS/board is powered on.\n"
583 " os_off = enable bypass when OS/board is powered off.\n"
584 " power_on = enable bypass when power supply is turned on.\n"
585 " power_off = enable bypass when power supply is turned off."
588 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
589 " Set the bypass watchdog timeout to 'n' seconds"
590 " where 0 = instant.\n\n"
592 "show bypass config (port_id)\n"
593 " Show the bypass configuration for a bypass enabled NIC"
594 " using the lowest port on the NIC.\n\n"
596 #ifdef RTE_LIBRTE_PMD_BOND
597 "create bonded device (mode) (socket)\n"
598 " Create a new bonded device with specific bonding mode and socket.\n\n"
600 "add bonding slave (slave_id) (port_id)\n"
601 " Add a slave device to a bonded device.\n\n"
603 "remove bonding slave (slave_id) (port_id)\n"
604 " Remove a slave device from a bonded device.\n\n"
606 "set bonding mode (value) (port_id)\n"
607 " Set the bonding mode on a bonded device.\n\n"
609 "set bonding primary (slave_id) (port_id)\n"
610 " Set the primary slave for a bonded device.\n\n"
612 "show bonding config (port_id)\n"
613 " Show the bonding config for port_id.\n\n"
615 "set bonding mac_addr (port_id) (address)\n"
616 " Set the MAC address of a bonded device.\n\n"
618 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
619 " Set Aggregation mode for IEEE802.3AD (mode 4)"
621 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
622 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
624 "set bonding mon_period (port_id) (value)\n"
625 " Set the bonding link status monitoring polling period in ms.\n\n"
627 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
628 " Enable/disable dedicated queues for LACP control traffic.\n\n"
631 "set link-up port (port_id)\n"
632 " Set link up for a port.\n\n"
634 "set link-down port (port_id)\n"
635 " Set link down for a port.\n\n"
637 "E-tag set insertion on port-tag-id (value)"
638 " port (port_id) vf (vf_id)\n"
639 " Enable E-tag insertion for a VF on a port\n\n"
641 "E-tag set insertion off port (port_id) vf (vf_id)\n"
642 " Disable E-tag insertion for a VF on a port\n\n"
644 "E-tag set stripping (on|off) port (port_id)\n"
645 " Enable/disable E-tag stripping on a port\n\n"
647 "E-tag set forwarding (on|off) port (port_id)\n"
648 " Enable/disable E-tag based forwarding"
651 "E-tag set filter add e-tag-id (value) dst-pool"
652 " (pool_id) port (port_id)\n"
653 " Add an E-tag forwarding filter on a port\n\n"
655 "E-tag set filter del e-tag-id (value) port (port_id)\n"
656 " Delete an E-tag forwarding filter on a port\n\n"
658 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
659 " Load a profile package on a port\n\n"
661 "ddp del (port_id) (backup_profile_path)\n"
662 " Delete a profile package from a port\n\n"
664 "ptype mapping get (port_id) (valid_only)\n"
665 " Get ptype mapping on a port\n\n"
667 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
668 " Replace target with the pkt_type in ptype mapping\n\n"
670 "ptype mapping reset (port_id)\n"
671 " Reset ptype mapping on a port\n\n"
673 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
674 " Update a ptype mapping item on a port\n\n"
676 "set port (port_id) ptype_mask (ptype_mask)\n"
677 " set packet types classification for a specific port\n\n"
679 "set port (port_id) queue-region region_id (value) "
680 "queue_start_index (value) queue_num (value)\n"
681 " Set a queue region on a port\n\n"
683 "set port (port_id) queue-region region_id (value) "
685 " Set a flowtype region index on a port\n\n"
687 "set port (port_id) queue-region UP (value) region_id (value)\n"
688 " Set the mapping of User Priority to "
689 "queue region on a port\n\n"
691 "set port (port_id) queue-region flush (on|off)\n"
692 " flush all queue region related configuration\n\n"
694 "show port meter cap (port_id)\n"
695 " Show port meter capability information\n\n"
697 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
698 " meter profile add - srtcm rfc 2697\n\n"
700 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
701 " meter profile add - trtcm rfc 2698\n\n"
703 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
704 " meter profile add - trtcm rfc 4115\n\n"
706 "del port meter profile (port_id) (profile_id)\n"
707 " meter profile delete\n\n"
709 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
710 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
711 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
712 "(dscp_tbl_entry63)]\n"
715 "enable port meter (port_id) (mtr_id)\n"
718 "disable port meter (port_id) (mtr_id)\n"
721 "del port meter (port_id) (mtr_id)\n"
724 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
725 " meter update meter profile\n\n"
727 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
728 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
729 " update meter dscp table entries\n\n"
731 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
732 "(action0) [(action1) (action2)]\n"
733 " meter update policer action\n\n"
735 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
736 " meter update stats\n\n"
738 "show port (port_id) queue-region\n"
739 " show all queue region related configuration info\n\n"
741 , list_pkt_forwarding_modes()
745 if (show_all || !strcmp(res->section, "ports")) {
751 "----------------\n\n"
753 "port start (port_id|all)\n"
754 " Start all ports or port_id.\n\n"
756 "port stop (port_id|all)\n"
757 " Stop all ports or port_id.\n\n"
759 "port close (port_id|all)\n"
760 " Close all ports or port_id.\n\n"
762 "port reset (port_id|all)\n"
763 " Reset all ports or port_id.\n\n"
765 "port attach (ident)\n"
766 " Attach physical or virtual dev by pci address or virtual device name\n\n"
768 "port detach (port_id)\n"
769 " Detach physical or virtual dev by port_id\n\n"
771 "port config (port_id|all)"
772 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
773 " duplex (half|full|auto)\n"
774 " Set speed and duplex for all ports or port_id\n\n"
776 "port config (port_id|all) loopback (mode)\n"
777 " Set loopback mode for all ports or port_id\n\n"
779 "port config all (rxq|txq|rxd|txd) (value)\n"
780 " Set number for rxq/txq/rxd/txd.\n\n"
782 "port config all max-pkt-len (value)\n"
783 " Set the max packet length.\n\n"
785 "port config all max-lro-pkt-size (value)\n"
786 " Set the max LRO aggregated packet size.\n\n"
788 "port config all drop-en (on|off)\n"
789 " Enable or disable packet drop on all RX queues of all ports when no "
790 "receive buffers available.\n\n"
792 "port config all rss (all|default|ip|tcp|udp|sctp|"
793 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
794 " Set the RSS mode.\n\n"
796 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
797 " Set the RSS redirection table.\n\n"
799 "port config (port_id) dcb vt (on|off) (traffic_class)"
801 " Set the DCB mode.\n\n"
803 "port config all burst (value)\n"
804 " Set the number of packets per burst.\n\n"
806 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
808 " Set the ring prefetch/host/writeback threshold"
809 " for tx/rx queue.\n\n"
811 "port config all (txfreet|txrst|rxfreet) (value)\n"
812 " Set free threshold for rx/tx, or set"
813 " tx rs bit threshold.\n\n"
814 "port config mtu X value\n"
815 " Set the MTU of port X to a given value\n\n"
817 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
818 " Set a rx/tx queue's ring size configuration, the new"
819 " value will take effect after command that (re-)start the port"
820 " or command that setup the specific queue\n\n"
822 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
823 " Start/stop a rx/tx queue of port X. Only take effect"
824 " when port X is started\n\n"
826 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
827 " Switch on/off a deferred start of port X rx/tx queue. Only"
828 " take effect when port X is stopped.\n\n"
830 "port (port_id) (rxq|txq) (queue_id) setup\n"
831 " Setup a rx/tx queue of port X.\n\n"
833 "port config (port_id|all) l2-tunnel E-tag ether-type"
835 " Set the value of E-tag ether-type.\n\n"
837 "port config (port_id|all) l2-tunnel E-tag"
838 " (enable|disable)\n"
839 " Enable/disable the E-tag support.\n\n"
841 "port config (port_id) pctype mapping reset\n"
842 " Reset flow type to pctype mapping on a port\n\n"
844 "port config (port_id) pctype mapping update"
845 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
846 " Update a flow type to pctype mapping item on a port\n\n"
848 "port config (port_id) pctype (pctype_id) hash_inset|"
849 "fdir_inset|fdir_flx_inset get|set|clear field\n"
851 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
853 "port config (port_id) pctype (pctype_id) hash_inset|"
854 "fdir_inset|fdir_flx_inset clear all"
855 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
857 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
858 " Add/remove UDP tunnel port for tunneling offload\n\n"
860 "port config <port_id> rx_offload vlan_strip|"
861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 "outer_ipv4_cksum|macsec_strip|header_split|"
863 "vlan_filter|vlan_extend|jumbo_frame|"
864 "scatter|timestamp|security|keep_crc on|off\n"
865 " Enable or disable a per port Rx offloading"
866 " on all Rx queues of a port\n\n"
868 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
869 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 "outer_ipv4_cksum|macsec_strip|header_split|"
871 "vlan_filter|vlan_extend|jumbo_frame|"
872 "scatter|timestamp|security|keep_crc on|off\n"
873 " Enable or disable a per queue Rx offloading"
874 " only on a specific Rx queue\n\n"
876 "port config (port_id) tx_offload vlan_insert|"
877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
880 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
882 " Enable or disable a per port Tx offloading"
883 " on all Tx queues of a port\n\n"
885 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
886 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
889 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
891 " Enable or disable a per queue Tx offloading"
892 " only on a specific Tx queue\n\n"
894 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
895 " Load an eBPF program as a callback"
896 " for particular RX/TX queue\n\n"
898 "bpf-unload rx|tx (port) (queue)\n"
899 " Unload previously loaded eBPF program"
900 " for particular RX/TX queue\n\n"
902 "port config (port_id) tx_metadata (value)\n"
903 " Set Tx metadata value per port. Testpmd will add this value"
904 " to any Tx packet sent from this port\n\n"
906 "port config (port_id) dynf (name) set|clear\n"
907 " Register a dynf and Set/clear this flag on Tx. "
908 "Testpmd will set this value to any Tx packet "
909 "sent from this port\n\n"
913 if (show_all || !strcmp(res->section, "registers")) {
921 "read reg (port_id) (address)\n"
922 " Display value of a port register.\n\n"
924 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
925 " Display a port register bit field.\n\n"
927 "read regbit (port_id) (address) (bit_x)\n"
928 " Display a single port register bit.\n\n"
930 "write reg (port_id) (address) (value)\n"
931 " Set value of a port register.\n\n"
933 "write regfield (port_id) (address) (bit_x) (bit_y)"
935 " Set bit field of a port register.\n\n"
937 "write regbit (port_id) (address) (bit_x) (value)\n"
938 " Set single bit value of a port register.\n\n"
941 if (show_all || !strcmp(res->section, "filters")) {
949 "ethertype_filter (port_id) (add|del)"
950 " (mac_addr|mac_ignr) (mac_address) ethertype"
951 " (ether_type) (drop|fwd) queue (queue_id)\n"
952 " Add/Del an ethertype filter.\n\n"
954 "2tuple_filter (port_id) (add|del)"
955 " dst_port (dst_port_value) protocol (protocol_value)"
956 " mask (mask_value) tcp_flags (tcp_flags_value)"
957 " priority (prio_value) queue (queue_id)\n"
958 " Add/Del a 2tuple filter.\n\n"
960 "5tuple_filter (port_id) (add|del)"
961 " dst_ip (dst_address) src_ip (src_address)"
962 " dst_port (dst_port_value) src_port (src_port_value)"
963 " protocol (protocol_value)"
964 " mask (mask_value) tcp_flags (tcp_flags_value)"
965 " priority (prio_value) queue (queue_id)\n"
966 " Add/Del a 5tuple filter.\n\n"
968 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
969 " Add/Del syn filter.\n\n"
971 "flex_filter (port_id) (add|del) len (len_value)"
972 " bytes (bytes_value) mask (mask_value)"
973 " priority (prio_value) queue (queue_id)\n"
974 " Add/Del a flex filter.\n\n"
976 "flow_director_filter (port_id) mode IP (add|del|update)"
977 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
978 " src (src_ip_address) dst (dst_ip_address)"
979 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
980 " vlan (vlan_value) flexbytes (flexbytes_value)"
981 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
982 " fd_id (fd_id_value)\n"
983 " Add/Del an IP type flow director filter.\n\n"
985 "flow_director_filter (port_id) mode IP (add|del|update)"
986 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
987 " src (src_ip_address) (src_port)"
988 " dst (dst_ip_address) (dst_port)"
989 " tos (tos_value) ttl (ttl_value)"
990 " vlan (vlan_value) flexbytes (flexbytes_value)"
991 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
992 " fd_id (fd_id_value)\n"
993 " Add/Del an UDP/TCP type flow director filter.\n\n"
995 "flow_director_filter (port_id) mode IP (add|del|update)"
996 " flow (ipv4-sctp|ipv6-sctp)"
997 " src (src_ip_address) (src_port)"
998 " dst (dst_ip_address) (dst_port)"
999 " tag (verification_tag) "
1000 " tos (tos_value) ttl (ttl_value)"
1001 " vlan (vlan_value)"
1002 " flexbytes (flexbytes_value) (drop|fwd)"
1003 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1004 " Add/Del a SCTP type flow director filter.\n\n"
1006 "flow_director_filter (port_id) mode IP (add|del|update)"
1007 " flow l2_payload ether (ethertype)"
1008 " flexbytes (flexbytes_value) (drop|fwd)"
1009 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1010 " Add/Del a l2 payload type flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1013 " mac (mac_address) vlan (vlan_value)"
1014 " flexbytes (flexbytes_value) (drop|fwd)"
1015 " queue (queue_id) fd_id (fd_id_value)\n"
1016 " Add/Del a MAC-VLAN flow director filter.\n\n"
1018 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1019 " mac (mac_address) vlan (vlan_value)"
1020 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1021 " flexbytes (flexbytes_value) (drop|fwd)"
1022 " queue (queue_id) fd_id (fd_id_value)\n"
1023 " Add/Del a Tunnel flow director filter.\n\n"
1025 "flow_director_filter (port_id) mode raw (add|del|update)"
1026 " flow (flow_id) (drop|fwd) queue (queue_id)"
1027 " fd_id (fd_id_value) packet (packet file name)\n"
1028 " Add/Del a raw type flow director filter.\n\n"
1030 "flush_flow_director (port_id)\n"
1031 " Flush all flow director entries of a device.\n\n"
1033 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1034 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1035 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1036 " Set flow director IP mask.\n\n"
1038 "flow_director_mask (port_id) mode MAC-VLAN"
1039 " vlan (vlan_value)\n"
1040 " Set flow director MAC-VLAN mask.\n\n"
1042 "flow_director_mask (port_id) mode Tunnel"
1043 " vlan (vlan_value) mac (mac_value)"
1044 " tunnel-type (tunnel_type_value)"
1045 " tunnel-id (tunnel_id_value)\n"
1046 " Set flow director Tunnel mask.\n\n"
1048 "flow_director_flex_mask (port_id)"
1049 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1050 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1052 " Configure mask of flex payload.\n\n"
1054 "flow_director_flex_payload (port_id)"
1055 " (raw|l2|l3|l4) (config)\n"
1056 " Configure flex payload selection.\n\n"
1058 "get_sym_hash_ena_per_port (port_id)\n"
1059 " get symmetric hash enable configuration per port.\n\n"
1061 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1062 " set symmetric hash enable configuration per port"
1063 " to enable or disable.\n\n"
1065 "get_hash_global_config (port_id)\n"
1066 " Get the global configurations of hash filters.\n\n"
1068 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1069 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1070 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1071 " (enable|disable)\n"
1072 " Set the global configurations of hash filters.\n\n"
1074 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1075 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1076 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1077 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1078 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1079 "ipv6-next-header|udp-src-port|udp-dst-port|"
1080 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1081 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1082 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1083 "fld-8th|none) (select|add)\n"
1084 " Set the input set for hash.\n\n"
1086 "set_fdir_input_set (port_id) "
1087 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1088 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1089 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1090 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1091 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1092 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1093 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1095 " Set the input set for FDir.\n\n"
1097 "flow validate {port_id}"
1098 " [group {group_id}] [priority {level}]"
1099 " [ingress] [egress]"
1100 " pattern {item} [/ {item} [...]] / end"
1101 " actions {action} [/ {action} [...]] / end\n"
1102 " Check whether a flow rule can be created.\n\n"
1104 "flow create {port_id}"
1105 " [group {group_id}] [priority {level}]"
1106 " [ingress] [egress]"
1107 " pattern {item} [/ {item} [...]] / end"
1108 " actions {action} [/ {action} [...]] / end\n"
1109 " Create a flow rule.\n\n"
1111 "flow destroy {port_id} rule {rule_id} [...]\n"
1112 " Destroy specific flow rules.\n\n"
1114 "flow flush {port_id}\n"
1115 " Destroy all flow rules.\n\n"
1117 "flow query {port_id} {rule_id} {action}\n"
1118 " Query an existing flow rule.\n\n"
1120 "flow list {port_id} [group {group_id}] [...]\n"
1121 " List existing flow rules sorted by priority,"
1122 " filtered by group identifiers.\n\n"
1124 "flow isolate {port_id} {boolean}\n"
1125 " Restrict ingress traffic to the defined"
1128 "flow aged {port_id} [destroy]\n"
1129 " List and destroy aged flows"
1132 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1133 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1134 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1135 " Configure the VXLAN encapsulation for flows.\n\n"
1137 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1138 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1139 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1140 " eth-dst (eth-dst)\n"
1141 " Configure the VXLAN encapsulation for flows.\n\n"
1143 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1144 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1145 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1146 " eth-dst (eth-dst)\n"
1147 " Configure the VXLAN encapsulation for flows.\n\n"
1149 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1150 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1152 " Configure the NVGRE encapsulation for flows.\n\n"
1154 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1155 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1156 " eth-src (eth-src) eth-dst (eth-dst)\n"
1157 " Configure the NVGRE encapsulation for flows.\n\n"
1159 "set raw_encap {flow items}\n"
1160 " Configure the encapsulation with raw data.\n\n"
1162 "set raw_decap {flow items}\n"
1163 " Configure the decapsulation with raw data.\n\n"
1168 if (show_all || !strcmp(res->section, "traffic_management")) {
1172 "Traffic Management:\n"
1174 "show port tm cap (port_id)\n"
1175 " Display the port TM capability.\n\n"
1177 "show port tm level cap (port_id) (level_id)\n"
1178 " Display the port TM hierarchical level capability.\n\n"
1180 "show port tm node cap (port_id) (node_id)\n"
1181 " Display the port TM node capability.\n\n"
1183 "show port tm node type (port_id) (node_id)\n"
1184 " Display the port TM node type.\n\n"
1186 "show port tm node stats (port_id) (node_id) (clear)\n"
1187 " Display the port TM node stats.\n\n"
1189 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1190 "set port tm hierarchy default (port_id)\n"
1191 " Set default traffic Management hierarchy on a port\n\n"
1194 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1195 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1196 " (packet_length_adjust)\n"
1197 " Add port tm node private shaper profile.\n\n"
1199 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1200 " Delete port tm node private shaper profile.\n\n"
1202 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1203 " (shaper_profile_id)\n"
1204 " Add/update port tm node shared shaper.\n\n"
1206 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1207 " Delete port tm node shared shaper.\n\n"
1209 "set port tm node shaper profile (port_id) (node_id)"
1210 " (shaper_profile_id)\n"
1211 " Set port tm node shaper profile.\n\n"
1213 "add port tm node wred profile (port_id) (wred_profile_id)"
1214 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1215 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1216 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1217 " Add port tm node wred profile.\n\n"
1219 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1220 " Delete port tm node wred profile.\n\n"
1222 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1223 " (priority) (weight) (level_id) (shaper_profile_id)"
1224 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1225 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1226 " Add port tm nonleaf node.\n\n"
1228 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1229 " (priority) (weight) (level_id) (shaper_profile_id)"
1230 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1231 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1232 " Add port tm leaf node.\n\n"
1234 "del port tm node (port_id) (node_id)\n"
1235 " Delete port tm node.\n\n"
1237 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1238 " (priority) (weight)\n"
1239 " Set port tm node parent.\n\n"
1241 "suspend port tm node (port_id) (node_id)"
1242 " Suspend tm node.\n\n"
1244 "resume port tm node (port_id) (node_id)"
1245 " Resume tm node.\n\n"
1247 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1248 " Commit tm hierarchy.\n\n"
1250 "set port tm mark ip_ecn (port) (green) (yellow)"
1252 " Enables/Disables the traffic management marking"
1253 " for IP ECN (Explicit Congestion Notification)"
1254 " packets on a given port\n\n"
1256 "set port tm mark ip_dscp (port) (green) (yellow)"
1258 " Enables/Disables the traffic management marking"
1259 " on the port for IP dscp packets\n\n"
1261 "set port tm mark vlan_dei (port) (green) (yellow)"
1263 " Enables/Disables the traffic management marking"
1264 " on the port for VLAN packets with DEI enabled\n\n"
1268 if (show_all || !strcmp(res->section, "devices")) {
1272 "Device Operations:\n"
1274 "device detach (identifier)\n"
1275 " Detach device by identifier.\n\n"
1281 cmdline_parse_token_string_t cmd_help_long_help =
1282 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1284 cmdline_parse_token_string_t cmd_help_long_section =
1285 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1286 "all#control#display#config#"
1287 "ports#registers#filters#traffic_management#devices");
1289 cmdline_parse_inst_t cmd_help_long = {
1290 .f = cmd_help_long_parsed,
1292 .help_str = "help all|control|display|config|ports|register|"
1293 "filters|traffic_management|devices: "
1296 (void *)&cmd_help_long_help,
1297 (void *)&cmd_help_long_section,
1303 /* *** start/stop/close all ports *** */
1304 struct cmd_operate_port_result {
1305 cmdline_fixed_string_t keyword;
1306 cmdline_fixed_string_t name;
1307 cmdline_fixed_string_t value;
1310 static void cmd_operate_port_parsed(void *parsed_result,
1311 __rte_unused struct cmdline *cl,
1312 __rte_unused void *data)
1314 struct cmd_operate_port_result *res = parsed_result;
1316 if (!strcmp(res->name, "start"))
1317 start_port(RTE_PORT_ALL);
1318 else if (!strcmp(res->name, "stop"))
1319 stop_port(RTE_PORT_ALL);
1320 else if (!strcmp(res->name, "close"))
1321 close_port(RTE_PORT_ALL);
1322 else if (!strcmp(res->name, "reset"))
1323 reset_port(RTE_PORT_ALL);
1325 printf("Unknown parameter\n");
1328 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1329 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1331 cmdline_parse_token_string_t cmd_operate_port_all_port =
1332 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1333 "start#stop#close#reset");
1334 cmdline_parse_token_string_t cmd_operate_port_all_all =
1335 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1337 cmdline_parse_inst_t cmd_operate_port = {
1338 .f = cmd_operate_port_parsed,
1340 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1342 (void *)&cmd_operate_port_all_cmd,
1343 (void *)&cmd_operate_port_all_port,
1344 (void *)&cmd_operate_port_all_all,
1349 /* *** start/stop/close specific port *** */
1350 struct cmd_operate_specific_port_result {
1351 cmdline_fixed_string_t keyword;
1352 cmdline_fixed_string_t name;
1356 static void cmd_operate_specific_port_parsed(void *parsed_result,
1357 __rte_unused struct cmdline *cl,
1358 __rte_unused void *data)
1360 struct cmd_operate_specific_port_result *res = parsed_result;
1362 if (!strcmp(res->name, "start"))
1363 start_port(res->value);
1364 else if (!strcmp(res->name, "stop"))
1365 stop_port(res->value);
1366 else if (!strcmp(res->name, "close"))
1367 close_port(res->value);
1368 else if (!strcmp(res->name, "reset"))
1369 reset_port(res->value);
1371 printf("Unknown parameter\n");
1374 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1375 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1377 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1378 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1379 name, "start#stop#close#reset");
1380 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1381 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1384 cmdline_parse_inst_t cmd_operate_specific_port = {
1385 .f = cmd_operate_specific_port_parsed,
1387 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1389 (void *)&cmd_operate_specific_port_cmd,
1390 (void *)&cmd_operate_specific_port_port,
1391 (void *)&cmd_operate_specific_port_id,
1396 /* *** enable port setup (after attach) via iterator or event *** */
1397 struct cmd_set_port_setup_on_result {
1398 cmdline_fixed_string_t set;
1399 cmdline_fixed_string_t port;
1400 cmdline_fixed_string_t setup;
1401 cmdline_fixed_string_t on;
1402 cmdline_fixed_string_t mode;
1405 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1406 __rte_unused struct cmdline *cl,
1407 __rte_unused void *data)
1409 struct cmd_set_port_setup_on_result *res = parsed_result;
1411 if (strcmp(res->mode, "event") == 0)
1412 setup_on_probe_event = true;
1413 else if (strcmp(res->mode, "iterator") == 0)
1414 setup_on_probe_event = false;
1416 printf("Unknown mode\n");
1419 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1420 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1422 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1423 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1425 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1426 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1428 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1429 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1431 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1432 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1433 mode, "iterator#event");
1435 cmdline_parse_inst_t cmd_set_port_setup_on = {
1436 .f = cmd_set_port_setup_on_parsed,
1438 .help_str = "set port setup on iterator|event",
1440 (void *)&cmd_set_port_setup_on_set,
1441 (void *)&cmd_set_port_setup_on_port,
1442 (void *)&cmd_set_port_setup_on_setup,
1443 (void *)&cmd_set_port_setup_on_on,
1444 (void *)&cmd_set_port_setup_on_mode,
1449 /* *** attach a specified port *** */
1450 struct cmd_operate_attach_port_result {
1451 cmdline_fixed_string_t port;
1452 cmdline_fixed_string_t keyword;
1453 cmdline_multi_string_t identifier;
1456 static void cmd_operate_attach_port_parsed(void *parsed_result,
1457 __rte_unused struct cmdline *cl,
1458 __rte_unused void *data)
1460 struct cmd_operate_attach_port_result *res = parsed_result;
1462 if (!strcmp(res->keyword, "attach"))
1463 attach_port(res->identifier);
1465 printf("Unknown parameter\n");
1468 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1469 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1471 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1472 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1474 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1475 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1476 identifier, TOKEN_STRING_MULTI);
1478 cmdline_parse_inst_t cmd_operate_attach_port = {
1479 .f = cmd_operate_attach_port_parsed,
1481 .help_str = "port attach <identifier>: "
1482 "(identifier: pci address or virtual dev name)",
1484 (void *)&cmd_operate_attach_port_port,
1485 (void *)&cmd_operate_attach_port_keyword,
1486 (void *)&cmd_operate_attach_port_identifier,
1491 /* *** detach a specified port *** */
1492 struct cmd_operate_detach_port_result {
1493 cmdline_fixed_string_t port;
1494 cmdline_fixed_string_t keyword;
1498 static void cmd_operate_detach_port_parsed(void *parsed_result,
1499 __rte_unused struct cmdline *cl,
1500 __rte_unused void *data)
1502 struct cmd_operate_detach_port_result *res = parsed_result;
1504 if (!strcmp(res->keyword, "detach")) {
1505 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1506 detach_port_device(res->port_id);
1508 printf("Unknown parameter\n");
1512 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1513 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1515 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1516 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1518 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1519 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1522 cmdline_parse_inst_t cmd_operate_detach_port = {
1523 .f = cmd_operate_detach_port_parsed,
1525 .help_str = "port detach <port_id>",
1527 (void *)&cmd_operate_detach_port_port,
1528 (void *)&cmd_operate_detach_port_keyword,
1529 (void *)&cmd_operate_detach_port_port_id,
1534 /* *** detach device by identifier *** */
1535 struct cmd_operate_detach_device_result {
1536 cmdline_fixed_string_t device;
1537 cmdline_fixed_string_t keyword;
1538 cmdline_fixed_string_t identifier;
1541 static void cmd_operate_detach_device_parsed(void *parsed_result,
1542 __rte_unused struct cmdline *cl,
1543 __rte_unused void *data)
1545 struct cmd_operate_detach_device_result *res = parsed_result;
1547 if (!strcmp(res->keyword, "detach"))
1548 detach_devargs(res->identifier);
1550 printf("Unknown parameter\n");
1553 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1554 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1556 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1557 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1559 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1560 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1563 cmdline_parse_inst_t cmd_operate_detach_device = {
1564 .f = cmd_operate_detach_device_parsed,
1566 .help_str = "device detach <identifier>:"
1567 "(identifier: pci address or virtual dev name)",
1569 (void *)&cmd_operate_detach_device_device,
1570 (void *)&cmd_operate_detach_device_keyword,
1571 (void *)&cmd_operate_detach_device_identifier,
1575 /* *** configure speed for all ports *** */
1576 struct cmd_config_speed_all {
1577 cmdline_fixed_string_t port;
1578 cmdline_fixed_string_t keyword;
1579 cmdline_fixed_string_t all;
1580 cmdline_fixed_string_t item1;
1581 cmdline_fixed_string_t item2;
1582 cmdline_fixed_string_t value1;
1583 cmdline_fixed_string_t value2;
1587 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1592 if (!strcmp(duplexstr, "half")) {
1593 duplex = ETH_LINK_HALF_DUPLEX;
1594 } else if (!strcmp(duplexstr, "full")) {
1595 duplex = ETH_LINK_FULL_DUPLEX;
1596 } else if (!strcmp(duplexstr, "auto")) {
1597 duplex = ETH_LINK_FULL_DUPLEX;
1599 printf("Unknown duplex parameter\n");
1603 if (!strcmp(speedstr, "10")) {
1604 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1605 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1606 } else if (!strcmp(speedstr, "100")) {
1607 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1608 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1610 if (duplex != ETH_LINK_FULL_DUPLEX) {
1611 printf("Invalid speed/duplex parameters\n");
1614 if (!strcmp(speedstr, "1000")) {
1615 *speed = ETH_LINK_SPEED_1G;
1616 } else if (!strcmp(speedstr, "10000")) {
1617 *speed = ETH_LINK_SPEED_10G;
1618 } else if (!strcmp(speedstr, "25000")) {
1619 *speed = ETH_LINK_SPEED_25G;
1620 } else if (!strcmp(speedstr, "40000")) {
1621 *speed = ETH_LINK_SPEED_40G;
1622 } else if (!strcmp(speedstr, "50000")) {
1623 *speed = ETH_LINK_SPEED_50G;
1624 } else if (!strcmp(speedstr, "100000")) {
1625 *speed = ETH_LINK_SPEED_100G;
1626 } else if (!strcmp(speedstr, "200000")) {
1627 *speed = ETH_LINK_SPEED_200G;
1628 } else if (!strcmp(speedstr, "auto")) {
1629 *speed = ETH_LINK_SPEED_AUTONEG;
1631 printf("Unknown speed parameter\n");
1640 cmd_config_speed_all_parsed(void *parsed_result,
1641 __rte_unused struct cmdline *cl,
1642 __rte_unused void *data)
1644 struct cmd_config_speed_all *res = parsed_result;
1645 uint32_t link_speed;
1648 if (!all_ports_stopped()) {
1649 printf("Please stop all ports first\n");
1653 if (parse_and_check_speed_duplex(res->value1, res->value2,
1657 RTE_ETH_FOREACH_DEV(pid) {
1658 ports[pid].dev_conf.link_speeds = link_speed;
1661 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1664 cmdline_parse_token_string_t cmd_config_speed_all_port =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1666 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1667 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1669 cmdline_parse_token_string_t cmd_config_speed_all_all =
1670 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1671 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1673 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1675 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1676 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1678 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1682 cmdline_parse_inst_t cmd_config_speed_all = {
1683 .f = cmd_config_speed_all_parsed,
1685 .help_str = "port config all speed "
1686 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1689 (void *)&cmd_config_speed_all_port,
1690 (void *)&cmd_config_speed_all_keyword,
1691 (void *)&cmd_config_speed_all_all,
1692 (void *)&cmd_config_speed_all_item1,
1693 (void *)&cmd_config_speed_all_value1,
1694 (void *)&cmd_config_speed_all_item2,
1695 (void *)&cmd_config_speed_all_value2,
1700 /* *** configure speed for specific port *** */
1701 struct cmd_config_speed_specific {
1702 cmdline_fixed_string_t port;
1703 cmdline_fixed_string_t keyword;
1705 cmdline_fixed_string_t item1;
1706 cmdline_fixed_string_t item2;
1707 cmdline_fixed_string_t value1;
1708 cmdline_fixed_string_t value2;
1712 cmd_config_speed_specific_parsed(void *parsed_result,
1713 __rte_unused struct cmdline *cl,
1714 __rte_unused void *data)
1716 struct cmd_config_speed_specific *res = parsed_result;
1717 uint32_t link_speed;
1719 if (!all_ports_stopped()) {
1720 printf("Please stop all ports first\n");
1724 if (port_id_is_invalid(res->id, ENABLED_WARN))
1727 if (parse_and_check_speed_duplex(res->value1, res->value2,
1731 ports[res->id].dev_conf.link_speeds = link_speed;
1733 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1737 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1738 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1740 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1741 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1743 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1744 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1745 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1746 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1748 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1749 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1750 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1751 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1752 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1754 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1755 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1758 cmdline_parse_inst_t cmd_config_speed_specific = {
1759 .f = cmd_config_speed_specific_parsed,
1761 .help_str = "port config <port_id> speed "
1762 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1765 (void *)&cmd_config_speed_specific_port,
1766 (void *)&cmd_config_speed_specific_keyword,
1767 (void *)&cmd_config_speed_specific_id,
1768 (void *)&cmd_config_speed_specific_item1,
1769 (void *)&cmd_config_speed_specific_value1,
1770 (void *)&cmd_config_speed_specific_item2,
1771 (void *)&cmd_config_speed_specific_value2,
1776 /* *** configure loopback for all ports *** */
1777 struct cmd_config_loopback_all {
1778 cmdline_fixed_string_t port;
1779 cmdline_fixed_string_t keyword;
1780 cmdline_fixed_string_t all;
1781 cmdline_fixed_string_t item;
1786 cmd_config_loopback_all_parsed(void *parsed_result,
1787 __rte_unused struct cmdline *cl,
1788 __rte_unused void *data)
1790 struct cmd_config_loopback_all *res = parsed_result;
1793 if (!all_ports_stopped()) {
1794 printf("Please stop all ports first\n");
1798 RTE_ETH_FOREACH_DEV(pid) {
1799 ports[pid].dev_conf.lpbk_mode = res->mode;
1802 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1805 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1806 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1807 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1808 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1810 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1811 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1812 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1813 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1815 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1816 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1818 cmdline_parse_inst_t cmd_config_loopback_all = {
1819 .f = cmd_config_loopback_all_parsed,
1821 .help_str = "port config all loopback <mode>",
1823 (void *)&cmd_config_loopback_all_port,
1824 (void *)&cmd_config_loopback_all_keyword,
1825 (void *)&cmd_config_loopback_all_all,
1826 (void *)&cmd_config_loopback_all_item,
1827 (void *)&cmd_config_loopback_all_mode,
1832 /* *** configure loopback for specific port *** */
1833 struct cmd_config_loopback_specific {
1834 cmdline_fixed_string_t port;
1835 cmdline_fixed_string_t keyword;
1837 cmdline_fixed_string_t item;
1842 cmd_config_loopback_specific_parsed(void *parsed_result,
1843 __rte_unused struct cmdline *cl,
1844 __rte_unused void *data)
1846 struct cmd_config_loopback_specific *res = parsed_result;
1848 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1851 if (!port_is_stopped(res->port_id)) {
1852 printf("Please stop port %u first\n", res->port_id);
1856 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1858 cmd_reconfig_device_queue(res->port_id, 1, 1);
1862 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1863 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1865 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1868 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1869 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1871 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1872 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1874 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1875 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1878 cmdline_parse_inst_t cmd_config_loopback_specific = {
1879 .f = cmd_config_loopback_specific_parsed,
1881 .help_str = "port config <port_id> loopback <mode>",
1883 (void *)&cmd_config_loopback_specific_port,
1884 (void *)&cmd_config_loopback_specific_keyword,
1885 (void *)&cmd_config_loopback_specific_id,
1886 (void *)&cmd_config_loopback_specific_item,
1887 (void *)&cmd_config_loopback_specific_mode,
1892 /* *** configure txq/rxq, txd/rxd *** */
1893 struct cmd_config_rx_tx {
1894 cmdline_fixed_string_t port;
1895 cmdline_fixed_string_t keyword;
1896 cmdline_fixed_string_t all;
1897 cmdline_fixed_string_t name;
1902 cmd_config_rx_tx_parsed(void *parsed_result,
1903 __rte_unused struct cmdline *cl,
1904 __rte_unused void *data)
1906 struct cmd_config_rx_tx *res = parsed_result;
1908 if (!all_ports_stopped()) {
1909 printf("Please stop all ports first\n");
1912 if (!strcmp(res->name, "rxq")) {
1913 if (!res->value && !nb_txq) {
1914 printf("Warning: Either rx or tx queues should be non zero\n");
1917 if (check_nb_rxq(res->value) != 0)
1919 nb_rxq = res->value;
1921 else if (!strcmp(res->name, "txq")) {
1922 if (!res->value && !nb_rxq) {
1923 printf("Warning: Either rx or tx queues should be non zero\n");
1926 if (check_nb_txq(res->value) != 0)
1928 nb_txq = res->value;
1930 else if (!strcmp(res->name, "rxd")) {
1931 if (check_nb_rxd(res->value) != 0)
1933 nb_rxd = res->value;
1934 } else if (!strcmp(res->name, "txd")) {
1935 if (check_nb_txd(res->value) != 0)
1938 nb_txd = res->value;
1940 printf("Unknown parameter\n");
1948 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1951 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1952 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1953 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1954 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1955 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1956 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1957 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1960 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1961 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1963 cmdline_parse_inst_t cmd_config_rx_tx = {
1964 .f = cmd_config_rx_tx_parsed,
1966 .help_str = "port config all rxq|txq|rxd|txd <value>",
1968 (void *)&cmd_config_rx_tx_port,
1969 (void *)&cmd_config_rx_tx_keyword,
1970 (void *)&cmd_config_rx_tx_all,
1971 (void *)&cmd_config_rx_tx_name,
1972 (void *)&cmd_config_rx_tx_value,
1977 /* *** config max packet length *** */
1978 struct cmd_config_max_pkt_len_result {
1979 cmdline_fixed_string_t port;
1980 cmdline_fixed_string_t keyword;
1981 cmdline_fixed_string_t all;
1982 cmdline_fixed_string_t name;
1987 cmd_config_max_pkt_len_parsed(void *parsed_result,
1988 __rte_unused struct cmdline *cl,
1989 __rte_unused void *data)
1991 struct cmd_config_max_pkt_len_result *res = parsed_result;
1994 if (!all_ports_stopped()) {
1995 printf("Please stop all ports first\n");
1999 RTE_ETH_FOREACH_DEV(pid) {
2000 struct rte_port *port = &ports[pid];
2001 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2003 if (!strcmp(res->name, "max-pkt-len")) {
2004 if (res->value < RTE_ETHER_MIN_LEN) {
2005 printf("max-pkt-len can not be less than %d\n",
2009 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2012 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2013 if (res->value > RTE_ETHER_MAX_LEN)
2014 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2016 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2017 port->dev_conf.rxmode.offloads = rx_offloads;
2019 printf("Unknown parameter\n");
2026 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2029 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2030 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2032 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2035 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2036 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2038 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2039 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2041 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2042 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2045 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2046 .f = cmd_config_max_pkt_len_parsed,
2048 .help_str = "port config all max-pkt-len <value>",
2050 (void *)&cmd_config_max_pkt_len_port,
2051 (void *)&cmd_config_max_pkt_len_keyword,
2052 (void *)&cmd_config_max_pkt_len_all,
2053 (void *)&cmd_config_max_pkt_len_name,
2054 (void *)&cmd_config_max_pkt_len_value,
2059 /* *** config max LRO aggregated packet size *** */
2060 struct cmd_config_max_lro_pkt_size_result {
2061 cmdline_fixed_string_t port;
2062 cmdline_fixed_string_t keyword;
2063 cmdline_fixed_string_t all;
2064 cmdline_fixed_string_t name;
2069 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2070 __rte_unused struct cmdline *cl,
2071 __rte_unused void *data)
2073 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2076 if (!all_ports_stopped()) {
2077 printf("Please stop all ports first\n");
2081 RTE_ETH_FOREACH_DEV(pid) {
2082 struct rte_port *port = &ports[pid];
2084 if (!strcmp(res->name, "max-lro-pkt-size")) {
2086 port->dev_conf.rxmode.max_lro_pkt_size)
2089 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2091 printf("Unknown parameter\n");
2098 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2101 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2102 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2104 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2105 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2107 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2108 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2110 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2111 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2112 name, "max-lro-pkt-size");
2113 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2114 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2117 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2118 .f = cmd_config_max_lro_pkt_size_parsed,
2120 .help_str = "port config all max-lro-pkt-size <value>",
2122 (void *)&cmd_config_max_lro_pkt_size_port,
2123 (void *)&cmd_config_max_lro_pkt_size_keyword,
2124 (void *)&cmd_config_max_lro_pkt_size_all,
2125 (void *)&cmd_config_max_lro_pkt_size_name,
2126 (void *)&cmd_config_max_lro_pkt_size_value,
2131 /* *** configure port MTU *** */
2132 struct cmd_config_mtu_result {
2133 cmdline_fixed_string_t port;
2134 cmdline_fixed_string_t keyword;
2135 cmdline_fixed_string_t mtu;
2141 cmd_config_mtu_parsed(void *parsed_result,
2142 __rte_unused struct cmdline *cl,
2143 __rte_unused void *data)
2145 struct cmd_config_mtu_result *res = parsed_result;
2147 if (res->value < RTE_ETHER_MIN_LEN) {
2148 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2151 port_mtu_set(res->port_id, res->value);
2154 cmdline_parse_token_string_t cmd_config_mtu_port =
2155 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2157 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2158 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2160 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2161 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2163 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2164 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2165 cmdline_parse_token_num_t cmd_config_mtu_value =
2166 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2168 cmdline_parse_inst_t cmd_config_mtu = {
2169 .f = cmd_config_mtu_parsed,
2171 .help_str = "port config mtu <port_id> <value>",
2173 (void *)&cmd_config_mtu_port,
2174 (void *)&cmd_config_mtu_keyword,
2175 (void *)&cmd_config_mtu_mtu,
2176 (void *)&cmd_config_mtu_port_id,
2177 (void *)&cmd_config_mtu_value,
2182 /* *** configure rx mode *** */
2183 struct cmd_config_rx_mode_flag {
2184 cmdline_fixed_string_t port;
2185 cmdline_fixed_string_t keyword;
2186 cmdline_fixed_string_t all;
2187 cmdline_fixed_string_t name;
2188 cmdline_fixed_string_t value;
2192 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2193 __rte_unused struct cmdline *cl,
2194 __rte_unused void *data)
2196 struct cmd_config_rx_mode_flag *res = parsed_result;
2198 if (!all_ports_stopped()) {
2199 printf("Please stop all ports first\n");
2203 if (!strcmp(res->name, "drop-en")) {
2204 if (!strcmp(res->value, "on"))
2206 else if (!strcmp(res->value, "off"))
2209 printf("Unknown parameter\n");
2213 printf("Unknown parameter\n");
2219 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2222 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2223 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2224 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2225 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2227 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2228 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2229 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2230 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2232 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2233 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2236 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2237 .f = cmd_config_rx_mode_flag_parsed,
2239 .help_str = "port config all drop-en on|off",
2241 (void *)&cmd_config_rx_mode_flag_port,
2242 (void *)&cmd_config_rx_mode_flag_keyword,
2243 (void *)&cmd_config_rx_mode_flag_all,
2244 (void *)&cmd_config_rx_mode_flag_name,
2245 (void *)&cmd_config_rx_mode_flag_value,
2250 /* *** configure rss *** */
2251 struct cmd_config_rss {
2252 cmdline_fixed_string_t port;
2253 cmdline_fixed_string_t keyword;
2254 cmdline_fixed_string_t all;
2255 cmdline_fixed_string_t name;
2256 cmdline_fixed_string_t value;
2260 cmd_config_rss_parsed(void *parsed_result,
2261 __rte_unused struct cmdline *cl,
2262 __rte_unused void *data)
2264 struct cmd_config_rss *res = parsed_result;
2265 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2266 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2267 int use_default = 0;
2268 int all_updated = 1;
2273 if (!strcmp(res->value, "all"))
2274 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2275 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2276 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2277 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2278 else if (!strcmp(res->value, "eth"))
2279 rss_conf.rss_hf = ETH_RSS_ETH;
2280 else if (!strcmp(res->value, "vlan"))
2281 rss_conf.rss_hf = ETH_RSS_VLAN;
2282 else if (!strcmp(res->value, "ip"))
2283 rss_conf.rss_hf = ETH_RSS_IP;
2284 else if (!strcmp(res->value, "udp"))
2285 rss_conf.rss_hf = ETH_RSS_UDP;
2286 else if (!strcmp(res->value, "tcp"))
2287 rss_conf.rss_hf = ETH_RSS_TCP;
2288 else if (!strcmp(res->value, "sctp"))
2289 rss_conf.rss_hf = ETH_RSS_SCTP;
2290 else if (!strcmp(res->value, "ether"))
2291 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2292 else if (!strcmp(res->value, "port"))
2293 rss_conf.rss_hf = ETH_RSS_PORT;
2294 else if (!strcmp(res->value, "vxlan"))
2295 rss_conf.rss_hf = ETH_RSS_VXLAN;
2296 else if (!strcmp(res->value, "geneve"))
2297 rss_conf.rss_hf = ETH_RSS_GENEVE;
2298 else if (!strcmp(res->value, "nvgre"))
2299 rss_conf.rss_hf = ETH_RSS_NVGRE;
2300 else if (!strcmp(res->value, "l3-src-only"))
2301 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2302 else if (!strcmp(res->value, "l3-dst-only"))
2303 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2304 else if (!strcmp(res->value, "l4-src-only"))
2305 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2306 else if (!strcmp(res->value, "l4-dst-only"))
2307 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2308 else if (!strcmp(res->value, "l2-src-only"))
2309 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2310 else if (!strcmp(res->value, "l2-dst-only"))
2311 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2312 else if (!strcmp(res->value, "l2tpv3"))
2313 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2314 else if (!strcmp(res->value, "esp"))
2315 rss_conf.rss_hf = ETH_RSS_ESP;
2316 else if (!strcmp(res->value, "ah"))
2317 rss_conf.rss_hf = ETH_RSS_AH;
2318 else if (!strcmp(res->value, "pfcp"))
2319 rss_conf.rss_hf = ETH_RSS_PFCP;
2320 else if (!strcmp(res->value, "pppoe"))
2321 rss_conf.rss_hf = ETH_RSS_PPPOE;
2322 else if (!strcmp(res->value, "gtpu"))
2323 rss_conf.rss_hf = ETH_RSS_GTPU;
2324 else if (!strcmp(res->value, "none"))
2325 rss_conf.rss_hf = 0;
2326 else if (!strcmp(res->value, "default"))
2328 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2329 atoi(res->value) < 64)
2330 rss_conf.rss_hf = 1ULL << atoi(res->value);
2332 printf("Unknown parameter\n");
2335 rss_conf.rss_key = NULL;
2336 /* Update global configuration for RSS types. */
2337 RTE_ETH_FOREACH_DEV(i) {
2338 struct rte_eth_rss_conf local_rss_conf;
2340 ret = eth_dev_info_get_print_err(i, &dev_info);
2345 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2347 local_rss_conf = rss_conf;
2348 local_rss_conf.rss_hf = rss_conf.rss_hf &
2349 dev_info.flow_type_rss_offloads;
2350 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2351 printf("Port %u modified RSS hash function based on hardware support,"
2352 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2353 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2355 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2358 printf("Configuration of RSS hash at ethernet port %d "
2359 "failed with error (%d): %s.\n",
2360 i, -diag, strerror(-diag));
2363 if (all_updated && !use_default) {
2364 rss_hf = rss_conf.rss_hf;
2365 printf("rss_hf %#"PRIx64"\n", rss_hf);
2369 cmdline_parse_token_string_t cmd_config_rss_port =
2370 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2371 cmdline_parse_token_string_t cmd_config_rss_keyword =
2372 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2373 cmdline_parse_token_string_t cmd_config_rss_all =
2374 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2375 cmdline_parse_token_string_t cmd_config_rss_name =
2376 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2377 cmdline_parse_token_string_t cmd_config_rss_value =
2378 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2380 cmdline_parse_inst_t cmd_config_rss = {
2381 .f = cmd_config_rss_parsed,
2383 .help_str = "port config all rss "
2384 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2385 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|<flowtype_id>",
2387 (void *)&cmd_config_rss_port,
2388 (void *)&cmd_config_rss_keyword,
2389 (void *)&cmd_config_rss_all,
2390 (void *)&cmd_config_rss_name,
2391 (void *)&cmd_config_rss_value,
2396 /* *** configure rss hash key *** */
2397 struct cmd_config_rss_hash_key {
2398 cmdline_fixed_string_t port;
2399 cmdline_fixed_string_t config;
2401 cmdline_fixed_string_t rss_hash_key;
2402 cmdline_fixed_string_t rss_type;
2403 cmdline_fixed_string_t key;
2407 hexa_digit_to_value(char hexa_digit)
2409 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2410 return (uint8_t) (hexa_digit - '0');
2411 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2412 return (uint8_t) ((hexa_digit - 'a') + 10);
2413 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2414 return (uint8_t) ((hexa_digit - 'A') + 10);
2415 /* Invalid hexa digit */
2420 parse_and_check_key_hexa_digit(char *key, int idx)
2424 hexa_v = hexa_digit_to_value(key[idx]);
2426 printf("invalid key: character %c at position %d is not a "
2427 "valid hexa digit\n", key[idx], idx);
2432 cmd_config_rss_hash_key_parsed(void *parsed_result,
2433 __rte_unused struct cmdline *cl,
2434 __rte_unused void *data)
2436 struct cmd_config_rss_hash_key *res = parsed_result;
2437 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2441 struct rte_eth_dev_info dev_info;
2442 uint8_t hash_key_size;
2446 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2450 if (dev_info.hash_key_size > 0 &&
2451 dev_info.hash_key_size <= sizeof(hash_key))
2452 hash_key_size = dev_info.hash_key_size;
2454 printf("dev_info did not provide a valid hash key size\n");
2457 /* Check the length of the RSS hash key */
2458 key_len = strlen(res->key);
2459 if (key_len != (hash_key_size * 2)) {
2460 printf("key length: %d invalid - key must be a string of %d"
2461 " hexa-decimal numbers\n",
2462 (int) key_len, hash_key_size * 2);
2465 /* Translate RSS hash key into binary representation */
2466 for (i = 0; i < hash_key_size; i++) {
2467 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2470 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2473 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2475 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2479 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2480 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2481 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2482 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2484 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2485 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2486 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2487 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2488 rss_hash_key, "rss-hash-key");
2489 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2490 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2491 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2492 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2493 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2494 "ipv6-tcp-ex#ipv6-udp-ex#"
2495 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2496 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2497 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2498 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2499 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2501 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2502 .f = cmd_config_rss_hash_key_parsed,
2504 .help_str = "port config <port_id> rss-hash-key "
2505 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2506 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2507 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2508 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2509 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2510 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2511 "<string of hex digits (variable length, NIC dependent)>",
2513 (void *)&cmd_config_rss_hash_key_port,
2514 (void *)&cmd_config_rss_hash_key_config,
2515 (void *)&cmd_config_rss_hash_key_port_id,
2516 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2517 (void *)&cmd_config_rss_hash_key_rss_type,
2518 (void *)&cmd_config_rss_hash_key_value,
2523 /* *** configure port rxq/txq ring size *** */
2524 struct cmd_config_rxtx_ring_size {
2525 cmdline_fixed_string_t port;
2526 cmdline_fixed_string_t config;
2528 cmdline_fixed_string_t rxtxq;
2530 cmdline_fixed_string_t rsize;
2535 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2536 __rte_unused struct cmdline *cl,
2537 __rte_unused void *data)
2539 struct cmd_config_rxtx_ring_size *res = parsed_result;
2540 struct rte_port *port;
2543 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2546 if (res->portid == (portid_t)RTE_PORT_ALL) {
2547 printf("Invalid port id\n");
2551 port = &ports[res->portid];
2553 if (!strcmp(res->rxtxq, "rxq"))
2555 else if (!strcmp(res->rxtxq, "txq"))
2558 printf("Unknown parameter\n");
2562 if (isrx && rx_queue_id_is_invalid(res->qid))
2564 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2567 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2568 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2574 port->nb_rx_desc[res->qid] = res->size;
2576 port->nb_tx_desc[res->qid] = res->size;
2578 cmd_reconfig_device_queue(res->portid, 0, 1);
2581 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2582 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2584 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2585 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2587 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2588 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2590 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2591 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2593 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2594 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2596 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2597 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2598 rsize, "ring_size");
2599 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2600 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2603 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2604 .f = cmd_config_rxtx_ring_size_parsed,
2606 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2608 (void *)&cmd_config_rxtx_ring_size_port,
2609 (void *)&cmd_config_rxtx_ring_size_config,
2610 (void *)&cmd_config_rxtx_ring_size_portid,
2611 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2612 (void *)&cmd_config_rxtx_ring_size_qid,
2613 (void *)&cmd_config_rxtx_ring_size_rsize,
2614 (void *)&cmd_config_rxtx_ring_size_size,
2619 /* *** configure port rxq/txq start/stop *** */
2620 struct cmd_config_rxtx_queue {
2621 cmdline_fixed_string_t port;
2623 cmdline_fixed_string_t rxtxq;
2625 cmdline_fixed_string_t opname;
2629 cmd_config_rxtx_queue_parsed(void *parsed_result,
2630 __rte_unused struct cmdline *cl,
2631 __rte_unused void *data)
2633 struct cmd_config_rxtx_queue *res = parsed_result;
2638 if (test_done == 0) {
2639 printf("Please stop forwarding first\n");
2643 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2646 if (port_is_started(res->portid) != 1) {
2647 printf("Please start port %u first\n", res->portid);
2651 if (!strcmp(res->rxtxq, "rxq"))
2653 else if (!strcmp(res->rxtxq, "txq"))
2656 printf("Unknown parameter\n");
2660 if (isrx && rx_queue_id_is_invalid(res->qid))
2662 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2665 if (!strcmp(res->opname, "start"))
2667 else if (!strcmp(res->opname, "stop"))
2670 printf("Unknown parameter\n");
2674 if (isstart && isrx)
2675 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2676 else if (!isstart && isrx)
2677 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2678 else if (isstart && !isrx)
2679 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2681 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2683 if (ret == -ENOTSUP)
2684 printf("Function not supported in PMD driver\n");
2687 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2688 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2689 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2690 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2691 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2692 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2693 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2694 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2695 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2696 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2699 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2700 .f = cmd_config_rxtx_queue_parsed,
2702 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2704 (void *)&cmd_config_rxtx_queue_port,
2705 (void *)&cmd_config_rxtx_queue_portid,
2706 (void *)&cmd_config_rxtx_queue_rxtxq,
2707 (void *)&cmd_config_rxtx_queue_qid,
2708 (void *)&cmd_config_rxtx_queue_opname,
2713 /* *** configure port rxq/txq deferred start on/off *** */
2714 struct cmd_config_deferred_start_rxtx_queue {
2715 cmdline_fixed_string_t port;
2717 cmdline_fixed_string_t rxtxq;
2719 cmdline_fixed_string_t opname;
2720 cmdline_fixed_string_t state;
2724 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2725 __rte_unused struct cmdline *cl,
2726 __rte_unused void *data)
2728 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2729 struct rte_port *port;
2732 uint8_t needreconfig = 0;
2734 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2737 if (port_is_started(res->port_id) != 0) {
2738 printf("Please stop port %u first\n", res->port_id);
2742 port = &ports[res->port_id];
2744 isrx = !strcmp(res->rxtxq, "rxq");
2746 if (isrx && rx_queue_id_is_invalid(res->qid))
2748 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2751 ison = !strcmp(res->state, "on");
2753 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2754 port->rx_conf[res->qid].rx_deferred_start = ison;
2756 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2757 port->tx_conf[res->qid].tx_deferred_start = ison;
2762 cmd_reconfig_device_queue(res->port_id, 0, 1);
2765 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2766 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2768 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2769 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2771 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2772 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2774 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2775 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2777 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2778 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2779 opname, "deferred_start");
2780 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2781 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2784 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2785 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2787 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2789 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2790 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2791 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2792 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2793 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2794 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2799 /* *** configure port rxq/txq setup *** */
2800 struct cmd_setup_rxtx_queue {
2801 cmdline_fixed_string_t port;
2803 cmdline_fixed_string_t rxtxq;
2805 cmdline_fixed_string_t setup;
2808 /* Common CLI fields for queue setup */
2809 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2810 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2811 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2812 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2813 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2814 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2815 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2816 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2817 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2818 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2821 cmd_setup_rxtx_queue_parsed(
2822 void *parsed_result,
2823 __rte_unused struct cmdline *cl,
2824 __rte_unused void *data)
2826 struct cmd_setup_rxtx_queue *res = parsed_result;
2827 struct rte_port *port;
2828 struct rte_mempool *mp;
2829 unsigned int socket_id;
2833 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2836 if (res->portid == (portid_t)RTE_PORT_ALL) {
2837 printf("Invalid port id\n");
2841 if (!strcmp(res->rxtxq, "rxq"))
2843 else if (!strcmp(res->rxtxq, "txq"))
2846 printf("Unknown parameter\n");
2850 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2851 printf("Invalid rx queue\n");
2853 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2854 printf("Invalid tx queue\n");
2858 port = &ports[res->portid];
2860 socket_id = rxring_numa[res->portid];
2861 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2862 socket_id = port->socket_id;
2864 mp = mbuf_pool_find(socket_id);
2866 printf("Failed to setup RX queue: "
2867 "No mempool allocation"
2868 " on the socket %d\n",
2869 rxring_numa[res->portid]);
2872 ret = rte_eth_rx_queue_setup(res->portid,
2874 port->nb_rx_desc[res->qid],
2876 &port->rx_conf[res->qid],
2879 printf("Failed to setup RX queue\n");
2881 socket_id = txring_numa[res->portid];
2882 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2883 socket_id = port->socket_id;
2885 ret = rte_eth_tx_queue_setup(res->portid,
2887 port->nb_tx_desc[res->qid],
2889 &port->tx_conf[res->qid]);
2891 printf("Failed to setup TX queue\n");
2895 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2896 .f = cmd_setup_rxtx_queue_parsed,
2898 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2900 (void *)&cmd_setup_rxtx_queue_port,
2901 (void *)&cmd_setup_rxtx_queue_portid,
2902 (void *)&cmd_setup_rxtx_queue_rxtxq,
2903 (void *)&cmd_setup_rxtx_queue_qid,
2904 (void *)&cmd_setup_rxtx_queue_setup,
2910 /* *** Configure RSS RETA *** */
2911 struct cmd_config_rss_reta {
2912 cmdline_fixed_string_t port;
2913 cmdline_fixed_string_t keyword;
2915 cmdline_fixed_string_t name;
2916 cmdline_fixed_string_t list_name;
2917 cmdline_fixed_string_t list_of_items;
2921 parse_reta_config(const char *str,
2922 struct rte_eth_rss_reta_entry64 *reta_conf,
2923 uint16_t nb_entries)
2927 uint16_t hash_index, idx, shift;
2930 const char *p, *p0 = str;
2937 unsigned long int_fld[_NUM_FLD];
2938 char *str_fld[_NUM_FLD];
2940 while ((p = strchr(p0,'(')) != NULL) {
2942 if((p0 = strchr(p,')')) == NULL)
2946 if(size >= sizeof(s))
2949 snprintf(s, sizeof(s), "%.*s", size, p);
2950 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2952 for (i = 0; i < _NUM_FLD; i++) {
2954 int_fld[i] = strtoul(str_fld[i], &end, 0);
2955 if (errno != 0 || end == str_fld[i] ||
2960 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2961 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2963 if (hash_index >= nb_entries) {
2964 printf("Invalid RETA hash index=%d\n", hash_index);
2968 idx = hash_index / RTE_RETA_GROUP_SIZE;
2969 shift = hash_index % RTE_RETA_GROUP_SIZE;
2970 reta_conf[idx].mask |= (1ULL << shift);
2971 reta_conf[idx].reta[shift] = nb_queue;
2978 cmd_set_rss_reta_parsed(void *parsed_result,
2979 __rte_unused struct cmdline *cl,
2980 __rte_unused void *data)
2983 struct rte_eth_dev_info dev_info;
2984 struct rte_eth_rss_reta_entry64 reta_conf[8];
2985 struct cmd_config_rss_reta *res = parsed_result;
2987 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2991 if (dev_info.reta_size == 0) {
2992 printf("Redirection table size is 0 which is "
2993 "invalid for RSS\n");
2996 printf("The reta size of port %d is %u\n",
2997 res->port_id, dev_info.reta_size);
2998 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2999 printf("Currently do not support more than %u entries of "
3000 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3004 memset(reta_conf, 0, sizeof(reta_conf));
3005 if (!strcmp(res->list_name, "reta")) {
3006 if (parse_reta_config(res->list_of_items, reta_conf,
3007 dev_info.reta_size)) {
3008 printf("Invalid RSS Redirection Table "
3009 "config entered\n");
3012 ret = rte_eth_dev_rss_reta_update(res->port_id,
3013 reta_conf, dev_info.reta_size);
3015 printf("Bad redirection table parameter, "
3016 "return code = %d \n", ret);
3020 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3021 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3022 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3023 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3024 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3025 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3026 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3027 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3028 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3029 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3030 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3031 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3033 cmdline_parse_inst_t cmd_config_rss_reta = {
3034 .f = cmd_set_rss_reta_parsed,
3036 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3038 (void *)&cmd_config_rss_reta_port,
3039 (void *)&cmd_config_rss_reta_keyword,
3040 (void *)&cmd_config_rss_reta_port_id,
3041 (void *)&cmd_config_rss_reta_name,
3042 (void *)&cmd_config_rss_reta_list_name,
3043 (void *)&cmd_config_rss_reta_list_of_items,
3048 /* *** SHOW PORT RETA INFO *** */
3049 struct cmd_showport_reta {
3050 cmdline_fixed_string_t show;
3051 cmdline_fixed_string_t port;
3053 cmdline_fixed_string_t rss;
3054 cmdline_fixed_string_t reta;
3056 cmdline_fixed_string_t list_of_items;
3060 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3061 uint16_t nb_entries,
3065 const char *p, *p0 = str;
3070 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3071 RTE_RETA_GROUP_SIZE;
3074 p = strchr(p0, '(');
3078 p0 = strchr(p, ')');
3082 if (size >= sizeof(s)) {
3083 printf("The string size exceeds the internal buffer size\n");
3086 snprintf(s, sizeof(s), "%.*s", size, p);
3087 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3088 if (ret <= 0 || ret != num) {
3089 printf("The bits of masks do not match the number of "
3090 "reta entries: %u\n", num);
3093 for (i = 0; i < ret; i++)
3094 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3100 cmd_showport_reta_parsed(void *parsed_result,
3101 __rte_unused struct cmdline *cl,
3102 __rte_unused void *data)
3104 struct cmd_showport_reta *res = parsed_result;
3105 struct rte_eth_rss_reta_entry64 reta_conf[8];
3106 struct rte_eth_dev_info dev_info;
3107 uint16_t max_reta_size;
3110 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3114 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3115 if (res->size == 0 || res->size > max_reta_size) {
3116 printf("Invalid redirection table size: %u (1-%u)\n",
3117 res->size, max_reta_size);
3121 memset(reta_conf, 0, sizeof(reta_conf));
3122 if (showport_parse_reta_config(reta_conf, res->size,
3123 res->list_of_items) < 0) {
3124 printf("Invalid string: %s for reta masks\n",
3125 res->list_of_items);
3128 port_rss_reta_info(res->port_id, reta_conf, res->size);
3131 cmdline_parse_token_string_t cmd_showport_reta_show =
3132 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3133 cmdline_parse_token_string_t cmd_showport_reta_port =
3134 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3135 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3136 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3137 cmdline_parse_token_string_t cmd_showport_reta_rss =
3138 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3139 cmdline_parse_token_string_t cmd_showport_reta_reta =
3140 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3141 cmdline_parse_token_num_t cmd_showport_reta_size =
3142 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3143 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3144 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3145 list_of_items, NULL);
3147 cmdline_parse_inst_t cmd_showport_reta = {
3148 .f = cmd_showport_reta_parsed,
3150 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3152 (void *)&cmd_showport_reta_show,
3153 (void *)&cmd_showport_reta_port,
3154 (void *)&cmd_showport_reta_port_id,
3155 (void *)&cmd_showport_reta_rss,
3156 (void *)&cmd_showport_reta_reta,
3157 (void *)&cmd_showport_reta_size,
3158 (void *)&cmd_showport_reta_list_of_items,
3163 /* *** Show RSS hash configuration *** */
3164 struct cmd_showport_rss_hash {
3165 cmdline_fixed_string_t show;
3166 cmdline_fixed_string_t port;
3168 cmdline_fixed_string_t rss_hash;
3169 cmdline_fixed_string_t rss_type;
3170 cmdline_fixed_string_t key; /* optional argument */
3173 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3174 __rte_unused struct cmdline *cl,
3177 struct cmd_showport_rss_hash *res = parsed_result;
3179 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3182 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3183 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3184 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3185 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3186 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3187 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3188 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3189 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3191 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3192 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3194 cmdline_parse_inst_t cmd_showport_rss_hash = {
3195 .f = cmd_showport_rss_hash_parsed,
3197 .help_str = "show port <port_id> rss-hash",
3199 (void *)&cmd_showport_rss_hash_show,
3200 (void *)&cmd_showport_rss_hash_port,
3201 (void *)&cmd_showport_rss_hash_port_id,
3202 (void *)&cmd_showport_rss_hash_rss_hash,
3207 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3208 .f = cmd_showport_rss_hash_parsed,
3210 .help_str = "show port <port_id> rss-hash key",
3212 (void *)&cmd_showport_rss_hash_show,
3213 (void *)&cmd_showport_rss_hash_port,
3214 (void *)&cmd_showport_rss_hash_port_id,
3215 (void *)&cmd_showport_rss_hash_rss_hash,
3216 (void *)&cmd_showport_rss_hash_rss_key,
3221 /* *** Configure DCB *** */
3222 struct cmd_config_dcb {
3223 cmdline_fixed_string_t port;
3224 cmdline_fixed_string_t config;
3226 cmdline_fixed_string_t dcb;
3227 cmdline_fixed_string_t vt;
3228 cmdline_fixed_string_t vt_en;
3230 cmdline_fixed_string_t pfc;
3231 cmdline_fixed_string_t pfc_en;
3235 cmd_config_dcb_parsed(void *parsed_result,
3236 __rte_unused struct cmdline *cl,
3237 __rte_unused void *data)
3239 struct cmd_config_dcb *res = parsed_result;
3240 portid_t port_id = res->port_id;
3241 struct rte_port *port;
3245 port = &ports[port_id];
3246 /** Check if the port is not started **/
3247 if (port->port_status != RTE_PORT_STOPPED) {
3248 printf("Please stop port %d first\n", port_id);
3252 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3253 printf("The invalid number of traffic class,"
3254 " only 4 or 8 allowed.\n");
3258 if (nb_fwd_lcores < res->num_tcs) {
3259 printf("nb_cores shouldn't be less than number of TCs.\n");
3262 if (!strncmp(res->pfc_en, "on", 2))
3267 /* DCB in VT mode */
3268 if (!strncmp(res->vt_en, "on", 2))
3269 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3270 (enum rte_eth_nb_tcs)res->num_tcs,
3273 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3274 (enum rte_eth_nb_tcs)res->num_tcs,
3279 printf("Cannot initialize network ports.\n");
3283 cmd_reconfig_device_queue(port_id, 1, 1);
3286 cmdline_parse_token_string_t cmd_config_dcb_port =
3287 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3288 cmdline_parse_token_string_t cmd_config_dcb_config =
3289 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3290 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3291 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3292 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3293 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3294 cmdline_parse_token_string_t cmd_config_dcb_vt =
3295 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3296 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3297 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3298 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3299 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3300 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3301 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3302 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3303 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3305 cmdline_parse_inst_t cmd_config_dcb = {
3306 .f = cmd_config_dcb_parsed,
3308 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3310 (void *)&cmd_config_dcb_port,
3311 (void *)&cmd_config_dcb_config,
3312 (void *)&cmd_config_dcb_port_id,
3313 (void *)&cmd_config_dcb_dcb,
3314 (void *)&cmd_config_dcb_vt,
3315 (void *)&cmd_config_dcb_vt_en,
3316 (void *)&cmd_config_dcb_num_tcs,
3317 (void *)&cmd_config_dcb_pfc,
3318 (void *)&cmd_config_dcb_pfc_en,
3323 /* *** configure number of packets per burst *** */
3324 struct cmd_config_burst {
3325 cmdline_fixed_string_t port;
3326 cmdline_fixed_string_t keyword;
3327 cmdline_fixed_string_t all;
3328 cmdline_fixed_string_t name;
3333 cmd_config_burst_parsed(void *parsed_result,
3334 __rte_unused struct cmdline *cl,
3335 __rte_unused void *data)
3337 struct cmd_config_burst *res = parsed_result;
3338 struct rte_eth_dev_info dev_info;
3339 uint16_t rec_nb_pkts;
3342 if (!all_ports_stopped()) {
3343 printf("Please stop all ports first\n");
3347 if (!strcmp(res->name, "burst")) {
3348 if (res->value == 0) {
3349 /* If user gives a value of zero, query the PMD for
3350 * its recommended Rx burst size. Testpmd uses a single
3351 * size for all ports, so assume all ports are the same
3352 * NIC model and use the values from Port 0.
3354 ret = eth_dev_info_get_print_err(0, &dev_info);
3358 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3360 if (rec_nb_pkts == 0) {
3361 printf("PMD does not recommend a burst size.\n"
3362 "User provided value must be between"
3363 " 1 and %d\n", MAX_PKT_BURST);
3365 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3366 printf("PMD recommended burst size of %d"
3367 " exceeds maximum value of %d\n",
3368 rec_nb_pkts, MAX_PKT_BURST);
3371 printf("Using PMD-provided burst value of %d\n",
3373 nb_pkt_per_burst = rec_nb_pkts;
3374 } else if (res->value > MAX_PKT_BURST) {
3375 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3378 nb_pkt_per_burst = res->value;
3380 printf("Unknown parameter\n");
3386 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3389 cmdline_parse_token_string_t cmd_config_burst_port =
3390 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3391 cmdline_parse_token_string_t cmd_config_burst_keyword =
3392 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3393 cmdline_parse_token_string_t cmd_config_burst_all =
3394 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3395 cmdline_parse_token_string_t cmd_config_burst_name =
3396 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3397 cmdline_parse_token_num_t cmd_config_burst_value =
3398 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3400 cmdline_parse_inst_t cmd_config_burst = {
3401 .f = cmd_config_burst_parsed,
3403 .help_str = "port config all burst <value>",
3405 (void *)&cmd_config_burst_port,
3406 (void *)&cmd_config_burst_keyword,
3407 (void *)&cmd_config_burst_all,
3408 (void *)&cmd_config_burst_name,
3409 (void *)&cmd_config_burst_value,
3414 /* *** configure rx/tx queues *** */
3415 struct cmd_config_thresh {
3416 cmdline_fixed_string_t port;
3417 cmdline_fixed_string_t keyword;
3418 cmdline_fixed_string_t all;
3419 cmdline_fixed_string_t name;
3424 cmd_config_thresh_parsed(void *parsed_result,
3425 __rte_unused struct cmdline *cl,
3426 __rte_unused void *data)
3428 struct cmd_config_thresh *res = parsed_result;
3430 if (!all_ports_stopped()) {
3431 printf("Please stop all ports first\n");
3435 if (!strcmp(res->name, "txpt"))
3436 tx_pthresh = res->value;
3437 else if(!strcmp(res->name, "txht"))
3438 tx_hthresh = res->value;
3439 else if(!strcmp(res->name, "txwt"))
3440 tx_wthresh = res->value;
3441 else if(!strcmp(res->name, "rxpt"))
3442 rx_pthresh = res->value;
3443 else if(!strcmp(res->name, "rxht"))
3444 rx_hthresh = res->value;
3445 else if(!strcmp(res->name, "rxwt"))
3446 rx_wthresh = res->value;
3448 printf("Unknown parameter\n");
3454 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3457 cmdline_parse_token_string_t cmd_config_thresh_port =
3458 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3459 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3460 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3461 cmdline_parse_token_string_t cmd_config_thresh_all =
3462 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3463 cmdline_parse_token_string_t cmd_config_thresh_name =
3464 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3465 "txpt#txht#txwt#rxpt#rxht#rxwt");
3466 cmdline_parse_token_num_t cmd_config_thresh_value =
3467 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3469 cmdline_parse_inst_t cmd_config_thresh = {
3470 .f = cmd_config_thresh_parsed,
3472 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3474 (void *)&cmd_config_thresh_port,
3475 (void *)&cmd_config_thresh_keyword,
3476 (void *)&cmd_config_thresh_all,
3477 (void *)&cmd_config_thresh_name,
3478 (void *)&cmd_config_thresh_value,
3483 /* *** configure free/rs threshold *** */
3484 struct cmd_config_threshold {
3485 cmdline_fixed_string_t port;
3486 cmdline_fixed_string_t keyword;
3487 cmdline_fixed_string_t all;
3488 cmdline_fixed_string_t name;
3493 cmd_config_threshold_parsed(void *parsed_result,
3494 __rte_unused struct cmdline *cl,
3495 __rte_unused void *data)
3497 struct cmd_config_threshold *res = parsed_result;
3499 if (!all_ports_stopped()) {
3500 printf("Please stop all ports first\n");
3504 if (!strcmp(res->name, "txfreet"))
3505 tx_free_thresh = res->value;
3506 else if (!strcmp(res->name, "txrst"))
3507 tx_rs_thresh = res->value;
3508 else if (!strcmp(res->name, "rxfreet"))
3509 rx_free_thresh = res->value;
3511 printf("Unknown parameter\n");
3517 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3520 cmdline_parse_token_string_t cmd_config_threshold_port =
3521 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3522 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3523 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3525 cmdline_parse_token_string_t cmd_config_threshold_all =
3526 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3527 cmdline_parse_token_string_t cmd_config_threshold_name =
3528 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3529 "txfreet#txrst#rxfreet");
3530 cmdline_parse_token_num_t cmd_config_threshold_value =
3531 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3533 cmdline_parse_inst_t cmd_config_threshold = {
3534 .f = cmd_config_threshold_parsed,
3536 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3538 (void *)&cmd_config_threshold_port,
3539 (void *)&cmd_config_threshold_keyword,
3540 (void *)&cmd_config_threshold_all,
3541 (void *)&cmd_config_threshold_name,
3542 (void *)&cmd_config_threshold_value,
3548 struct cmd_stop_result {
3549 cmdline_fixed_string_t stop;
3552 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3553 __rte_unused struct cmdline *cl,
3554 __rte_unused void *data)
3556 stop_packet_forwarding();
3559 cmdline_parse_token_string_t cmd_stop_stop =
3560 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3562 cmdline_parse_inst_t cmd_stop = {
3563 .f = cmd_stop_parsed,
3565 .help_str = "stop: Stop packet forwarding",
3567 (void *)&cmd_stop_stop,
3572 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3575 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3576 unsigned int *parsed_items, int check_unique_values)
3578 unsigned int nb_item;
3586 * First parse all items in the list and store their value.
3591 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3593 if ((c >= '0') && (c <= '9')) {
3594 value = (unsigned int) (value * 10 + (c - '0'));
3599 printf("character %c is not a decimal digit\n", c);
3603 printf("No valid value before comma\n");
3606 if (nb_item < max_items) {
3607 parsed_items[nb_item] = value;
3613 if (nb_item >= max_items) {
3614 printf("Number of %s = %u > %u (maximum items)\n",
3615 item_name, nb_item + 1, max_items);
3618 parsed_items[nb_item++] = value;
3619 if (! check_unique_values)
3623 * Then, check that all values in the list are differents.
3624 * No optimization here...
3626 for (i = 0; i < nb_item; i++) {
3627 for (j = i + 1; j < nb_item; j++) {
3628 if (parsed_items[j] == parsed_items[i]) {
3629 printf("duplicated %s %u at index %u and %u\n",
3630 item_name, parsed_items[i], i, j);
3638 struct cmd_set_list_result {
3639 cmdline_fixed_string_t cmd_keyword;
3640 cmdline_fixed_string_t list_name;
3641 cmdline_fixed_string_t list_of_items;
3644 static void cmd_set_list_parsed(void *parsed_result,
3645 __rte_unused struct cmdline *cl,
3646 __rte_unused void *data)
3648 struct cmd_set_list_result *res;
3650 unsigned int lcorelist[RTE_MAX_LCORE];
3651 unsigned int portlist[RTE_MAX_ETHPORTS];
3653 unsigned int nb_item;
3655 if (test_done == 0) {
3656 printf("Please stop forwarding first\n");
3660 res = parsed_result;
3661 if (!strcmp(res->list_name, "corelist")) {
3662 nb_item = parse_item_list(res->list_of_items, "core",
3664 parsed_items.lcorelist, 1);
3666 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3671 if (!strcmp(res->list_name, "portlist")) {
3672 nb_item = parse_item_list(res->list_of_items, "port",
3674 parsed_items.portlist, 1);
3676 set_fwd_ports_list(parsed_items.portlist, nb_item);
3682 cmdline_parse_token_string_t cmd_set_list_keyword =
3683 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3685 cmdline_parse_token_string_t cmd_set_list_name =
3686 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3687 "corelist#portlist");
3688 cmdline_parse_token_string_t cmd_set_list_of_items =
3689 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3692 cmdline_parse_inst_t cmd_set_fwd_list = {
3693 .f = cmd_set_list_parsed,
3695 .help_str = "set corelist|portlist <list0[,list1]*>",
3697 (void *)&cmd_set_list_keyword,
3698 (void *)&cmd_set_list_name,
3699 (void *)&cmd_set_list_of_items,
3704 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3706 struct cmd_setmask_result {
3707 cmdline_fixed_string_t set;
3708 cmdline_fixed_string_t mask;
3712 static void cmd_set_mask_parsed(void *parsed_result,
3713 __rte_unused struct cmdline *cl,
3714 __rte_unused void *data)
3716 struct cmd_setmask_result *res = parsed_result;
3718 if (test_done == 0) {
3719 printf("Please stop forwarding first\n");
3722 if (!strcmp(res->mask, "coremask")) {
3723 set_fwd_lcores_mask(res->hexavalue);
3725 } else if (!strcmp(res->mask, "portmask")) {
3726 set_fwd_ports_mask(res->hexavalue);
3731 cmdline_parse_token_string_t cmd_setmask_set =
3732 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3733 cmdline_parse_token_string_t cmd_setmask_mask =
3734 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3735 "coremask#portmask");
3736 cmdline_parse_token_num_t cmd_setmask_value =
3737 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3739 cmdline_parse_inst_t cmd_set_fwd_mask = {
3740 .f = cmd_set_mask_parsed,
3742 .help_str = "set coremask|portmask <hexadecimal value>",
3744 (void *)&cmd_setmask_set,
3745 (void *)&cmd_setmask_mask,
3746 (void *)&cmd_setmask_value,
3752 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3754 struct cmd_set_result {
3755 cmdline_fixed_string_t set;
3756 cmdline_fixed_string_t what;
3760 static void cmd_set_parsed(void *parsed_result,
3761 __rte_unused struct cmdline *cl,
3762 __rte_unused void *data)
3764 struct cmd_set_result *res = parsed_result;
3765 if (!strcmp(res->what, "nbport")) {
3766 set_fwd_ports_number(res->value);
3768 } else if (!strcmp(res->what, "nbcore")) {
3769 set_fwd_lcores_number(res->value);
3771 } else if (!strcmp(res->what, "burst"))
3772 set_nb_pkt_per_burst(res->value);
3773 else if (!strcmp(res->what, "verbose"))
3774 set_verbose_level(res->value);
3777 cmdline_parse_token_string_t cmd_set_set =
3778 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3779 cmdline_parse_token_string_t cmd_set_what =
3780 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3781 "nbport#nbcore#burst#verbose");
3782 cmdline_parse_token_num_t cmd_set_value =
3783 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3785 cmdline_parse_inst_t cmd_set_numbers = {
3786 .f = cmd_set_parsed,
3788 .help_str = "set nbport|nbcore|burst|verbose <value>",
3790 (void *)&cmd_set_set,
3791 (void *)&cmd_set_what,
3792 (void *)&cmd_set_value,
3797 /* *** SET LOG LEVEL CONFIGURATION *** */
3799 struct cmd_set_log_result {
3800 cmdline_fixed_string_t set;
3801 cmdline_fixed_string_t log;
3802 cmdline_fixed_string_t type;
3807 cmd_set_log_parsed(void *parsed_result,
3808 __rte_unused struct cmdline *cl,
3809 __rte_unused void *data)
3811 struct cmd_set_log_result *res;
3814 res = parsed_result;
3815 if (!strcmp(res->type, "global"))
3816 rte_log_set_global_level(res->level);
3818 ret = rte_log_set_level_regexp(res->type, res->level);
3820 printf("Unable to set log level\n");
3824 cmdline_parse_token_string_t cmd_set_log_set =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3826 cmdline_parse_token_string_t cmd_set_log_log =
3827 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3828 cmdline_parse_token_string_t cmd_set_log_type =
3829 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3830 cmdline_parse_token_num_t cmd_set_log_level =
3831 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3833 cmdline_parse_inst_t cmd_set_log = {
3834 .f = cmd_set_log_parsed,
3836 .help_str = "set log global|<type> <level>",
3838 (void *)&cmd_set_log_set,
3839 (void *)&cmd_set_log_log,
3840 (void *)&cmd_set_log_type,
3841 (void *)&cmd_set_log_level,
3846 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3848 struct cmd_set_txpkts_result {
3849 cmdline_fixed_string_t cmd_keyword;
3850 cmdline_fixed_string_t txpkts;
3851 cmdline_fixed_string_t seg_lengths;
3855 cmd_set_txpkts_parsed(void *parsed_result,
3856 __rte_unused struct cmdline *cl,
3857 __rte_unused void *data)
3859 struct cmd_set_txpkts_result *res;
3860 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3861 unsigned int nb_segs;
3863 res = parsed_result;
3864 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3865 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3867 set_tx_pkt_segments(seg_lengths, nb_segs);
3870 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3871 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3872 cmd_keyword, "set");
3873 cmdline_parse_token_string_t cmd_set_txpkts_name =
3874 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3876 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3877 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3880 cmdline_parse_inst_t cmd_set_txpkts = {
3881 .f = cmd_set_txpkts_parsed,
3883 .help_str = "set txpkts <len0[,len1]*>",
3885 (void *)&cmd_set_txpkts_keyword,
3886 (void *)&cmd_set_txpkts_name,
3887 (void *)&cmd_set_txpkts_lengths,
3892 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3894 struct cmd_set_txsplit_result {
3895 cmdline_fixed_string_t cmd_keyword;
3896 cmdline_fixed_string_t txsplit;
3897 cmdline_fixed_string_t mode;
3901 cmd_set_txsplit_parsed(void *parsed_result,
3902 __rte_unused struct cmdline *cl,
3903 __rte_unused void *data)
3905 struct cmd_set_txsplit_result *res;
3907 res = parsed_result;
3908 set_tx_pkt_split(res->mode);
3911 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3912 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3913 cmd_keyword, "set");
3914 cmdline_parse_token_string_t cmd_set_txsplit_name =
3915 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3916 txsplit, "txsplit");
3917 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3918 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3921 cmdline_parse_inst_t cmd_set_txsplit = {
3922 .f = cmd_set_txsplit_parsed,
3924 .help_str = "set txsplit on|off|rand",
3926 (void *)&cmd_set_txsplit_keyword,
3927 (void *)&cmd_set_txsplit_name,
3928 (void *)&cmd_set_txsplit_mode,
3933 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3934 struct cmd_rx_vlan_filter_all_result {
3935 cmdline_fixed_string_t rx_vlan;
3936 cmdline_fixed_string_t what;
3937 cmdline_fixed_string_t all;
3942 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3943 __rte_unused struct cmdline *cl,
3944 __rte_unused void *data)
3946 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3948 if (!strcmp(res->what, "add"))
3949 rx_vlan_all_filter_set(res->port_id, 1);
3951 rx_vlan_all_filter_set(res->port_id, 0);
3954 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3955 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3956 rx_vlan, "rx_vlan");
3957 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3958 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3960 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3961 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3963 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3964 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3967 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3968 .f = cmd_rx_vlan_filter_all_parsed,
3970 .help_str = "rx_vlan add|rm all <port_id>: "
3971 "Add/Remove all identifiers to/from the set of VLAN "
3972 "identifiers filtered by a port",
3974 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3975 (void *)&cmd_rx_vlan_filter_all_what,
3976 (void *)&cmd_rx_vlan_filter_all_all,
3977 (void *)&cmd_rx_vlan_filter_all_portid,
3982 /* *** VLAN OFFLOAD SET ON A PORT *** */
3983 struct cmd_vlan_offload_result {
3984 cmdline_fixed_string_t vlan;
3985 cmdline_fixed_string_t set;
3986 cmdline_fixed_string_t vlan_type;
3987 cmdline_fixed_string_t what;
3988 cmdline_fixed_string_t on;
3989 cmdline_fixed_string_t port_id;
3993 cmd_vlan_offload_parsed(void *parsed_result,
3994 __rte_unused struct cmdline *cl,
3995 __rte_unused void *data)
3998 struct cmd_vlan_offload_result *res = parsed_result;
4001 portid_t port_id = 0;
4005 len = strnlen(str, STR_TOKEN_SIZE);
4007 /* Get port_id first */
4015 tmp = strtoul(str, NULL, 0);
4016 /* If port_id greater that what portid_t can represent, return */
4017 if(tmp >= RTE_MAX_ETHPORTS)
4019 port_id = (portid_t)tmp;
4021 if (!strcmp(res->on, "on"))
4026 if (!strcmp(res->what, "strip"))
4027 rx_vlan_strip_set(port_id, on);
4028 else if(!strcmp(res->what, "stripq")){
4029 uint16_t queue_id = 0;
4031 /* No queue_id, return */
4033 printf("must specify (port,queue_id)\n");
4036 tmp = strtoul(str + i + 1, NULL, 0);
4037 /* If queue_id greater that what 16-bits can represent, return */
4041 queue_id = (uint16_t)tmp;
4042 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4044 else if (!strcmp(res->what, "filter"))
4045 rx_vlan_filter_set(port_id, on);
4046 else if (!strcmp(res->what, "qinq_strip"))
4047 rx_vlan_qinq_strip_set(port_id, on);
4049 vlan_extend_set(port_id, on);
4054 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4055 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4057 cmdline_parse_token_string_t cmd_vlan_offload_set =
4058 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4060 cmdline_parse_token_string_t cmd_vlan_offload_what =
4061 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4062 what, "strip#filter#qinq_strip#extend#stripq");
4063 cmdline_parse_token_string_t cmd_vlan_offload_on =
4064 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4066 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4067 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4070 cmdline_parse_inst_t cmd_vlan_offload = {
4071 .f = cmd_vlan_offload_parsed,
4073 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4074 "<port_id[,queue_id]>: "
4075 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4077 (void *)&cmd_vlan_offload_vlan,
4078 (void *)&cmd_vlan_offload_set,
4079 (void *)&cmd_vlan_offload_what,
4080 (void *)&cmd_vlan_offload_on,
4081 (void *)&cmd_vlan_offload_portid,
4086 /* *** VLAN TPID SET ON A PORT *** */
4087 struct cmd_vlan_tpid_result {
4088 cmdline_fixed_string_t vlan;
4089 cmdline_fixed_string_t set;
4090 cmdline_fixed_string_t vlan_type;
4091 cmdline_fixed_string_t what;
4097 cmd_vlan_tpid_parsed(void *parsed_result,
4098 __rte_unused struct cmdline *cl,
4099 __rte_unused void *data)
4101 struct cmd_vlan_tpid_result *res = parsed_result;
4102 enum rte_vlan_type vlan_type;
4104 if (!strcmp(res->vlan_type, "inner"))
4105 vlan_type = ETH_VLAN_TYPE_INNER;
4106 else if (!strcmp(res->vlan_type, "outer"))
4107 vlan_type = ETH_VLAN_TYPE_OUTER;
4109 printf("Unknown vlan type\n");
4112 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4115 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4116 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4118 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4119 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4121 cmdline_parse_token_string_t cmd_vlan_type =
4122 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4123 vlan_type, "inner#outer");
4124 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4125 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4127 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4128 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4130 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4131 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4134 cmdline_parse_inst_t cmd_vlan_tpid = {
4135 .f = cmd_vlan_tpid_parsed,
4137 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4138 "Set the VLAN Ether type",
4140 (void *)&cmd_vlan_tpid_vlan,
4141 (void *)&cmd_vlan_tpid_set,
4142 (void *)&cmd_vlan_type,
4143 (void *)&cmd_vlan_tpid_what,
4144 (void *)&cmd_vlan_tpid_tpid,
4145 (void *)&cmd_vlan_tpid_portid,
4150 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4151 struct cmd_rx_vlan_filter_result {
4152 cmdline_fixed_string_t rx_vlan;
4153 cmdline_fixed_string_t what;
4159 cmd_rx_vlan_filter_parsed(void *parsed_result,
4160 __rte_unused struct cmdline *cl,
4161 __rte_unused void *data)
4163 struct cmd_rx_vlan_filter_result *res = parsed_result;
4165 if (!strcmp(res->what, "add"))
4166 rx_vft_set(res->port_id, res->vlan_id, 1);
4168 rx_vft_set(res->port_id, res->vlan_id, 0);
4171 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4172 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4173 rx_vlan, "rx_vlan");
4174 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4175 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4177 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4178 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4180 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4181 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4184 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4185 .f = cmd_rx_vlan_filter_parsed,
4187 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4188 "Add/Remove a VLAN identifier to/from the set of VLAN "
4189 "identifiers filtered by a port",
4191 (void *)&cmd_rx_vlan_filter_rx_vlan,
4192 (void *)&cmd_rx_vlan_filter_what,
4193 (void *)&cmd_rx_vlan_filter_vlanid,
4194 (void *)&cmd_rx_vlan_filter_portid,
4199 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4200 struct cmd_tx_vlan_set_result {
4201 cmdline_fixed_string_t tx_vlan;
4202 cmdline_fixed_string_t set;
4208 cmd_tx_vlan_set_parsed(void *parsed_result,
4209 __rte_unused struct cmdline *cl,
4210 __rte_unused void *data)
4212 struct cmd_tx_vlan_set_result *res = parsed_result;
4214 if (!port_is_stopped(res->port_id)) {
4215 printf("Please stop port %d first\n", res->port_id);
4219 tx_vlan_set(res->port_id, res->vlan_id);
4221 cmd_reconfig_device_queue(res->port_id, 1, 1);
4224 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4225 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4226 tx_vlan, "tx_vlan");
4227 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4228 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4230 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4231 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4233 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4234 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4237 cmdline_parse_inst_t cmd_tx_vlan_set = {
4238 .f = cmd_tx_vlan_set_parsed,
4240 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4241 "Enable hardware insertion of a single VLAN header "
4242 "with a given TAG Identifier in packets sent on a port",
4244 (void *)&cmd_tx_vlan_set_tx_vlan,
4245 (void *)&cmd_tx_vlan_set_set,
4246 (void *)&cmd_tx_vlan_set_portid,
4247 (void *)&cmd_tx_vlan_set_vlanid,
4252 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4253 struct cmd_tx_vlan_set_qinq_result {
4254 cmdline_fixed_string_t tx_vlan;
4255 cmdline_fixed_string_t set;
4258 uint16_t vlan_id_outer;
4262 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4263 __rte_unused struct cmdline *cl,
4264 __rte_unused void *data)
4266 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4268 if (!port_is_stopped(res->port_id)) {
4269 printf("Please stop port %d first\n", res->port_id);
4273 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4275 cmd_reconfig_device_queue(res->port_id, 1, 1);
4278 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4279 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4280 tx_vlan, "tx_vlan");
4281 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4282 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4284 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4285 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4287 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4288 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4290 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4291 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4292 vlan_id_outer, UINT16);
4294 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4295 .f = cmd_tx_vlan_set_qinq_parsed,
4297 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4298 "Enable hardware insertion of double VLAN header "
4299 "with given TAG Identifiers in packets sent on a port",
4301 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4302 (void *)&cmd_tx_vlan_set_qinq_set,
4303 (void *)&cmd_tx_vlan_set_qinq_portid,
4304 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4305 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4310 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4311 struct cmd_tx_vlan_set_pvid_result {
4312 cmdline_fixed_string_t tx_vlan;
4313 cmdline_fixed_string_t set;
4314 cmdline_fixed_string_t pvid;
4317 cmdline_fixed_string_t mode;
4321 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4322 __rte_unused struct cmdline *cl,
4323 __rte_unused void *data)
4325 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4327 if (strcmp(res->mode, "on") == 0)
4328 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4330 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4333 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4334 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4335 tx_vlan, "tx_vlan");
4336 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4337 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4339 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4340 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4342 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4343 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4345 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4346 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4348 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4349 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4352 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4353 .f = cmd_tx_vlan_set_pvid_parsed,
4355 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4357 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4358 (void *)&cmd_tx_vlan_set_pvid_set,
4359 (void *)&cmd_tx_vlan_set_pvid_pvid,
4360 (void *)&cmd_tx_vlan_set_pvid_port_id,
4361 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4362 (void *)&cmd_tx_vlan_set_pvid_mode,
4367 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4368 struct cmd_tx_vlan_reset_result {
4369 cmdline_fixed_string_t tx_vlan;
4370 cmdline_fixed_string_t reset;
4375 cmd_tx_vlan_reset_parsed(void *parsed_result,
4376 __rte_unused struct cmdline *cl,
4377 __rte_unused void *data)
4379 struct cmd_tx_vlan_reset_result *res = parsed_result;
4381 if (!port_is_stopped(res->port_id)) {
4382 printf("Please stop port %d first\n", res->port_id);
4386 tx_vlan_reset(res->port_id);
4388 cmd_reconfig_device_queue(res->port_id, 1, 1);
4391 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4392 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4393 tx_vlan, "tx_vlan");
4394 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4395 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4397 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4398 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4401 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4402 .f = cmd_tx_vlan_reset_parsed,
4404 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4405 "VLAN header in packets sent on a port",
4407 (void *)&cmd_tx_vlan_reset_tx_vlan,
4408 (void *)&cmd_tx_vlan_reset_reset,
4409 (void *)&cmd_tx_vlan_reset_portid,
4415 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4416 struct cmd_csum_result {
4417 cmdline_fixed_string_t csum;
4418 cmdline_fixed_string_t mode;
4419 cmdline_fixed_string_t proto;
4420 cmdline_fixed_string_t hwsw;
4425 csum_show(int port_id)
4427 struct rte_eth_dev_info dev_info;
4428 uint64_t tx_offloads;
4431 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4432 printf("Parse tunnel is %s\n",
4433 (ports[port_id].parse_tunnel) ? "on" : "off");
4434 printf("IP checksum offload is %s\n",
4435 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4436 printf("UDP checksum offload is %s\n",
4437 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4438 printf("TCP checksum offload is %s\n",
4439 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4440 printf("SCTP checksum offload is %s\n",
4441 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4442 printf("Outer-Ip checksum offload is %s\n",
4443 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4444 printf("Outer-Udp checksum offload is %s\n",
4445 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4447 /* display warnings if configuration is not supported by the NIC */
4448 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4452 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4453 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4454 printf("Warning: hardware IP checksum enabled but not "
4455 "supported by port %d\n", port_id);
4457 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4458 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4459 printf("Warning: hardware UDP checksum enabled but not "
4460 "supported by port %d\n", port_id);
4462 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4463 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4464 printf("Warning: hardware TCP checksum enabled but not "
4465 "supported by port %d\n", port_id);
4467 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4468 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4469 printf("Warning: hardware SCTP checksum enabled but not "
4470 "supported by port %d\n", port_id);
4472 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4473 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4474 printf("Warning: hardware outer IP checksum enabled but not "
4475 "supported by port %d\n", port_id);
4477 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4478 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4480 printf("Warning: hardware outer UDP checksum enabled but not "
4481 "supported by port %d\n", port_id);
4486 cmd_config_queue_tx_offloads(struct rte_port *port)
4490 /* Apply queue tx offloads configuration */
4491 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4492 port->tx_conf[k].offloads =
4493 port->dev_conf.txmode.offloads;
4497 cmd_csum_parsed(void *parsed_result,
4498 __rte_unused struct cmdline *cl,
4499 __rte_unused void *data)
4501 struct cmd_csum_result *res = parsed_result;
4503 uint64_t csum_offloads = 0;
4504 struct rte_eth_dev_info dev_info;
4507 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4508 printf("invalid port %d\n", res->port_id);
4511 if (!port_is_stopped(res->port_id)) {
4512 printf("Please stop port %d first\n", res->port_id);
4516 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4520 if (!strcmp(res->mode, "set")) {
4522 if (!strcmp(res->hwsw, "hw"))
4525 if (!strcmp(res->proto, "ip")) {
4526 if (hw == 0 || (dev_info.tx_offload_capa &
4527 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4528 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4530 printf("IP checksum offload is not supported "
4531 "by port %u\n", res->port_id);
4533 } else if (!strcmp(res->proto, "udp")) {
4534 if (hw == 0 || (dev_info.tx_offload_capa &
4535 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4536 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4538 printf("UDP checksum offload is not supported "
4539 "by port %u\n", res->port_id);
4541 } else if (!strcmp(res->proto, "tcp")) {
4542 if (hw == 0 || (dev_info.tx_offload_capa &
4543 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4544 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4546 printf("TCP checksum offload is not supported "
4547 "by port %u\n", res->port_id);
4549 } else if (!strcmp(res->proto, "sctp")) {
4550 if (hw == 0 || (dev_info.tx_offload_capa &
4551 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4552 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4554 printf("SCTP checksum offload is not supported "
4555 "by port %u\n", res->port_id);
4557 } else if (!strcmp(res->proto, "outer-ip")) {
4558 if (hw == 0 || (dev_info.tx_offload_capa &
4559 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4561 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4563 printf("Outer IP checksum offload is not "
4564 "supported by port %u\n", res->port_id);
4566 } else if (!strcmp(res->proto, "outer-udp")) {
4567 if (hw == 0 || (dev_info.tx_offload_capa &
4568 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4570 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4572 printf("Outer UDP checksum offload is not "
4573 "supported by port %u\n", res->port_id);
4578 ports[res->port_id].dev_conf.txmode.offloads |=
4581 ports[res->port_id].dev_conf.txmode.offloads &=
4584 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4586 csum_show(res->port_id);
4588 cmd_reconfig_device_queue(res->port_id, 1, 1);
4591 cmdline_parse_token_string_t cmd_csum_csum =
4592 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4594 cmdline_parse_token_string_t cmd_csum_mode =
4595 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4597 cmdline_parse_token_string_t cmd_csum_proto =
4598 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4599 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4600 cmdline_parse_token_string_t cmd_csum_hwsw =
4601 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4603 cmdline_parse_token_num_t cmd_csum_portid =
4604 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4607 cmdline_parse_inst_t cmd_csum_set = {
4608 .f = cmd_csum_parsed,
4610 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4611 "Enable/Disable hardware calculation of L3/L4 checksum when "
4612 "using csum forward engine",
4614 (void *)&cmd_csum_csum,
4615 (void *)&cmd_csum_mode,
4616 (void *)&cmd_csum_proto,
4617 (void *)&cmd_csum_hwsw,
4618 (void *)&cmd_csum_portid,
4623 cmdline_parse_token_string_t cmd_csum_mode_show =
4624 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4627 cmdline_parse_inst_t cmd_csum_show = {
4628 .f = cmd_csum_parsed,
4630 .help_str = "csum show <port_id>: Show checksum offload configuration",
4632 (void *)&cmd_csum_csum,
4633 (void *)&cmd_csum_mode_show,
4634 (void *)&cmd_csum_portid,
4639 /* Enable/disable tunnel parsing */
4640 struct cmd_csum_tunnel_result {
4641 cmdline_fixed_string_t csum;
4642 cmdline_fixed_string_t parse;
4643 cmdline_fixed_string_t onoff;
4648 cmd_csum_tunnel_parsed(void *parsed_result,
4649 __rte_unused struct cmdline *cl,
4650 __rte_unused void *data)
4652 struct cmd_csum_tunnel_result *res = parsed_result;
4654 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4657 if (!strcmp(res->onoff, "on"))
4658 ports[res->port_id].parse_tunnel = 1;
4660 ports[res->port_id].parse_tunnel = 0;
4662 csum_show(res->port_id);
4665 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4666 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4668 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4669 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4670 parse, "parse-tunnel");
4671 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4672 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4674 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4675 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4678 cmdline_parse_inst_t cmd_csum_tunnel = {
4679 .f = cmd_csum_tunnel_parsed,
4681 .help_str = "csum parse-tunnel on|off <port_id>: "
4682 "Enable/Disable parsing of tunnels for csum engine",
4684 (void *)&cmd_csum_tunnel_csum,
4685 (void *)&cmd_csum_tunnel_parse,
4686 (void *)&cmd_csum_tunnel_onoff,
4687 (void *)&cmd_csum_tunnel_portid,
4692 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4693 struct cmd_tso_set_result {
4694 cmdline_fixed_string_t tso;
4695 cmdline_fixed_string_t mode;
4701 cmd_tso_set_parsed(void *parsed_result,
4702 __rte_unused struct cmdline *cl,
4703 __rte_unused void *data)
4705 struct cmd_tso_set_result *res = parsed_result;
4706 struct rte_eth_dev_info dev_info;
4709 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4711 if (!port_is_stopped(res->port_id)) {
4712 printf("Please stop port %d first\n", res->port_id);
4716 if (!strcmp(res->mode, "set"))
4717 ports[res->port_id].tso_segsz = res->tso_segsz;
4719 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4723 if ((ports[res->port_id].tso_segsz != 0) &&
4724 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4725 printf("Error: TSO is not supported by port %d\n",
4730 if (ports[res->port_id].tso_segsz == 0) {
4731 ports[res->port_id].dev_conf.txmode.offloads &=
4732 ~DEV_TX_OFFLOAD_TCP_TSO;
4733 printf("TSO for non-tunneled packets is disabled\n");
4735 ports[res->port_id].dev_conf.txmode.offloads |=
4736 DEV_TX_OFFLOAD_TCP_TSO;
4737 printf("TSO segment size for non-tunneled packets is %d\n",
4738 ports[res->port_id].tso_segsz);
4740 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4742 /* display warnings if configuration is not supported by the NIC */
4743 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4747 if ((ports[res->port_id].tso_segsz != 0) &&
4748 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4749 printf("Warning: TSO enabled but not "
4750 "supported by port %d\n", res->port_id);
4753 cmd_reconfig_device_queue(res->port_id, 1, 1);
4756 cmdline_parse_token_string_t cmd_tso_set_tso =
4757 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4759 cmdline_parse_token_string_t cmd_tso_set_mode =
4760 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4762 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4763 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4765 cmdline_parse_token_num_t cmd_tso_set_portid =
4766 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4769 cmdline_parse_inst_t cmd_tso_set = {
4770 .f = cmd_tso_set_parsed,
4772 .help_str = "tso set <tso_segsz> <port_id>: "
4773 "Set TSO segment size of non-tunneled packets for csum engine "
4776 (void *)&cmd_tso_set_tso,
4777 (void *)&cmd_tso_set_mode,
4778 (void *)&cmd_tso_set_tso_segsz,
4779 (void *)&cmd_tso_set_portid,
4784 cmdline_parse_token_string_t cmd_tso_show_mode =
4785 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4789 cmdline_parse_inst_t cmd_tso_show = {
4790 .f = cmd_tso_set_parsed,
4792 .help_str = "tso show <port_id>: "
4793 "Show TSO segment size of non-tunneled packets for csum engine",
4795 (void *)&cmd_tso_set_tso,
4796 (void *)&cmd_tso_show_mode,
4797 (void *)&cmd_tso_set_portid,
4802 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4803 struct cmd_tunnel_tso_set_result {
4804 cmdline_fixed_string_t tso;
4805 cmdline_fixed_string_t mode;
4810 static struct rte_eth_dev_info
4811 check_tunnel_tso_nic_support(portid_t port_id)
4813 struct rte_eth_dev_info dev_info;
4815 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4818 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4819 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4820 "not enabled for port %d\n", port_id);
4821 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4822 printf("Warning: GRE TUNNEL TSO not supported therefore "
4823 "not enabled for port %d\n", port_id);
4824 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4825 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4826 "not enabled for port %d\n", port_id);
4827 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4828 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4829 "not enabled for port %d\n", port_id);
4830 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4831 printf("Warning: IP TUNNEL TSO not supported therefore "
4832 "not enabled for port %d\n", port_id);
4833 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4834 printf("Warning: UDP TUNNEL TSO not supported therefore "
4835 "not enabled for port %d\n", port_id);
4840 cmd_tunnel_tso_set_parsed(void *parsed_result,
4841 __rte_unused struct cmdline *cl,
4842 __rte_unused void *data)
4844 struct cmd_tunnel_tso_set_result *res = parsed_result;
4845 struct rte_eth_dev_info dev_info;
4847 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4849 if (!port_is_stopped(res->port_id)) {
4850 printf("Please stop port %d first\n", res->port_id);
4854 if (!strcmp(res->mode, "set"))
4855 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4857 dev_info = check_tunnel_tso_nic_support(res->port_id);
4858 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4859 ports[res->port_id].dev_conf.txmode.offloads &=
4860 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4861 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4862 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4863 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4864 DEV_TX_OFFLOAD_IP_TNL_TSO |
4865 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4866 printf("TSO for tunneled packets is disabled\n");
4868 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4869 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4870 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4871 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4872 DEV_TX_OFFLOAD_IP_TNL_TSO |
4873 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4875 ports[res->port_id].dev_conf.txmode.offloads |=
4876 (tso_offloads & dev_info.tx_offload_capa);
4877 printf("TSO segment size for tunneled packets is %d\n",
4878 ports[res->port_id].tunnel_tso_segsz);
4880 /* Below conditions are needed to make it work:
4881 * (1) tunnel TSO is supported by the NIC;
4882 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4884 * (3) for tunneled pkts with outer L3 of IPv4,
4885 * "csum set outer-ip" must be set to hw, because after tso,
4886 * total_len of outer IP header is changed, and the checksum
4887 * of outer IP header calculated by sw should be wrong; that
4888 * is not necessary for IPv6 tunneled pkts because there's no
4889 * checksum in IP header anymore.
4892 if (!ports[res->port_id].parse_tunnel)
4893 printf("Warning: csum parse_tunnel must be set "
4894 "so that tunneled packets are recognized\n");
4895 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4896 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4897 printf("Warning: csum set outer-ip must be set to hw "
4898 "if outer L3 is IPv4; not necessary for IPv6\n");
4901 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4902 cmd_reconfig_device_queue(res->port_id, 1, 1);
4905 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4906 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4908 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4909 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4911 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4912 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4914 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4915 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4918 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4919 .f = cmd_tunnel_tso_set_parsed,
4921 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4922 "Set TSO segment size of tunneled packets for csum engine "
4925 (void *)&cmd_tunnel_tso_set_tso,
4926 (void *)&cmd_tunnel_tso_set_mode,
4927 (void *)&cmd_tunnel_tso_set_tso_segsz,
4928 (void *)&cmd_tunnel_tso_set_portid,
4933 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4934 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4938 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4939 .f = cmd_tunnel_tso_set_parsed,
4941 .help_str = "tunnel_tso show <port_id> "
4942 "Show TSO segment size of tunneled packets for csum engine",
4944 (void *)&cmd_tunnel_tso_set_tso,
4945 (void *)&cmd_tunnel_tso_show_mode,
4946 (void *)&cmd_tunnel_tso_set_portid,
4951 /* *** SET GRO FOR A PORT *** */
4952 struct cmd_gro_enable_result {
4953 cmdline_fixed_string_t cmd_set;
4954 cmdline_fixed_string_t cmd_port;
4955 cmdline_fixed_string_t cmd_keyword;
4956 cmdline_fixed_string_t cmd_onoff;
4961 cmd_gro_enable_parsed(void *parsed_result,
4962 __rte_unused struct cmdline *cl,
4963 __rte_unused void *data)
4965 struct cmd_gro_enable_result *res;
4967 res = parsed_result;
4968 if (!strcmp(res->cmd_keyword, "gro"))
4969 setup_gro(res->cmd_onoff, res->cmd_pid);
4972 cmdline_parse_token_string_t cmd_gro_enable_set =
4973 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4975 cmdline_parse_token_string_t cmd_gro_enable_port =
4976 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4977 cmd_keyword, "port");
4978 cmdline_parse_token_num_t cmd_gro_enable_pid =
4979 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4981 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4982 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4983 cmd_keyword, "gro");
4984 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4985 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4986 cmd_onoff, "on#off");
4988 cmdline_parse_inst_t cmd_gro_enable = {
4989 .f = cmd_gro_enable_parsed,
4991 .help_str = "set port <port_id> gro on|off",
4993 (void *)&cmd_gro_enable_set,
4994 (void *)&cmd_gro_enable_port,
4995 (void *)&cmd_gro_enable_pid,
4996 (void *)&cmd_gro_enable_keyword,
4997 (void *)&cmd_gro_enable_onoff,
5002 /* *** DISPLAY GRO CONFIGURATION *** */
5003 struct cmd_gro_show_result {
5004 cmdline_fixed_string_t cmd_show;
5005 cmdline_fixed_string_t cmd_port;
5006 cmdline_fixed_string_t cmd_keyword;
5011 cmd_gro_show_parsed(void *parsed_result,
5012 __rte_unused struct cmdline *cl,
5013 __rte_unused void *data)
5015 struct cmd_gro_show_result *res;
5017 res = parsed_result;
5018 if (!strcmp(res->cmd_keyword, "gro"))
5019 show_gro(res->cmd_pid);
5022 cmdline_parse_token_string_t cmd_gro_show_show =
5023 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5025 cmdline_parse_token_string_t cmd_gro_show_port =
5026 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5028 cmdline_parse_token_num_t cmd_gro_show_pid =
5029 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5031 cmdline_parse_token_string_t cmd_gro_show_keyword =
5032 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5033 cmd_keyword, "gro");
5035 cmdline_parse_inst_t cmd_gro_show = {
5036 .f = cmd_gro_show_parsed,
5038 .help_str = "show port <port_id> gro",
5040 (void *)&cmd_gro_show_show,
5041 (void *)&cmd_gro_show_port,
5042 (void *)&cmd_gro_show_pid,
5043 (void *)&cmd_gro_show_keyword,
5048 /* *** SET FLUSH CYCLES FOR GRO *** */
5049 struct cmd_gro_flush_result {
5050 cmdline_fixed_string_t cmd_set;
5051 cmdline_fixed_string_t cmd_keyword;
5052 cmdline_fixed_string_t cmd_flush;
5057 cmd_gro_flush_parsed(void *parsed_result,
5058 __rte_unused struct cmdline *cl,
5059 __rte_unused void *data)
5061 struct cmd_gro_flush_result *res;
5063 res = parsed_result;
5064 if ((!strcmp(res->cmd_keyword, "gro")) &&
5065 (!strcmp(res->cmd_flush, "flush")))
5066 setup_gro_flush_cycles(res->cmd_cycles);
5069 cmdline_parse_token_string_t cmd_gro_flush_set =
5070 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5072 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5073 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5074 cmd_keyword, "gro");
5075 cmdline_parse_token_string_t cmd_gro_flush_flush =
5076 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5077 cmd_flush, "flush");
5078 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5079 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5082 cmdline_parse_inst_t cmd_gro_flush = {
5083 .f = cmd_gro_flush_parsed,
5085 .help_str = "set gro flush <cycles>",
5087 (void *)&cmd_gro_flush_set,
5088 (void *)&cmd_gro_flush_keyword,
5089 (void *)&cmd_gro_flush_flush,
5090 (void *)&cmd_gro_flush_cycles,
5095 /* *** ENABLE/DISABLE GSO *** */
5096 struct cmd_gso_enable_result {
5097 cmdline_fixed_string_t cmd_set;
5098 cmdline_fixed_string_t cmd_port;
5099 cmdline_fixed_string_t cmd_keyword;
5100 cmdline_fixed_string_t cmd_mode;
5105 cmd_gso_enable_parsed(void *parsed_result,
5106 __rte_unused struct cmdline *cl,
5107 __rte_unused void *data)
5109 struct cmd_gso_enable_result *res;
5111 res = parsed_result;
5112 if (!strcmp(res->cmd_keyword, "gso"))
5113 setup_gso(res->cmd_mode, res->cmd_pid);
5116 cmdline_parse_token_string_t cmd_gso_enable_set =
5117 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5119 cmdline_parse_token_string_t cmd_gso_enable_port =
5120 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5122 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5123 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5124 cmd_keyword, "gso");
5125 cmdline_parse_token_string_t cmd_gso_enable_mode =
5126 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5127 cmd_mode, "on#off");
5128 cmdline_parse_token_num_t cmd_gso_enable_pid =
5129 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5132 cmdline_parse_inst_t cmd_gso_enable = {
5133 .f = cmd_gso_enable_parsed,
5135 .help_str = "set port <port_id> gso on|off",
5137 (void *)&cmd_gso_enable_set,
5138 (void *)&cmd_gso_enable_port,
5139 (void *)&cmd_gso_enable_pid,
5140 (void *)&cmd_gso_enable_keyword,
5141 (void *)&cmd_gso_enable_mode,
5146 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5147 struct cmd_gso_size_result {
5148 cmdline_fixed_string_t cmd_set;
5149 cmdline_fixed_string_t cmd_keyword;
5150 cmdline_fixed_string_t cmd_segsz;
5155 cmd_gso_size_parsed(void *parsed_result,
5156 __rte_unused struct cmdline *cl,
5157 __rte_unused void *data)
5159 struct cmd_gso_size_result *res = parsed_result;
5161 if (test_done == 0) {
5162 printf("Before setting GSO segsz, please first"
5163 " stop forwarding\n");
5167 if (!strcmp(res->cmd_keyword, "gso") &&
5168 !strcmp(res->cmd_segsz, "segsz")) {
5169 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5170 printf("gso_size should be larger than %zu."
5171 " Please input a legal value\n",
5172 RTE_GSO_SEG_SIZE_MIN);
5174 gso_max_segment_size = res->cmd_size;
5178 cmdline_parse_token_string_t cmd_gso_size_set =
5179 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5181 cmdline_parse_token_string_t cmd_gso_size_keyword =
5182 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5183 cmd_keyword, "gso");
5184 cmdline_parse_token_string_t cmd_gso_size_segsz =
5185 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5186 cmd_segsz, "segsz");
5187 cmdline_parse_token_num_t cmd_gso_size_size =
5188 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5191 cmdline_parse_inst_t cmd_gso_size = {
5192 .f = cmd_gso_size_parsed,
5194 .help_str = "set gso segsz <length>",
5196 (void *)&cmd_gso_size_set,
5197 (void *)&cmd_gso_size_keyword,
5198 (void *)&cmd_gso_size_segsz,
5199 (void *)&cmd_gso_size_size,
5204 /* *** SHOW GSO CONFIGURATION *** */
5205 struct cmd_gso_show_result {
5206 cmdline_fixed_string_t cmd_show;
5207 cmdline_fixed_string_t cmd_port;
5208 cmdline_fixed_string_t cmd_keyword;
5213 cmd_gso_show_parsed(void *parsed_result,
5214 __rte_unused struct cmdline *cl,
5215 __rte_unused void *data)
5217 struct cmd_gso_show_result *res = parsed_result;
5219 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5220 printf("invalid port id %u\n", res->cmd_pid);
5223 if (!strcmp(res->cmd_keyword, "gso")) {
5224 if (gso_ports[res->cmd_pid].enable) {
5225 printf("Max GSO'd packet size: %uB\n"
5226 "Supported GSO types: TCP/IPv4, "
5227 "UDP/IPv4, VxLAN with inner "
5228 "TCP/IPv4 packet, GRE with inner "
5229 "TCP/IPv4 packet\n",
5230 gso_max_segment_size);
5232 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5236 cmdline_parse_token_string_t cmd_gso_show_show =
5237 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5239 cmdline_parse_token_string_t cmd_gso_show_port =
5240 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5242 cmdline_parse_token_string_t cmd_gso_show_keyword =
5243 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5244 cmd_keyword, "gso");
5245 cmdline_parse_token_num_t cmd_gso_show_pid =
5246 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5249 cmdline_parse_inst_t cmd_gso_show = {
5250 .f = cmd_gso_show_parsed,
5252 .help_str = "show port <port_id> gso",
5254 (void *)&cmd_gso_show_show,
5255 (void *)&cmd_gso_show_port,
5256 (void *)&cmd_gso_show_pid,
5257 (void *)&cmd_gso_show_keyword,
5262 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5263 struct cmd_set_flush_rx {
5264 cmdline_fixed_string_t set;
5265 cmdline_fixed_string_t flush_rx;
5266 cmdline_fixed_string_t mode;
5270 cmd_set_flush_rx_parsed(void *parsed_result,
5271 __rte_unused struct cmdline *cl,
5272 __rte_unused void *data)
5274 struct cmd_set_flush_rx *res = parsed_result;
5275 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5278 cmdline_parse_token_string_t cmd_setflushrx_set =
5279 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5281 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5282 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5283 flush_rx, "flush_rx");
5284 cmdline_parse_token_string_t cmd_setflushrx_mode =
5285 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5289 cmdline_parse_inst_t cmd_set_flush_rx = {
5290 .f = cmd_set_flush_rx_parsed,
5291 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5294 (void *)&cmd_setflushrx_set,
5295 (void *)&cmd_setflushrx_flush_rx,
5296 (void *)&cmd_setflushrx_mode,
5301 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5302 struct cmd_set_link_check {
5303 cmdline_fixed_string_t set;
5304 cmdline_fixed_string_t link_check;
5305 cmdline_fixed_string_t mode;
5309 cmd_set_link_check_parsed(void *parsed_result,
5310 __rte_unused struct cmdline *cl,
5311 __rte_unused void *data)
5313 struct cmd_set_link_check *res = parsed_result;
5314 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5317 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5318 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5320 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5321 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5322 link_check, "link_check");
5323 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5324 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5328 cmdline_parse_inst_t cmd_set_link_check = {
5329 .f = cmd_set_link_check_parsed,
5330 .help_str = "set link_check on|off: Enable/Disable link status check "
5331 "when starting/stopping a port",
5334 (void *)&cmd_setlinkcheck_set,
5335 (void *)&cmd_setlinkcheck_link_check,
5336 (void *)&cmd_setlinkcheck_mode,
5341 /* *** SET NIC BYPASS MODE *** */
5342 struct cmd_set_bypass_mode_result {
5343 cmdline_fixed_string_t set;
5344 cmdline_fixed_string_t bypass;
5345 cmdline_fixed_string_t mode;
5346 cmdline_fixed_string_t value;
5351 cmd_set_bypass_mode_parsed(void *parsed_result,
5352 __rte_unused struct cmdline *cl,
5353 __rte_unused void *data)
5355 struct cmd_set_bypass_mode_result *res = parsed_result;
5356 portid_t port_id = res->port_id;
5357 int32_t rc = -EINVAL;
5359 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5360 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5362 if (!strcmp(res->value, "bypass"))
5363 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5364 else if (!strcmp(res->value, "isolate"))
5365 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5367 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5369 /* Set the bypass mode for the relevant port. */
5370 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5373 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5376 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5377 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5379 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5380 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5382 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5383 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5385 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5386 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5387 value, "normal#bypass#isolate");
5388 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5389 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5392 cmdline_parse_inst_t cmd_set_bypass_mode = {
5393 .f = cmd_set_bypass_mode_parsed,
5394 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5395 "Set the NIC bypass mode for port_id",
5398 (void *)&cmd_setbypass_mode_set,
5399 (void *)&cmd_setbypass_mode_bypass,
5400 (void *)&cmd_setbypass_mode_mode,
5401 (void *)&cmd_setbypass_mode_value,
5402 (void *)&cmd_setbypass_mode_port,
5407 /* *** SET NIC BYPASS EVENT *** */
5408 struct cmd_set_bypass_event_result {
5409 cmdline_fixed_string_t set;
5410 cmdline_fixed_string_t bypass;
5411 cmdline_fixed_string_t event;
5412 cmdline_fixed_string_t event_value;
5413 cmdline_fixed_string_t mode;
5414 cmdline_fixed_string_t mode_value;
5419 cmd_set_bypass_event_parsed(void *parsed_result,
5420 __rte_unused struct cmdline *cl,
5421 __rte_unused void *data)
5423 int32_t rc = -EINVAL;
5424 struct cmd_set_bypass_event_result *res = parsed_result;
5425 portid_t port_id = res->port_id;
5427 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5428 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5429 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5431 if (!strcmp(res->event_value, "timeout"))
5432 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5433 else if (!strcmp(res->event_value, "os_on"))
5434 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5435 else if (!strcmp(res->event_value, "os_off"))
5436 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5437 else if (!strcmp(res->event_value, "power_on"))
5438 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5439 else if (!strcmp(res->event_value, "power_off"))
5440 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5442 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5444 if (!strcmp(res->mode_value, "bypass"))
5445 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5446 else if (!strcmp(res->mode_value, "isolate"))
5447 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5449 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5451 /* Set the watchdog timeout. */
5452 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5455 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5456 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5460 printf("Failed to set timeout value %u "
5461 "for port %d, errto code: %d.\n",
5462 bypass_timeout, port_id, rc);
5466 /* Set the bypass event to transition to bypass mode. */
5467 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5472 printf("\t Failed to set bypass event for port = %d.\n",
5476 cmdline_parse_token_string_t cmd_setbypass_event_set =
5477 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5479 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5480 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5482 cmdline_parse_token_string_t cmd_setbypass_event_event =
5483 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5485 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5486 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5487 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5488 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5489 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5491 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5492 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5493 mode_value, "normal#bypass#isolate");
5494 cmdline_parse_token_num_t cmd_setbypass_event_port =
5495 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5498 cmdline_parse_inst_t cmd_set_bypass_event = {
5499 .f = cmd_set_bypass_event_parsed,
5500 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5501 "power_off mode normal|bypass|isolate <port_id>: "
5502 "Set the NIC bypass event mode for port_id",
5505 (void *)&cmd_setbypass_event_set,
5506 (void *)&cmd_setbypass_event_bypass,
5507 (void *)&cmd_setbypass_event_event,
5508 (void *)&cmd_setbypass_event_event_value,
5509 (void *)&cmd_setbypass_event_mode,
5510 (void *)&cmd_setbypass_event_mode_value,
5511 (void *)&cmd_setbypass_event_port,
5517 /* *** SET NIC BYPASS TIMEOUT *** */
5518 struct cmd_set_bypass_timeout_result {
5519 cmdline_fixed_string_t set;
5520 cmdline_fixed_string_t bypass;
5521 cmdline_fixed_string_t timeout;
5522 cmdline_fixed_string_t value;
5526 cmd_set_bypass_timeout_parsed(void *parsed_result,
5527 __rte_unused struct cmdline *cl,
5528 __rte_unused void *data)
5530 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5532 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5533 if (!strcmp(res->value, "1.5"))
5534 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5535 else if (!strcmp(res->value, "2"))
5536 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5537 else if (!strcmp(res->value, "3"))
5538 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5539 else if (!strcmp(res->value, "4"))
5540 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5541 else if (!strcmp(res->value, "8"))
5542 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5543 else if (!strcmp(res->value, "16"))
5544 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5545 else if (!strcmp(res->value, "32"))
5546 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5548 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5552 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5553 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5555 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5556 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5558 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5559 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5560 timeout, "timeout");
5561 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5562 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5563 value, "0#1.5#2#3#4#8#16#32");
5565 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5566 .f = cmd_set_bypass_timeout_parsed,
5567 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5568 "Set the NIC bypass watchdog timeout in seconds",
5571 (void *)&cmd_setbypass_timeout_set,
5572 (void *)&cmd_setbypass_timeout_bypass,
5573 (void *)&cmd_setbypass_timeout_timeout,
5574 (void *)&cmd_setbypass_timeout_value,
5579 /* *** SHOW NIC BYPASS MODE *** */
5580 struct cmd_show_bypass_config_result {
5581 cmdline_fixed_string_t show;
5582 cmdline_fixed_string_t bypass;
5583 cmdline_fixed_string_t config;
5588 cmd_show_bypass_config_parsed(void *parsed_result,
5589 __rte_unused struct cmdline *cl,
5590 __rte_unused void *data)
5592 struct cmd_show_bypass_config_result *res = parsed_result;
5593 portid_t port_id = res->port_id;
5595 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5596 uint32_t event_mode;
5597 uint32_t bypass_mode;
5598 uint32_t timeout = bypass_timeout;
5601 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5602 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5603 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5604 {"UNKNOWN", "normal", "bypass", "isolate"};
5605 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5613 /* Display the bypass mode.*/
5614 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5615 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5619 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5620 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5622 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5625 /* Display the bypass timeout.*/
5626 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5627 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5629 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5631 /* Display the bypass events and associated modes. */
5632 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5634 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5635 printf("\tFailed to get bypass mode for event = %s\n",
5638 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5639 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5641 printf("\tbypass event: %-16s = %s\n", events[i],
5647 printf("\tFailed to get bypass configuration for port = %d\n",
5651 cmdline_parse_token_string_t cmd_showbypass_config_show =
5652 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5654 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5655 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5657 cmdline_parse_token_string_t cmd_showbypass_config_config =
5658 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5660 cmdline_parse_token_num_t cmd_showbypass_config_port =
5661 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5664 cmdline_parse_inst_t cmd_show_bypass_config = {
5665 .f = cmd_show_bypass_config_parsed,
5666 .help_str = "show bypass config <port_id>: "
5667 "Show the NIC bypass config for port_id",
5670 (void *)&cmd_showbypass_config_show,
5671 (void *)&cmd_showbypass_config_bypass,
5672 (void *)&cmd_showbypass_config_config,
5673 (void *)&cmd_showbypass_config_port,
5678 #ifdef RTE_LIBRTE_PMD_BOND
5679 /* *** SET BONDING MODE *** */
5680 struct cmd_set_bonding_mode_result {
5681 cmdline_fixed_string_t set;
5682 cmdline_fixed_string_t bonding;
5683 cmdline_fixed_string_t mode;
5688 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5689 __rte_unused struct cmdline *cl,
5690 __rte_unused void *data)
5692 struct cmd_set_bonding_mode_result *res = parsed_result;
5693 portid_t port_id = res->port_id;
5695 /* Set the bonding mode for the relevant port. */
5696 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5697 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5700 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5701 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5703 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5705 bonding, "bonding");
5706 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5707 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5709 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5710 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5712 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5713 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5716 cmdline_parse_inst_t cmd_set_bonding_mode = {
5717 .f = cmd_set_bonding_mode_parsed,
5718 .help_str = "set bonding mode <mode_value> <port_id>: "
5719 "Set the bonding mode for port_id",
5722 (void *) &cmd_setbonding_mode_set,
5723 (void *) &cmd_setbonding_mode_bonding,
5724 (void *) &cmd_setbonding_mode_mode,
5725 (void *) &cmd_setbonding_mode_value,
5726 (void *) &cmd_setbonding_mode_port,
5731 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5732 struct cmd_set_bonding_lacp_dedicated_queues_result {
5733 cmdline_fixed_string_t set;
5734 cmdline_fixed_string_t bonding;
5735 cmdline_fixed_string_t lacp;
5736 cmdline_fixed_string_t dedicated_queues;
5738 cmdline_fixed_string_t mode;
5741 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5742 __rte_unused struct cmdline *cl,
5743 __rte_unused void *data)
5745 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5746 portid_t port_id = res->port_id;
5747 struct rte_port *port;
5749 port = &ports[port_id];
5751 /** Check if the port is not started **/
5752 if (port->port_status != RTE_PORT_STOPPED) {
5753 printf("Please stop port %d first\n", port_id);
5757 if (!strcmp(res->mode, "enable")) {
5758 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5759 printf("Dedicate queues for LACP control packets"
5762 printf("Enabling dedicate queues for LACP control "
5763 "packets on port %d failed\n", port_id);
5764 } else if (!strcmp(res->mode, "disable")) {
5765 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5766 printf("Dedicated queues for LACP control packets "
5769 printf("Disabling dedicated queues for LACP control "
5770 "traffic on port %d failed\n", port_id);
5774 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5775 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5777 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5778 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5779 bonding, "bonding");
5780 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5781 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5783 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5784 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5785 dedicated_queues, "dedicated_queues");
5786 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5787 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5789 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5790 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5791 mode, "enable#disable");
5793 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5794 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5795 .help_str = "set bonding lacp dedicated_queues <port_id> "
5797 "Enable/disable dedicated queues for LACP control traffic for port_id",
5800 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5801 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5802 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5803 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5804 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5805 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5810 /* *** SET BALANCE XMIT POLICY *** */
5811 struct cmd_set_bonding_balance_xmit_policy_result {
5812 cmdline_fixed_string_t set;
5813 cmdline_fixed_string_t bonding;
5814 cmdline_fixed_string_t balance_xmit_policy;
5816 cmdline_fixed_string_t policy;
5819 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5820 __rte_unused struct cmdline *cl,
5821 __rte_unused void *data)
5823 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5824 portid_t port_id = res->port_id;
5827 if (!strcmp(res->policy, "l2")) {
5828 policy = BALANCE_XMIT_POLICY_LAYER2;
5829 } else if (!strcmp(res->policy, "l23")) {
5830 policy = BALANCE_XMIT_POLICY_LAYER23;
5831 } else if (!strcmp(res->policy, "l34")) {
5832 policy = BALANCE_XMIT_POLICY_LAYER34;
5834 printf("\t Invalid xmit policy selection");
5838 /* Set the bonding mode for the relevant port. */
5839 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5840 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5845 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5846 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5848 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5849 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5850 bonding, "bonding");
5851 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5852 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5853 balance_xmit_policy, "balance_xmit_policy");
5854 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5855 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5857 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5858 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5859 policy, "l2#l23#l34");
5861 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5862 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5863 .help_str = "set bonding balance_xmit_policy <port_id> "
5865 "Set the bonding balance_xmit_policy for port_id",
5868 (void *)&cmd_setbonding_balance_xmit_policy_set,
5869 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5870 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5871 (void *)&cmd_setbonding_balance_xmit_policy_port,
5872 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5877 /* *** SHOW NIC BONDING CONFIGURATION *** */
5878 struct cmd_show_bonding_config_result {
5879 cmdline_fixed_string_t show;
5880 cmdline_fixed_string_t bonding;
5881 cmdline_fixed_string_t config;
5885 static void cmd_show_bonding_config_parsed(void *parsed_result,
5886 __rte_unused struct cmdline *cl,
5887 __rte_unused void *data)
5889 struct cmd_show_bonding_config_result *res = parsed_result;
5890 int bonding_mode, agg_mode;
5891 portid_t slaves[RTE_MAX_ETHPORTS];
5892 int num_slaves, num_active_slaves;
5895 portid_t port_id = res->port_id;
5897 /* Display the bonding mode.*/
5898 bonding_mode = rte_eth_bond_mode_get(port_id);
5899 if (bonding_mode < 0) {
5900 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5903 printf("\tBonding mode: %d\n", bonding_mode);
5905 if (bonding_mode == BONDING_MODE_BALANCE) {
5906 int balance_xmit_policy;
5908 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5909 if (balance_xmit_policy < 0) {
5910 printf("\tFailed to get balance xmit policy for port = %d\n",
5914 printf("\tBalance Xmit Policy: ");
5916 switch (balance_xmit_policy) {
5917 case BALANCE_XMIT_POLICY_LAYER2:
5918 printf("BALANCE_XMIT_POLICY_LAYER2");
5920 case BALANCE_XMIT_POLICY_LAYER23:
5921 printf("BALANCE_XMIT_POLICY_LAYER23");
5923 case BALANCE_XMIT_POLICY_LAYER34:
5924 printf("BALANCE_XMIT_POLICY_LAYER34");
5931 if (bonding_mode == BONDING_MODE_8023AD) {
5932 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5933 printf("\tIEEE802.3AD Aggregator Mode: ");
5936 printf("bandwidth");
5948 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5950 if (num_slaves < 0) {
5951 printf("\tFailed to get slave list for port = %d\n", port_id);
5954 if (num_slaves > 0) {
5955 printf("\tSlaves (%d): [", num_slaves);
5956 for (i = 0; i < num_slaves - 1; i++)
5957 printf("%d ", slaves[i]);
5959 printf("%d]\n", slaves[num_slaves - 1]);
5961 printf("\tSlaves: []\n");
5965 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5968 if (num_active_slaves < 0) {
5969 printf("\tFailed to get active slave list for port = %d\n", port_id);
5972 if (num_active_slaves > 0) {
5973 printf("\tActive Slaves (%d): [", num_active_slaves);
5974 for (i = 0; i < num_active_slaves - 1; i++)
5975 printf("%d ", slaves[i]);
5977 printf("%d]\n", slaves[num_active_slaves - 1]);
5980 printf("\tActive Slaves: []\n");
5984 primary_id = rte_eth_bond_primary_get(port_id);
5985 if (primary_id < 0) {
5986 printf("\tFailed to get primary slave for port = %d\n", port_id);
5989 printf("\tPrimary: [%d]\n", primary_id);
5993 cmdline_parse_token_string_t cmd_showbonding_config_show =
5994 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5996 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5997 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5998 bonding, "bonding");
5999 cmdline_parse_token_string_t cmd_showbonding_config_config =
6000 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6002 cmdline_parse_token_num_t cmd_showbonding_config_port =
6003 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6006 cmdline_parse_inst_t cmd_show_bonding_config = {
6007 .f = cmd_show_bonding_config_parsed,
6008 .help_str = "show bonding config <port_id>: "
6009 "Show the bonding config for port_id",
6012 (void *)&cmd_showbonding_config_show,
6013 (void *)&cmd_showbonding_config_bonding,
6014 (void *)&cmd_showbonding_config_config,
6015 (void *)&cmd_showbonding_config_port,
6020 /* *** SET BONDING PRIMARY *** */
6021 struct cmd_set_bonding_primary_result {
6022 cmdline_fixed_string_t set;
6023 cmdline_fixed_string_t bonding;
6024 cmdline_fixed_string_t primary;
6029 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6030 __rte_unused struct cmdline *cl,
6031 __rte_unused void *data)
6033 struct cmd_set_bonding_primary_result *res = parsed_result;
6034 portid_t master_port_id = res->port_id;
6035 portid_t slave_port_id = res->slave_id;
6037 /* Set the primary slave for a bonded device. */
6038 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6039 printf("\t Failed to set primary slave for port = %d.\n",
6046 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6047 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6049 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6050 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6051 bonding, "bonding");
6052 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6053 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6054 primary, "primary");
6055 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6056 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6058 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6059 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6062 cmdline_parse_inst_t cmd_set_bonding_primary = {
6063 .f = cmd_set_bonding_primary_parsed,
6064 .help_str = "set bonding primary <slave_id> <port_id>: "
6065 "Set the primary slave for port_id",
6068 (void *)&cmd_setbonding_primary_set,
6069 (void *)&cmd_setbonding_primary_bonding,
6070 (void *)&cmd_setbonding_primary_primary,
6071 (void *)&cmd_setbonding_primary_slave,
6072 (void *)&cmd_setbonding_primary_port,
6077 /* *** ADD SLAVE *** */
6078 struct cmd_add_bonding_slave_result {
6079 cmdline_fixed_string_t add;
6080 cmdline_fixed_string_t bonding;
6081 cmdline_fixed_string_t slave;
6086 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6087 __rte_unused struct cmdline *cl,
6088 __rte_unused void *data)
6090 struct cmd_add_bonding_slave_result *res = parsed_result;
6091 portid_t master_port_id = res->port_id;
6092 portid_t slave_port_id = res->slave_id;
6094 /* add the slave for a bonded device. */
6095 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6096 printf("\t Failed to add slave %d to master port = %d.\n",
6097 slave_port_id, master_port_id);
6101 set_port_slave_flag(slave_port_id);
6104 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6105 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6107 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6108 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6109 bonding, "bonding");
6110 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6111 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6113 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6114 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6116 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6117 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6120 cmdline_parse_inst_t cmd_add_bonding_slave = {
6121 .f = cmd_add_bonding_slave_parsed,
6122 .help_str = "add bonding slave <slave_id> <port_id>: "
6123 "Add a slave device to a bonded device",
6126 (void *)&cmd_addbonding_slave_add,
6127 (void *)&cmd_addbonding_slave_bonding,
6128 (void *)&cmd_addbonding_slave_slave,
6129 (void *)&cmd_addbonding_slave_slaveid,
6130 (void *)&cmd_addbonding_slave_port,
6135 /* *** REMOVE SLAVE *** */
6136 struct cmd_remove_bonding_slave_result {
6137 cmdline_fixed_string_t remove;
6138 cmdline_fixed_string_t bonding;
6139 cmdline_fixed_string_t slave;
6144 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6145 __rte_unused struct cmdline *cl,
6146 __rte_unused void *data)
6148 struct cmd_remove_bonding_slave_result *res = parsed_result;
6149 portid_t master_port_id = res->port_id;
6150 portid_t slave_port_id = res->slave_id;
6152 /* remove the slave from a bonded device. */
6153 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6154 printf("\t Failed to remove slave %d from master port = %d.\n",
6155 slave_port_id, master_port_id);
6159 clear_port_slave_flag(slave_port_id);
6162 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6163 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6165 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6166 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6167 bonding, "bonding");
6168 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6169 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6171 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6172 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6174 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6175 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6178 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6179 .f = cmd_remove_bonding_slave_parsed,
6180 .help_str = "remove bonding slave <slave_id> <port_id>: "
6181 "Remove a slave device from a bonded device",
6184 (void *)&cmd_removebonding_slave_remove,
6185 (void *)&cmd_removebonding_slave_bonding,
6186 (void *)&cmd_removebonding_slave_slave,
6187 (void *)&cmd_removebonding_slave_slaveid,
6188 (void *)&cmd_removebonding_slave_port,
6193 /* *** CREATE BONDED DEVICE *** */
6194 struct cmd_create_bonded_device_result {
6195 cmdline_fixed_string_t create;
6196 cmdline_fixed_string_t bonded;
6197 cmdline_fixed_string_t device;
6202 static int bond_dev_num = 0;
6204 static void cmd_create_bonded_device_parsed(void *parsed_result,
6205 __rte_unused struct cmdline *cl,
6206 __rte_unused void *data)
6208 struct cmd_create_bonded_device_result *res = parsed_result;
6209 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6213 if (test_done == 0) {
6214 printf("Please stop forwarding first\n");
6218 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6221 /* Create a new bonded device. */
6222 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6224 printf("\t Failed to create bonded device.\n");
6227 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6230 /* Update number of ports */
6231 nb_ports = rte_eth_dev_count_avail();
6232 reconfig(port_id, res->socket);
6233 ret = rte_eth_promiscuous_enable(port_id);
6235 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6236 port_id, rte_strerror(-ret));
6238 ports[port_id].need_setup = 0;
6239 ports[port_id].port_status = RTE_PORT_STOPPED;
6244 cmdline_parse_token_string_t cmd_createbonded_device_create =
6245 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6247 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6248 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6250 cmdline_parse_token_string_t cmd_createbonded_device_device =
6251 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6253 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6254 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6256 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6257 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6260 cmdline_parse_inst_t cmd_create_bonded_device = {
6261 .f = cmd_create_bonded_device_parsed,
6262 .help_str = "create bonded device <mode> <socket>: "
6263 "Create a new bonded device with specific bonding mode and socket",
6266 (void *)&cmd_createbonded_device_create,
6267 (void *)&cmd_createbonded_device_bonded,
6268 (void *)&cmd_createbonded_device_device,
6269 (void *)&cmd_createbonded_device_mode,
6270 (void *)&cmd_createbonded_device_socket,
6275 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6276 struct cmd_set_bond_mac_addr_result {
6277 cmdline_fixed_string_t set;
6278 cmdline_fixed_string_t bonding;
6279 cmdline_fixed_string_t mac_addr;
6281 struct rte_ether_addr address;
6284 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6285 __rte_unused struct cmdline *cl,
6286 __rte_unused void *data)
6288 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6291 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6294 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6296 /* check the return value and print it if is < 0 */
6298 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6301 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6302 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6303 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6304 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6306 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6307 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6309 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6310 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6312 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6313 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6315 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6316 .f = cmd_set_bond_mac_addr_parsed,
6318 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6320 (void *)&cmd_set_bond_mac_addr_set,
6321 (void *)&cmd_set_bond_mac_addr_bonding,
6322 (void *)&cmd_set_bond_mac_addr_mac,
6323 (void *)&cmd_set_bond_mac_addr_portnum,
6324 (void *)&cmd_set_bond_mac_addr_addr,
6330 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6331 struct cmd_set_bond_mon_period_result {
6332 cmdline_fixed_string_t set;
6333 cmdline_fixed_string_t bonding;
6334 cmdline_fixed_string_t mon_period;
6339 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6340 __rte_unused struct cmdline *cl,
6341 __rte_unused void *data)
6343 struct cmd_set_bond_mon_period_result *res = parsed_result;
6346 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6348 /* check the return value and print it if is < 0 */
6350 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6353 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6354 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6356 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6357 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6358 bonding, "bonding");
6359 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6360 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6361 mon_period, "mon_period");
6362 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6363 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6365 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6366 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6369 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6370 .f = cmd_set_bond_mon_period_parsed,
6372 .help_str = "set bonding mon_period <port_id> <period_ms>",
6374 (void *)&cmd_set_bond_mon_period_set,
6375 (void *)&cmd_set_bond_mon_period_bonding,
6376 (void *)&cmd_set_bond_mon_period_mon_period,
6377 (void *)&cmd_set_bond_mon_period_portnum,
6378 (void *)&cmd_set_bond_mon_period_period_ms,
6385 struct cmd_set_bonding_agg_mode_policy_result {
6386 cmdline_fixed_string_t set;
6387 cmdline_fixed_string_t bonding;
6388 cmdline_fixed_string_t agg_mode;
6390 cmdline_fixed_string_t policy;
6395 cmd_set_bonding_agg_mode(void *parsed_result,
6396 __rte_unused struct cmdline *cl,
6397 __rte_unused void *data)
6399 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6400 uint8_t policy = AGG_BANDWIDTH;
6402 if (!strcmp(res->policy, "bandwidth"))
6403 policy = AGG_BANDWIDTH;
6404 else if (!strcmp(res->policy, "stable"))
6405 policy = AGG_STABLE;
6406 else if (!strcmp(res->policy, "count"))
6409 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6413 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6414 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6416 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6417 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6418 bonding, "bonding");
6420 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6421 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6422 agg_mode, "agg_mode");
6424 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6425 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6428 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6429 TOKEN_STRING_INITIALIZER(
6430 struct cmd_set_bonding_balance_xmit_policy_result,
6431 policy, "stable#bandwidth#count");
6433 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6434 .f = cmd_set_bonding_agg_mode,
6436 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6438 (void *)&cmd_set_bonding_agg_mode_set,
6439 (void *)&cmd_set_bonding_agg_mode_bonding,
6440 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6441 (void *)&cmd_set_bonding_agg_mode_portnum,
6442 (void *)&cmd_set_bonding_agg_mode_policy_string,
6448 #endif /* RTE_LIBRTE_PMD_BOND */
6450 /* *** SET FORWARDING MODE *** */
6451 struct cmd_set_fwd_mode_result {
6452 cmdline_fixed_string_t set;
6453 cmdline_fixed_string_t fwd;
6454 cmdline_fixed_string_t mode;
6457 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6458 __rte_unused struct cmdline *cl,
6459 __rte_unused void *data)
6461 struct cmd_set_fwd_mode_result *res = parsed_result;
6464 set_pkt_forwarding_mode(res->mode);
6467 cmdline_parse_token_string_t cmd_setfwd_set =
6468 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6469 cmdline_parse_token_string_t cmd_setfwd_fwd =
6470 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6471 cmdline_parse_token_string_t cmd_setfwd_mode =
6472 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6473 "" /* defined at init */);
6475 cmdline_parse_inst_t cmd_set_fwd_mode = {
6476 .f = cmd_set_fwd_mode_parsed,
6478 .help_str = NULL, /* defined at init */
6480 (void *)&cmd_setfwd_set,
6481 (void *)&cmd_setfwd_fwd,
6482 (void *)&cmd_setfwd_mode,
6487 static void cmd_set_fwd_mode_init(void)
6490 static char token[128];
6491 static char help[256];
6492 cmdline_parse_token_string_t *token_struct;
6494 modes = list_pkt_forwarding_modes();
6495 snprintf(help, sizeof(help), "set fwd %s: "
6496 "Set packet forwarding mode", modes);
6497 cmd_set_fwd_mode.help_str = help;
6499 /* string token separator is # */
6500 for (c = token; *modes != '\0'; modes++)
6505 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6506 token_struct->string_data.str = token;
6509 /* *** SET RETRY FORWARDING MODE *** */
6510 struct cmd_set_fwd_retry_mode_result {
6511 cmdline_fixed_string_t set;
6512 cmdline_fixed_string_t fwd;
6513 cmdline_fixed_string_t mode;
6514 cmdline_fixed_string_t retry;
6517 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6518 __rte_unused struct cmdline *cl,
6519 __rte_unused void *data)
6521 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6524 set_pkt_forwarding_mode(res->mode);
6527 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6528 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6530 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6531 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6533 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6534 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6536 "" /* defined at init */);
6537 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6538 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6541 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6542 .f = cmd_set_fwd_retry_mode_parsed,
6544 .help_str = NULL, /* defined at init */
6546 (void *)&cmd_setfwd_retry_set,
6547 (void *)&cmd_setfwd_retry_fwd,
6548 (void *)&cmd_setfwd_retry_mode,
6549 (void *)&cmd_setfwd_retry_retry,
6554 static void cmd_set_fwd_retry_mode_init(void)
6557 static char token[128];
6558 static char help[256];
6559 cmdline_parse_token_string_t *token_struct;
6561 modes = list_pkt_forwarding_retry_modes();
6562 snprintf(help, sizeof(help), "set fwd %s retry: "
6563 "Set packet forwarding mode with retry", modes);
6564 cmd_set_fwd_retry_mode.help_str = help;
6566 /* string token separator is # */
6567 for (c = token; *modes != '\0'; modes++)
6572 token_struct = (cmdline_parse_token_string_t *)
6573 cmd_set_fwd_retry_mode.tokens[2];
6574 token_struct->string_data.str = token;
6577 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6578 struct cmd_set_burst_tx_retry_result {
6579 cmdline_fixed_string_t set;
6580 cmdline_fixed_string_t burst;
6581 cmdline_fixed_string_t tx;
6582 cmdline_fixed_string_t delay;
6584 cmdline_fixed_string_t retry;
6588 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6589 __rte_unused struct cmdline *cl,
6590 __rte_unused void *data)
6592 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6594 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6595 && !strcmp(res->tx, "tx")) {
6596 if (!strcmp(res->delay, "delay"))
6597 burst_tx_delay_time = res->time;
6598 if (!strcmp(res->retry, "retry"))
6599 burst_tx_retry_num = res->retry_num;
6604 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6605 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6606 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6607 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6609 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6610 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6611 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6612 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6613 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6614 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6615 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6616 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6617 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6618 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6620 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6621 .f = cmd_set_burst_tx_retry_parsed,
6622 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6624 (void *)&cmd_set_burst_tx_retry_set,
6625 (void *)&cmd_set_burst_tx_retry_burst,
6626 (void *)&cmd_set_burst_tx_retry_tx,
6627 (void *)&cmd_set_burst_tx_retry_delay,
6628 (void *)&cmd_set_burst_tx_retry_time,
6629 (void *)&cmd_set_burst_tx_retry_retry,
6630 (void *)&cmd_set_burst_tx_retry_retry_num,
6635 /* *** SET PROMISC MODE *** */
6636 struct cmd_set_promisc_mode_result {
6637 cmdline_fixed_string_t set;
6638 cmdline_fixed_string_t promisc;
6639 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6640 uint16_t port_num; /* valid if "allports" argument == 0 */
6641 cmdline_fixed_string_t mode;
6644 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6645 __rte_unused struct cmdline *cl,
6648 struct cmd_set_promisc_mode_result *res = parsed_result;
6652 if (!strcmp(res->mode, "on"))
6659 RTE_ETH_FOREACH_DEV(i)
6660 eth_set_promisc_mode(i, enable);
6662 eth_set_promisc_mode(res->port_num, enable);
6666 cmdline_parse_token_string_t cmd_setpromisc_set =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6668 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6669 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6671 cmdline_parse_token_string_t cmd_setpromisc_portall =
6672 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6674 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6675 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6677 cmdline_parse_token_string_t cmd_setpromisc_mode =
6678 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6681 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6682 .f = cmd_set_promisc_mode_parsed,
6684 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6686 (void *)&cmd_setpromisc_set,
6687 (void *)&cmd_setpromisc_promisc,
6688 (void *)&cmd_setpromisc_portall,
6689 (void *)&cmd_setpromisc_mode,
6694 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6695 .f = cmd_set_promisc_mode_parsed,
6697 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6699 (void *)&cmd_setpromisc_set,
6700 (void *)&cmd_setpromisc_promisc,
6701 (void *)&cmd_setpromisc_portnum,
6702 (void *)&cmd_setpromisc_mode,
6707 /* *** SET ALLMULTI MODE *** */
6708 struct cmd_set_allmulti_mode_result {
6709 cmdline_fixed_string_t set;
6710 cmdline_fixed_string_t allmulti;
6711 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6712 uint16_t port_num; /* valid if "allports" argument == 0 */
6713 cmdline_fixed_string_t mode;
6716 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6717 __rte_unused struct cmdline *cl,
6720 struct cmd_set_allmulti_mode_result *res = parsed_result;
6724 if (!strcmp(res->mode, "on"))
6731 RTE_ETH_FOREACH_DEV(i) {
6732 eth_set_allmulticast_mode(i, enable);
6736 eth_set_allmulticast_mode(res->port_num, enable);
6740 cmdline_parse_token_string_t cmd_setallmulti_set =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6742 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6743 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6745 cmdline_parse_token_string_t cmd_setallmulti_portall =
6746 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6748 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6749 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6751 cmdline_parse_token_string_t cmd_setallmulti_mode =
6752 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6755 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6756 .f = cmd_set_allmulti_mode_parsed,
6758 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6760 (void *)&cmd_setallmulti_set,
6761 (void *)&cmd_setallmulti_allmulti,
6762 (void *)&cmd_setallmulti_portall,
6763 (void *)&cmd_setallmulti_mode,
6768 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6769 .f = cmd_set_allmulti_mode_parsed,
6771 .help_str = "set allmulti <port_id> on|off: "
6772 "Set allmulti mode on port_id",
6774 (void *)&cmd_setallmulti_set,
6775 (void *)&cmd_setallmulti_allmulti,
6776 (void *)&cmd_setallmulti_portnum,
6777 (void *)&cmd_setallmulti_mode,
6782 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6783 struct cmd_link_flow_ctrl_set_result {
6784 cmdline_fixed_string_t set;
6785 cmdline_fixed_string_t flow_ctrl;
6786 cmdline_fixed_string_t rx;
6787 cmdline_fixed_string_t rx_lfc_mode;
6788 cmdline_fixed_string_t tx;
6789 cmdline_fixed_string_t tx_lfc_mode;
6790 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6791 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6792 cmdline_fixed_string_t autoneg_str;
6793 cmdline_fixed_string_t autoneg;
6794 cmdline_fixed_string_t hw_str;
6795 uint32_t high_water;
6796 cmdline_fixed_string_t lw_str;
6798 cmdline_fixed_string_t pt_str;
6799 uint16_t pause_time;
6800 cmdline_fixed_string_t xon_str;
6805 cmdline_parse_token_string_t cmd_lfc_set_set =
6806 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6808 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6809 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6810 flow_ctrl, "flow_ctrl");
6811 cmdline_parse_token_string_t cmd_lfc_set_rx =
6812 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6814 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6815 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6816 rx_lfc_mode, "on#off");
6817 cmdline_parse_token_string_t cmd_lfc_set_tx =
6818 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6820 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6821 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6822 tx_lfc_mode, "on#off");
6823 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6824 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6825 hw_str, "high_water");
6826 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6827 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6828 high_water, UINT32);
6829 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6830 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6831 lw_str, "low_water");
6832 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6833 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6835 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6836 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6837 pt_str, "pause_time");
6838 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6839 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6840 pause_time, UINT16);
6841 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6842 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6843 xon_str, "send_xon");
6844 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6845 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6847 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6848 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6849 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6850 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6851 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6852 mac_ctrl_frame_fwd_mode, "on#off");
6853 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6854 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6855 autoneg_str, "autoneg");
6856 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6857 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6859 cmdline_parse_token_num_t cmd_lfc_set_portid =
6860 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6863 /* forward declaration */
6865 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6868 cmdline_parse_inst_t cmd_link_flow_control_set = {
6869 .f = cmd_link_flow_ctrl_set_parsed,
6871 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6872 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6873 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6875 (void *)&cmd_lfc_set_set,
6876 (void *)&cmd_lfc_set_flow_ctrl,
6877 (void *)&cmd_lfc_set_rx,
6878 (void *)&cmd_lfc_set_rx_mode,
6879 (void *)&cmd_lfc_set_tx,
6880 (void *)&cmd_lfc_set_tx_mode,
6881 (void *)&cmd_lfc_set_high_water,
6882 (void *)&cmd_lfc_set_low_water,
6883 (void *)&cmd_lfc_set_pause_time,
6884 (void *)&cmd_lfc_set_send_xon,
6885 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6886 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6887 (void *)&cmd_lfc_set_autoneg_str,
6888 (void *)&cmd_lfc_set_autoneg,
6889 (void *)&cmd_lfc_set_portid,
6894 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6895 .f = cmd_link_flow_ctrl_set_parsed,
6896 .data = (void *)&cmd_link_flow_control_set_rx,
6897 .help_str = "set flow_ctrl rx on|off <port_id>: "
6898 "Change rx flow control parameter",
6900 (void *)&cmd_lfc_set_set,
6901 (void *)&cmd_lfc_set_flow_ctrl,
6902 (void *)&cmd_lfc_set_rx,
6903 (void *)&cmd_lfc_set_rx_mode,
6904 (void *)&cmd_lfc_set_portid,
6909 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6910 .f = cmd_link_flow_ctrl_set_parsed,
6911 .data = (void *)&cmd_link_flow_control_set_tx,
6912 .help_str = "set flow_ctrl tx on|off <port_id>: "
6913 "Change tx flow control parameter",
6915 (void *)&cmd_lfc_set_set,
6916 (void *)&cmd_lfc_set_flow_ctrl,
6917 (void *)&cmd_lfc_set_tx,
6918 (void *)&cmd_lfc_set_tx_mode,
6919 (void *)&cmd_lfc_set_portid,
6924 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6925 .f = cmd_link_flow_ctrl_set_parsed,
6926 .data = (void *)&cmd_link_flow_control_set_hw,
6927 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6928 "Change high water flow control parameter",
6930 (void *)&cmd_lfc_set_set,
6931 (void *)&cmd_lfc_set_flow_ctrl,
6932 (void *)&cmd_lfc_set_high_water_str,
6933 (void *)&cmd_lfc_set_high_water,
6934 (void *)&cmd_lfc_set_portid,
6939 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6940 .f = cmd_link_flow_ctrl_set_parsed,
6941 .data = (void *)&cmd_link_flow_control_set_lw,
6942 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6943 "Change low water flow control parameter",
6945 (void *)&cmd_lfc_set_set,
6946 (void *)&cmd_lfc_set_flow_ctrl,
6947 (void *)&cmd_lfc_set_low_water_str,
6948 (void *)&cmd_lfc_set_low_water,
6949 (void *)&cmd_lfc_set_portid,
6954 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6955 .f = cmd_link_flow_ctrl_set_parsed,
6956 .data = (void *)&cmd_link_flow_control_set_pt,
6957 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6958 "Change pause time flow control parameter",
6960 (void *)&cmd_lfc_set_set,
6961 (void *)&cmd_lfc_set_flow_ctrl,
6962 (void *)&cmd_lfc_set_pause_time_str,
6963 (void *)&cmd_lfc_set_pause_time,
6964 (void *)&cmd_lfc_set_portid,
6969 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6970 .f = cmd_link_flow_ctrl_set_parsed,
6971 .data = (void *)&cmd_link_flow_control_set_xon,
6972 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6973 "Change send_xon flow control parameter",
6975 (void *)&cmd_lfc_set_set,
6976 (void *)&cmd_lfc_set_flow_ctrl,
6977 (void *)&cmd_lfc_set_send_xon_str,
6978 (void *)&cmd_lfc_set_send_xon,
6979 (void *)&cmd_lfc_set_portid,
6984 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6985 .f = cmd_link_flow_ctrl_set_parsed,
6986 .data = (void *)&cmd_link_flow_control_set_macfwd,
6987 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6988 "Change mac ctrl fwd flow control parameter",
6990 (void *)&cmd_lfc_set_set,
6991 (void *)&cmd_lfc_set_flow_ctrl,
6992 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6993 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6994 (void *)&cmd_lfc_set_portid,
6999 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7000 .f = cmd_link_flow_ctrl_set_parsed,
7001 .data = (void *)&cmd_link_flow_control_set_autoneg,
7002 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7003 "Change autoneg flow control parameter",
7005 (void *)&cmd_lfc_set_set,
7006 (void *)&cmd_lfc_set_flow_ctrl,
7007 (void *)&cmd_lfc_set_autoneg_str,
7008 (void *)&cmd_lfc_set_autoneg,
7009 (void *)&cmd_lfc_set_portid,
7015 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7016 __rte_unused struct cmdline *cl,
7019 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7020 cmdline_parse_inst_t *cmd = data;
7021 struct rte_eth_fc_conf fc_conf;
7027 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7028 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7029 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7030 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7032 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7033 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7036 /* Partial command line, retrieve current configuration */
7038 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7040 printf("cannot get current flow ctrl parameters, return"
7041 "code = %d\n", ret);
7045 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7046 (fc_conf.mode == RTE_FC_FULL))
7048 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7049 (fc_conf.mode == RTE_FC_FULL))
7053 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7054 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7056 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7057 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7059 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7061 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7062 fc_conf.high_water = res->high_water;
7064 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7065 fc_conf.low_water = res->low_water;
7067 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7068 fc_conf.pause_time = res->pause_time;
7070 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7071 fc_conf.send_xon = res->send_xon;
7073 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7074 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7075 fc_conf.mac_ctrl_frame_fwd = 1;
7077 fc_conf.mac_ctrl_frame_fwd = 0;
7080 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7081 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7083 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7085 printf("bad flow contrl parameter, return code = %d \n", ret);
7088 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7089 struct cmd_priority_flow_ctrl_set_result {
7090 cmdline_fixed_string_t set;
7091 cmdline_fixed_string_t pfc_ctrl;
7092 cmdline_fixed_string_t rx;
7093 cmdline_fixed_string_t rx_pfc_mode;
7094 cmdline_fixed_string_t tx;
7095 cmdline_fixed_string_t tx_pfc_mode;
7096 uint32_t high_water;
7098 uint16_t pause_time;
7104 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7105 __rte_unused struct cmdline *cl,
7106 __rte_unused void *data)
7108 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7109 struct rte_eth_pfc_conf pfc_conf;
7110 int rx_fc_enable, tx_fc_enable;
7114 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7115 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7116 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7117 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7119 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7120 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7123 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7124 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7125 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7126 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7127 pfc_conf.fc.high_water = res->high_water;
7128 pfc_conf.fc.low_water = res->low_water;
7129 pfc_conf.fc.pause_time = res->pause_time;
7130 pfc_conf.priority = res->priority;
7132 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7134 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7137 cmdline_parse_token_string_t cmd_pfc_set_set =
7138 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7140 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7141 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7142 pfc_ctrl, "pfc_ctrl");
7143 cmdline_parse_token_string_t cmd_pfc_set_rx =
7144 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7146 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7147 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7148 rx_pfc_mode, "on#off");
7149 cmdline_parse_token_string_t cmd_pfc_set_tx =
7150 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7152 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7153 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7154 tx_pfc_mode, "on#off");
7155 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7156 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7157 high_water, UINT32);
7158 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7159 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7161 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7162 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7163 pause_time, UINT16);
7164 cmdline_parse_token_num_t cmd_pfc_set_priority =
7165 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7167 cmdline_parse_token_num_t cmd_pfc_set_portid =
7168 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7171 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7172 .f = cmd_priority_flow_ctrl_set_parsed,
7174 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7175 "<pause_time> <priority> <port_id>: "
7176 "Configure the Ethernet priority flow control",
7178 (void *)&cmd_pfc_set_set,
7179 (void *)&cmd_pfc_set_flow_ctrl,
7180 (void *)&cmd_pfc_set_rx,
7181 (void *)&cmd_pfc_set_rx_mode,
7182 (void *)&cmd_pfc_set_tx,
7183 (void *)&cmd_pfc_set_tx_mode,
7184 (void *)&cmd_pfc_set_high_water,
7185 (void *)&cmd_pfc_set_low_water,
7186 (void *)&cmd_pfc_set_pause_time,
7187 (void *)&cmd_pfc_set_priority,
7188 (void *)&cmd_pfc_set_portid,
7193 /* *** RESET CONFIGURATION *** */
7194 struct cmd_reset_result {
7195 cmdline_fixed_string_t reset;
7196 cmdline_fixed_string_t def;
7199 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7201 __rte_unused void *data)
7203 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7204 set_def_fwd_config();
7207 cmdline_parse_token_string_t cmd_reset_set =
7208 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7209 cmdline_parse_token_string_t cmd_reset_def =
7210 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7213 cmdline_parse_inst_t cmd_reset = {
7214 .f = cmd_reset_parsed,
7216 .help_str = "set default: Reset default forwarding configuration",
7218 (void *)&cmd_reset_set,
7219 (void *)&cmd_reset_def,
7224 /* *** START FORWARDING *** */
7225 struct cmd_start_result {
7226 cmdline_fixed_string_t start;
7229 cmdline_parse_token_string_t cmd_start_start =
7230 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7232 static void cmd_start_parsed(__rte_unused void *parsed_result,
7233 __rte_unused struct cmdline *cl,
7234 __rte_unused void *data)
7236 start_packet_forwarding(0);
7239 cmdline_parse_inst_t cmd_start = {
7240 .f = cmd_start_parsed,
7242 .help_str = "start: Start packet forwarding",
7244 (void *)&cmd_start_start,
7249 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7250 struct cmd_start_tx_first_result {
7251 cmdline_fixed_string_t start;
7252 cmdline_fixed_string_t tx_first;
7256 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7257 __rte_unused struct cmdline *cl,
7258 __rte_unused void *data)
7260 start_packet_forwarding(1);
7263 cmdline_parse_token_string_t cmd_start_tx_first_start =
7264 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7266 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7267 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7268 tx_first, "tx_first");
7270 cmdline_parse_inst_t cmd_start_tx_first = {
7271 .f = cmd_start_tx_first_parsed,
7273 .help_str = "start tx_first: Start packet forwarding, "
7274 "after sending 1 burst of packets",
7276 (void *)&cmd_start_tx_first_start,
7277 (void *)&cmd_start_tx_first_tx_first,
7282 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7283 struct cmd_start_tx_first_n_result {
7284 cmdline_fixed_string_t start;
7285 cmdline_fixed_string_t tx_first;
7290 cmd_start_tx_first_n_parsed(void *parsed_result,
7291 __rte_unused struct cmdline *cl,
7292 __rte_unused void *data)
7294 struct cmd_start_tx_first_n_result *res = parsed_result;
7296 start_packet_forwarding(res->tx_num);
7299 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7300 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7302 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7303 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7304 tx_first, "tx_first");
7305 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7306 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7309 cmdline_parse_inst_t cmd_start_tx_first_n = {
7310 .f = cmd_start_tx_first_n_parsed,
7312 .help_str = "start tx_first <num>: "
7313 "packet forwarding, after sending <num> bursts of packets",
7315 (void *)&cmd_start_tx_first_n_start,
7316 (void *)&cmd_start_tx_first_n_tx_first,
7317 (void *)&cmd_start_tx_first_n_tx_num,
7322 /* *** SET LINK UP *** */
7323 struct cmd_set_link_up_result {
7324 cmdline_fixed_string_t set;
7325 cmdline_fixed_string_t link_up;
7326 cmdline_fixed_string_t port;
7330 cmdline_parse_token_string_t cmd_set_link_up_set =
7331 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7332 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7333 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7335 cmdline_parse_token_string_t cmd_set_link_up_port =
7336 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7337 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7338 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7340 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7341 __rte_unused struct cmdline *cl,
7342 __rte_unused void *data)
7344 struct cmd_set_link_up_result *res = parsed_result;
7345 dev_set_link_up(res->port_id);
7348 cmdline_parse_inst_t cmd_set_link_up = {
7349 .f = cmd_set_link_up_parsed,
7351 .help_str = "set link-up port <port id>",
7353 (void *)&cmd_set_link_up_set,
7354 (void *)&cmd_set_link_up_link_up,
7355 (void *)&cmd_set_link_up_port,
7356 (void *)&cmd_set_link_up_port_id,
7361 /* *** SET LINK DOWN *** */
7362 struct cmd_set_link_down_result {
7363 cmdline_fixed_string_t set;
7364 cmdline_fixed_string_t link_down;
7365 cmdline_fixed_string_t port;
7369 cmdline_parse_token_string_t cmd_set_link_down_set =
7370 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7371 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7372 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7374 cmdline_parse_token_string_t cmd_set_link_down_port =
7375 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7376 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7377 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7379 static void cmd_set_link_down_parsed(
7380 __rte_unused void *parsed_result,
7381 __rte_unused struct cmdline *cl,
7382 __rte_unused void *data)
7384 struct cmd_set_link_down_result *res = parsed_result;
7385 dev_set_link_down(res->port_id);
7388 cmdline_parse_inst_t cmd_set_link_down = {
7389 .f = cmd_set_link_down_parsed,
7391 .help_str = "set link-down port <port id>",
7393 (void *)&cmd_set_link_down_set,
7394 (void *)&cmd_set_link_down_link_down,
7395 (void *)&cmd_set_link_down_port,
7396 (void *)&cmd_set_link_down_port_id,
7401 /* *** SHOW CFG *** */
7402 struct cmd_showcfg_result {
7403 cmdline_fixed_string_t show;
7404 cmdline_fixed_string_t cfg;
7405 cmdline_fixed_string_t what;
7408 static void cmd_showcfg_parsed(void *parsed_result,
7409 __rte_unused struct cmdline *cl,
7410 __rte_unused void *data)
7412 struct cmd_showcfg_result *res = parsed_result;
7413 if (!strcmp(res->what, "rxtx"))
7414 rxtx_config_display();
7415 else if (!strcmp(res->what, "cores"))
7416 fwd_lcores_config_display();
7417 else if (!strcmp(res->what, "fwd"))
7418 pkt_fwd_config_display(&cur_fwd_config);
7419 else if (!strcmp(res->what, "txpkts"))
7420 show_tx_pkt_segments();
7423 cmdline_parse_token_string_t cmd_showcfg_show =
7424 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7425 cmdline_parse_token_string_t cmd_showcfg_port =
7426 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7427 cmdline_parse_token_string_t cmd_showcfg_what =
7428 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7429 "rxtx#cores#fwd#txpkts");
7431 cmdline_parse_inst_t cmd_showcfg = {
7432 .f = cmd_showcfg_parsed,
7434 .help_str = "show config rxtx|cores|fwd|txpkts",
7436 (void *)&cmd_showcfg_show,
7437 (void *)&cmd_showcfg_port,
7438 (void *)&cmd_showcfg_what,
7443 /* *** SHOW ALL PORT INFO *** */
7444 struct cmd_showportall_result {
7445 cmdline_fixed_string_t show;
7446 cmdline_fixed_string_t port;
7447 cmdline_fixed_string_t what;
7448 cmdline_fixed_string_t all;
7451 static void cmd_showportall_parsed(void *parsed_result,
7452 __rte_unused struct cmdline *cl,
7453 __rte_unused void *data)
7457 struct cmd_showportall_result *res = parsed_result;
7458 if (!strcmp(res->show, "clear")) {
7459 if (!strcmp(res->what, "stats"))
7460 RTE_ETH_FOREACH_DEV(i)
7462 else if (!strcmp(res->what, "xstats"))
7463 RTE_ETH_FOREACH_DEV(i)
7464 nic_xstats_clear(i);
7465 } else if (!strcmp(res->what, "info"))
7466 RTE_ETH_FOREACH_DEV(i)
7467 port_infos_display(i);
7468 else if (!strcmp(res->what, "summary")) {
7469 port_summary_header_display();
7470 RTE_ETH_FOREACH_DEV(i)
7471 port_summary_display(i);
7473 else if (!strcmp(res->what, "stats"))
7474 RTE_ETH_FOREACH_DEV(i)
7475 nic_stats_display(i);
7476 else if (!strcmp(res->what, "xstats"))
7477 RTE_ETH_FOREACH_DEV(i)
7478 nic_xstats_display(i);
7479 else if (!strcmp(res->what, "fdir"))
7480 RTE_ETH_FOREACH_DEV(i)
7482 else if (!strcmp(res->what, "stat_qmap"))
7483 RTE_ETH_FOREACH_DEV(i)
7484 nic_stats_mapping_display(i);
7485 else if (!strcmp(res->what, "dcb_tc"))
7486 RTE_ETH_FOREACH_DEV(i)
7487 port_dcb_info_display(i);
7488 else if (!strcmp(res->what, "cap"))
7489 RTE_ETH_FOREACH_DEV(i)
7490 port_offload_cap_display(i);
7493 cmdline_parse_token_string_t cmd_showportall_show =
7494 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7496 cmdline_parse_token_string_t cmd_showportall_port =
7497 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7498 cmdline_parse_token_string_t cmd_showportall_what =
7499 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7500 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7501 cmdline_parse_token_string_t cmd_showportall_all =
7502 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7503 cmdline_parse_inst_t cmd_showportall = {
7504 .f = cmd_showportall_parsed,
7506 .help_str = "show|clear port "
7507 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7509 (void *)&cmd_showportall_show,
7510 (void *)&cmd_showportall_port,
7511 (void *)&cmd_showportall_what,
7512 (void *)&cmd_showportall_all,
7517 /* *** SHOW PORT INFO *** */
7518 struct cmd_showport_result {
7519 cmdline_fixed_string_t show;
7520 cmdline_fixed_string_t port;
7521 cmdline_fixed_string_t what;
7525 static void cmd_showport_parsed(void *parsed_result,
7526 __rte_unused struct cmdline *cl,
7527 __rte_unused void *data)
7529 struct cmd_showport_result *res = parsed_result;
7530 if (!strcmp(res->show, "clear")) {
7531 if (!strcmp(res->what, "stats"))
7532 nic_stats_clear(res->portnum);
7533 else if (!strcmp(res->what, "xstats"))
7534 nic_xstats_clear(res->portnum);
7535 } else if (!strcmp(res->what, "info"))
7536 port_infos_display(res->portnum);
7537 else if (!strcmp(res->what, "summary")) {
7538 port_summary_header_display();
7539 port_summary_display(res->portnum);
7541 else if (!strcmp(res->what, "stats"))
7542 nic_stats_display(res->portnum);
7543 else if (!strcmp(res->what, "xstats"))
7544 nic_xstats_display(res->portnum);
7545 else if (!strcmp(res->what, "fdir"))
7546 fdir_get_infos(res->portnum);
7547 else if (!strcmp(res->what, "stat_qmap"))
7548 nic_stats_mapping_display(res->portnum);
7549 else if (!strcmp(res->what, "dcb_tc"))
7550 port_dcb_info_display(res->portnum);
7551 else if (!strcmp(res->what, "cap"))
7552 port_offload_cap_display(res->portnum);
7555 cmdline_parse_token_string_t cmd_showport_show =
7556 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7558 cmdline_parse_token_string_t cmd_showport_port =
7559 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7560 cmdline_parse_token_string_t cmd_showport_what =
7561 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7562 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7563 cmdline_parse_token_num_t cmd_showport_portnum =
7564 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7566 cmdline_parse_inst_t cmd_showport = {
7567 .f = cmd_showport_parsed,
7569 .help_str = "show|clear port "
7570 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7573 (void *)&cmd_showport_show,
7574 (void *)&cmd_showport_port,
7575 (void *)&cmd_showport_what,
7576 (void *)&cmd_showport_portnum,
7581 /* *** SHOW DEVICE INFO *** */
7582 struct cmd_showdevice_result {
7583 cmdline_fixed_string_t show;
7584 cmdline_fixed_string_t device;
7585 cmdline_fixed_string_t what;
7586 cmdline_fixed_string_t identifier;
7589 static void cmd_showdevice_parsed(void *parsed_result,
7590 __rte_unused struct cmdline *cl,
7591 __rte_unused void *data)
7593 struct cmd_showdevice_result *res = parsed_result;
7594 if (!strcmp(res->what, "info")) {
7595 if (!strcmp(res->identifier, "all"))
7596 device_infos_display(NULL);
7598 device_infos_display(res->identifier);
7602 cmdline_parse_token_string_t cmd_showdevice_show =
7603 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7605 cmdline_parse_token_string_t cmd_showdevice_device =
7606 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7607 cmdline_parse_token_string_t cmd_showdevice_what =
7608 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7610 cmdline_parse_token_string_t cmd_showdevice_identifier =
7611 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7614 cmdline_parse_inst_t cmd_showdevice = {
7615 .f = cmd_showdevice_parsed,
7617 .help_str = "show device info <identifier>|all",
7619 (void *)&cmd_showdevice_show,
7620 (void *)&cmd_showdevice_device,
7621 (void *)&cmd_showdevice_what,
7622 (void *)&cmd_showdevice_identifier,
7626 /* *** SHOW QUEUE INFO *** */
7627 struct cmd_showqueue_result {
7628 cmdline_fixed_string_t show;
7629 cmdline_fixed_string_t type;
7630 cmdline_fixed_string_t what;
7636 cmd_showqueue_parsed(void *parsed_result,
7637 __rte_unused struct cmdline *cl,
7638 __rte_unused void *data)
7640 struct cmd_showqueue_result *res = parsed_result;
7642 if (!strcmp(res->type, "rxq"))
7643 rx_queue_infos_display(res->portnum, res->queuenum);
7644 else if (!strcmp(res->type, "txq"))
7645 tx_queue_infos_display(res->portnum, res->queuenum);
7648 cmdline_parse_token_string_t cmd_showqueue_show =
7649 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7650 cmdline_parse_token_string_t cmd_showqueue_type =
7651 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7652 cmdline_parse_token_string_t cmd_showqueue_what =
7653 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7654 cmdline_parse_token_num_t cmd_showqueue_portnum =
7655 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7656 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7657 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7659 cmdline_parse_inst_t cmd_showqueue = {
7660 .f = cmd_showqueue_parsed,
7662 .help_str = "show rxq|txq info <port_id> <queue_id>",
7664 (void *)&cmd_showqueue_show,
7665 (void *)&cmd_showqueue_type,
7666 (void *)&cmd_showqueue_what,
7667 (void *)&cmd_showqueue_portnum,
7668 (void *)&cmd_showqueue_queuenum,
7673 /* show/clear fwd engine statistics */
7675 cmdline_fixed_string_t action;
7676 cmdline_fixed_string_t fwd;
7677 cmdline_fixed_string_t stats;
7678 cmdline_fixed_string_t all;
7681 cmdline_parse_token_string_t cmd_fwd_action =
7682 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7683 cmdline_parse_token_string_t cmd_fwd_fwd =
7684 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7685 cmdline_parse_token_string_t cmd_fwd_stats =
7686 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7687 cmdline_parse_token_string_t cmd_fwd_all =
7688 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7691 cmd_showfwdall_parsed(void *parsed_result,
7692 __rte_unused struct cmdline *cl,
7693 __rte_unused void *data)
7695 struct fwd_result *res = parsed_result;
7697 if (!strcmp(res->action, "show"))
7698 fwd_stats_display();
7703 static cmdline_parse_inst_t cmd_showfwdall = {
7704 .f = cmd_showfwdall_parsed,
7706 .help_str = "show|clear fwd stats all",
7708 (void *)&cmd_fwd_action,
7709 (void *)&cmd_fwd_fwd,
7710 (void *)&cmd_fwd_stats,
7711 (void *)&cmd_fwd_all,
7716 /* *** READ PORT REGISTER *** */
7717 struct cmd_read_reg_result {
7718 cmdline_fixed_string_t read;
7719 cmdline_fixed_string_t reg;
7725 cmd_read_reg_parsed(void *parsed_result,
7726 __rte_unused struct cmdline *cl,
7727 __rte_unused void *data)
7729 struct cmd_read_reg_result *res = parsed_result;
7730 port_reg_display(res->port_id, res->reg_off);
7733 cmdline_parse_token_string_t cmd_read_reg_read =
7734 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7735 cmdline_parse_token_string_t cmd_read_reg_reg =
7736 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7737 cmdline_parse_token_num_t cmd_read_reg_port_id =
7738 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7739 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7740 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7742 cmdline_parse_inst_t cmd_read_reg = {
7743 .f = cmd_read_reg_parsed,
7745 .help_str = "read reg <port_id> <reg_off>",
7747 (void *)&cmd_read_reg_read,
7748 (void *)&cmd_read_reg_reg,
7749 (void *)&cmd_read_reg_port_id,
7750 (void *)&cmd_read_reg_reg_off,
7755 /* *** READ PORT REGISTER BIT FIELD *** */
7756 struct cmd_read_reg_bit_field_result {
7757 cmdline_fixed_string_t read;
7758 cmdline_fixed_string_t regfield;
7766 cmd_read_reg_bit_field_parsed(void *parsed_result,
7767 __rte_unused struct cmdline *cl,
7768 __rte_unused void *data)
7770 struct cmd_read_reg_bit_field_result *res = parsed_result;
7771 port_reg_bit_field_display(res->port_id, res->reg_off,
7772 res->bit1_pos, res->bit2_pos);
7775 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7776 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7778 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7779 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7780 regfield, "regfield");
7781 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7782 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7784 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7785 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7787 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7788 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7790 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7791 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7794 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7795 .f = cmd_read_reg_bit_field_parsed,
7797 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7798 "Read register bit field between bit_x and bit_y included",
7800 (void *)&cmd_read_reg_bit_field_read,
7801 (void *)&cmd_read_reg_bit_field_regfield,
7802 (void *)&cmd_read_reg_bit_field_port_id,
7803 (void *)&cmd_read_reg_bit_field_reg_off,
7804 (void *)&cmd_read_reg_bit_field_bit1_pos,
7805 (void *)&cmd_read_reg_bit_field_bit2_pos,
7810 /* *** READ PORT REGISTER BIT *** */
7811 struct cmd_read_reg_bit_result {
7812 cmdline_fixed_string_t read;
7813 cmdline_fixed_string_t regbit;
7820 cmd_read_reg_bit_parsed(void *parsed_result,
7821 __rte_unused struct cmdline *cl,
7822 __rte_unused void *data)
7824 struct cmd_read_reg_bit_result *res = parsed_result;
7825 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7828 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7829 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7830 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7831 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7833 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7834 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7835 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7836 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7837 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7838 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7840 cmdline_parse_inst_t cmd_read_reg_bit = {
7841 .f = cmd_read_reg_bit_parsed,
7843 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7845 (void *)&cmd_read_reg_bit_read,
7846 (void *)&cmd_read_reg_bit_regbit,
7847 (void *)&cmd_read_reg_bit_port_id,
7848 (void *)&cmd_read_reg_bit_reg_off,
7849 (void *)&cmd_read_reg_bit_bit_pos,
7854 /* *** WRITE PORT REGISTER *** */
7855 struct cmd_write_reg_result {
7856 cmdline_fixed_string_t write;
7857 cmdline_fixed_string_t reg;
7864 cmd_write_reg_parsed(void *parsed_result,
7865 __rte_unused struct cmdline *cl,
7866 __rte_unused void *data)
7868 struct cmd_write_reg_result *res = parsed_result;
7869 port_reg_set(res->port_id, res->reg_off, res->value);
7872 cmdline_parse_token_string_t cmd_write_reg_write =
7873 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7874 cmdline_parse_token_string_t cmd_write_reg_reg =
7875 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7876 cmdline_parse_token_num_t cmd_write_reg_port_id =
7877 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7878 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7879 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7880 cmdline_parse_token_num_t cmd_write_reg_value =
7881 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7883 cmdline_parse_inst_t cmd_write_reg = {
7884 .f = cmd_write_reg_parsed,
7886 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7888 (void *)&cmd_write_reg_write,
7889 (void *)&cmd_write_reg_reg,
7890 (void *)&cmd_write_reg_port_id,
7891 (void *)&cmd_write_reg_reg_off,
7892 (void *)&cmd_write_reg_value,
7897 /* *** WRITE PORT REGISTER BIT FIELD *** */
7898 struct cmd_write_reg_bit_field_result {
7899 cmdline_fixed_string_t write;
7900 cmdline_fixed_string_t regfield;
7909 cmd_write_reg_bit_field_parsed(void *parsed_result,
7910 __rte_unused struct cmdline *cl,
7911 __rte_unused void *data)
7913 struct cmd_write_reg_bit_field_result *res = parsed_result;
7914 port_reg_bit_field_set(res->port_id, res->reg_off,
7915 res->bit1_pos, res->bit2_pos, res->value);
7918 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7919 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7921 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7922 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7923 regfield, "regfield");
7924 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7925 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7927 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7928 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7930 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7931 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7933 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7934 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7936 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7937 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7940 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7941 .f = cmd_write_reg_bit_field_parsed,
7943 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7945 "Set register bit field between bit_x and bit_y included",
7947 (void *)&cmd_write_reg_bit_field_write,
7948 (void *)&cmd_write_reg_bit_field_regfield,
7949 (void *)&cmd_write_reg_bit_field_port_id,
7950 (void *)&cmd_write_reg_bit_field_reg_off,
7951 (void *)&cmd_write_reg_bit_field_bit1_pos,
7952 (void *)&cmd_write_reg_bit_field_bit2_pos,
7953 (void *)&cmd_write_reg_bit_field_value,
7958 /* *** WRITE PORT REGISTER BIT *** */
7959 struct cmd_write_reg_bit_result {
7960 cmdline_fixed_string_t write;
7961 cmdline_fixed_string_t regbit;
7969 cmd_write_reg_bit_parsed(void *parsed_result,
7970 __rte_unused struct cmdline *cl,
7971 __rte_unused void *data)
7973 struct cmd_write_reg_bit_result *res = parsed_result;
7974 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7977 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7978 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7980 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7981 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7983 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7984 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7985 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7986 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7987 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7988 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7989 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7990 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7992 cmdline_parse_inst_t cmd_write_reg_bit = {
7993 .f = cmd_write_reg_bit_parsed,
7995 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7998 (void *)&cmd_write_reg_bit_write,
7999 (void *)&cmd_write_reg_bit_regbit,
8000 (void *)&cmd_write_reg_bit_port_id,
8001 (void *)&cmd_write_reg_bit_reg_off,
8002 (void *)&cmd_write_reg_bit_bit_pos,
8003 (void *)&cmd_write_reg_bit_value,
8008 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8009 struct cmd_read_rxd_txd_result {
8010 cmdline_fixed_string_t read;
8011 cmdline_fixed_string_t rxd_txd;
8018 cmd_read_rxd_txd_parsed(void *parsed_result,
8019 __rte_unused struct cmdline *cl,
8020 __rte_unused void *data)
8022 struct cmd_read_rxd_txd_result *res = parsed_result;
8024 if (!strcmp(res->rxd_txd, "rxd"))
8025 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8026 else if (!strcmp(res->rxd_txd, "txd"))
8027 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8030 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8031 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8032 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8033 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8035 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8036 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8037 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8038 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8039 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8040 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8042 cmdline_parse_inst_t cmd_read_rxd_txd = {
8043 .f = cmd_read_rxd_txd_parsed,
8045 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8047 (void *)&cmd_read_rxd_txd_read,
8048 (void *)&cmd_read_rxd_txd_rxd_txd,
8049 (void *)&cmd_read_rxd_txd_port_id,
8050 (void *)&cmd_read_rxd_txd_queue_id,
8051 (void *)&cmd_read_rxd_txd_desc_id,
8057 struct cmd_quit_result {
8058 cmdline_fixed_string_t quit;
8061 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8063 __rte_unused void *data)
8068 cmdline_parse_token_string_t cmd_quit_quit =
8069 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8071 cmdline_parse_inst_t cmd_quit = {
8072 .f = cmd_quit_parsed,
8074 .help_str = "quit: Exit application",
8076 (void *)&cmd_quit_quit,
8081 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8082 struct cmd_mac_addr_result {
8083 cmdline_fixed_string_t mac_addr_cmd;
8084 cmdline_fixed_string_t what;
8086 struct rte_ether_addr address;
8089 static void cmd_mac_addr_parsed(void *parsed_result,
8090 __rte_unused struct cmdline *cl,
8091 __rte_unused void *data)
8093 struct cmd_mac_addr_result *res = parsed_result;
8096 if (strcmp(res->what, "add") == 0)
8097 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8098 else if (strcmp(res->what, "set") == 0)
8099 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8102 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8104 /* check the return value and print it if is < 0 */
8106 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8110 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8111 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8113 cmdline_parse_token_string_t cmd_mac_addr_what =
8114 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8116 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8117 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8119 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8120 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8122 cmdline_parse_inst_t cmd_mac_addr = {
8123 .f = cmd_mac_addr_parsed,
8125 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8126 "Add/Remove/Set MAC address on port_id",
8128 (void *)&cmd_mac_addr_cmd,
8129 (void *)&cmd_mac_addr_what,
8130 (void *)&cmd_mac_addr_portnum,
8131 (void *)&cmd_mac_addr_addr,
8136 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8137 struct cmd_eth_peer_result {
8138 cmdline_fixed_string_t set;
8139 cmdline_fixed_string_t eth_peer;
8141 cmdline_fixed_string_t peer_addr;
8144 static void cmd_set_eth_peer_parsed(void *parsed_result,
8145 __rte_unused struct cmdline *cl,
8146 __rte_unused void *data)
8148 struct cmd_eth_peer_result *res = parsed_result;
8150 if (test_done == 0) {
8151 printf("Please stop forwarding first\n");
8154 if (!strcmp(res->eth_peer, "eth-peer")) {
8155 set_fwd_eth_peer(res->port_id, res->peer_addr);
8159 cmdline_parse_token_string_t cmd_eth_peer_set =
8160 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8161 cmdline_parse_token_string_t cmd_eth_peer =
8162 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8163 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8164 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8165 cmdline_parse_token_string_t cmd_eth_peer_addr =
8166 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8168 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8169 .f = cmd_set_eth_peer_parsed,
8171 .help_str = "set eth-peer <port_id> <peer_mac>",
8173 (void *)&cmd_eth_peer_set,
8174 (void *)&cmd_eth_peer,
8175 (void *)&cmd_eth_peer_port_id,
8176 (void *)&cmd_eth_peer_addr,
8181 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8182 struct cmd_set_qmap_result {
8183 cmdline_fixed_string_t set;
8184 cmdline_fixed_string_t qmap;
8185 cmdline_fixed_string_t what;
8192 cmd_set_qmap_parsed(void *parsed_result,
8193 __rte_unused struct cmdline *cl,
8194 __rte_unused void *data)
8196 struct cmd_set_qmap_result *res = parsed_result;
8197 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8199 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8202 cmdline_parse_token_string_t cmd_setqmap_set =
8203 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8205 cmdline_parse_token_string_t cmd_setqmap_qmap =
8206 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8208 cmdline_parse_token_string_t cmd_setqmap_what =
8209 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8211 cmdline_parse_token_num_t cmd_setqmap_portid =
8212 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8214 cmdline_parse_token_num_t cmd_setqmap_queueid =
8215 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8217 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8218 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8221 cmdline_parse_inst_t cmd_set_qmap = {
8222 .f = cmd_set_qmap_parsed,
8224 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8225 "Set statistics mapping value on tx|rx queue_id of port_id",
8227 (void *)&cmd_setqmap_set,
8228 (void *)&cmd_setqmap_qmap,
8229 (void *)&cmd_setqmap_what,
8230 (void *)&cmd_setqmap_portid,
8231 (void *)&cmd_setqmap_queueid,
8232 (void *)&cmd_setqmap_mapvalue,
8237 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8238 struct cmd_set_xstats_hide_zero_result {
8239 cmdline_fixed_string_t keyword;
8240 cmdline_fixed_string_t name;
8241 cmdline_fixed_string_t on_off;
8245 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8246 __rte_unused struct cmdline *cl,
8247 __rte_unused void *data)
8249 struct cmd_set_xstats_hide_zero_result *res;
8250 uint16_t on_off = 0;
8252 res = parsed_result;
8253 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8254 set_xstats_hide_zero(on_off);
8257 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8258 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8260 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8261 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8262 name, "xstats-hide-zero");
8263 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8264 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8267 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8268 .f = cmd_set_xstats_hide_zero_parsed,
8270 .help_str = "set xstats-hide-zero on|off",
8272 (void *)&cmd_set_xstats_hide_zero_keyword,
8273 (void *)&cmd_set_xstats_hide_zero_name,
8274 (void *)&cmd_set_xstats_hide_zero_on_off,
8279 /* *** CONFIGURE UNICAST HASH TABLE *** */
8280 struct cmd_set_uc_hash_table {
8281 cmdline_fixed_string_t set;
8282 cmdline_fixed_string_t port;
8284 cmdline_fixed_string_t what;
8285 struct rte_ether_addr address;
8286 cmdline_fixed_string_t mode;
8290 cmd_set_uc_hash_parsed(void *parsed_result,
8291 __rte_unused struct cmdline *cl,
8292 __rte_unused void *data)
8295 struct cmd_set_uc_hash_table *res = parsed_result;
8297 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8299 if (strcmp(res->what, "uta") == 0)
8300 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8301 &res->address,(uint8_t)is_on);
8303 printf("bad unicast hash table parameter, return code = %d \n", ret);
8307 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8308 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8310 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8311 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8313 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8314 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8316 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8317 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8319 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8320 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8322 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8323 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8326 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8327 .f = cmd_set_uc_hash_parsed,
8329 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8331 (void *)&cmd_set_uc_hash_set,
8332 (void *)&cmd_set_uc_hash_port,
8333 (void *)&cmd_set_uc_hash_portid,
8334 (void *)&cmd_set_uc_hash_what,
8335 (void *)&cmd_set_uc_hash_mac,
8336 (void *)&cmd_set_uc_hash_mode,
8341 struct cmd_set_uc_all_hash_table {
8342 cmdline_fixed_string_t set;
8343 cmdline_fixed_string_t port;
8345 cmdline_fixed_string_t what;
8346 cmdline_fixed_string_t value;
8347 cmdline_fixed_string_t mode;
8351 cmd_set_uc_all_hash_parsed(void *parsed_result,
8352 __rte_unused struct cmdline *cl,
8353 __rte_unused void *data)
8356 struct cmd_set_uc_all_hash_table *res = parsed_result;
8358 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8360 if ((strcmp(res->what, "uta") == 0) &&
8361 (strcmp(res->value, "all") == 0))
8362 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8364 printf("bad unicast hash table parameter,"
8365 "return code = %d \n", ret);
8368 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8369 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8371 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8372 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8374 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8375 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8377 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8378 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8380 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8381 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8383 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8384 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8387 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8388 .f = cmd_set_uc_all_hash_parsed,
8390 .help_str = "set port <port_id> uta all on|off",
8392 (void *)&cmd_set_uc_all_hash_set,
8393 (void *)&cmd_set_uc_all_hash_port,
8394 (void *)&cmd_set_uc_all_hash_portid,
8395 (void *)&cmd_set_uc_all_hash_what,
8396 (void *)&cmd_set_uc_all_hash_value,
8397 (void *)&cmd_set_uc_all_hash_mode,
8402 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8403 struct cmd_set_vf_macvlan_filter {
8404 cmdline_fixed_string_t set;
8405 cmdline_fixed_string_t port;
8407 cmdline_fixed_string_t vf;
8409 struct rte_ether_addr address;
8410 cmdline_fixed_string_t filter_type;
8411 cmdline_fixed_string_t mode;
8415 cmd_set_vf_macvlan_parsed(void *parsed_result,
8416 __rte_unused struct cmdline *cl,
8417 __rte_unused void *data)
8420 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8421 struct rte_eth_mac_filter filter;
8423 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8425 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8427 /* set VF MAC filter */
8431 filter.dst_id = res->vf_id;
8433 if (!strcmp(res->filter_type, "exact-mac"))
8434 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8435 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8436 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8437 else if (!strcmp(res->filter_type, "hashmac"))
8438 filter.filter_type = RTE_MAC_HASH_MATCH;
8439 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8440 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8442 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8445 ret = rte_eth_dev_filter_ctrl(res->port_id,
8446 RTE_ETH_FILTER_MACVLAN,
8450 ret = rte_eth_dev_filter_ctrl(res->port_id,
8451 RTE_ETH_FILTER_MACVLAN,
8452 RTE_ETH_FILTER_DELETE,
8456 printf("bad set MAC hash parameter, return code = %d\n", ret);
8460 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8461 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8463 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8464 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8466 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8467 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8469 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8470 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8472 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8473 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8475 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8476 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8478 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8479 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8480 filter_type, "exact-mac#exact-mac-vlan"
8481 "#hashmac#hashmac-vlan");
8482 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8483 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8486 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8487 .f = cmd_set_vf_macvlan_parsed,
8489 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8490 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8491 "Exact match rule: exact match of MAC or MAC and VLAN; "
8492 "hash match rule: hash match of MAC and exact match of VLAN",
8494 (void *)&cmd_set_vf_macvlan_set,
8495 (void *)&cmd_set_vf_macvlan_port,
8496 (void *)&cmd_set_vf_macvlan_portid,
8497 (void *)&cmd_set_vf_macvlan_vf,
8498 (void *)&cmd_set_vf_macvlan_vf_id,
8499 (void *)&cmd_set_vf_macvlan_mac,
8500 (void *)&cmd_set_vf_macvlan_filter_type,
8501 (void *)&cmd_set_vf_macvlan_mode,
8506 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8507 struct cmd_set_vf_traffic {
8508 cmdline_fixed_string_t set;
8509 cmdline_fixed_string_t port;
8511 cmdline_fixed_string_t vf;
8513 cmdline_fixed_string_t what;
8514 cmdline_fixed_string_t mode;
8518 cmd_set_vf_traffic_parsed(void *parsed_result,
8519 __rte_unused struct cmdline *cl,
8520 __rte_unused void *data)
8522 struct cmd_set_vf_traffic *res = parsed_result;
8523 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8524 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8526 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8529 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8530 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8532 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8533 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8535 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8536 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8538 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8539 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8541 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8542 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8544 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8545 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8547 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8548 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8551 cmdline_parse_inst_t cmd_set_vf_traffic = {
8552 .f = cmd_set_vf_traffic_parsed,
8554 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8556 (void *)&cmd_setvf_traffic_set,
8557 (void *)&cmd_setvf_traffic_port,
8558 (void *)&cmd_setvf_traffic_portid,
8559 (void *)&cmd_setvf_traffic_vf,
8560 (void *)&cmd_setvf_traffic_vfid,
8561 (void *)&cmd_setvf_traffic_what,
8562 (void *)&cmd_setvf_traffic_mode,
8567 /* *** CONFIGURE VF RECEIVE MODE *** */
8568 struct cmd_set_vf_rxmode {
8569 cmdline_fixed_string_t set;
8570 cmdline_fixed_string_t port;
8572 cmdline_fixed_string_t vf;
8574 cmdline_fixed_string_t what;
8575 cmdline_fixed_string_t mode;
8576 cmdline_fixed_string_t on;
8580 cmd_set_vf_rxmode_parsed(void *parsed_result,
8581 __rte_unused struct cmdline *cl,
8582 __rte_unused void *data)
8585 uint16_t vf_rxmode = 0;
8586 struct cmd_set_vf_rxmode *res = parsed_result;
8588 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8589 if (!strcmp(res->what,"rxmode")) {
8590 if (!strcmp(res->mode, "AUPE"))
8591 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8592 else if (!strcmp(res->mode, "ROPE"))
8593 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8594 else if (!strcmp(res->mode, "BAM"))
8595 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8596 else if (!strncmp(res->mode, "MPE",3))
8597 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8600 RTE_SET_USED(is_on);
8602 #ifdef RTE_LIBRTE_IXGBE_PMD
8603 if (ret == -ENOTSUP)
8604 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8605 vf_rxmode, (uint8_t)is_on);
8607 #ifdef RTE_LIBRTE_BNXT_PMD
8608 if (ret == -ENOTSUP)
8609 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8610 vf_rxmode, (uint8_t)is_on);
8613 printf("bad VF receive mode parameter, return code = %d \n",
8617 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8618 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8620 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8621 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8623 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8624 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8626 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8627 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8629 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8630 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8632 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8633 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8635 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8636 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8637 mode, "AUPE#ROPE#BAM#MPE");
8638 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8639 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8642 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8643 .f = cmd_set_vf_rxmode_parsed,
8645 .help_str = "set port <port_id> vf <vf_id> rxmode "
8646 "AUPE|ROPE|BAM|MPE on|off",
8648 (void *)&cmd_set_vf_rxmode_set,
8649 (void *)&cmd_set_vf_rxmode_port,
8650 (void *)&cmd_set_vf_rxmode_portid,
8651 (void *)&cmd_set_vf_rxmode_vf,
8652 (void *)&cmd_set_vf_rxmode_vfid,
8653 (void *)&cmd_set_vf_rxmode_what,
8654 (void *)&cmd_set_vf_rxmode_mode,
8655 (void *)&cmd_set_vf_rxmode_on,
8660 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8661 struct cmd_vf_mac_addr_result {
8662 cmdline_fixed_string_t mac_addr_cmd;
8663 cmdline_fixed_string_t what;
8664 cmdline_fixed_string_t port;
8666 cmdline_fixed_string_t vf;
8668 struct rte_ether_addr address;
8671 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8672 __rte_unused struct cmdline *cl,
8673 __rte_unused void *data)
8675 struct cmd_vf_mac_addr_result *res = parsed_result;
8678 if (strcmp(res->what, "add") != 0)
8681 #ifdef RTE_LIBRTE_I40E_PMD
8682 if (ret == -ENOTSUP)
8683 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8686 #ifdef RTE_LIBRTE_BNXT_PMD
8687 if (ret == -ENOTSUP)
8688 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8693 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8697 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8698 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8699 mac_addr_cmd,"mac_addr");
8700 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8701 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8703 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8704 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8706 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8707 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8709 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8710 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8712 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8713 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8715 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8716 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8719 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8720 .f = cmd_vf_mac_addr_parsed,
8722 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8723 "Add MAC address filtering for a VF on port_id",
8725 (void *)&cmd_vf_mac_addr_cmd,
8726 (void *)&cmd_vf_mac_addr_what,
8727 (void *)&cmd_vf_mac_addr_port,
8728 (void *)&cmd_vf_mac_addr_portnum,
8729 (void *)&cmd_vf_mac_addr_vf,
8730 (void *)&cmd_vf_mac_addr_vfnum,
8731 (void *)&cmd_vf_mac_addr_addr,
8736 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8737 struct cmd_vf_rx_vlan_filter {
8738 cmdline_fixed_string_t rx_vlan;
8739 cmdline_fixed_string_t what;
8741 cmdline_fixed_string_t port;
8743 cmdline_fixed_string_t vf;
8748 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8749 __rte_unused struct cmdline *cl,
8750 __rte_unused void *data)
8752 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8755 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8757 #ifdef RTE_LIBRTE_IXGBE_PMD
8758 if (ret == -ENOTSUP)
8759 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8760 res->vlan_id, res->vf_mask, is_add);
8762 #ifdef RTE_LIBRTE_I40E_PMD
8763 if (ret == -ENOTSUP)
8764 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8765 res->vlan_id, res->vf_mask, is_add);
8767 #ifdef RTE_LIBRTE_BNXT_PMD
8768 if (ret == -ENOTSUP)
8769 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8770 res->vlan_id, res->vf_mask, is_add);
8777 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8778 res->vlan_id, res->vf_mask);
8781 printf("invalid port_id %d\n", res->port_id);
8784 printf("function not implemented or supported\n");
8787 printf("programming error: (%s)\n", strerror(-ret));
8791 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8792 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8793 rx_vlan, "rx_vlan");
8794 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8795 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8797 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8798 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8800 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8801 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8803 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8804 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8806 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8807 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8809 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8810 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8813 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8814 .f = cmd_vf_rx_vlan_filter_parsed,
8816 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8817 "(vf_mask = hexadecimal VF mask)",
8819 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8820 (void *)&cmd_vf_rx_vlan_filter_what,
8821 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8822 (void *)&cmd_vf_rx_vlan_filter_port,
8823 (void *)&cmd_vf_rx_vlan_filter_portid,
8824 (void *)&cmd_vf_rx_vlan_filter_vf,
8825 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8830 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8831 struct cmd_queue_rate_limit_result {
8832 cmdline_fixed_string_t set;
8833 cmdline_fixed_string_t port;
8835 cmdline_fixed_string_t queue;
8837 cmdline_fixed_string_t rate;
8841 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8842 __rte_unused struct cmdline *cl,
8843 __rte_unused void *data)
8845 struct cmd_queue_rate_limit_result *res = parsed_result;
8848 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8849 && (strcmp(res->queue, "queue") == 0)
8850 && (strcmp(res->rate, "rate") == 0))
8851 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8854 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8858 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8859 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8861 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8862 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8864 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8865 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8867 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8868 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8870 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8871 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8873 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8874 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8876 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8877 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8880 cmdline_parse_inst_t cmd_queue_rate_limit = {
8881 .f = cmd_queue_rate_limit_parsed,
8883 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8884 "Set rate limit for a queue on port_id",
8886 (void *)&cmd_queue_rate_limit_set,
8887 (void *)&cmd_queue_rate_limit_port,
8888 (void *)&cmd_queue_rate_limit_portnum,
8889 (void *)&cmd_queue_rate_limit_queue,
8890 (void *)&cmd_queue_rate_limit_queuenum,
8891 (void *)&cmd_queue_rate_limit_rate,
8892 (void *)&cmd_queue_rate_limit_ratenum,
8897 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8898 struct cmd_vf_rate_limit_result {
8899 cmdline_fixed_string_t set;
8900 cmdline_fixed_string_t port;
8902 cmdline_fixed_string_t vf;
8904 cmdline_fixed_string_t rate;
8906 cmdline_fixed_string_t q_msk;
8910 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8911 __rte_unused struct cmdline *cl,
8912 __rte_unused void *data)
8914 struct cmd_vf_rate_limit_result *res = parsed_result;
8917 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8918 && (strcmp(res->vf, "vf") == 0)
8919 && (strcmp(res->rate, "rate") == 0)
8920 && (strcmp(res->q_msk, "queue_mask") == 0))
8921 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8922 res->rate_num, res->q_msk_val);
8924 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8928 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8929 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8931 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8932 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8934 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8935 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8937 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8938 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8940 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8941 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8943 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8944 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8946 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8947 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8949 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8950 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8951 q_msk, "queue_mask");
8952 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8953 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8956 cmdline_parse_inst_t cmd_vf_rate_limit = {
8957 .f = cmd_vf_rate_limit_parsed,
8959 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8960 "queue_mask <queue_mask_value>: "
8961 "Set rate limit for queues of VF on port_id",
8963 (void *)&cmd_vf_rate_limit_set,
8964 (void *)&cmd_vf_rate_limit_port,
8965 (void *)&cmd_vf_rate_limit_portnum,
8966 (void *)&cmd_vf_rate_limit_vf,
8967 (void *)&cmd_vf_rate_limit_vfnum,
8968 (void *)&cmd_vf_rate_limit_rate,
8969 (void *)&cmd_vf_rate_limit_ratenum,
8970 (void *)&cmd_vf_rate_limit_q_msk,
8971 (void *)&cmd_vf_rate_limit_q_msk_val,
8976 /* *** ADD TUNNEL FILTER OF A PORT *** */
8977 struct cmd_tunnel_filter_result {
8978 cmdline_fixed_string_t cmd;
8979 cmdline_fixed_string_t what;
8981 struct rte_ether_addr outer_mac;
8982 struct rte_ether_addr inner_mac;
8983 cmdline_ipaddr_t ip_value;
8984 uint16_t inner_vlan;
8985 cmdline_fixed_string_t tunnel_type;
8986 cmdline_fixed_string_t filter_type;
8992 cmd_tunnel_filter_parsed(void *parsed_result,
8993 __rte_unused struct cmdline *cl,
8994 __rte_unused void *data)
8996 struct cmd_tunnel_filter_result *res = parsed_result;
8997 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9000 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9002 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9003 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9004 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9006 if (res->ip_value.family == AF_INET) {
9007 tunnel_filter_conf.ip_addr.ipv4_addr =
9008 res->ip_value.addr.ipv4.s_addr;
9009 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9011 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9012 &(res->ip_value.addr.ipv6),
9013 sizeof(struct in6_addr));
9014 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9017 if (!strcmp(res->filter_type, "imac-ivlan"))
9018 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9019 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9020 tunnel_filter_conf.filter_type =
9021 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9022 else if (!strcmp(res->filter_type, "imac-tenid"))
9023 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9024 else if (!strcmp(res->filter_type, "imac"))
9025 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9026 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9027 tunnel_filter_conf.filter_type =
9028 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9029 else if (!strcmp(res->filter_type, "oip"))
9030 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9031 else if (!strcmp(res->filter_type, "iip"))
9032 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9034 printf("The filter type is not supported");
9038 if (!strcmp(res->tunnel_type, "vxlan"))
9039 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9040 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9041 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9042 else if (!strcmp(res->tunnel_type, "nvgre"))
9043 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9044 else if (!strcmp(res->tunnel_type, "ipingre"))
9045 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9047 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9051 tunnel_filter_conf.tenant_id = res->tenant_id;
9052 tunnel_filter_conf.queue_id = res->queue_num;
9053 if (!strcmp(res->what, "add"))
9054 ret = rte_eth_dev_filter_ctrl(res->port_id,
9055 RTE_ETH_FILTER_TUNNEL,
9057 &tunnel_filter_conf);
9059 ret = rte_eth_dev_filter_ctrl(res->port_id,
9060 RTE_ETH_FILTER_TUNNEL,
9061 RTE_ETH_FILTER_DELETE,
9062 &tunnel_filter_conf);
9064 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9068 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9069 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9070 cmd, "tunnel_filter");
9071 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9072 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9074 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9075 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9077 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9078 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9080 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9081 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9083 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9084 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9085 inner_vlan, UINT16);
9086 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9087 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9089 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9090 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9091 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9093 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9094 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9095 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9096 "imac#omac-imac-tenid");
9097 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9098 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9100 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9101 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9104 cmdline_parse_inst_t cmd_tunnel_filter = {
9105 .f = cmd_tunnel_filter_parsed,
9107 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9108 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9109 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9110 "<queue_id>: Add/Rm tunnel filter of a port",
9112 (void *)&cmd_tunnel_filter_cmd,
9113 (void *)&cmd_tunnel_filter_what,
9114 (void *)&cmd_tunnel_filter_port_id,
9115 (void *)&cmd_tunnel_filter_outer_mac,
9116 (void *)&cmd_tunnel_filter_inner_mac,
9117 (void *)&cmd_tunnel_filter_ip_value,
9118 (void *)&cmd_tunnel_filter_innner_vlan,
9119 (void *)&cmd_tunnel_filter_tunnel_type,
9120 (void *)&cmd_tunnel_filter_filter_type,
9121 (void *)&cmd_tunnel_filter_tenant_id,
9122 (void *)&cmd_tunnel_filter_queue_num,
9127 /* *** CONFIGURE TUNNEL UDP PORT *** */
9128 struct cmd_tunnel_udp_config {
9129 cmdline_fixed_string_t cmd;
9130 cmdline_fixed_string_t what;
9136 cmd_tunnel_udp_config_parsed(void *parsed_result,
9137 __rte_unused struct cmdline *cl,
9138 __rte_unused void *data)
9140 struct cmd_tunnel_udp_config *res = parsed_result;
9141 struct rte_eth_udp_tunnel tunnel_udp;
9144 tunnel_udp.udp_port = res->udp_port;
9146 if (!strcmp(res->cmd, "rx_vxlan_port"))
9147 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9149 if (!strcmp(res->what, "add"))
9150 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9153 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9157 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9160 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9161 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9162 cmd, "rx_vxlan_port");
9163 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9164 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9166 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9167 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9169 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9170 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9173 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9174 .f = cmd_tunnel_udp_config_parsed,
9176 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9177 "Add/Remove a tunneling UDP port filter",
9179 (void *)&cmd_tunnel_udp_config_cmd,
9180 (void *)&cmd_tunnel_udp_config_what,
9181 (void *)&cmd_tunnel_udp_config_udp_port,
9182 (void *)&cmd_tunnel_udp_config_port_id,
9187 struct cmd_config_tunnel_udp_port {
9188 cmdline_fixed_string_t port;
9189 cmdline_fixed_string_t config;
9191 cmdline_fixed_string_t udp_tunnel_port;
9192 cmdline_fixed_string_t action;
9193 cmdline_fixed_string_t tunnel_type;
9198 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9199 __rte_unused struct cmdline *cl,
9200 __rte_unused void *data)
9202 struct cmd_config_tunnel_udp_port *res = parsed_result;
9203 struct rte_eth_udp_tunnel tunnel_udp;
9206 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9209 tunnel_udp.udp_port = res->udp_port;
9211 if (!strcmp(res->tunnel_type, "vxlan")) {
9212 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9213 } else if (!strcmp(res->tunnel_type, "geneve")) {
9214 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9215 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9216 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9218 printf("Invalid tunnel type\n");
9222 if (!strcmp(res->action, "add"))
9223 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9226 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9230 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9233 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9234 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9236 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9237 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9239 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9240 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9242 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9243 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9246 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9247 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9249 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9250 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9251 "vxlan#geneve#vxlan-gpe");
9252 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9253 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9256 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9257 .f = cmd_cfg_tunnel_udp_port_parsed,
9259 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9261 (void *)&cmd_config_tunnel_udp_port_port,
9262 (void *)&cmd_config_tunnel_udp_port_config,
9263 (void *)&cmd_config_tunnel_udp_port_port_id,
9264 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9265 (void *)&cmd_config_tunnel_udp_port_action,
9266 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9267 (void *)&cmd_config_tunnel_udp_port_value,
9272 /* *** GLOBAL CONFIG *** */
9273 struct cmd_global_config_result {
9274 cmdline_fixed_string_t cmd;
9276 cmdline_fixed_string_t cfg_type;
9281 cmd_global_config_parsed(void *parsed_result,
9282 __rte_unused struct cmdline *cl,
9283 __rte_unused void *data)
9285 struct cmd_global_config_result *res = parsed_result;
9286 struct rte_eth_global_cfg conf;
9289 memset(&conf, 0, sizeof(conf));
9290 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9291 conf.cfg.gre_key_len = res->len;
9292 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9293 RTE_ETH_FILTER_SET, &conf);
9295 printf("Global config error\n");
9298 cmdline_parse_token_string_t cmd_global_config_cmd =
9299 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9301 cmdline_parse_token_num_t cmd_global_config_port_id =
9302 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9304 cmdline_parse_token_string_t cmd_global_config_type =
9305 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9306 cfg_type, "gre-key-len");
9307 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9308 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9311 cmdline_parse_inst_t cmd_global_config = {
9312 .f = cmd_global_config_parsed,
9313 .data = (void *)NULL,
9314 .help_str = "global_config <port_id> gre-key-len <key_len>",
9316 (void *)&cmd_global_config_cmd,
9317 (void *)&cmd_global_config_port_id,
9318 (void *)&cmd_global_config_type,
9319 (void *)&cmd_global_config_gre_key_len,
9324 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9325 struct cmd_set_mirror_mask_result {
9326 cmdline_fixed_string_t set;
9327 cmdline_fixed_string_t port;
9329 cmdline_fixed_string_t mirror;
9331 cmdline_fixed_string_t what;
9332 cmdline_fixed_string_t value;
9333 cmdline_fixed_string_t dstpool;
9335 cmdline_fixed_string_t on;
9338 cmdline_parse_token_string_t cmd_mirror_mask_set =
9339 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9341 cmdline_parse_token_string_t cmd_mirror_mask_port =
9342 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9344 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9345 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9347 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9348 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9349 mirror, "mirror-rule");
9350 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9351 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9353 cmdline_parse_token_string_t cmd_mirror_mask_what =
9354 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9355 what, "pool-mirror-up#pool-mirror-down"
9357 cmdline_parse_token_string_t cmd_mirror_mask_value =
9358 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9360 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9361 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9362 dstpool, "dst-pool");
9363 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9364 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9366 cmdline_parse_token_string_t cmd_mirror_mask_on =
9367 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9371 cmd_set_mirror_mask_parsed(void *parsed_result,
9372 __rte_unused struct cmdline *cl,
9373 __rte_unused void *data)
9376 struct cmd_set_mirror_mask_result *res = parsed_result;
9377 struct rte_eth_mirror_conf mr_conf;
9379 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9381 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9383 mr_conf.dst_pool = res->dstpool_id;
9385 if (!strcmp(res->what, "pool-mirror-up")) {
9386 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9387 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9388 } else if (!strcmp(res->what, "pool-mirror-down")) {
9389 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9390 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9391 } else if (!strcmp(res->what, "vlan-mirror")) {
9392 mr_conf.rule_type = ETH_MIRROR_VLAN;
9393 nb_item = parse_item_list(res->value, "vlan",
9394 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9398 for (i = 0; i < nb_item; i++) {
9399 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9400 printf("Invalid vlan_id: must be < 4096\n");
9404 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9405 mr_conf.vlan.vlan_mask |= 1ULL << i;
9409 if (!strcmp(res->on, "on"))
9410 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9413 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9416 printf("mirror rule add error: (%s)\n", strerror(-ret));
9419 cmdline_parse_inst_t cmd_set_mirror_mask = {
9420 .f = cmd_set_mirror_mask_parsed,
9422 .help_str = "set port <port_id> mirror-rule <rule_id> "
9423 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9424 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9426 (void *)&cmd_mirror_mask_set,
9427 (void *)&cmd_mirror_mask_port,
9428 (void *)&cmd_mirror_mask_portid,
9429 (void *)&cmd_mirror_mask_mirror,
9430 (void *)&cmd_mirror_mask_ruleid,
9431 (void *)&cmd_mirror_mask_what,
9432 (void *)&cmd_mirror_mask_value,
9433 (void *)&cmd_mirror_mask_dstpool,
9434 (void *)&cmd_mirror_mask_poolid,
9435 (void *)&cmd_mirror_mask_on,
9440 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9441 struct cmd_set_mirror_link_result {
9442 cmdline_fixed_string_t set;
9443 cmdline_fixed_string_t port;
9445 cmdline_fixed_string_t mirror;
9447 cmdline_fixed_string_t what;
9448 cmdline_fixed_string_t dstpool;
9450 cmdline_fixed_string_t on;
9453 cmdline_parse_token_string_t cmd_mirror_link_set =
9454 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9456 cmdline_parse_token_string_t cmd_mirror_link_port =
9457 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9459 cmdline_parse_token_num_t cmd_mirror_link_portid =
9460 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9462 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9463 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9464 mirror, "mirror-rule");
9465 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9466 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9468 cmdline_parse_token_string_t cmd_mirror_link_what =
9469 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9470 what, "uplink-mirror#downlink-mirror");
9471 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9472 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9473 dstpool, "dst-pool");
9474 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9475 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9477 cmdline_parse_token_string_t cmd_mirror_link_on =
9478 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9482 cmd_set_mirror_link_parsed(void *parsed_result,
9483 __rte_unused struct cmdline *cl,
9484 __rte_unused void *data)
9487 struct cmd_set_mirror_link_result *res = parsed_result;
9488 struct rte_eth_mirror_conf mr_conf;
9490 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9491 if (!strcmp(res->what, "uplink-mirror"))
9492 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9494 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9496 mr_conf.dst_pool = res->dstpool_id;
9498 if (!strcmp(res->on, "on"))
9499 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9502 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9505 /* check the return value and print it if is < 0 */
9507 printf("mirror rule add error: (%s)\n", strerror(-ret));
9511 cmdline_parse_inst_t cmd_set_mirror_link = {
9512 .f = cmd_set_mirror_link_parsed,
9514 .help_str = "set port <port_id> mirror-rule <rule_id> "
9515 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9517 (void *)&cmd_mirror_link_set,
9518 (void *)&cmd_mirror_link_port,
9519 (void *)&cmd_mirror_link_portid,
9520 (void *)&cmd_mirror_link_mirror,
9521 (void *)&cmd_mirror_link_ruleid,
9522 (void *)&cmd_mirror_link_what,
9523 (void *)&cmd_mirror_link_dstpool,
9524 (void *)&cmd_mirror_link_poolid,
9525 (void *)&cmd_mirror_link_on,
9530 /* *** RESET VM MIRROR RULE *** */
9531 struct cmd_rm_mirror_rule_result {
9532 cmdline_fixed_string_t reset;
9533 cmdline_fixed_string_t port;
9535 cmdline_fixed_string_t mirror;
9539 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9540 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9542 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9543 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9545 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9546 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9548 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9549 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9550 mirror, "mirror-rule");
9551 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9552 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9556 cmd_reset_mirror_rule_parsed(void *parsed_result,
9557 __rte_unused struct cmdline *cl,
9558 __rte_unused void *data)
9561 struct cmd_set_mirror_link_result *res = parsed_result;
9563 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9565 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9568 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9569 .f = cmd_reset_mirror_rule_parsed,
9571 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9573 (void *)&cmd_rm_mirror_rule_reset,
9574 (void *)&cmd_rm_mirror_rule_port,
9575 (void *)&cmd_rm_mirror_rule_portid,
9576 (void *)&cmd_rm_mirror_rule_mirror,
9577 (void *)&cmd_rm_mirror_rule_ruleid,
9582 /* ******************************************************************************** */
9584 struct cmd_dump_result {
9585 cmdline_fixed_string_t dump;
9589 dump_struct_sizes(void)
9591 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9592 DUMP_SIZE(struct rte_mbuf);
9593 DUMP_SIZE(struct rte_mempool);
9594 DUMP_SIZE(struct rte_ring);
9599 /* Dump the socket memory statistics on console */
9601 dump_socket_mem(FILE *f)
9603 struct rte_malloc_socket_stats socket_stats;
9608 unsigned int n_alloc = 0;
9609 unsigned int n_free = 0;
9610 static size_t last_allocs;
9611 static size_t last_total;
9614 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9615 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9616 !socket_stats.heap_totalsz_bytes)
9618 total += socket_stats.heap_totalsz_bytes;
9619 alloc += socket_stats.heap_allocsz_bytes;
9620 free += socket_stats.heap_freesz_bytes;
9621 n_alloc += socket_stats.alloc_count;
9622 n_free += socket_stats.free_count;
9624 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9626 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9627 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9628 (double)socket_stats.heap_allocsz_bytes * 100 /
9629 (double)socket_stats.heap_totalsz_bytes,
9630 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9631 socket_stats.alloc_count,
9632 socket_stats.free_count);
9635 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9636 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9637 (double)alloc * 100 / (double)total,
9638 (double)free / (1024 * 1024),
9641 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9642 ((double)total - (double)last_total) / (1024 * 1024),
9643 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9644 last_allocs = alloc;
9648 static void cmd_dump_parsed(void *parsed_result,
9649 __rte_unused struct cmdline *cl,
9650 __rte_unused void *data)
9652 struct cmd_dump_result *res = parsed_result;
9654 if (!strcmp(res->dump, "dump_physmem"))
9655 rte_dump_physmem_layout(stdout);
9656 else if (!strcmp(res->dump, "dump_socket_mem"))
9657 dump_socket_mem(stdout);
9658 else if (!strcmp(res->dump, "dump_memzone"))
9659 rte_memzone_dump(stdout);
9660 else if (!strcmp(res->dump, "dump_struct_sizes"))
9661 dump_struct_sizes();
9662 else if (!strcmp(res->dump, "dump_ring"))
9663 rte_ring_list_dump(stdout);
9664 else if (!strcmp(res->dump, "dump_mempool"))
9665 rte_mempool_list_dump(stdout);
9666 else if (!strcmp(res->dump, "dump_devargs"))
9667 rte_devargs_dump(stdout);
9668 else if (!strcmp(res->dump, "dump_log_types"))
9669 rte_log_dump(stdout);
9672 cmdline_parse_token_string_t cmd_dump_dump =
9673 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9677 "dump_struct_sizes#"
9683 cmdline_parse_inst_t cmd_dump = {
9684 .f = cmd_dump_parsed, /* function to call */
9685 .data = NULL, /* 2nd arg of func */
9686 .help_str = "Dump status",
9687 .tokens = { /* token list, NULL terminated */
9688 (void *)&cmd_dump_dump,
9693 /* ******************************************************************************** */
9695 struct cmd_dump_one_result {
9696 cmdline_fixed_string_t dump;
9697 cmdline_fixed_string_t name;
9700 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9701 __rte_unused void *data)
9703 struct cmd_dump_one_result *res = parsed_result;
9705 if (!strcmp(res->dump, "dump_ring")) {
9707 r = rte_ring_lookup(res->name);
9709 cmdline_printf(cl, "Cannot find ring\n");
9712 rte_ring_dump(stdout, r);
9713 } else if (!strcmp(res->dump, "dump_mempool")) {
9714 struct rte_mempool *mp;
9715 mp = rte_mempool_lookup(res->name);
9717 cmdline_printf(cl, "Cannot find mempool\n");
9720 rte_mempool_dump(stdout, mp);
9724 cmdline_parse_token_string_t cmd_dump_one_dump =
9725 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9726 "dump_ring#dump_mempool");
9728 cmdline_parse_token_string_t cmd_dump_one_name =
9729 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9731 cmdline_parse_inst_t cmd_dump_one = {
9732 .f = cmd_dump_one_parsed, /* function to call */
9733 .data = NULL, /* 2nd arg of func */
9734 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9735 .tokens = { /* token list, NULL terminated */
9736 (void *)&cmd_dump_one_dump,
9737 (void *)&cmd_dump_one_name,
9742 /* *** Add/Del syn filter *** */
9743 struct cmd_syn_filter_result {
9744 cmdline_fixed_string_t filter;
9746 cmdline_fixed_string_t ops;
9747 cmdline_fixed_string_t priority;
9748 cmdline_fixed_string_t high;
9749 cmdline_fixed_string_t queue;
9754 cmd_syn_filter_parsed(void *parsed_result,
9755 __rte_unused struct cmdline *cl,
9756 __rte_unused void *data)
9758 struct cmd_syn_filter_result *res = parsed_result;
9759 struct rte_eth_syn_filter syn_filter;
9762 ret = rte_eth_dev_filter_supported(res->port_id,
9763 RTE_ETH_FILTER_SYN);
9765 printf("syn filter is not supported on port %u.\n",
9770 memset(&syn_filter, 0, sizeof(syn_filter));
9772 if (!strcmp(res->ops, "add")) {
9773 if (!strcmp(res->high, "high"))
9774 syn_filter.hig_pri = 1;
9776 syn_filter.hig_pri = 0;
9778 syn_filter.queue = res->queue_id;
9779 ret = rte_eth_dev_filter_ctrl(res->port_id,
9784 ret = rte_eth_dev_filter_ctrl(res->port_id,
9786 RTE_ETH_FILTER_DELETE,
9790 printf("syn filter programming error: (%s)\n",
9794 cmdline_parse_token_string_t cmd_syn_filter_filter =
9795 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9796 filter, "syn_filter");
9797 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9798 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9800 cmdline_parse_token_string_t cmd_syn_filter_ops =
9801 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9803 cmdline_parse_token_string_t cmd_syn_filter_priority =
9804 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9805 priority, "priority");
9806 cmdline_parse_token_string_t cmd_syn_filter_high =
9807 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9809 cmdline_parse_token_string_t cmd_syn_filter_queue =
9810 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9812 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9813 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9816 cmdline_parse_inst_t cmd_syn_filter = {
9817 .f = cmd_syn_filter_parsed,
9819 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9820 "<queue_id>: Add/Delete syn filter",
9822 (void *)&cmd_syn_filter_filter,
9823 (void *)&cmd_syn_filter_port_id,
9824 (void *)&cmd_syn_filter_ops,
9825 (void *)&cmd_syn_filter_priority,
9826 (void *)&cmd_syn_filter_high,
9827 (void *)&cmd_syn_filter_queue,
9828 (void *)&cmd_syn_filter_queue_id,
9833 /* *** queue region set *** */
9834 struct cmd_queue_region_result {
9835 cmdline_fixed_string_t set;
9836 cmdline_fixed_string_t port;
9838 cmdline_fixed_string_t cmd;
9839 cmdline_fixed_string_t region;
9841 cmdline_fixed_string_t queue_start_index;
9843 cmdline_fixed_string_t queue_num;
9844 uint8_t queue_num_value;
9848 cmd_queue_region_parsed(void *parsed_result,
9849 __rte_unused struct cmdline *cl,
9850 __rte_unused void *data)
9852 struct cmd_queue_region_result *res = parsed_result;
9854 #ifdef RTE_LIBRTE_I40E_PMD
9855 struct rte_pmd_i40e_queue_region_conf region_conf;
9856 enum rte_pmd_i40e_queue_region_op op_type;
9859 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9862 #ifdef RTE_LIBRTE_I40E_PMD
9863 memset(®ion_conf, 0, sizeof(region_conf));
9864 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9865 region_conf.region_id = res->region_id;
9866 region_conf.queue_num = res->queue_num_value;
9867 region_conf.queue_start_index = res->queue_id;
9869 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9870 op_type, ®ion_conf);
9877 printf("function not implemented or supported\n");
9880 printf("queue region config error: (%s)\n", strerror(-ret));
9884 cmdline_parse_token_string_t cmd_queue_region_set =
9885 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9887 cmdline_parse_token_string_t cmd_queue_region_port =
9888 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9889 cmdline_parse_token_num_t cmd_queue_region_port_id =
9890 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9892 cmdline_parse_token_string_t cmd_queue_region_cmd =
9893 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9894 cmd, "queue-region");
9895 cmdline_parse_token_string_t cmd_queue_region_id =
9896 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9897 region, "region_id");
9898 cmdline_parse_token_num_t cmd_queue_region_index =
9899 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9901 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9902 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9903 queue_start_index, "queue_start_index");
9904 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9905 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9907 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9908 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9909 queue_num, "queue_num");
9910 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9911 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9912 queue_num_value, UINT8);
9914 cmdline_parse_inst_t cmd_queue_region = {
9915 .f = cmd_queue_region_parsed,
9917 .help_str = "set port <port_id> queue-region region_id <value> "
9918 "queue_start_index <value> queue_num <value>: Set a queue region",
9920 (void *)&cmd_queue_region_set,
9921 (void *)&cmd_queue_region_port,
9922 (void *)&cmd_queue_region_port_id,
9923 (void *)&cmd_queue_region_cmd,
9924 (void *)&cmd_queue_region_id,
9925 (void *)&cmd_queue_region_index,
9926 (void *)&cmd_queue_region_queue_start_index,
9927 (void *)&cmd_queue_region_queue_id,
9928 (void *)&cmd_queue_region_queue_num,
9929 (void *)&cmd_queue_region_queue_num_value,
9934 /* *** queue region and flowtype set *** */
9935 struct cmd_region_flowtype_result {
9936 cmdline_fixed_string_t set;
9937 cmdline_fixed_string_t port;
9939 cmdline_fixed_string_t cmd;
9940 cmdline_fixed_string_t region;
9942 cmdline_fixed_string_t flowtype;
9943 uint8_t flowtype_id;
9947 cmd_region_flowtype_parsed(void *parsed_result,
9948 __rte_unused struct cmdline *cl,
9949 __rte_unused void *data)
9951 struct cmd_region_flowtype_result *res = parsed_result;
9953 #ifdef RTE_LIBRTE_I40E_PMD
9954 struct rte_pmd_i40e_queue_region_conf region_conf;
9955 enum rte_pmd_i40e_queue_region_op op_type;
9958 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9961 #ifdef RTE_LIBRTE_I40E_PMD
9962 memset(®ion_conf, 0, sizeof(region_conf));
9964 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9965 region_conf.region_id = res->region_id;
9966 region_conf.hw_flowtype = res->flowtype_id;
9968 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9969 op_type, ®ion_conf);
9976 printf("function not implemented or supported\n");
9979 printf("region flowtype config error: (%s)\n", strerror(-ret));
9983 cmdline_parse_token_string_t cmd_region_flowtype_set =
9984 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9986 cmdline_parse_token_string_t cmd_region_flowtype_port =
9987 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9989 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9990 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9992 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9993 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9994 cmd, "queue-region");
9995 cmdline_parse_token_string_t cmd_region_flowtype_index =
9996 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9997 region, "region_id");
9998 cmdline_parse_token_num_t cmd_region_flowtype_id =
9999 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10001 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10002 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10003 flowtype, "flowtype");
10004 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10005 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10006 flowtype_id, UINT8);
10007 cmdline_parse_inst_t cmd_region_flowtype = {
10008 .f = cmd_region_flowtype_parsed,
10010 .help_str = "set port <port_id> queue-region region_id <value> "
10011 "flowtype <value>: Set a flowtype region index",
10013 (void *)&cmd_region_flowtype_set,
10014 (void *)&cmd_region_flowtype_port,
10015 (void *)&cmd_region_flowtype_port_index,
10016 (void *)&cmd_region_flowtype_cmd,
10017 (void *)&cmd_region_flowtype_index,
10018 (void *)&cmd_region_flowtype_id,
10019 (void *)&cmd_region_flowtype_flow_index,
10020 (void *)&cmd_region_flowtype_flow_id,
10025 /* *** User Priority (UP) to queue region (region_id) set *** */
10026 struct cmd_user_priority_region_result {
10027 cmdline_fixed_string_t set;
10028 cmdline_fixed_string_t port;
10030 cmdline_fixed_string_t cmd;
10031 cmdline_fixed_string_t user_priority;
10032 uint8_t user_priority_id;
10033 cmdline_fixed_string_t region;
10038 cmd_user_priority_region_parsed(void *parsed_result,
10039 __rte_unused struct cmdline *cl,
10040 __rte_unused void *data)
10042 struct cmd_user_priority_region_result *res = parsed_result;
10043 int ret = -ENOTSUP;
10044 #ifdef RTE_LIBRTE_I40E_PMD
10045 struct rte_pmd_i40e_queue_region_conf region_conf;
10046 enum rte_pmd_i40e_queue_region_op op_type;
10049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10052 #ifdef RTE_LIBRTE_I40E_PMD
10053 memset(®ion_conf, 0, sizeof(region_conf));
10054 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10055 region_conf.user_priority = res->user_priority_id;
10056 region_conf.region_id = res->region_id;
10058 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10059 op_type, ®ion_conf);
10066 printf("function not implemented or supported\n");
10069 printf("user_priority region config error: (%s)\n",
10074 cmdline_parse_token_string_t cmd_user_priority_region_set =
10075 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10077 cmdline_parse_token_string_t cmd_user_priority_region_port =
10078 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10080 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10081 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10083 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10084 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10085 cmd, "queue-region");
10086 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10087 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10088 user_priority, "UP");
10089 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10090 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10091 user_priority_id, UINT8);
10092 cmdline_parse_token_string_t cmd_user_priority_region_region =
10093 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10094 region, "region_id");
10095 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10096 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10099 cmdline_parse_inst_t cmd_user_priority_region = {
10100 .f = cmd_user_priority_region_parsed,
10102 .help_str = "set port <port_id> queue-region UP <value> "
10103 "region_id <value>: Set the mapping of User Priority (UP) "
10104 "to queue region (region_id) ",
10106 (void *)&cmd_user_priority_region_set,
10107 (void *)&cmd_user_priority_region_port,
10108 (void *)&cmd_user_priority_region_port_index,
10109 (void *)&cmd_user_priority_region_cmd,
10110 (void *)&cmd_user_priority_region_UP,
10111 (void *)&cmd_user_priority_region_UP_id,
10112 (void *)&cmd_user_priority_region_region,
10113 (void *)&cmd_user_priority_region_region_id,
10118 /* *** flush all queue region related configuration *** */
10119 struct cmd_flush_queue_region_result {
10120 cmdline_fixed_string_t set;
10121 cmdline_fixed_string_t port;
10123 cmdline_fixed_string_t cmd;
10124 cmdline_fixed_string_t flush;
10125 cmdline_fixed_string_t what;
10129 cmd_flush_queue_region_parsed(void *parsed_result,
10130 __rte_unused struct cmdline *cl,
10131 __rte_unused void *data)
10133 struct cmd_flush_queue_region_result *res = parsed_result;
10134 int ret = -ENOTSUP;
10135 #ifdef RTE_LIBRTE_I40E_PMD
10136 struct rte_pmd_i40e_queue_region_conf region_conf;
10137 enum rte_pmd_i40e_queue_region_op op_type;
10140 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10143 #ifdef RTE_LIBRTE_I40E_PMD
10144 memset(®ion_conf, 0, sizeof(region_conf));
10146 if (strcmp(res->what, "on") == 0)
10147 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10149 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10151 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10152 op_type, ®ion_conf);
10159 printf("function not implemented or supported\n");
10162 printf("queue region config flush error: (%s)\n",
10167 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10168 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10170 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10171 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10173 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10174 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10176 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10177 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10178 cmd, "queue-region");
10179 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10180 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10182 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10183 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10186 cmdline_parse_inst_t cmd_flush_queue_region = {
10187 .f = cmd_flush_queue_region_parsed,
10189 .help_str = "set port <port_id> queue-region flush on|off"
10190 ": flush all queue region related configuration",
10192 (void *)&cmd_flush_queue_region_set,
10193 (void *)&cmd_flush_queue_region_port,
10194 (void *)&cmd_flush_queue_region_port_index,
10195 (void *)&cmd_flush_queue_region_cmd,
10196 (void *)&cmd_flush_queue_region_flush,
10197 (void *)&cmd_flush_queue_region_what,
10202 /* *** get all queue region related configuration info *** */
10203 struct cmd_show_queue_region_info {
10204 cmdline_fixed_string_t show;
10205 cmdline_fixed_string_t port;
10207 cmdline_fixed_string_t cmd;
10211 cmd_show_queue_region_info_parsed(void *parsed_result,
10212 __rte_unused struct cmdline *cl,
10213 __rte_unused void *data)
10215 struct cmd_show_queue_region_info *res = parsed_result;
10216 int ret = -ENOTSUP;
10217 #ifdef RTE_LIBRTE_I40E_PMD
10218 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10219 enum rte_pmd_i40e_queue_region_op op_type;
10222 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10225 #ifdef RTE_LIBRTE_I40E_PMD
10226 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10228 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10230 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10231 op_type, &rte_pmd_regions);
10233 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10240 printf("function not implemented or supported\n");
10243 printf("queue region config info show error: (%s)\n",
10248 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10249 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10251 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10252 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10254 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10255 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10257 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10258 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10259 cmd, "queue-region");
10261 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10262 .f = cmd_show_queue_region_info_parsed,
10264 .help_str = "show port <port_id> queue-region"
10265 ": show all queue region related configuration info",
10267 (void *)&cmd_show_queue_region_info_get,
10268 (void *)&cmd_show_queue_region_info_port,
10269 (void *)&cmd_show_queue_region_info_port_index,
10270 (void *)&cmd_show_queue_region_info_cmd,
10275 /* *** ADD/REMOVE A 2tuple FILTER *** */
10276 struct cmd_2tuple_filter_result {
10277 cmdline_fixed_string_t filter;
10279 cmdline_fixed_string_t ops;
10280 cmdline_fixed_string_t dst_port;
10281 uint16_t dst_port_value;
10282 cmdline_fixed_string_t protocol;
10283 uint8_t protocol_value;
10284 cmdline_fixed_string_t mask;
10285 uint8_t mask_value;
10286 cmdline_fixed_string_t tcp_flags;
10287 uint8_t tcp_flags_value;
10288 cmdline_fixed_string_t priority;
10289 uint8_t priority_value;
10290 cmdline_fixed_string_t queue;
10295 cmd_2tuple_filter_parsed(void *parsed_result,
10296 __rte_unused struct cmdline *cl,
10297 __rte_unused void *data)
10299 struct rte_eth_ntuple_filter filter;
10300 struct cmd_2tuple_filter_result *res = parsed_result;
10303 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10305 printf("ntuple filter is not supported on port %u.\n",
10310 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10312 filter.flags = RTE_2TUPLE_FLAGS;
10313 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10314 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10315 filter.proto = res->protocol_value;
10316 filter.priority = res->priority_value;
10317 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10318 printf("nonzero tcp_flags is only meaningful"
10319 " when protocol is TCP.\n");
10322 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10323 printf("invalid TCP flags.\n");
10327 if (res->tcp_flags_value != 0) {
10328 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10329 filter.tcp_flags = res->tcp_flags_value;
10332 /* need convert to big endian. */
10333 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10334 filter.queue = res->queue_id;
10336 if (!strcmp(res->ops, "add"))
10337 ret = rte_eth_dev_filter_ctrl(res->port_id,
10338 RTE_ETH_FILTER_NTUPLE,
10339 RTE_ETH_FILTER_ADD,
10342 ret = rte_eth_dev_filter_ctrl(res->port_id,
10343 RTE_ETH_FILTER_NTUPLE,
10344 RTE_ETH_FILTER_DELETE,
10347 printf("2tuple filter programming error: (%s)\n",
10352 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10353 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10354 filter, "2tuple_filter");
10355 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10356 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10358 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10359 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10361 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10362 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10363 dst_port, "dst_port");
10364 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10365 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10366 dst_port_value, UINT16);
10367 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10368 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10369 protocol, "protocol");
10370 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10371 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10372 protocol_value, UINT8);
10373 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10374 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10376 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10377 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10379 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10380 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10381 tcp_flags, "tcp_flags");
10382 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10383 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10384 tcp_flags_value, UINT8);
10385 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10386 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10387 priority, "priority");
10388 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10389 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10390 priority_value, UINT8);
10391 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10392 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10394 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10395 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10398 cmdline_parse_inst_t cmd_2tuple_filter = {
10399 .f = cmd_2tuple_filter_parsed,
10401 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10402 "<value> mask <value> tcp_flags <value> priority <value> queue "
10403 "<queue_id>: Add a 2tuple filter",
10405 (void *)&cmd_2tuple_filter_filter,
10406 (void *)&cmd_2tuple_filter_port_id,
10407 (void *)&cmd_2tuple_filter_ops,
10408 (void *)&cmd_2tuple_filter_dst_port,
10409 (void *)&cmd_2tuple_filter_dst_port_value,
10410 (void *)&cmd_2tuple_filter_protocol,
10411 (void *)&cmd_2tuple_filter_protocol_value,
10412 (void *)&cmd_2tuple_filter_mask,
10413 (void *)&cmd_2tuple_filter_mask_value,
10414 (void *)&cmd_2tuple_filter_tcp_flags,
10415 (void *)&cmd_2tuple_filter_tcp_flags_value,
10416 (void *)&cmd_2tuple_filter_priority,
10417 (void *)&cmd_2tuple_filter_priority_value,
10418 (void *)&cmd_2tuple_filter_queue,
10419 (void *)&cmd_2tuple_filter_queue_id,
10424 /* *** ADD/REMOVE A 5tuple FILTER *** */
10425 struct cmd_5tuple_filter_result {
10426 cmdline_fixed_string_t filter;
10428 cmdline_fixed_string_t ops;
10429 cmdline_fixed_string_t dst_ip;
10430 cmdline_ipaddr_t dst_ip_value;
10431 cmdline_fixed_string_t src_ip;
10432 cmdline_ipaddr_t src_ip_value;
10433 cmdline_fixed_string_t dst_port;
10434 uint16_t dst_port_value;
10435 cmdline_fixed_string_t src_port;
10436 uint16_t src_port_value;
10437 cmdline_fixed_string_t protocol;
10438 uint8_t protocol_value;
10439 cmdline_fixed_string_t mask;
10440 uint8_t mask_value;
10441 cmdline_fixed_string_t tcp_flags;
10442 uint8_t tcp_flags_value;
10443 cmdline_fixed_string_t priority;
10444 uint8_t priority_value;
10445 cmdline_fixed_string_t queue;
10450 cmd_5tuple_filter_parsed(void *parsed_result,
10451 __rte_unused struct cmdline *cl,
10452 __rte_unused void *data)
10454 struct rte_eth_ntuple_filter filter;
10455 struct cmd_5tuple_filter_result *res = parsed_result;
10458 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10460 printf("ntuple filter is not supported on port %u.\n",
10465 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10467 filter.flags = RTE_5TUPLE_FLAGS;
10468 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10469 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10470 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10471 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10472 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10473 filter.proto = res->protocol_value;
10474 filter.priority = res->priority_value;
10475 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10476 printf("nonzero tcp_flags is only meaningful"
10477 " when protocol is TCP.\n");
10480 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10481 printf("invalid TCP flags.\n");
10485 if (res->tcp_flags_value != 0) {
10486 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10487 filter.tcp_flags = res->tcp_flags_value;
10490 if (res->dst_ip_value.family == AF_INET)
10491 /* no need to convert, already big endian. */
10492 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10494 if (filter.dst_ip_mask == 0) {
10495 printf("can not support ipv6 involved compare.\n");
10501 if (res->src_ip_value.family == AF_INET)
10502 /* no need to convert, already big endian. */
10503 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10505 if (filter.src_ip_mask == 0) {
10506 printf("can not support ipv6 involved compare.\n");
10511 /* need convert to big endian. */
10512 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10513 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10514 filter.queue = res->queue_id;
10516 if (!strcmp(res->ops, "add"))
10517 ret = rte_eth_dev_filter_ctrl(res->port_id,
10518 RTE_ETH_FILTER_NTUPLE,
10519 RTE_ETH_FILTER_ADD,
10522 ret = rte_eth_dev_filter_ctrl(res->port_id,
10523 RTE_ETH_FILTER_NTUPLE,
10524 RTE_ETH_FILTER_DELETE,
10527 printf("5tuple filter programming error: (%s)\n",
10531 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10532 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10533 filter, "5tuple_filter");
10534 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10535 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10537 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10538 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10540 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10541 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10543 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10544 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10546 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10547 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10549 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10550 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10552 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10553 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10554 dst_port, "dst_port");
10555 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10556 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10557 dst_port_value, UINT16);
10558 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10559 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10560 src_port, "src_port");
10561 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10562 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10563 src_port_value, UINT16);
10564 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10565 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10566 protocol, "protocol");
10567 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10568 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10569 protocol_value, UINT8);
10570 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10571 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10573 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10574 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10576 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10577 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10578 tcp_flags, "tcp_flags");
10579 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10580 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10581 tcp_flags_value, UINT8);
10582 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10583 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10584 priority, "priority");
10585 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10586 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10587 priority_value, UINT8);
10588 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10589 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10591 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10592 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10595 cmdline_parse_inst_t cmd_5tuple_filter = {
10596 .f = cmd_5tuple_filter_parsed,
10598 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10599 "src_ip <value> dst_port <value> src_port <value> "
10600 "protocol <value> mask <value> tcp_flags <value> "
10601 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10603 (void *)&cmd_5tuple_filter_filter,
10604 (void *)&cmd_5tuple_filter_port_id,
10605 (void *)&cmd_5tuple_filter_ops,
10606 (void *)&cmd_5tuple_filter_dst_ip,
10607 (void *)&cmd_5tuple_filter_dst_ip_value,
10608 (void *)&cmd_5tuple_filter_src_ip,
10609 (void *)&cmd_5tuple_filter_src_ip_value,
10610 (void *)&cmd_5tuple_filter_dst_port,
10611 (void *)&cmd_5tuple_filter_dst_port_value,
10612 (void *)&cmd_5tuple_filter_src_port,
10613 (void *)&cmd_5tuple_filter_src_port_value,
10614 (void *)&cmd_5tuple_filter_protocol,
10615 (void *)&cmd_5tuple_filter_protocol_value,
10616 (void *)&cmd_5tuple_filter_mask,
10617 (void *)&cmd_5tuple_filter_mask_value,
10618 (void *)&cmd_5tuple_filter_tcp_flags,
10619 (void *)&cmd_5tuple_filter_tcp_flags_value,
10620 (void *)&cmd_5tuple_filter_priority,
10621 (void *)&cmd_5tuple_filter_priority_value,
10622 (void *)&cmd_5tuple_filter_queue,
10623 (void *)&cmd_5tuple_filter_queue_id,
10628 /* *** ADD/REMOVE A flex FILTER *** */
10629 struct cmd_flex_filter_result {
10630 cmdline_fixed_string_t filter;
10631 cmdline_fixed_string_t ops;
10633 cmdline_fixed_string_t len;
10635 cmdline_fixed_string_t bytes;
10636 cmdline_fixed_string_t bytes_value;
10637 cmdline_fixed_string_t mask;
10638 cmdline_fixed_string_t mask_value;
10639 cmdline_fixed_string_t priority;
10640 uint8_t priority_value;
10641 cmdline_fixed_string_t queue;
10645 static int xdigit2val(unsigned char c)
10650 else if (isupper(c))
10651 val = c - 'A' + 10;
10653 val = c - 'a' + 10;
10658 cmd_flex_filter_parsed(void *parsed_result,
10659 __rte_unused struct cmdline *cl,
10660 __rte_unused void *data)
10663 struct rte_eth_flex_filter filter;
10664 struct cmd_flex_filter_result *res = parsed_result;
10665 char *bytes_ptr, *mask_ptr;
10666 uint16_t len, i, j = 0;
10671 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10672 printf("the len exceed the max length 128\n");
10675 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10676 filter.len = res->len_value;
10677 filter.priority = res->priority_value;
10678 filter.queue = res->queue_id;
10679 bytes_ptr = res->bytes_value;
10680 mask_ptr = res->mask_value;
10682 /* translate bytes string to array. */
10683 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10684 (bytes_ptr[1] == 'X')))
10686 len = strnlen(bytes_ptr, res->len_value * 2);
10687 if (len == 0 || (len % 8 != 0)) {
10688 printf("please check len and bytes input\n");
10691 for (i = 0; i < len; i++) {
10693 if (isxdigit(c) == 0) {
10694 /* invalid characters. */
10695 printf("invalid input\n");
10698 val = xdigit2val(c);
10701 filter.bytes[j] = byte;
10702 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10709 /* translate mask string to uint8_t array. */
10710 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10711 (mask_ptr[1] == 'X')))
10713 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10715 printf("invalid input\n");
10720 for (i = 0; i < len; i++) {
10722 if (isxdigit(c) == 0) {
10723 /* invalid characters. */
10724 printf("invalid input\n");
10727 val = xdigit2val(c);
10730 filter.mask[j] = byte;
10731 printf("mask[%d]:%02x ", j, filter.mask[j]);
10739 if (!strcmp(res->ops, "add"))
10740 ret = rte_eth_dev_filter_ctrl(res->port_id,
10741 RTE_ETH_FILTER_FLEXIBLE,
10742 RTE_ETH_FILTER_ADD,
10745 ret = rte_eth_dev_filter_ctrl(res->port_id,
10746 RTE_ETH_FILTER_FLEXIBLE,
10747 RTE_ETH_FILTER_DELETE,
10751 printf("flex filter setting error: (%s)\n", strerror(-ret));
10754 cmdline_parse_token_string_t cmd_flex_filter_filter =
10755 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10756 filter, "flex_filter");
10757 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10758 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10760 cmdline_parse_token_string_t cmd_flex_filter_ops =
10761 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10763 cmdline_parse_token_string_t cmd_flex_filter_len =
10764 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10766 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10767 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10769 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10770 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10772 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10773 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10774 bytes_value, NULL);
10775 cmdline_parse_token_string_t cmd_flex_filter_mask =
10776 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10778 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10779 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10781 cmdline_parse_token_string_t cmd_flex_filter_priority =
10782 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10783 priority, "priority");
10784 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10785 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10786 priority_value, UINT8);
10787 cmdline_parse_token_string_t cmd_flex_filter_queue =
10788 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10790 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10791 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10793 cmdline_parse_inst_t cmd_flex_filter = {
10794 .f = cmd_flex_filter_parsed,
10796 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10797 "<value> mask <value> priority <value> queue <queue_id>: "
10798 "Add/Del a flex filter",
10800 (void *)&cmd_flex_filter_filter,
10801 (void *)&cmd_flex_filter_port_id,
10802 (void *)&cmd_flex_filter_ops,
10803 (void *)&cmd_flex_filter_len,
10804 (void *)&cmd_flex_filter_len_value,
10805 (void *)&cmd_flex_filter_bytes,
10806 (void *)&cmd_flex_filter_bytes_value,
10807 (void *)&cmd_flex_filter_mask,
10808 (void *)&cmd_flex_filter_mask_value,
10809 (void *)&cmd_flex_filter_priority,
10810 (void *)&cmd_flex_filter_priority_value,
10811 (void *)&cmd_flex_filter_queue,
10812 (void *)&cmd_flex_filter_queue_id,
10817 /* *** Filters Control *** */
10819 /* *** deal with ethertype filter *** */
10820 struct cmd_ethertype_filter_result {
10821 cmdline_fixed_string_t filter;
10823 cmdline_fixed_string_t ops;
10824 cmdline_fixed_string_t mac;
10825 struct rte_ether_addr mac_addr;
10826 cmdline_fixed_string_t ethertype;
10827 uint16_t ethertype_value;
10828 cmdline_fixed_string_t drop;
10829 cmdline_fixed_string_t queue;
10833 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10834 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10835 filter, "ethertype_filter");
10836 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10837 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10839 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10840 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10842 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10843 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10844 mac, "mac_addr#mac_ignr");
10845 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10846 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10848 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10849 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10850 ethertype, "ethertype");
10851 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10852 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10853 ethertype_value, UINT16);
10854 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10855 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10857 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10858 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10860 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10861 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10865 cmd_ethertype_filter_parsed(void *parsed_result,
10866 __rte_unused struct cmdline *cl,
10867 __rte_unused void *data)
10869 struct cmd_ethertype_filter_result *res = parsed_result;
10870 struct rte_eth_ethertype_filter filter;
10873 ret = rte_eth_dev_filter_supported(res->port_id,
10874 RTE_ETH_FILTER_ETHERTYPE);
10876 printf("ethertype filter is not supported on port %u.\n",
10881 memset(&filter, 0, sizeof(filter));
10882 if (!strcmp(res->mac, "mac_addr")) {
10883 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10884 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10885 sizeof(struct rte_ether_addr));
10887 if (!strcmp(res->drop, "drop"))
10888 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10889 filter.ether_type = res->ethertype_value;
10890 filter.queue = res->queue_id;
10892 if (!strcmp(res->ops, "add"))
10893 ret = rte_eth_dev_filter_ctrl(res->port_id,
10894 RTE_ETH_FILTER_ETHERTYPE,
10895 RTE_ETH_FILTER_ADD,
10898 ret = rte_eth_dev_filter_ctrl(res->port_id,
10899 RTE_ETH_FILTER_ETHERTYPE,
10900 RTE_ETH_FILTER_DELETE,
10903 printf("ethertype filter programming error: (%s)\n",
10907 cmdline_parse_inst_t cmd_ethertype_filter = {
10908 .f = cmd_ethertype_filter_parsed,
10910 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10911 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10912 "Add or delete an ethertype filter entry",
10914 (void *)&cmd_ethertype_filter_filter,
10915 (void *)&cmd_ethertype_filter_port_id,
10916 (void *)&cmd_ethertype_filter_ops,
10917 (void *)&cmd_ethertype_filter_mac,
10918 (void *)&cmd_ethertype_filter_mac_addr,
10919 (void *)&cmd_ethertype_filter_ethertype,
10920 (void *)&cmd_ethertype_filter_ethertype_value,
10921 (void *)&cmd_ethertype_filter_drop,
10922 (void *)&cmd_ethertype_filter_queue,
10923 (void *)&cmd_ethertype_filter_queue_id,
10928 /* *** deal with flow director filter *** */
10929 struct cmd_flow_director_result {
10930 cmdline_fixed_string_t flow_director_filter;
10932 cmdline_fixed_string_t mode;
10933 cmdline_fixed_string_t mode_value;
10934 cmdline_fixed_string_t ops;
10935 cmdline_fixed_string_t flow;
10936 cmdline_fixed_string_t flow_type;
10937 cmdline_fixed_string_t ether;
10938 uint16_t ether_type;
10939 cmdline_fixed_string_t src;
10940 cmdline_ipaddr_t ip_src;
10942 cmdline_fixed_string_t dst;
10943 cmdline_ipaddr_t ip_dst;
10945 cmdline_fixed_string_t verify_tag;
10946 uint32_t verify_tag_value;
10947 cmdline_fixed_string_t tos;
10949 cmdline_fixed_string_t proto;
10950 uint8_t proto_value;
10951 cmdline_fixed_string_t ttl;
10953 cmdline_fixed_string_t vlan;
10954 uint16_t vlan_value;
10955 cmdline_fixed_string_t flexbytes;
10956 cmdline_fixed_string_t flexbytes_value;
10957 cmdline_fixed_string_t pf_vf;
10958 cmdline_fixed_string_t drop;
10959 cmdline_fixed_string_t queue;
10961 cmdline_fixed_string_t fd_id;
10962 uint32_t fd_id_value;
10963 cmdline_fixed_string_t mac;
10964 struct rte_ether_addr mac_addr;
10965 cmdline_fixed_string_t tunnel;
10966 cmdline_fixed_string_t tunnel_type;
10967 cmdline_fixed_string_t tunnel_id;
10968 uint32_t tunnel_id_value;
10969 cmdline_fixed_string_t packet;
10974 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10977 const char *p, *p0 = q_arg;
10979 unsigned long int_fld;
10980 char *str_fld[max_num];
10985 p = strchr(p0, '(');
10989 p0 = strchr(p, ')');
10994 if (size >= sizeof(s))
10997 snprintf(s, sizeof(s), "%.*s", size, p);
10998 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10999 if (ret < 0 || ret > max_num)
11001 for (i = 0; i < ret; i++) {
11003 int_fld = strtoul(str_fld[i], &end, 0);
11004 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11006 flexbytes[i] = (uint8_t)int_fld;
11012 str2flowtype(char *string)
11015 static const struct {
11018 } flowtype_str[] = {
11019 {"raw", RTE_ETH_FLOW_RAW},
11020 {"ipv4", RTE_ETH_FLOW_IPV4},
11021 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11022 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11023 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11024 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11025 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11026 {"ipv6", RTE_ETH_FLOW_IPV6},
11027 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11028 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11029 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11030 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11031 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11032 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11035 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11036 if (!strcmp(flowtype_str[i].str, string))
11037 return flowtype_str[i].type;
11040 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11041 return (uint16_t)atoi(string);
11043 return RTE_ETH_FLOW_UNKNOWN;
11046 static enum rte_eth_fdir_tunnel_type
11047 str2fdir_tunneltype(char *string)
11051 static const struct {
11053 enum rte_eth_fdir_tunnel_type type;
11054 } tunneltype_str[] = {
11055 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11056 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11059 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11060 if (!strcmp(tunneltype_str[i].str, string))
11061 return tunneltype_str[i].type;
11063 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11066 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11068 if ((ip_addr).family == AF_INET) \
11069 (ip) = (ip_addr).addr.ipv4.s_addr; \
11071 printf("invalid parameter.\n"); \
11076 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11078 if ((ip_addr).family == AF_INET6) \
11079 rte_memcpy(&(ip), \
11080 &((ip_addr).addr.ipv6), \
11081 sizeof(struct in6_addr)); \
11083 printf("invalid parameter.\n"); \
11089 cmd_flow_director_filter_parsed(void *parsed_result,
11090 __rte_unused struct cmdline *cl,
11091 __rte_unused void *data)
11093 struct cmd_flow_director_result *res = parsed_result;
11094 struct rte_eth_fdir_filter entry;
11095 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11097 unsigned long vf_id;
11100 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11102 printf("flow director is not supported on port %u.\n",
11106 memset(flexbytes, 0, sizeof(flexbytes));
11107 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11109 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11110 if (strcmp(res->mode_value, "MAC-VLAN")) {
11111 printf("Please set mode to MAC-VLAN.\n");
11114 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11115 if (strcmp(res->mode_value, "Tunnel")) {
11116 printf("Please set mode to Tunnel.\n");
11120 if (!strcmp(res->mode_value, "raw")) {
11121 #ifdef RTE_LIBRTE_I40E_PMD
11122 struct rte_pmd_i40e_flow_type_mapping
11123 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11124 struct rte_pmd_i40e_pkt_template_conf conf;
11125 uint16_t flow_type = str2flowtype(res->flow_type);
11126 uint16_t i, port = res->port_id;
11129 memset(&conf, 0, sizeof(conf));
11131 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11132 printf("Invalid flow type specified.\n");
11135 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11139 if (mapping[flow_type].pctype == 0ULL) {
11140 printf("Invalid flow type specified.\n");
11143 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11144 if (mapping[flow_type].pctype & (1ULL << i)) {
11145 conf.input.pctype = i;
11150 conf.input.packet = open_file(res->filepath,
11151 &conf.input.length);
11152 if (!conf.input.packet)
11154 if (!strcmp(res->drop, "drop"))
11155 conf.action.behavior =
11156 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11158 conf.action.behavior =
11159 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11160 conf.action.report_status =
11161 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11162 conf.action.rx_queue = res->queue_id;
11163 conf.soft_id = res->fd_id_value;
11164 add = strcmp(res->ops, "del") ? 1 : 0;
11165 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11169 printf("flow director config error: (%s)\n",
11171 close_file(conf.input.packet);
11174 } else if (strcmp(res->mode_value, "IP")) {
11175 printf("Please set mode to IP or raw.\n");
11178 entry.input.flow_type = str2flowtype(res->flow_type);
11181 ret = parse_flexbytes(res->flexbytes_value,
11183 RTE_ETH_FDIR_MAX_FLEXLEN);
11185 printf("error: Cannot parse flexbytes input.\n");
11189 switch (entry.input.flow_type) {
11190 case RTE_ETH_FLOW_FRAG_IPV4:
11191 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11192 entry.input.flow.ip4_flow.proto = res->proto_value;
11194 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11195 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11196 IPV4_ADDR_TO_UINT(res->ip_dst,
11197 entry.input.flow.ip4_flow.dst_ip);
11198 IPV4_ADDR_TO_UINT(res->ip_src,
11199 entry.input.flow.ip4_flow.src_ip);
11200 entry.input.flow.ip4_flow.tos = res->tos_value;
11201 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11202 /* need convert to big endian. */
11203 entry.input.flow.udp4_flow.dst_port =
11204 rte_cpu_to_be_16(res->port_dst);
11205 entry.input.flow.udp4_flow.src_port =
11206 rte_cpu_to_be_16(res->port_src);
11208 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11209 IPV4_ADDR_TO_UINT(res->ip_dst,
11210 entry.input.flow.sctp4_flow.ip.dst_ip);
11211 IPV4_ADDR_TO_UINT(res->ip_src,
11212 entry.input.flow.sctp4_flow.ip.src_ip);
11213 entry.input.flow.ip4_flow.tos = res->tos_value;
11214 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11215 /* need convert to big endian. */
11216 entry.input.flow.sctp4_flow.dst_port =
11217 rte_cpu_to_be_16(res->port_dst);
11218 entry.input.flow.sctp4_flow.src_port =
11219 rte_cpu_to_be_16(res->port_src);
11220 entry.input.flow.sctp4_flow.verify_tag =
11221 rte_cpu_to_be_32(res->verify_tag_value);
11223 case RTE_ETH_FLOW_FRAG_IPV6:
11224 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11225 entry.input.flow.ipv6_flow.proto = res->proto_value;
11227 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11228 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11229 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11230 entry.input.flow.ipv6_flow.dst_ip);
11231 IPV6_ADDR_TO_ARRAY(res->ip_src,
11232 entry.input.flow.ipv6_flow.src_ip);
11233 entry.input.flow.ipv6_flow.tc = res->tos_value;
11234 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11235 /* need convert to big endian. */
11236 entry.input.flow.udp6_flow.dst_port =
11237 rte_cpu_to_be_16(res->port_dst);
11238 entry.input.flow.udp6_flow.src_port =
11239 rte_cpu_to_be_16(res->port_src);
11241 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11242 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11243 entry.input.flow.sctp6_flow.ip.dst_ip);
11244 IPV6_ADDR_TO_ARRAY(res->ip_src,
11245 entry.input.flow.sctp6_flow.ip.src_ip);
11246 entry.input.flow.ipv6_flow.tc = res->tos_value;
11247 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11248 /* need convert to big endian. */
11249 entry.input.flow.sctp6_flow.dst_port =
11250 rte_cpu_to_be_16(res->port_dst);
11251 entry.input.flow.sctp6_flow.src_port =
11252 rte_cpu_to_be_16(res->port_src);
11253 entry.input.flow.sctp6_flow.verify_tag =
11254 rte_cpu_to_be_32(res->verify_tag_value);
11256 case RTE_ETH_FLOW_L2_PAYLOAD:
11257 entry.input.flow.l2_flow.ether_type =
11258 rte_cpu_to_be_16(res->ether_type);
11264 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11265 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11267 sizeof(struct rte_ether_addr));
11269 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11270 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11272 sizeof(struct rte_ether_addr));
11273 entry.input.flow.tunnel_flow.tunnel_type =
11274 str2fdir_tunneltype(res->tunnel_type);
11275 entry.input.flow.tunnel_flow.tunnel_id =
11276 rte_cpu_to_be_32(res->tunnel_id_value);
11279 rte_memcpy(entry.input.flow_ext.flexbytes,
11281 RTE_ETH_FDIR_MAX_FLEXLEN);
11283 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11285 entry.action.flex_off = 0; /*use 0 by default */
11286 if (!strcmp(res->drop, "drop"))
11287 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11289 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11291 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11292 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11293 if (!strcmp(res->pf_vf, "pf"))
11294 entry.input.flow_ext.is_vf = 0;
11295 else if (!strncmp(res->pf_vf, "vf", 2)) {
11296 struct rte_eth_dev_info dev_info;
11298 ret = eth_dev_info_get_print_err(res->port_id,
11304 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11305 if (errno != 0 || *end != '\0' ||
11306 vf_id >= dev_info.max_vfs) {
11307 printf("invalid parameter %s.\n", res->pf_vf);
11310 entry.input.flow_ext.is_vf = 1;
11311 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11313 printf("invalid parameter %s.\n", res->pf_vf);
11318 /* set to report FD ID by default */
11319 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11320 entry.action.rx_queue = res->queue_id;
11321 entry.soft_id = res->fd_id_value;
11322 if (!strcmp(res->ops, "add"))
11323 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11324 RTE_ETH_FILTER_ADD, &entry);
11325 else if (!strcmp(res->ops, "del"))
11326 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11327 RTE_ETH_FILTER_DELETE, &entry);
11329 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11330 RTE_ETH_FILTER_UPDATE, &entry);
11332 printf("flow director programming error: (%s)\n",
11336 cmdline_parse_token_string_t cmd_flow_director_filter =
11337 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11338 flow_director_filter, "flow_director_filter");
11339 cmdline_parse_token_num_t cmd_flow_director_port_id =
11340 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11342 cmdline_parse_token_string_t cmd_flow_director_ops =
11343 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11344 ops, "add#del#update");
11345 cmdline_parse_token_string_t cmd_flow_director_flow =
11346 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11348 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11349 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11351 cmdline_parse_token_string_t cmd_flow_director_ether =
11352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11354 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11355 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11356 ether_type, UINT16);
11357 cmdline_parse_token_string_t cmd_flow_director_src =
11358 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11360 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11361 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11363 cmdline_parse_token_num_t cmd_flow_director_port_src =
11364 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11366 cmdline_parse_token_string_t cmd_flow_director_dst =
11367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11369 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11370 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11372 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11373 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11375 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11377 verify_tag, "verify_tag");
11378 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11379 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11380 verify_tag_value, UINT32);
11381 cmdline_parse_token_string_t cmd_flow_director_tos =
11382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11384 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11385 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11387 cmdline_parse_token_string_t cmd_flow_director_proto =
11388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11390 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11391 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11392 proto_value, UINT8);
11393 cmdline_parse_token_string_t cmd_flow_director_ttl =
11394 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11396 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11397 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11399 cmdline_parse_token_string_t cmd_flow_director_vlan =
11400 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11402 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11403 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11404 vlan_value, UINT16);
11405 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11406 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11407 flexbytes, "flexbytes");
11408 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11409 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11410 flexbytes_value, NULL);
11411 cmdline_parse_token_string_t cmd_flow_director_drop =
11412 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11414 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11417 cmdline_parse_token_string_t cmd_flow_director_queue =
11418 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11420 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11421 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11423 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11426 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11427 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11428 fd_id_value, UINT32);
11430 cmdline_parse_token_string_t cmd_flow_director_mode =
11431 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11433 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11434 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11436 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11437 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11438 mode_value, "MAC-VLAN");
11439 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11441 mode_value, "Tunnel");
11442 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11443 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11444 mode_value, "raw");
11445 cmdline_parse_token_string_t cmd_flow_director_mac =
11446 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11448 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11449 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11451 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11452 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11454 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11455 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11456 tunnel_type, "NVGRE#VxLAN");
11457 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11458 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11459 tunnel_id, "tunnel-id");
11460 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11461 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11462 tunnel_id_value, UINT32);
11463 cmdline_parse_token_string_t cmd_flow_director_packet =
11464 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11466 cmdline_parse_token_string_t cmd_flow_director_filepath =
11467 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11470 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11471 .f = cmd_flow_director_filter_parsed,
11473 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11474 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11475 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11476 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11477 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11478 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11479 "fd_id <fd_id_value>: "
11480 "Add or delete an ip flow director entry on NIC",
11482 (void *)&cmd_flow_director_filter,
11483 (void *)&cmd_flow_director_port_id,
11484 (void *)&cmd_flow_director_mode,
11485 (void *)&cmd_flow_director_mode_ip,
11486 (void *)&cmd_flow_director_ops,
11487 (void *)&cmd_flow_director_flow,
11488 (void *)&cmd_flow_director_flow_type,
11489 (void *)&cmd_flow_director_src,
11490 (void *)&cmd_flow_director_ip_src,
11491 (void *)&cmd_flow_director_dst,
11492 (void *)&cmd_flow_director_ip_dst,
11493 (void *)&cmd_flow_director_tos,
11494 (void *)&cmd_flow_director_tos_value,
11495 (void *)&cmd_flow_director_proto,
11496 (void *)&cmd_flow_director_proto_value,
11497 (void *)&cmd_flow_director_ttl,
11498 (void *)&cmd_flow_director_ttl_value,
11499 (void *)&cmd_flow_director_vlan,
11500 (void *)&cmd_flow_director_vlan_value,
11501 (void *)&cmd_flow_director_flexbytes,
11502 (void *)&cmd_flow_director_flexbytes_value,
11503 (void *)&cmd_flow_director_drop,
11504 (void *)&cmd_flow_director_pf_vf,
11505 (void *)&cmd_flow_director_queue,
11506 (void *)&cmd_flow_director_queue_id,
11507 (void *)&cmd_flow_director_fd_id,
11508 (void *)&cmd_flow_director_fd_id_value,
11513 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11514 .f = cmd_flow_director_filter_parsed,
11516 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11517 "director entry on NIC",
11519 (void *)&cmd_flow_director_filter,
11520 (void *)&cmd_flow_director_port_id,
11521 (void *)&cmd_flow_director_mode,
11522 (void *)&cmd_flow_director_mode_ip,
11523 (void *)&cmd_flow_director_ops,
11524 (void *)&cmd_flow_director_flow,
11525 (void *)&cmd_flow_director_flow_type,
11526 (void *)&cmd_flow_director_src,
11527 (void *)&cmd_flow_director_ip_src,
11528 (void *)&cmd_flow_director_port_src,
11529 (void *)&cmd_flow_director_dst,
11530 (void *)&cmd_flow_director_ip_dst,
11531 (void *)&cmd_flow_director_port_dst,
11532 (void *)&cmd_flow_director_tos,
11533 (void *)&cmd_flow_director_tos_value,
11534 (void *)&cmd_flow_director_ttl,
11535 (void *)&cmd_flow_director_ttl_value,
11536 (void *)&cmd_flow_director_vlan,
11537 (void *)&cmd_flow_director_vlan_value,
11538 (void *)&cmd_flow_director_flexbytes,
11539 (void *)&cmd_flow_director_flexbytes_value,
11540 (void *)&cmd_flow_director_drop,
11541 (void *)&cmd_flow_director_pf_vf,
11542 (void *)&cmd_flow_director_queue,
11543 (void *)&cmd_flow_director_queue_id,
11544 (void *)&cmd_flow_director_fd_id,
11545 (void *)&cmd_flow_director_fd_id_value,
11550 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11551 .f = cmd_flow_director_filter_parsed,
11553 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11554 "director entry on NIC",
11556 (void *)&cmd_flow_director_filter,
11557 (void *)&cmd_flow_director_port_id,
11558 (void *)&cmd_flow_director_mode,
11559 (void *)&cmd_flow_director_mode_ip,
11560 (void *)&cmd_flow_director_ops,
11561 (void *)&cmd_flow_director_flow,
11562 (void *)&cmd_flow_director_flow_type,
11563 (void *)&cmd_flow_director_src,
11564 (void *)&cmd_flow_director_ip_src,
11565 (void *)&cmd_flow_director_port_src,
11566 (void *)&cmd_flow_director_dst,
11567 (void *)&cmd_flow_director_ip_dst,
11568 (void *)&cmd_flow_director_port_dst,
11569 (void *)&cmd_flow_director_verify_tag,
11570 (void *)&cmd_flow_director_verify_tag_value,
11571 (void *)&cmd_flow_director_tos,
11572 (void *)&cmd_flow_director_tos_value,
11573 (void *)&cmd_flow_director_ttl,
11574 (void *)&cmd_flow_director_ttl_value,
11575 (void *)&cmd_flow_director_vlan,
11576 (void *)&cmd_flow_director_vlan_value,
11577 (void *)&cmd_flow_director_flexbytes,
11578 (void *)&cmd_flow_director_flexbytes_value,
11579 (void *)&cmd_flow_director_drop,
11580 (void *)&cmd_flow_director_pf_vf,
11581 (void *)&cmd_flow_director_queue,
11582 (void *)&cmd_flow_director_queue_id,
11583 (void *)&cmd_flow_director_fd_id,
11584 (void *)&cmd_flow_director_fd_id_value,
11589 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11590 .f = cmd_flow_director_filter_parsed,
11592 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11593 "director entry on NIC",
11595 (void *)&cmd_flow_director_filter,
11596 (void *)&cmd_flow_director_port_id,
11597 (void *)&cmd_flow_director_mode,
11598 (void *)&cmd_flow_director_mode_ip,
11599 (void *)&cmd_flow_director_ops,
11600 (void *)&cmd_flow_director_flow,
11601 (void *)&cmd_flow_director_flow_type,
11602 (void *)&cmd_flow_director_ether,
11603 (void *)&cmd_flow_director_ether_type,
11604 (void *)&cmd_flow_director_flexbytes,
11605 (void *)&cmd_flow_director_flexbytes_value,
11606 (void *)&cmd_flow_director_drop,
11607 (void *)&cmd_flow_director_pf_vf,
11608 (void *)&cmd_flow_director_queue,
11609 (void *)&cmd_flow_director_queue_id,
11610 (void *)&cmd_flow_director_fd_id,
11611 (void *)&cmd_flow_director_fd_id_value,
11616 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11617 .f = cmd_flow_director_filter_parsed,
11619 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11620 "director entry on NIC",
11622 (void *)&cmd_flow_director_filter,
11623 (void *)&cmd_flow_director_port_id,
11624 (void *)&cmd_flow_director_mode,
11625 (void *)&cmd_flow_director_mode_mac_vlan,
11626 (void *)&cmd_flow_director_ops,
11627 (void *)&cmd_flow_director_mac,
11628 (void *)&cmd_flow_director_mac_addr,
11629 (void *)&cmd_flow_director_vlan,
11630 (void *)&cmd_flow_director_vlan_value,
11631 (void *)&cmd_flow_director_flexbytes,
11632 (void *)&cmd_flow_director_flexbytes_value,
11633 (void *)&cmd_flow_director_drop,
11634 (void *)&cmd_flow_director_queue,
11635 (void *)&cmd_flow_director_queue_id,
11636 (void *)&cmd_flow_director_fd_id,
11637 (void *)&cmd_flow_director_fd_id_value,
11642 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11643 .f = cmd_flow_director_filter_parsed,
11645 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11646 "director entry on NIC",
11648 (void *)&cmd_flow_director_filter,
11649 (void *)&cmd_flow_director_port_id,
11650 (void *)&cmd_flow_director_mode,
11651 (void *)&cmd_flow_director_mode_tunnel,
11652 (void *)&cmd_flow_director_ops,
11653 (void *)&cmd_flow_director_mac,
11654 (void *)&cmd_flow_director_mac_addr,
11655 (void *)&cmd_flow_director_vlan,
11656 (void *)&cmd_flow_director_vlan_value,
11657 (void *)&cmd_flow_director_tunnel,
11658 (void *)&cmd_flow_director_tunnel_type,
11659 (void *)&cmd_flow_director_tunnel_id,
11660 (void *)&cmd_flow_director_tunnel_id_value,
11661 (void *)&cmd_flow_director_flexbytes,
11662 (void *)&cmd_flow_director_flexbytes_value,
11663 (void *)&cmd_flow_director_drop,
11664 (void *)&cmd_flow_director_queue,
11665 (void *)&cmd_flow_director_queue_id,
11666 (void *)&cmd_flow_director_fd_id,
11667 (void *)&cmd_flow_director_fd_id_value,
11672 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11673 .f = cmd_flow_director_filter_parsed,
11675 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11676 "director entry on NIC",
11678 (void *)&cmd_flow_director_filter,
11679 (void *)&cmd_flow_director_port_id,
11680 (void *)&cmd_flow_director_mode,
11681 (void *)&cmd_flow_director_mode_raw,
11682 (void *)&cmd_flow_director_ops,
11683 (void *)&cmd_flow_director_flow,
11684 (void *)&cmd_flow_director_flow_type,
11685 (void *)&cmd_flow_director_drop,
11686 (void *)&cmd_flow_director_queue,
11687 (void *)&cmd_flow_director_queue_id,
11688 (void *)&cmd_flow_director_fd_id,
11689 (void *)&cmd_flow_director_fd_id_value,
11690 (void *)&cmd_flow_director_packet,
11691 (void *)&cmd_flow_director_filepath,
11696 struct cmd_flush_flow_director_result {
11697 cmdline_fixed_string_t flush_flow_director;
11701 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11702 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11703 flush_flow_director, "flush_flow_director");
11704 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11705 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11709 cmd_flush_flow_director_parsed(void *parsed_result,
11710 __rte_unused struct cmdline *cl,
11711 __rte_unused void *data)
11713 struct cmd_flow_director_result *res = parsed_result;
11716 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11718 printf("flow director is not supported on port %u.\n",
11723 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11724 RTE_ETH_FILTER_FLUSH, NULL);
11726 printf("flow director table flushing error: (%s)\n",
11730 cmdline_parse_inst_t cmd_flush_flow_director = {
11731 .f = cmd_flush_flow_director_parsed,
11733 .help_str = "flush_flow_director <port_id>: "
11734 "Flush all flow director entries of a device on NIC",
11736 (void *)&cmd_flush_flow_director_flush,
11737 (void *)&cmd_flush_flow_director_port_id,
11742 /* *** deal with flow director mask *** */
11743 struct cmd_flow_director_mask_result {
11744 cmdline_fixed_string_t flow_director_mask;
11746 cmdline_fixed_string_t mode;
11747 cmdline_fixed_string_t mode_value;
11748 cmdline_fixed_string_t vlan;
11749 uint16_t vlan_mask;
11750 cmdline_fixed_string_t src_mask;
11751 cmdline_ipaddr_t ipv4_src;
11752 cmdline_ipaddr_t ipv6_src;
11754 cmdline_fixed_string_t dst_mask;
11755 cmdline_ipaddr_t ipv4_dst;
11756 cmdline_ipaddr_t ipv6_dst;
11758 cmdline_fixed_string_t mac;
11759 uint8_t mac_addr_byte_mask;
11760 cmdline_fixed_string_t tunnel_id;
11761 uint32_t tunnel_id_mask;
11762 cmdline_fixed_string_t tunnel_type;
11763 uint8_t tunnel_type_mask;
11767 cmd_flow_director_mask_parsed(void *parsed_result,
11768 __rte_unused struct cmdline *cl,
11769 __rte_unused void *data)
11771 struct cmd_flow_director_mask_result *res = parsed_result;
11772 struct rte_eth_fdir_masks *mask;
11773 struct rte_port *port;
11775 port = &ports[res->port_id];
11776 /** Check if the port is not started **/
11777 if (port->port_status != RTE_PORT_STOPPED) {
11778 printf("Please stop port %d first\n", res->port_id);
11782 mask = &port->dev_conf.fdir_conf.mask;
11784 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11785 if (strcmp(res->mode_value, "MAC-VLAN")) {
11786 printf("Please set mode to MAC-VLAN.\n");
11790 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11791 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11792 if (strcmp(res->mode_value, "Tunnel")) {
11793 printf("Please set mode to Tunnel.\n");
11797 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11798 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11799 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11800 mask->tunnel_type_mask = res->tunnel_type_mask;
11802 if (strcmp(res->mode_value, "IP")) {
11803 printf("Please set mode to IP.\n");
11807 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11808 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11809 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11810 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11811 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11812 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11813 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11816 cmd_reconfig_device_queue(res->port_id, 1, 1);
11819 cmdline_parse_token_string_t cmd_flow_director_mask =
11820 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11821 flow_director_mask, "flow_director_mask");
11822 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11823 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11825 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11828 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11829 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11830 vlan_mask, UINT16);
11831 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11833 src_mask, "src_mask");
11834 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11835 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11837 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11838 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11840 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11841 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11843 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11844 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11845 dst_mask, "dst_mask");
11846 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11847 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11849 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11850 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11852 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11853 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11856 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11857 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11859 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11860 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11862 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11863 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11864 mode_value, "MAC-VLAN");
11865 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11866 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11867 mode_value, "Tunnel");
11868 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11871 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11872 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11873 mac_addr_byte_mask, UINT8);
11874 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11876 tunnel_type, "tunnel-type");
11877 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11878 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11879 tunnel_type_mask, UINT8);
11880 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11881 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11882 tunnel_id, "tunnel-id");
11883 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11884 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11885 tunnel_id_mask, UINT32);
11887 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11888 .f = cmd_flow_director_mask_parsed,
11890 .help_str = "flow_director_mask ... : "
11891 "Set IP mode flow director's mask on NIC",
11893 (void *)&cmd_flow_director_mask,
11894 (void *)&cmd_flow_director_mask_port_id,
11895 (void *)&cmd_flow_director_mask_mode,
11896 (void *)&cmd_flow_director_mask_mode_ip,
11897 (void *)&cmd_flow_director_mask_vlan,
11898 (void *)&cmd_flow_director_mask_vlan_value,
11899 (void *)&cmd_flow_director_mask_src,
11900 (void *)&cmd_flow_director_mask_ipv4_src,
11901 (void *)&cmd_flow_director_mask_ipv6_src,
11902 (void *)&cmd_flow_director_mask_port_src,
11903 (void *)&cmd_flow_director_mask_dst,
11904 (void *)&cmd_flow_director_mask_ipv4_dst,
11905 (void *)&cmd_flow_director_mask_ipv6_dst,
11906 (void *)&cmd_flow_director_mask_port_dst,
11911 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11912 .f = cmd_flow_director_mask_parsed,
11914 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11915 "flow director's mask on NIC",
11917 (void *)&cmd_flow_director_mask,
11918 (void *)&cmd_flow_director_mask_port_id,
11919 (void *)&cmd_flow_director_mask_mode,
11920 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11921 (void *)&cmd_flow_director_mask_vlan,
11922 (void *)&cmd_flow_director_mask_vlan_value,
11927 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11928 .f = cmd_flow_director_mask_parsed,
11930 .help_str = "flow_director_mask ... : Set tunnel mode "
11931 "flow director's mask on NIC",
11933 (void *)&cmd_flow_director_mask,
11934 (void *)&cmd_flow_director_mask_port_id,
11935 (void *)&cmd_flow_director_mask_mode,
11936 (void *)&cmd_flow_director_mask_mode_tunnel,
11937 (void *)&cmd_flow_director_mask_vlan,
11938 (void *)&cmd_flow_director_mask_vlan_value,
11939 (void *)&cmd_flow_director_mask_mac,
11940 (void *)&cmd_flow_director_mask_mac_value,
11941 (void *)&cmd_flow_director_mask_tunnel_type,
11942 (void *)&cmd_flow_director_mask_tunnel_type_value,
11943 (void *)&cmd_flow_director_mask_tunnel_id,
11944 (void *)&cmd_flow_director_mask_tunnel_id_value,
11949 /* *** deal with flow director mask on flexible payload *** */
11950 struct cmd_flow_director_flex_mask_result {
11951 cmdline_fixed_string_t flow_director_flexmask;
11953 cmdline_fixed_string_t flow;
11954 cmdline_fixed_string_t flow_type;
11955 cmdline_fixed_string_t mask;
11959 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11960 __rte_unused struct cmdline *cl,
11961 __rte_unused void *data)
11963 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11964 struct rte_eth_fdir_info fdir_info;
11965 struct rte_eth_fdir_flex_mask flex_mask;
11966 struct rte_port *port;
11967 uint64_t flow_type_mask;
11971 port = &ports[res->port_id];
11972 /** Check if the port is not started **/
11973 if (port->port_status != RTE_PORT_STOPPED) {
11974 printf("Please stop port %d first\n", res->port_id);
11978 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11979 ret = parse_flexbytes(res->mask,
11981 RTE_ETH_FDIR_MAX_FLEXLEN);
11983 printf("error: Cannot parse mask input.\n");
11987 memset(&fdir_info, 0, sizeof(fdir_info));
11988 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11989 RTE_ETH_FILTER_INFO, &fdir_info);
11991 printf("Cannot get FDir filter info\n");
11995 if (!strcmp(res->flow_type, "none")) {
11996 /* means don't specify the flow type */
11997 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11998 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11999 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12000 0, sizeof(struct rte_eth_fdir_flex_mask));
12001 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12002 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12004 sizeof(struct rte_eth_fdir_flex_mask));
12005 cmd_reconfig_device_queue(res->port_id, 1, 1);
12008 flow_type_mask = fdir_info.flow_types_mask[0];
12009 if (!strcmp(res->flow_type, "all")) {
12010 if (!flow_type_mask) {
12011 printf("No flow type supported\n");
12014 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12015 if (flow_type_mask & (1ULL << i)) {
12016 flex_mask.flow_type = i;
12017 fdir_set_flex_mask(res->port_id, &flex_mask);
12020 cmd_reconfig_device_queue(res->port_id, 1, 1);
12023 flex_mask.flow_type = str2flowtype(res->flow_type);
12024 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12025 printf("Flow type %s not supported on port %d\n",
12026 res->flow_type, res->port_id);
12029 fdir_set_flex_mask(res->port_id, &flex_mask);
12030 cmd_reconfig_device_queue(res->port_id, 1, 1);
12033 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12034 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12035 flow_director_flexmask,
12036 "flow_director_flex_mask");
12037 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12038 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12040 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12041 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12043 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12044 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12045 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12046 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12047 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12048 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12051 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12052 .f = cmd_flow_director_flex_mask_parsed,
12054 .help_str = "flow_director_flex_mask ... : "
12055 "Set flow director's flex mask on NIC",
12057 (void *)&cmd_flow_director_flexmask,
12058 (void *)&cmd_flow_director_flexmask_port_id,
12059 (void *)&cmd_flow_director_flexmask_flow,
12060 (void *)&cmd_flow_director_flexmask_flow_type,
12061 (void *)&cmd_flow_director_flexmask_mask,
12066 /* *** deal with flow director flexible payload configuration *** */
12067 struct cmd_flow_director_flexpayload_result {
12068 cmdline_fixed_string_t flow_director_flexpayload;
12070 cmdline_fixed_string_t payload_layer;
12071 cmdline_fixed_string_t payload_cfg;
12075 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12078 const char *p, *p0 = q_arg;
12080 unsigned long int_fld;
12081 char *str_fld[max_num];
12086 p = strchr(p0, '(');
12090 p0 = strchr(p, ')');
12095 if (size >= sizeof(s))
12098 snprintf(s, sizeof(s), "%.*s", size, p);
12099 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12100 if (ret < 0 || ret > max_num)
12102 for (i = 0; i < ret; i++) {
12104 int_fld = strtoul(str_fld[i], &end, 0);
12105 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12107 offsets[i] = (uint16_t)int_fld;
12113 cmd_flow_director_flxpld_parsed(void *parsed_result,
12114 __rte_unused struct cmdline *cl,
12115 __rte_unused void *data)
12117 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12118 struct rte_eth_flex_payload_cfg flex_cfg;
12119 struct rte_port *port;
12122 port = &ports[res->port_id];
12123 /** Check if the port is not started **/
12124 if (port->port_status != RTE_PORT_STOPPED) {
12125 printf("Please stop port %d first\n", res->port_id);
12129 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12131 if (!strcmp(res->payload_layer, "raw"))
12132 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12133 else if (!strcmp(res->payload_layer, "l2"))
12134 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12135 else if (!strcmp(res->payload_layer, "l3"))
12136 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12137 else if (!strcmp(res->payload_layer, "l4"))
12138 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12140 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12141 RTE_ETH_FDIR_MAX_FLEXLEN);
12143 printf("error: Cannot parse flex payload input.\n");
12147 fdir_set_flex_payload(res->port_id, &flex_cfg);
12148 cmd_reconfig_device_queue(res->port_id, 1, 1);
12151 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12153 flow_director_flexpayload,
12154 "flow_director_flex_payload");
12155 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12156 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12158 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12159 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12160 payload_layer, "raw#l2#l3#l4");
12161 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12162 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12163 payload_cfg, NULL);
12165 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12166 .f = cmd_flow_director_flxpld_parsed,
12168 .help_str = "flow_director_flexpayload ... : "
12169 "Set flow director's flex payload on NIC",
12171 (void *)&cmd_flow_director_flexpayload,
12172 (void *)&cmd_flow_director_flexpayload_port_id,
12173 (void *)&cmd_flow_director_flexpayload_payload_layer,
12174 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12179 /* Generic flow interface command. */
12180 extern cmdline_parse_inst_t cmd_flow;
12182 /* *** Classification Filters Control *** */
12183 /* *** Get symmetric hash enable per port *** */
12184 struct cmd_get_sym_hash_ena_per_port_result {
12185 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12190 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12191 __rte_unused struct cmdline *cl,
12192 __rte_unused void *data)
12194 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12195 struct rte_eth_hash_filter_info info;
12198 if (rte_eth_dev_filter_supported(res->port_id,
12199 RTE_ETH_FILTER_HASH) < 0) {
12200 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12205 memset(&info, 0, sizeof(info));
12206 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12207 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12208 RTE_ETH_FILTER_GET, &info);
12211 printf("Cannot get symmetric hash enable per port "
12212 "on port %u\n", res->port_id);
12216 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12217 "enabled" : "disabled", res->port_id);
12220 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12221 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12222 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12223 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12224 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12227 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12228 .f = cmd_get_sym_hash_per_port_parsed,
12230 .help_str = "get_sym_hash_ena_per_port <port_id>",
12232 (void *)&cmd_get_sym_hash_ena_per_port_all,
12233 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12238 /* *** Set symmetric hash enable per port *** */
12239 struct cmd_set_sym_hash_ena_per_port_result {
12240 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12241 cmdline_fixed_string_t enable;
12246 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12247 __rte_unused struct cmdline *cl,
12248 __rte_unused void *data)
12250 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12251 struct rte_eth_hash_filter_info info;
12254 if (rte_eth_dev_filter_supported(res->port_id,
12255 RTE_ETH_FILTER_HASH) < 0) {
12256 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12261 memset(&info, 0, sizeof(info));
12262 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12263 if (!strcmp(res->enable, "enable"))
12264 info.info.enable = 1;
12265 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12266 RTE_ETH_FILTER_SET, &info);
12268 printf("Cannot set symmetric hash enable per port on "
12269 "port %u\n", res->port_id);
12272 printf("Symmetric hash has been set to %s on port %u\n",
12273 res->enable, res->port_id);
12276 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12277 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12278 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12279 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12280 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12282 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12283 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12284 enable, "enable#disable");
12286 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12287 .f = cmd_set_sym_hash_per_port_parsed,
12289 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12291 (void *)&cmd_set_sym_hash_ena_per_port_all,
12292 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12293 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12298 /* Get global config of hash function */
12299 struct cmd_get_hash_global_config_result {
12300 cmdline_fixed_string_t get_hash_global_config;
12305 flowtype_to_str(uint16_t ftype)
12311 } ftype_table[] = {
12312 {"ipv4", RTE_ETH_FLOW_IPV4},
12313 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12314 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12315 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12316 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12317 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12318 {"ipv6", RTE_ETH_FLOW_IPV6},
12319 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12320 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12321 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12322 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12323 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12324 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12325 {"port", RTE_ETH_FLOW_PORT},
12326 {"vxlan", RTE_ETH_FLOW_VXLAN},
12327 {"geneve", RTE_ETH_FLOW_GENEVE},
12328 {"nvgre", RTE_ETH_FLOW_NVGRE},
12329 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12332 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12333 if (ftype_table[i].ftype == ftype)
12334 return ftype_table[i].str;
12341 cmd_get_hash_global_config_parsed(void *parsed_result,
12342 __rte_unused struct cmdline *cl,
12343 __rte_unused void *data)
12345 struct cmd_get_hash_global_config_result *res = parsed_result;
12346 struct rte_eth_hash_filter_info info;
12347 uint32_t idx, offset;
12352 if (rte_eth_dev_filter_supported(res->port_id,
12353 RTE_ETH_FILTER_HASH) < 0) {
12354 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12359 memset(&info, 0, sizeof(info));
12360 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12361 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12362 RTE_ETH_FILTER_GET, &info);
12364 printf("Cannot get hash global configurations by port %d\n",
12369 switch (info.info.global_conf.hash_func) {
12370 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12371 printf("Hash function is Toeplitz\n");
12373 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12374 printf("Hash function is Simple XOR\n");
12376 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12377 printf("Hash function is Symmetric Toeplitz\n");
12380 printf("Unknown hash function\n");
12384 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12385 idx = i / UINT64_BIT;
12386 offset = i % UINT64_BIT;
12387 if (!(info.info.global_conf.valid_bit_mask[idx] &
12390 str = flowtype_to_str(i);
12393 printf("Symmetric hash is %s globally for flow type %s "
12395 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12396 (1ULL << offset)) ? "enabled" : "disabled"), str,
12401 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12402 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12403 get_hash_global_config, "get_hash_global_config");
12404 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12405 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12408 cmdline_parse_inst_t cmd_get_hash_global_config = {
12409 .f = cmd_get_hash_global_config_parsed,
12411 .help_str = "get_hash_global_config <port_id>",
12413 (void *)&cmd_get_hash_global_config_all,
12414 (void *)&cmd_get_hash_global_config_port_id,
12419 /* Set global config of hash function */
12420 struct cmd_set_hash_global_config_result {
12421 cmdline_fixed_string_t set_hash_global_config;
12423 cmdline_fixed_string_t hash_func;
12424 cmdline_fixed_string_t flow_type;
12425 cmdline_fixed_string_t enable;
12429 cmd_set_hash_global_config_parsed(void *parsed_result,
12430 __rte_unused struct cmdline *cl,
12431 __rte_unused void *data)
12433 struct cmd_set_hash_global_config_result *res = parsed_result;
12434 struct rte_eth_hash_filter_info info;
12435 uint32_t ftype, idx, offset;
12438 if (rte_eth_dev_filter_supported(res->port_id,
12439 RTE_ETH_FILTER_HASH) < 0) {
12440 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12444 memset(&info, 0, sizeof(info));
12445 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12446 if (!strcmp(res->hash_func, "toeplitz"))
12447 info.info.global_conf.hash_func =
12448 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12449 else if (!strcmp(res->hash_func, "simple_xor"))
12450 info.info.global_conf.hash_func =
12451 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12452 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12453 info.info.global_conf.hash_func =
12454 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12455 else if (!strcmp(res->hash_func, "default"))
12456 info.info.global_conf.hash_func =
12457 RTE_ETH_HASH_FUNCTION_DEFAULT;
12459 ftype = str2flowtype(res->flow_type);
12460 idx = ftype / UINT64_BIT;
12461 offset = ftype % UINT64_BIT;
12462 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12463 if (!strcmp(res->enable, "enable"))
12464 info.info.global_conf.sym_hash_enable_mask[idx] |=
12466 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12467 RTE_ETH_FILTER_SET, &info);
12469 printf("Cannot set global hash configurations by port %d\n",
12472 printf("Global hash configurations have been set "
12473 "successfully by port %d\n", res->port_id);
12476 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12477 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12478 set_hash_global_config, "set_hash_global_config");
12479 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12480 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12482 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12483 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12484 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12485 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12486 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12488 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12489 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12490 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12491 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12492 enable, "enable#disable");
12494 cmdline_parse_inst_t cmd_set_hash_global_config = {
12495 .f = cmd_set_hash_global_config_parsed,
12497 .help_str = "set_hash_global_config <port_id> "
12498 "toeplitz|simple_xor|symmetric_toeplitz|default "
12499 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12500 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12501 "l2_payload enable|disable",
12503 (void *)&cmd_set_hash_global_config_all,
12504 (void *)&cmd_set_hash_global_config_port_id,
12505 (void *)&cmd_set_hash_global_config_hash_func,
12506 (void *)&cmd_set_hash_global_config_flow_type,
12507 (void *)&cmd_set_hash_global_config_enable,
12512 /* Set hash input set */
12513 struct cmd_set_hash_input_set_result {
12514 cmdline_fixed_string_t set_hash_input_set;
12516 cmdline_fixed_string_t flow_type;
12517 cmdline_fixed_string_t inset_field;
12518 cmdline_fixed_string_t select;
12521 static enum rte_eth_input_set_field
12522 str2inset(char *string)
12526 static const struct {
12528 enum rte_eth_input_set_field inset;
12529 } inset_table[] = {
12530 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12531 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12532 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12533 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12534 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12535 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12536 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12537 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12538 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12539 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12540 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12541 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12542 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12543 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12544 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12545 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12546 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12547 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12548 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12549 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12550 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12551 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12552 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12553 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12554 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12555 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12556 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12557 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12558 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12559 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12560 {"none", RTE_ETH_INPUT_SET_NONE},
12563 for (i = 0; i < RTE_DIM(inset_table); i++) {
12564 if (!strcmp(string, inset_table[i].str))
12565 return inset_table[i].inset;
12568 return RTE_ETH_INPUT_SET_UNKNOWN;
12572 cmd_set_hash_input_set_parsed(void *parsed_result,
12573 __rte_unused struct cmdline *cl,
12574 __rte_unused void *data)
12576 struct cmd_set_hash_input_set_result *res = parsed_result;
12577 struct rte_eth_hash_filter_info info;
12579 memset(&info, 0, sizeof(info));
12580 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12581 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12582 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12583 info.info.input_set_conf.inset_size = 1;
12584 if (!strcmp(res->select, "select"))
12585 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12586 else if (!strcmp(res->select, "add"))
12587 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12588 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12589 RTE_ETH_FILTER_SET, &info);
12592 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12593 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12594 set_hash_input_set, "set_hash_input_set");
12595 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12596 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12598 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12599 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12601 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12602 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12604 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12605 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12606 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12607 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12608 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12610 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12611 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12612 select, "select#add");
12614 cmdline_parse_inst_t cmd_set_hash_input_set = {
12615 .f = cmd_set_hash_input_set_parsed,
12617 .help_str = "set_hash_input_set <port_id> "
12618 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12619 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12620 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12621 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12622 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12623 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12624 "fld-7th|fld-8th|none select|add",
12626 (void *)&cmd_set_hash_input_set_cmd,
12627 (void *)&cmd_set_hash_input_set_port_id,
12628 (void *)&cmd_set_hash_input_set_flow_type,
12629 (void *)&cmd_set_hash_input_set_field,
12630 (void *)&cmd_set_hash_input_set_select,
12635 /* Set flow director input set */
12636 struct cmd_set_fdir_input_set_result {
12637 cmdline_fixed_string_t set_fdir_input_set;
12639 cmdline_fixed_string_t flow_type;
12640 cmdline_fixed_string_t inset_field;
12641 cmdline_fixed_string_t select;
12645 cmd_set_fdir_input_set_parsed(void *parsed_result,
12646 __rte_unused struct cmdline *cl,
12647 __rte_unused void *data)
12649 struct cmd_set_fdir_input_set_result *res = parsed_result;
12650 struct rte_eth_fdir_filter_info info;
12652 memset(&info, 0, sizeof(info));
12653 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12654 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12655 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12656 info.info.input_set_conf.inset_size = 1;
12657 if (!strcmp(res->select, "select"))
12658 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12659 else if (!strcmp(res->select, "add"))
12660 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12661 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12662 RTE_ETH_FILTER_SET, &info);
12665 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12666 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12667 set_fdir_input_set, "set_fdir_input_set");
12668 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12669 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12671 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12672 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12674 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12675 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12676 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12677 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12679 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12680 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12681 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12682 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12683 "sctp-veri-tag#none");
12684 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12685 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12686 select, "select#add");
12688 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12689 .f = cmd_set_fdir_input_set_parsed,
12691 .help_str = "set_fdir_input_set <port_id> "
12692 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12693 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12694 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12695 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12696 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12697 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12698 "sctp-veri-tag|none select|add",
12700 (void *)&cmd_set_fdir_input_set_cmd,
12701 (void *)&cmd_set_fdir_input_set_port_id,
12702 (void *)&cmd_set_fdir_input_set_flow_type,
12703 (void *)&cmd_set_fdir_input_set_field,
12704 (void *)&cmd_set_fdir_input_set_select,
12709 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12710 struct cmd_mcast_addr_result {
12711 cmdline_fixed_string_t mcast_addr_cmd;
12712 cmdline_fixed_string_t what;
12714 struct rte_ether_addr mc_addr;
12717 static void cmd_mcast_addr_parsed(void *parsed_result,
12718 __rte_unused struct cmdline *cl,
12719 __rte_unused void *data)
12721 struct cmd_mcast_addr_result *res = parsed_result;
12723 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12724 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12725 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12726 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12727 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12730 if (strcmp(res->what, "add") == 0)
12731 mcast_addr_add(res->port_num, &res->mc_addr);
12733 mcast_addr_remove(res->port_num, &res->mc_addr);
12736 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12737 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12738 mcast_addr_cmd, "mcast_addr");
12739 cmdline_parse_token_string_t cmd_mcast_addr_what =
12740 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12742 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12743 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12744 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12745 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12747 cmdline_parse_inst_t cmd_mcast_addr = {
12748 .f = cmd_mcast_addr_parsed,
12750 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12751 "Add/Remove multicast MAC address on port_id",
12753 (void *)&cmd_mcast_addr_cmd,
12754 (void *)&cmd_mcast_addr_what,
12755 (void *)&cmd_mcast_addr_portnum,
12756 (void *)&cmd_mcast_addr_addr,
12761 /* l2 tunnel config
12762 * only support E-tag now.
12765 /* Ether type config */
12766 struct cmd_config_l2_tunnel_eth_type_result {
12767 cmdline_fixed_string_t port;
12768 cmdline_fixed_string_t config;
12769 cmdline_fixed_string_t all;
12771 cmdline_fixed_string_t l2_tunnel;
12772 cmdline_fixed_string_t l2_tunnel_type;
12773 cmdline_fixed_string_t eth_type;
12774 uint16_t eth_type_val;
12777 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12778 TOKEN_STRING_INITIALIZER
12779 (struct cmd_config_l2_tunnel_eth_type_result,
12781 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12782 TOKEN_STRING_INITIALIZER
12783 (struct cmd_config_l2_tunnel_eth_type_result,
12785 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12786 TOKEN_STRING_INITIALIZER
12787 (struct cmd_config_l2_tunnel_eth_type_result,
12789 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12790 TOKEN_NUM_INITIALIZER
12791 (struct cmd_config_l2_tunnel_eth_type_result,
12793 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12794 TOKEN_STRING_INITIALIZER
12795 (struct cmd_config_l2_tunnel_eth_type_result,
12796 l2_tunnel, "l2-tunnel");
12797 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12798 TOKEN_STRING_INITIALIZER
12799 (struct cmd_config_l2_tunnel_eth_type_result,
12800 l2_tunnel_type, "E-tag");
12801 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12802 TOKEN_STRING_INITIALIZER
12803 (struct cmd_config_l2_tunnel_eth_type_result,
12804 eth_type, "ether-type");
12805 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12806 TOKEN_NUM_INITIALIZER
12807 (struct cmd_config_l2_tunnel_eth_type_result,
12808 eth_type_val, UINT16);
12810 static enum rte_eth_tunnel_type
12811 str2fdir_l2_tunnel_type(char *string)
12815 static const struct {
12817 enum rte_eth_tunnel_type type;
12818 } l2_tunnel_type_str[] = {
12819 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12822 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12823 if (!strcmp(l2_tunnel_type_str[i].str, string))
12824 return l2_tunnel_type_str[i].type;
12826 return RTE_TUNNEL_TYPE_NONE;
12829 /* ether type config for all ports */
12831 cmd_config_l2_tunnel_eth_type_all_parsed
12832 (void *parsed_result,
12833 __rte_unused struct cmdline *cl,
12834 __rte_unused void *data)
12836 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12837 struct rte_eth_l2_tunnel_conf entry;
12840 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12841 entry.ether_type = res->eth_type_val;
12843 RTE_ETH_FOREACH_DEV(pid) {
12844 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12848 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12849 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12851 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12853 (void *)&cmd_config_l2_tunnel_eth_type_port,
12854 (void *)&cmd_config_l2_tunnel_eth_type_config,
12855 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12856 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12857 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12858 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12859 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12864 /* ether type config for a specific port */
12866 cmd_config_l2_tunnel_eth_type_specific_parsed(
12867 void *parsed_result,
12868 __rte_unused struct cmdline *cl,
12869 __rte_unused void *data)
12871 struct cmd_config_l2_tunnel_eth_type_result *res =
12873 struct rte_eth_l2_tunnel_conf entry;
12875 if (port_id_is_invalid(res->id, ENABLED_WARN))
12878 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12879 entry.ether_type = res->eth_type_val;
12881 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12884 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12885 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12887 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12889 (void *)&cmd_config_l2_tunnel_eth_type_port,
12890 (void *)&cmd_config_l2_tunnel_eth_type_config,
12891 (void *)&cmd_config_l2_tunnel_eth_type_id,
12892 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12893 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12894 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12895 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12900 /* Enable/disable l2 tunnel */
12901 struct cmd_config_l2_tunnel_en_dis_result {
12902 cmdline_fixed_string_t port;
12903 cmdline_fixed_string_t config;
12904 cmdline_fixed_string_t all;
12906 cmdline_fixed_string_t l2_tunnel;
12907 cmdline_fixed_string_t l2_tunnel_type;
12908 cmdline_fixed_string_t en_dis;
12911 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12912 TOKEN_STRING_INITIALIZER
12913 (struct cmd_config_l2_tunnel_en_dis_result,
12915 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12916 TOKEN_STRING_INITIALIZER
12917 (struct cmd_config_l2_tunnel_en_dis_result,
12919 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12920 TOKEN_STRING_INITIALIZER
12921 (struct cmd_config_l2_tunnel_en_dis_result,
12923 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12924 TOKEN_NUM_INITIALIZER
12925 (struct cmd_config_l2_tunnel_en_dis_result,
12927 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12928 TOKEN_STRING_INITIALIZER
12929 (struct cmd_config_l2_tunnel_en_dis_result,
12930 l2_tunnel, "l2-tunnel");
12931 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12932 TOKEN_STRING_INITIALIZER
12933 (struct cmd_config_l2_tunnel_en_dis_result,
12934 l2_tunnel_type, "E-tag");
12935 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12936 TOKEN_STRING_INITIALIZER
12937 (struct cmd_config_l2_tunnel_en_dis_result,
12938 en_dis, "enable#disable");
12940 /* enable/disable l2 tunnel for all ports */
12942 cmd_config_l2_tunnel_en_dis_all_parsed(
12943 void *parsed_result,
12944 __rte_unused struct cmdline *cl,
12945 __rte_unused void *data)
12947 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12948 struct rte_eth_l2_tunnel_conf entry;
12952 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12954 if (!strcmp("enable", res->en_dis))
12959 RTE_ETH_FOREACH_DEV(pid) {
12960 rte_eth_dev_l2_tunnel_offload_set(pid,
12962 ETH_L2_TUNNEL_ENABLE_MASK,
12967 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12968 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12970 .help_str = "port config all l2-tunnel E-tag enable|disable",
12972 (void *)&cmd_config_l2_tunnel_en_dis_port,
12973 (void *)&cmd_config_l2_tunnel_en_dis_config,
12974 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12975 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12976 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12977 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12982 /* enable/disable l2 tunnel for a port */
12984 cmd_config_l2_tunnel_en_dis_specific_parsed(
12985 void *parsed_result,
12986 __rte_unused struct cmdline *cl,
12987 __rte_unused void *data)
12989 struct cmd_config_l2_tunnel_en_dis_result *res =
12991 struct rte_eth_l2_tunnel_conf entry;
12993 if (port_id_is_invalid(res->id, ENABLED_WARN))
12996 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12998 if (!strcmp("enable", res->en_dis))
12999 rte_eth_dev_l2_tunnel_offload_set(res->id,
13001 ETH_L2_TUNNEL_ENABLE_MASK,
13004 rte_eth_dev_l2_tunnel_offload_set(res->id,
13006 ETH_L2_TUNNEL_ENABLE_MASK,
13010 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13011 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13013 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13015 (void *)&cmd_config_l2_tunnel_en_dis_port,
13016 (void *)&cmd_config_l2_tunnel_en_dis_config,
13017 (void *)&cmd_config_l2_tunnel_en_dis_id,
13018 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13019 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13020 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13025 /* E-tag configuration */
13027 /* Common result structure for all E-tag configuration */
13028 struct cmd_config_e_tag_result {
13029 cmdline_fixed_string_t e_tag;
13030 cmdline_fixed_string_t set;
13031 cmdline_fixed_string_t insertion;
13032 cmdline_fixed_string_t stripping;
13033 cmdline_fixed_string_t forwarding;
13034 cmdline_fixed_string_t filter;
13035 cmdline_fixed_string_t add;
13036 cmdline_fixed_string_t del;
13037 cmdline_fixed_string_t on;
13038 cmdline_fixed_string_t off;
13039 cmdline_fixed_string_t on_off;
13040 cmdline_fixed_string_t port_tag_id;
13041 uint32_t port_tag_id_val;
13042 cmdline_fixed_string_t e_tag_id;
13043 uint16_t e_tag_id_val;
13044 cmdline_fixed_string_t dst_pool;
13045 uint8_t dst_pool_val;
13046 cmdline_fixed_string_t port;
13048 cmdline_fixed_string_t vf;
13052 /* Common CLI fields for all E-tag configuration */
13053 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13054 TOKEN_STRING_INITIALIZER
13055 (struct cmd_config_e_tag_result,
13057 cmdline_parse_token_string_t cmd_config_e_tag_set =
13058 TOKEN_STRING_INITIALIZER
13059 (struct cmd_config_e_tag_result,
13061 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13062 TOKEN_STRING_INITIALIZER
13063 (struct cmd_config_e_tag_result,
13064 insertion, "insertion");
13065 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13066 TOKEN_STRING_INITIALIZER
13067 (struct cmd_config_e_tag_result,
13068 stripping, "stripping");
13069 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13070 TOKEN_STRING_INITIALIZER
13071 (struct cmd_config_e_tag_result,
13072 forwarding, "forwarding");
13073 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13074 TOKEN_STRING_INITIALIZER
13075 (struct cmd_config_e_tag_result,
13077 cmdline_parse_token_string_t cmd_config_e_tag_add =
13078 TOKEN_STRING_INITIALIZER
13079 (struct cmd_config_e_tag_result,
13081 cmdline_parse_token_string_t cmd_config_e_tag_del =
13082 TOKEN_STRING_INITIALIZER
13083 (struct cmd_config_e_tag_result,
13085 cmdline_parse_token_string_t cmd_config_e_tag_on =
13086 TOKEN_STRING_INITIALIZER
13087 (struct cmd_config_e_tag_result,
13089 cmdline_parse_token_string_t cmd_config_e_tag_off =
13090 TOKEN_STRING_INITIALIZER
13091 (struct cmd_config_e_tag_result,
13093 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13094 TOKEN_STRING_INITIALIZER
13095 (struct cmd_config_e_tag_result,
13097 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13098 TOKEN_STRING_INITIALIZER
13099 (struct cmd_config_e_tag_result,
13100 port_tag_id, "port-tag-id");
13101 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13102 TOKEN_NUM_INITIALIZER
13103 (struct cmd_config_e_tag_result,
13104 port_tag_id_val, UINT32);
13105 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13106 TOKEN_STRING_INITIALIZER
13107 (struct cmd_config_e_tag_result,
13108 e_tag_id, "e-tag-id");
13109 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13110 TOKEN_NUM_INITIALIZER
13111 (struct cmd_config_e_tag_result,
13112 e_tag_id_val, UINT16);
13113 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13114 TOKEN_STRING_INITIALIZER
13115 (struct cmd_config_e_tag_result,
13116 dst_pool, "dst-pool");
13117 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13118 TOKEN_NUM_INITIALIZER
13119 (struct cmd_config_e_tag_result,
13120 dst_pool_val, UINT8);
13121 cmdline_parse_token_string_t cmd_config_e_tag_port =
13122 TOKEN_STRING_INITIALIZER
13123 (struct cmd_config_e_tag_result,
13125 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13126 TOKEN_NUM_INITIALIZER
13127 (struct cmd_config_e_tag_result,
13129 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13130 TOKEN_STRING_INITIALIZER
13131 (struct cmd_config_e_tag_result,
13133 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13134 TOKEN_NUM_INITIALIZER
13135 (struct cmd_config_e_tag_result,
13138 /* E-tag insertion configuration */
13140 cmd_config_e_tag_insertion_en_parsed(
13141 void *parsed_result,
13142 __rte_unused struct cmdline *cl,
13143 __rte_unused void *data)
13145 struct cmd_config_e_tag_result *res =
13147 struct rte_eth_l2_tunnel_conf entry;
13149 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13152 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13153 entry.tunnel_id = res->port_tag_id_val;
13154 entry.vf_id = res->vf_id;
13155 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13157 ETH_L2_TUNNEL_INSERTION_MASK,
13162 cmd_config_e_tag_insertion_dis_parsed(
13163 void *parsed_result,
13164 __rte_unused struct cmdline *cl,
13165 __rte_unused void *data)
13167 struct cmd_config_e_tag_result *res =
13169 struct rte_eth_l2_tunnel_conf entry;
13171 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13174 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13175 entry.vf_id = res->vf_id;
13177 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13179 ETH_L2_TUNNEL_INSERTION_MASK,
13183 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13184 .f = cmd_config_e_tag_insertion_en_parsed,
13186 .help_str = "E-tag ... : E-tag insertion enable",
13188 (void *)&cmd_config_e_tag_e_tag,
13189 (void *)&cmd_config_e_tag_set,
13190 (void *)&cmd_config_e_tag_insertion,
13191 (void *)&cmd_config_e_tag_on,
13192 (void *)&cmd_config_e_tag_port_tag_id,
13193 (void *)&cmd_config_e_tag_port_tag_id_val,
13194 (void *)&cmd_config_e_tag_port,
13195 (void *)&cmd_config_e_tag_port_id,
13196 (void *)&cmd_config_e_tag_vf,
13197 (void *)&cmd_config_e_tag_vf_id,
13202 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13203 .f = cmd_config_e_tag_insertion_dis_parsed,
13205 .help_str = "E-tag ... : E-tag insertion disable",
13207 (void *)&cmd_config_e_tag_e_tag,
13208 (void *)&cmd_config_e_tag_set,
13209 (void *)&cmd_config_e_tag_insertion,
13210 (void *)&cmd_config_e_tag_off,
13211 (void *)&cmd_config_e_tag_port,
13212 (void *)&cmd_config_e_tag_port_id,
13213 (void *)&cmd_config_e_tag_vf,
13214 (void *)&cmd_config_e_tag_vf_id,
13219 /* E-tag stripping configuration */
13221 cmd_config_e_tag_stripping_parsed(
13222 void *parsed_result,
13223 __rte_unused struct cmdline *cl,
13224 __rte_unused void *data)
13226 struct cmd_config_e_tag_result *res =
13228 struct rte_eth_l2_tunnel_conf entry;
13230 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13233 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13235 if (!strcmp(res->on_off, "on"))
13236 rte_eth_dev_l2_tunnel_offload_set
13239 ETH_L2_TUNNEL_STRIPPING_MASK,
13242 rte_eth_dev_l2_tunnel_offload_set
13245 ETH_L2_TUNNEL_STRIPPING_MASK,
13249 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13250 .f = cmd_config_e_tag_stripping_parsed,
13252 .help_str = "E-tag ... : E-tag stripping enable/disable",
13254 (void *)&cmd_config_e_tag_e_tag,
13255 (void *)&cmd_config_e_tag_set,
13256 (void *)&cmd_config_e_tag_stripping,
13257 (void *)&cmd_config_e_tag_on_off,
13258 (void *)&cmd_config_e_tag_port,
13259 (void *)&cmd_config_e_tag_port_id,
13264 /* E-tag forwarding configuration */
13266 cmd_config_e_tag_forwarding_parsed(
13267 void *parsed_result,
13268 __rte_unused struct cmdline *cl,
13269 __rte_unused void *data)
13271 struct cmd_config_e_tag_result *res = parsed_result;
13272 struct rte_eth_l2_tunnel_conf entry;
13274 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13277 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13279 if (!strcmp(res->on_off, "on"))
13280 rte_eth_dev_l2_tunnel_offload_set
13283 ETH_L2_TUNNEL_FORWARDING_MASK,
13286 rte_eth_dev_l2_tunnel_offload_set
13289 ETH_L2_TUNNEL_FORWARDING_MASK,
13293 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13294 .f = cmd_config_e_tag_forwarding_parsed,
13296 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13298 (void *)&cmd_config_e_tag_e_tag,
13299 (void *)&cmd_config_e_tag_set,
13300 (void *)&cmd_config_e_tag_forwarding,
13301 (void *)&cmd_config_e_tag_on_off,
13302 (void *)&cmd_config_e_tag_port,
13303 (void *)&cmd_config_e_tag_port_id,
13308 /* E-tag filter configuration */
13310 cmd_config_e_tag_filter_add_parsed(
13311 void *parsed_result,
13312 __rte_unused struct cmdline *cl,
13313 __rte_unused void *data)
13315 struct cmd_config_e_tag_result *res = parsed_result;
13316 struct rte_eth_l2_tunnel_conf entry;
13319 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13322 if (res->e_tag_id_val > 0x3fff) {
13323 printf("e-tag-id must be equal or less than 0x3fff.\n");
13327 ret = rte_eth_dev_filter_supported(res->port_id,
13328 RTE_ETH_FILTER_L2_TUNNEL);
13330 printf("E-tag filter is not supported on port %u.\n",
13335 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13336 entry.tunnel_id = res->e_tag_id_val;
13337 entry.pool = res->dst_pool_val;
13339 ret = rte_eth_dev_filter_ctrl(res->port_id,
13340 RTE_ETH_FILTER_L2_TUNNEL,
13341 RTE_ETH_FILTER_ADD,
13344 printf("E-tag filter programming error: (%s)\n",
13348 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13349 .f = cmd_config_e_tag_filter_add_parsed,
13351 .help_str = "E-tag ... : E-tag filter add",
13353 (void *)&cmd_config_e_tag_e_tag,
13354 (void *)&cmd_config_e_tag_set,
13355 (void *)&cmd_config_e_tag_filter,
13356 (void *)&cmd_config_e_tag_add,
13357 (void *)&cmd_config_e_tag_e_tag_id,
13358 (void *)&cmd_config_e_tag_e_tag_id_val,
13359 (void *)&cmd_config_e_tag_dst_pool,
13360 (void *)&cmd_config_e_tag_dst_pool_val,
13361 (void *)&cmd_config_e_tag_port,
13362 (void *)&cmd_config_e_tag_port_id,
13368 cmd_config_e_tag_filter_del_parsed(
13369 void *parsed_result,
13370 __rte_unused struct cmdline *cl,
13371 __rte_unused void *data)
13373 struct cmd_config_e_tag_result *res = parsed_result;
13374 struct rte_eth_l2_tunnel_conf entry;
13377 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13380 if (res->e_tag_id_val > 0x3fff) {
13381 printf("e-tag-id must be less than 0x3fff.\n");
13385 ret = rte_eth_dev_filter_supported(res->port_id,
13386 RTE_ETH_FILTER_L2_TUNNEL);
13388 printf("E-tag filter is not supported on port %u.\n",
13393 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13394 entry.tunnel_id = res->e_tag_id_val;
13396 ret = rte_eth_dev_filter_ctrl(res->port_id,
13397 RTE_ETH_FILTER_L2_TUNNEL,
13398 RTE_ETH_FILTER_DELETE,
13401 printf("E-tag filter programming error: (%s)\n",
13405 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13406 .f = cmd_config_e_tag_filter_del_parsed,
13408 .help_str = "E-tag ... : E-tag filter delete",
13410 (void *)&cmd_config_e_tag_e_tag,
13411 (void *)&cmd_config_e_tag_set,
13412 (void *)&cmd_config_e_tag_filter,
13413 (void *)&cmd_config_e_tag_del,
13414 (void *)&cmd_config_e_tag_e_tag_id,
13415 (void *)&cmd_config_e_tag_e_tag_id_val,
13416 (void *)&cmd_config_e_tag_port,
13417 (void *)&cmd_config_e_tag_port_id,
13422 /* vf vlan anti spoof configuration */
13424 /* Common result structure for vf vlan anti spoof */
13425 struct cmd_vf_vlan_anti_spoof_result {
13426 cmdline_fixed_string_t set;
13427 cmdline_fixed_string_t vf;
13428 cmdline_fixed_string_t vlan;
13429 cmdline_fixed_string_t antispoof;
13432 cmdline_fixed_string_t on_off;
13435 /* Common CLI fields for vf vlan anti spoof enable disable */
13436 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13437 TOKEN_STRING_INITIALIZER
13438 (struct cmd_vf_vlan_anti_spoof_result,
13440 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13441 TOKEN_STRING_INITIALIZER
13442 (struct cmd_vf_vlan_anti_spoof_result,
13444 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13445 TOKEN_STRING_INITIALIZER
13446 (struct cmd_vf_vlan_anti_spoof_result,
13448 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13449 TOKEN_STRING_INITIALIZER
13450 (struct cmd_vf_vlan_anti_spoof_result,
13451 antispoof, "antispoof");
13452 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13453 TOKEN_NUM_INITIALIZER
13454 (struct cmd_vf_vlan_anti_spoof_result,
13456 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13457 TOKEN_NUM_INITIALIZER
13458 (struct cmd_vf_vlan_anti_spoof_result,
13460 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13461 TOKEN_STRING_INITIALIZER
13462 (struct cmd_vf_vlan_anti_spoof_result,
13466 cmd_set_vf_vlan_anti_spoof_parsed(
13467 void *parsed_result,
13468 __rte_unused struct cmdline *cl,
13469 __rte_unused void *data)
13471 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13472 int ret = -ENOTSUP;
13474 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13476 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13479 #ifdef RTE_LIBRTE_IXGBE_PMD
13480 if (ret == -ENOTSUP)
13481 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13482 res->vf_id, is_on);
13484 #ifdef RTE_LIBRTE_I40E_PMD
13485 if (ret == -ENOTSUP)
13486 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13487 res->vf_id, is_on);
13489 #ifdef RTE_LIBRTE_BNXT_PMD
13490 if (ret == -ENOTSUP)
13491 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13492 res->vf_id, is_on);
13499 printf("invalid vf_id %d\n", res->vf_id);
13502 printf("invalid port_id %d\n", res->port_id);
13505 printf("function not implemented\n");
13508 printf("programming error: (%s)\n", strerror(-ret));
13512 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13513 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13515 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13517 (void *)&cmd_vf_vlan_anti_spoof_set,
13518 (void *)&cmd_vf_vlan_anti_spoof_vf,
13519 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13520 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13521 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13522 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13523 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13528 /* vf mac anti spoof configuration */
13530 /* Common result structure for vf mac anti spoof */
13531 struct cmd_vf_mac_anti_spoof_result {
13532 cmdline_fixed_string_t set;
13533 cmdline_fixed_string_t vf;
13534 cmdline_fixed_string_t mac;
13535 cmdline_fixed_string_t antispoof;
13538 cmdline_fixed_string_t on_off;
13541 /* Common CLI fields for vf mac anti spoof enable disable */
13542 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13543 TOKEN_STRING_INITIALIZER
13544 (struct cmd_vf_mac_anti_spoof_result,
13546 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13547 TOKEN_STRING_INITIALIZER
13548 (struct cmd_vf_mac_anti_spoof_result,
13550 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13551 TOKEN_STRING_INITIALIZER
13552 (struct cmd_vf_mac_anti_spoof_result,
13554 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13555 TOKEN_STRING_INITIALIZER
13556 (struct cmd_vf_mac_anti_spoof_result,
13557 antispoof, "antispoof");
13558 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13559 TOKEN_NUM_INITIALIZER
13560 (struct cmd_vf_mac_anti_spoof_result,
13562 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13563 TOKEN_NUM_INITIALIZER
13564 (struct cmd_vf_mac_anti_spoof_result,
13566 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13567 TOKEN_STRING_INITIALIZER
13568 (struct cmd_vf_mac_anti_spoof_result,
13572 cmd_set_vf_mac_anti_spoof_parsed(
13573 void *parsed_result,
13574 __rte_unused struct cmdline *cl,
13575 __rte_unused void *data)
13577 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13578 int ret = -ENOTSUP;
13580 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13582 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13585 #ifdef RTE_LIBRTE_IXGBE_PMD
13586 if (ret == -ENOTSUP)
13587 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13588 res->vf_id, is_on);
13590 #ifdef RTE_LIBRTE_I40E_PMD
13591 if (ret == -ENOTSUP)
13592 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13593 res->vf_id, is_on);
13595 #ifdef RTE_LIBRTE_BNXT_PMD
13596 if (ret == -ENOTSUP)
13597 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13598 res->vf_id, is_on);
13605 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13608 printf("invalid port_id %d\n", res->port_id);
13611 printf("function not implemented\n");
13614 printf("programming error: (%s)\n", strerror(-ret));
13618 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13619 .f = cmd_set_vf_mac_anti_spoof_parsed,
13621 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13623 (void *)&cmd_vf_mac_anti_spoof_set,
13624 (void *)&cmd_vf_mac_anti_spoof_vf,
13625 (void *)&cmd_vf_mac_anti_spoof_mac,
13626 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13627 (void *)&cmd_vf_mac_anti_spoof_port_id,
13628 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13629 (void *)&cmd_vf_mac_anti_spoof_on_off,
13634 /* vf vlan strip queue configuration */
13636 /* Common result structure for vf mac anti spoof */
13637 struct cmd_vf_vlan_stripq_result {
13638 cmdline_fixed_string_t set;
13639 cmdline_fixed_string_t vf;
13640 cmdline_fixed_string_t vlan;
13641 cmdline_fixed_string_t stripq;
13644 cmdline_fixed_string_t on_off;
13647 /* Common CLI fields for vf vlan strip enable disable */
13648 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13649 TOKEN_STRING_INITIALIZER
13650 (struct cmd_vf_vlan_stripq_result,
13652 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13653 TOKEN_STRING_INITIALIZER
13654 (struct cmd_vf_vlan_stripq_result,
13656 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13657 TOKEN_STRING_INITIALIZER
13658 (struct cmd_vf_vlan_stripq_result,
13660 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13661 TOKEN_STRING_INITIALIZER
13662 (struct cmd_vf_vlan_stripq_result,
13664 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13665 TOKEN_NUM_INITIALIZER
13666 (struct cmd_vf_vlan_stripq_result,
13668 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13669 TOKEN_NUM_INITIALIZER
13670 (struct cmd_vf_vlan_stripq_result,
13672 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13673 TOKEN_STRING_INITIALIZER
13674 (struct cmd_vf_vlan_stripq_result,
13678 cmd_set_vf_vlan_stripq_parsed(
13679 void *parsed_result,
13680 __rte_unused struct cmdline *cl,
13681 __rte_unused void *data)
13683 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13684 int ret = -ENOTSUP;
13686 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13688 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13691 #ifdef RTE_LIBRTE_IXGBE_PMD
13692 if (ret == -ENOTSUP)
13693 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13694 res->vf_id, is_on);
13696 #ifdef RTE_LIBRTE_I40E_PMD
13697 if (ret == -ENOTSUP)
13698 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13699 res->vf_id, is_on);
13701 #ifdef RTE_LIBRTE_BNXT_PMD
13702 if (ret == -ENOTSUP)
13703 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13704 res->vf_id, is_on);
13711 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13714 printf("invalid port_id %d\n", res->port_id);
13717 printf("function not implemented\n");
13720 printf("programming error: (%s)\n", strerror(-ret));
13724 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13725 .f = cmd_set_vf_vlan_stripq_parsed,
13727 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13729 (void *)&cmd_vf_vlan_stripq_set,
13730 (void *)&cmd_vf_vlan_stripq_vf,
13731 (void *)&cmd_vf_vlan_stripq_vlan,
13732 (void *)&cmd_vf_vlan_stripq_stripq,
13733 (void *)&cmd_vf_vlan_stripq_port_id,
13734 (void *)&cmd_vf_vlan_stripq_vf_id,
13735 (void *)&cmd_vf_vlan_stripq_on_off,
13740 /* vf vlan insert configuration */
13742 /* Common result structure for vf vlan insert */
13743 struct cmd_vf_vlan_insert_result {
13744 cmdline_fixed_string_t set;
13745 cmdline_fixed_string_t vf;
13746 cmdline_fixed_string_t vlan;
13747 cmdline_fixed_string_t insert;
13753 /* Common CLI fields for vf vlan insert enable disable */
13754 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13755 TOKEN_STRING_INITIALIZER
13756 (struct cmd_vf_vlan_insert_result,
13758 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13759 TOKEN_STRING_INITIALIZER
13760 (struct cmd_vf_vlan_insert_result,
13762 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13763 TOKEN_STRING_INITIALIZER
13764 (struct cmd_vf_vlan_insert_result,
13766 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13767 TOKEN_STRING_INITIALIZER
13768 (struct cmd_vf_vlan_insert_result,
13770 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13771 TOKEN_NUM_INITIALIZER
13772 (struct cmd_vf_vlan_insert_result,
13774 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13775 TOKEN_NUM_INITIALIZER
13776 (struct cmd_vf_vlan_insert_result,
13778 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13779 TOKEN_NUM_INITIALIZER
13780 (struct cmd_vf_vlan_insert_result,
13784 cmd_set_vf_vlan_insert_parsed(
13785 void *parsed_result,
13786 __rte_unused struct cmdline *cl,
13787 __rte_unused void *data)
13789 struct cmd_vf_vlan_insert_result *res = parsed_result;
13790 int ret = -ENOTSUP;
13792 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13795 #ifdef RTE_LIBRTE_IXGBE_PMD
13796 if (ret == -ENOTSUP)
13797 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13800 #ifdef RTE_LIBRTE_I40E_PMD
13801 if (ret == -ENOTSUP)
13802 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13805 #ifdef RTE_LIBRTE_BNXT_PMD
13806 if (ret == -ENOTSUP)
13807 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13815 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13818 printf("invalid port_id %d\n", res->port_id);
13821 printf("function not implemented\n");
13824 printf("programming error: (%s)\n", strerror(-ret));
13828 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13829 .f = cmd_set_vf_vlan_insert_parsed,
13831 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13833 (void *)&cmd_vf_vlan_insert_set,
13834 (void *)&cmd_vf_vlan_insert_vf,
13835 (void *)&cmd_vf_vlan_insert_vlan,
13836 (void *)&cmd_vf_vlan_insert_insert,
13837 (void *)&cmd_vf_vlan_insert_port_id,
13838 (void *)&cmd_vf_vlan_insert_vf_id,
13839 (void *)&cmd_vf_vlan_insert_vlan_id,
13844 /* tx loopback configuration */
13846 /* Common result structure for tx loopback */
13847 struct cmd_tx_loopback_result {
13848 cmdline_fixed_string_t set;
13849 cmdline_fixed_string_t tx;
13850 cmdline_fixed_string_t loopback;
13852 cmdline_fixed_string_t on_off;
13855 /* Common CLI fields for tx loopback enable disable */
13856 cmdline_parse_token_string_t cmd_tx_loopback_set =
13857 TOKEN_STRING_INITIALIZER
13858 (struct cmd_tx_loopback_result,
13860 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13861 TOKEN_STRING_INITIALIZER
13862 (struct cmd_tx_loopback_result,
13864 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13865 TOKEN_STRING_INITIALIZER
13866 (struct cmd_tx_loopback_result,
13867 loopback, "loopback");
13868 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13869 TOKEN_NUM_INITIALIZER
13870 (struct cmd_tx_loopback_result,
13872 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13873 TOKEN_STRING_INITIALIZER
13874 (struct cmd_tx_loopback_result,
13878 cmd_set_tx_loopback_parsed(
13879 void *parsed_result,
13880 __rte_unused struct cmdline *cl,
13881 __rte_unused void *data)
13883 struct cmd_tx_loopback_result *res = parsed_result;
13884 int ret = -ENOTSUP;
13886 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13888 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13891 #ifdef RTE_LIBRTE_IXGBE_PMD
13892 if (ret == -ENOTSUP)
13893 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13895 #ifdef RTE_LIBRTE_I40E_PMD
13896 if (ret == -ENOTSUP)
13897 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13899 #ifdef RTE_LIBRTE_BNXT_PMD
13900 if (ret == -ENOTSUP)
13901 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13903 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13904 if (ret == -ENOTSUP)
13905 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13912 printf("invalid is_on %d\n", is_on);
13915 printf("invalid port_id %d\n", res->port_id);
13918 printf("function not implemented\n");
13921 printf("programming error: (%s)\n", strerror(-ret));
13925 cmdline_parse_inst_t cmd_set_tx_loopback = {
13926 .f = cmd_set_tx_loopback_parsed,
13928 .help_str = "set tx loopback <port_id> on|off",
13930 (void *)&cmd_tx_loopback_set,
13931 (void *)&cmd_tx_loopback_tx,
13932 (void *)&cmd_tx_loopback_loopback,
13933 (void *)&cmd_tx_loopback_port_id,
13934 (void *)&cmd_tx_loopback_on_off,
13939 /* all queues drop enable configuration */
13941 /* Common result structure for all queues drop enable */
13942 struct cmd_all_queues_drop_en_result {
13943 cmdline_fixed_string_t set;
13944 cmdline_fixed_string_t all;
13945 cmdline_fixed_string_t queues;
13946 cmdline_fixed_string_t drop;
13948 cmdline_fixed_string_t on_off;
13951 /* Common CLI fields for tx loopback enable disable */
13952 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13953 TOKEN_STRING_INITIALIZER
13954 (struct cmd_all_queues_drop_en_result,
13956 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13957 TOKEN_STRING_INITIALIZER
13958 (struct cmd_all_queues_drop_en_result,
13960 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13961 TOKEN_STRING_INITIALIZER
13962 (struct cmd_all_queues_drop_en_result,
13964 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13965 TOKEN_STRING_INITIALIZER
13966 (struct cmd_all_queues_drop_en_result,
13968 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13969 TOKEN_NUM_INITIALIZER
13970 (struct cmd_all_queues_drop_en_result,
13972 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13973 TOKEN_STRING_INITIALIZER
13974 (struct cmd_all_queues_drop_en_result,
13978 cmd_set_all_queues_drop_en_parsed(
13979 void *parsed_result,
13980 __rte_unused struct cmdline *cl,
13981 __rte_unused void *data)
13983 struct cmd_all_queues_drop_en_result *res = parsed_result;
13984 int ret = -ENOTSUP;
13985 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13987 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13990 #ifdef RTE_LIBRTE_IXGBE_PMD
13991 if (ret == -ENOTSUP)
13992 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13994 #ifdef RTE_LIBRTE_BNXT_PMD
13995 if (ret == -ENOTSUP)
13996 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14002 printf("invalid is_on %d\n", is_on);
14005 printf("invalid port_id %d\n", res->port_id);
14008 printf("function not implemented\n");
14011 printf("programming error: (%s)\n", strerror(-ret));
14015 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14016 .f = cmd_set_all_queues_drop_en_parsed,
14018 .help_str = "set all queues drop <port_id> on|off",
14020 (void *)&cmd_all_queues_drop_en_set,
14021 (void *)&cmd_all_queues_drop_en_all,
14022 (void *)&cmd_all_queues_drop_en_queues,
14023 (void *)&cmd_all_queues_drop_en_drop,
14024 (void *)&cmd_all_queues_drop_en_port_id,
14025 (void *)&cmd_all_queues_drop_en_on_off,
14030 /* vf split drop enable configuration */
14032 /* Common result structure for vf split drop enable */
14033 struct cmd_vf_split_drop_en_result {
14034 cmdline_fixed_string_t set;
14035 cmdline_fixed_string_t vf;
14036 cmdline_fixed_string_t split;
14037 cmdline_fixed_string_t drop;
14040 cmdline_fixed_string_t on_off;
14043 /* Common CLI fields for vf split drop enable disable */
14044 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14045 TOKEN_STRING_INITIALIZER
14046 (struct cmd_vf_split_drop_en_result,
14048 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14049 TOKEN_STRING_INITIALIZER
14050 (struct cmd_vf_split_drop_en_result,
14052 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14053 TOKEN_STRING_INITIALIZER
14054 (struct cmd_vf_split_drop_en_result,
14056 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14057 TOKEN_STRING_INITIALIZER
14058 (struct cmd_vf_split_drop_en_result,
14060 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14061 TOKEN_NUM_INITIALIZER
14062 (struct cmd_vf_split_drop_en_result,
14064 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14065 TOKEN_NUM_INITIALIZER
14066 (struct cmd_vf_split_drop_en_result,
14068 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14069 TOKEN_STRING_INITIALIZER
14070 (struct cmd_vf_split_drop_en_result,
14074 cmd_set_vf_split_drop_en_parsed(
14075 void *parsed_result,
14076 __rte_unused struct cmdline *cl,
14077 __rte_unused void *data)
14079 struct cmd_vf_split_drop_en_result *res = parsed_result;
14080 int ret = -ENOTSUP;
14081 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14083 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14086 #ifdef RTE_LIBRTE_IXGBE_PMD
14087 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14094 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14097 printf("invalid port_id %d\n", res->port_id);
14100 printf("not supported on port %d\n", res->port_id);
14103 printf("programming error: (%s)\n", strerror(-ret));
14107 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14108 .f = cmd_set_vf_split_drop_en_parsed,
14110 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14112 (void *)&cmd_vf_split_drop_en_set,
14113 (void *)&cmd_vf_split_drop_en_vf,
14114 (void *)&cmd_vf_split_drop_en_split,
14115 (void *)&cmd_vf_split_drop_en_drop,
14116 (void *)&cmd_vf_split_drop_en_port_id,
14117 (void *)&cmd_vf_split_drop_en_vf_id,
14118 (void *)&cmd_vf_split_drop_en_on_off,
14123 /* vf mac address configuration */
14125 /* Common result structure for vf mac address */
14126 struct cmd_set_vf_mac_addr_result {
14127 cmdline_fixed_string_t set;
14128 cmdline_fixed_string_t vf;
14129 cmdline_fixed_string_t mac;
14130 cmdline_fixed_string_t addr;
14133 struct rte_ether_addr mac_addr;
14137 /* Common CLI fields for vf split drop enable disable */
14138 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14139 TOKEN_STRING_INITIALIZER
14140 (struct cmd_set_vf_mac_addr_result,
14142 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14143 TOKEN_STRING_INITIALIZER
14144 (struct cmd_set_vf_mac_addr_result,
14146 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14147 TOKEN_STRING_INITIALIZER
14148 (struct cmd_set_vf_mac_addr_result,
14150 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14151 TOKEN_STRING_INITIALIZER
14152 (struct cmd_set_vf_mac_addr_result,
14154 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14155 TOKEN_NUM_INITIALIZER
14156 (struct cmd_set_vf_mac_addr_result,
14158 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14159 TOKEN_NUM_INITIALIZER
14160 (struct cmd_set_vf_mac_addr_result,
14162 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14163 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14167 cmd_set_vf_mac_addr_parsed(
14168 void *parsed_result,
14169 __rte_unused struct cmdline *cl,
14170 __rte_unused void *data)
14172 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14173 int ret = -ENOTSUP;
14175 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14178 #ifdef RTE_LIBRTE_IXGBE_PMD
14179 if (ret == -ENOTSUP)
14180 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14183 #ifdef RTE_LIBRTE_I40E_PMD
14184 if (ret == -ENOTSUP)
14185 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14188 #ifdef RTE_LIBRTE_BNXT_PMD
14189 if (ret == -ENOTSUP)
14190 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14198 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14201 printf("invalid port_id %d\n", res->port_id);
14204 printf("function not implemented\n");
14207 printf("programming error: (%s)\n", strerror(-ret));
14211 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14212 .f = cmd_set_vf_mac_addr_parsed,
14214 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14216 (void *)&cmd_set_vf_mac_addr_set,
14217 (void *)&cmd_set_vf_mac_addr_vf,
14218 (void *)&cmd_set_vf_mac_addr_mac,
14219 (void *)&cmd_set_vf_mac_addr_addr,
14220 (void *)&cmd_set_vf_mac_addr_port_id,
14221 (void *)&cmd_set_vf_mac_addr_vf_id,
14222 (void *)&cmd_set_vf_mac_addr_mac_addr,
14227 /* MACsec configuration */
14229 /* Common result structure for MACsec offload enable */
14230 struct cmd_macsec_offload_on_result {
14231 cmdline_fixed_string_t set;
14232 cmdline_fixed_string_t macsec;
14233 cmdline_fixed_string_t offload;
14235 cmdline_fixed_string_t on;
14236 cmdline_fixed_string_t encrypt;
14237 cmdline_fixed_string_t en_on_off;
14238 cmdline_fixed_string_t replay_protect;
14239 cmdline_fixed_string_t rp_on_off;
14242 /* Common CLI fields for MACsec offload disable */
14243 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14244 TOKEN_STRING_INITIALIZER
14245 (struct cmd_macsec_offload_on_result,
14247 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14248 TOKEN_STRING_INITIALIZER
14249 (struct cmd_macsec_offload_on_result,
14251 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14252 TOKEN_STRING_INITIALIZER
14253 (struct cmd_macsec_offload_on_result,
14254 offload, "offload");
14255 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14256 TOKEN_NUM_INITIALIZER
14257 (struct cmd_macsec_offload_on_result,
14259 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14260 TOKEN_STRING_INITIALIZER
14261 (struct cmd_macsec_offload_on_result,
14263 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14264 TOKEN_STRING_INITIALIZER
14265 (struct cmd_macsec_offload_on_result,
14266 encrypt, "encrypt");
14267 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14268 TOKEN_STRING_INITIALIZER
14269 (struct cmd_macsec_offload_on_result,
14270 en_on_off, "on#off");
14271 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14272 TOKEN_STRING_INITIALIZER
14273 (struct cmd_macsec_offload_on_result,
14274 replay_protect, "replay-protect");
14275 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14276 TOKEN_STRING_INITIALIZER
14277 (struct cmd_macsec_offload_on_result,
14278 rp_on_off, "on#off");
14281 cmd_set_macsec_offload_on_parsed(
14282 void *parsed_result,
14283 __rte_unused struct cmdline *cl,
14284 __rte_unused void *data)
14286 struct cmd_macsec_offload_on_result *res = parsed_result;
14287 int ret = -ENOTSUP;
14288 portid_t port_id = res->port_id;
14289 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14290 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14291 struct rte_eth_dev_info dev_info;
14293 if (port_id_is_invalid(port_id, ENABLED_WARN))
14295 if (!port_is_stopped(port_id)) {
14296 printf("Please stop port %d first\n", port_id);
14300 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14304 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14305 #ifdef RTE_LIBRTE_IXGBE_PMD
14306 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14314 ports[port_id].dev_conf.txmode.offloads |=
14315 DEV_TX_OFFLOAD_MACSEC_INSERT;
14316 cmd_reconfig_device_queue(port_id, 1, 1);
14319 printf("invalid port_id %d\n", port_id);
14322 printf("not supported on port %d\n", port_id);
14325 printf("programming error: (%s)\n", strerror(-ret));
14329 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14330 .f = cmd_set_macsec_offload_on_parsed,
14332 .help_str = "set macsec offload <port_id> on "
14333 "encrypt on|off replay-protect on|off",
14335 (void *)&cmd_macsec_offload_on_set,
14336 (void *)&cmd_macsec_offload_on_macsec,
14337 (void *)&cmd_macsec_offload_on_offload,
14338 (void *)&cmd_macsec_offload_on_port_id,
14339 (void *)&cmd_macsec_offload_on_on,
14340 (void *)&cmd_macsec_offload_on_encrypt,
14341 (void *)&cmd_macsec_offload_on_en_on_off,
14342 (void *)&cmd_macsec_offload_on_replay_protect,
14343 (void *)&cmd_macsec_offload_on_rp_on_off,
14348 /* Common result structure for MACsec offload disable */
14349 struct cmd_macsec_offload_off_result {
14350 cmdline_fixed_string_t set;
14351 cmdline_fixed_string_t macsec;
14352 cmdline_fixed_string_t offload;
14354 cmdline_fixed_string_t off;
14357 /* Common CLI fields for MACsec offload disable */
14358 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14359 TOKEN_STRING_INITIALIZER
14360 (struct cmd_macsec_offload_off_result,
14362 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14363 TOKEN_STRING_INITIALIZER
14364 (struct cmd_macsec_offload_off_result,
14366 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14367 TOKEN_STRING_INITIALIZER
14368 (struct cmd_macsec_offload_off_result,
14369 offload, "offload");
14370 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14371 TOKEN_NUM_INITIALIZER
14372 (struct cmd_macsec_offload_off_result,
14374 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14375 TOKEN_STRING_INITIALIZER
14376 (struct cmd_macsec_offload_off_result,
14380 cmd_set_macsec_offload_off_parsed(
14381 void *parsed_result,
14382 __rte_unused struct cmdline *cl,
14383 __rte_unused void *data)
14385 struct cmd_macsec_offload_off_result *res = parsed_result;
14386 int ret = -ENOTSUP;
14387 struct rte_eth_dev_info dev_info;
14388 portid_t port_id = res->port_id;
14390 if (port_id_is_invalid(port_id, ENABLED_WARN))
14392 if (!port_is_stopped(port_id)) {
14393 printf("Please stop port %d first\n", port_id);
14397 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14401 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14402 #ifdef RTE_LIBRTE_IXGBE_PMD
14403 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14408 ports[port_id].dev_conf.txmode.offloads &=
14409 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14410 cmd_reconfig_device_queue(port_id, 1, 1);
14413 printf("invalid port_id %d\n", port_id);
14416 printf("not supported on port %d\n", port_id);
14419 printf("programming error: (%s)\n", strerror(-ret));
14423 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14424 .f = cmd_set_macsec_offload_off_parsed,
14426 .help_str = "set macsec offload <port_id> off",
14428 (void *)&cmd_macsec_offload_off_set,
14429 (void *)&cmd_macsec_offload_off_macsec,
14430 (void *)&cmd_macsec_offload_off_offload,
14431 (void *)&cmd_macsec_offload_off_port_id,
14432 (void *)&cmd_macsec_offload_off_off,
14437 /* Common result structure for MACsec secure connection configure */
14438 struct cmd_macsec_sc_result {
14439 cmdline_fixed_string_t set;
14440 cmdline_fixed_string_t macsec;
14441 cmdline_fixed_string_t sc;
14442 cmdline_fixed_string_t tx_rx;
14444 struct rte_ether_addr mac;
14448 /* Common CLI fields for MACsec secure connection configure */
14449 cmdline_parse_token_string_t cmd_macsec_sc_set =
14450 TOKEN_STRING_INITIALIZER
14451 (struct cmd_macsec_sc_result,
14453 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14454 TOKEN_STRING_INITIALIZER
14455 (struct cmd_macsec_sc_result,
14457 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14458 TOKEN_STRING_INITIALIZER
14459 (struct cmd_macsec_sc_result,
14461 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14462 TOKEN_STRING_INITIALIZER
14463 (struct cmd_macsec_sc_result,
14465 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14466 TOKEN_NUM_INITIALIZER
14467 (struct cmd_macsec_sc_result,
14469 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14470 TOKEN_ETHERADDR_INITIALIZER
14471 (struct cmd_macsec_sc_result,
14473 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14474 TOKEN_NUM_INITIALIZER
14475 (struct cmd_macsec_sc_result,
14479 cmd_set_macsec_sc_parsed(
14480 void *parsed_result,
14481 __rte_unused struct cmdline *cl,
14482 __rte_unused void *data)
14484 struct cmd_macsec_sc_result *res = parsed_result;
14485 int ret = -ENOTSUP;
14486 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14488 #ifdef RTE_LIBRTE_IXGBE_PMD
14490 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14491 res->mac.addr_bytes) :
14492 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14493 res->mac.addr_bytes, res->pi);
14495 RTE_SET_USED(is_tx);
14501 printf("invalid port_id %d\n", res->port_id);
14504 printf("not supported on port %d\n", res->port_id);
14507 printf("programming error: (%s)\n", strerror(-ret));
14511 cmdline_parse_inst_t cmd_set_macsec_sc = {
14512 .f = cmd_set_macsec_sc_parsed,
14514 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14516 (void *)&cmd_macsec_sc_set,
14517 (void *)&cmd_macsec_sc_macsec,
14518 (void *)&cmd_macsec_sc_sc,
14519 (void *)&cmd_macsec_sc_tx_rx,
14520 (void *)&cmd_macsec_sc_port_id,
14521 (void *)&cmd_macsec_sc_mac,
14522 (void *)&cmd_macsec_sc_pi,
14527 /* Common result structure for MACsec secure connection configure */
14528 struct cmd_macsec_sa_result {
14529 cmdline_fixed_string_t set;
14530 cmdline_fixed_string_t macsec;
14531 cmdline_fixed_string_t sa;
14532 cmdline_fixed_string_t tx_rx;
14537 cmdline_fixed_string_t key;
14540 /* Common CLI fields for MACsec secure connection configure */
14541 cmdline_parse_token_string_t cmd_macsec_sa_set =
14542 TOKEN_STRING_INITIALIZER
14543 (struct cmd_macsec_sa_result,
14545 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14546 TOKEN_STRING_INITIALIZER
14547 (struct cmd_macsec_sa_result,
14549 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14550 TOKEN_STRING_INITIALIZER
14551 (struct cmd_macsec_sa_result,
14553 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14554 TOKEN_STRING_INITIALIZER
14555 (struct cmd_macsec_sa_result,
14557 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14558 TOKEN_NUM_INITIALIZER
14559 (struct cmd_macsec_sa_result,
14561 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14562 TOKEN_NUM_INITIALIZER
14563 (struct cmd_macsec_sa_result,
14565 cmdline_parse_token_num_t cmd_macsec_sa_an =
14566 TOKEN_NUM_INITIALIZER
14567 (struct cmd_macsec_sa_result,
14569 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14570 TOKEN_NUM_INITIALIZER
14571 (struct cmd_macsec_sa_result,
14573 cmdline_parse_token_string_t cmd_macsec_sa_key =
14574 TOKEN_STRING_INITIALIZER
14575 (struct cmd_macsec_sa_result,
14579 cmd_set_macsec_sa_parsed(
14580 void *parsed_result,
14581 __rte_unused struct cmdline *cl,
14582 __rte_unused void *data)
14584 struct cmd_macsec_sa_result *res = parsed_result;
14585 int ret = -ENOTSUP;
14586 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14587 uint8_t key[16] = { 0 };
14593 key_len = strlen(res->key) / 2;
14597 for (i = 0; i < key_len; i++) {
14598 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14601 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14604 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14607 #ifdef RTE_LIBRTE_IXGBE_PMD
14609 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14610 res->idx, res->an, res->pn, key) :
14611 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14612 res->idx, res->an, res->pn, key);
14614 RTE_SET_USED(is_tx);
14621 printf("invalid idx %d or an %d\n", res->idx, res->an);
14624 printf("invalid port_id %d\n", res->port_id);
14627 printf("not supported on port %d\n", res->port_id);
14630 printf("programming error: (%s)\n", strerror(-ret));
14634 cmdline_parse_inst_t cmd_set_macsec_sa = {
14635 .f = cmd_set_macsec_sa_parsed,
14637 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14639 (void *)&cmd_macsec_sa_set,
14640 (void *)&cmd_macsec_sa_macsec,
14641 (void *)&cmd_macsec_sa_sa,
14642 (void *)&cmd_macsec_sa_tx_rx,
14643 (void *)&cmd_macsec_sa_port_id,
14644 (void *)&cmd_macsec_sa_idx,
14645 (void *)&cmd_macsec_sa_an,
14646 (void *)&cmd_macsec_sa_pn,
14647 (void *)&cmd_macsec_sa_key,
14652 /* VF unicast promiscuous mode configuration */
14654 /* Common result structure for VF unicast promiscuous mode */
14655 struct cmd_vf_promisc_result {
14656 cmdline_fixed_string_t set;
14657 cmdline_fixed_string_t vf;
14658 cmdline_fixed_string_t promisc;
14661 cmdline_fixed_string_t on_off;
14664 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14665 cmdline_parse_token_string_t cmd_vf_promisc_set =
14666 TOKEN_STRING_INITIALIZER
14667 (struct cmd_vf_promisc_result,
14669 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14670 TOKEN_STRING_INITIALIZER
14671 (struct cmd_vf_promisc_result,
14673 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14674 TOKEN_STRING_INITIALIZER
14675 (struct cmd_vf_promisc_result,
14676 promisc, "promisc");
14677 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14678 TOKEN_NUM_INITIALIZER
14679 (struct cmd_vf_promisc_result,
14681 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14682 TOKEN_NUM_INITIALIZER
14683 (struct cmd_vf_promisc_result,
14685 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14686 TOKEN_STRING_INITIALIZER
14687 (struct cmd_vf_promisc_result,
14691 cmd_set_vf_promisc_parsed(
14692 void *parsed_result,
14693 __rte_unused struct cmdline *cl,
14694 __rte_unused void *data)
14696 struct cmd_vf_promisc_result *res = parsed_result;
14697 int ret = -ENOTSUP;
14699 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14701 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14704 #ifdef RTE_LIBRTE_I40E_PMD
14705 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14706 res->vf_id, is_on);
14713 printf("invalid vf_id %d\n", res->vf_id);
14716 printf("invalid port_id %d\n", res->port_id);
14719 printf("function not implemented\n");
14722 printf("programming error: (%s)\n", strerror(-ret));
14726 cmdline_parse_inst_t cmd_set_vf_promisc = {
14727 .f = cmd_set_vf_promisc_parsed,
14729 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14730 "Set unicast promiscuous mode for a VF from the PF",
14732 (void *)&cmd_vf_promisc_set,
14733 (void *)&cmd_vf_promisc_vf,
14734 (void *)&cmd_vf_promisc_promisc,
14735 (void *)&cmd_vf_promisc_port_id,
14736 (void *)&cmd_vf_promisc_vf_id,
14737 (void *)&cmd_vf_promisc_on_off,
14742 /* VF multicast promiscuous mode configuration */
14744 /* Common result structure for VF multicast promiscuous mode */
14745 struct cmd_vf_allmulti_result {
14746 cmdline_fixed_string_t set;
14747 cmdline_fixed_string_t vf;
14748 cmdline_fixed_string_t allmulti;
14751 cmdline_fixed_string_t on_off;
14754 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14755 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14756 TOKEN_STRING_INITIALIZER
14757 (struct cmd_vf_allmulti_result,
14759 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14760 TOKEN_STRING_INITIALIZER
14761 (struct cmd_vf_allmulti_result,
14763 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14764 TOKEN_STRING_INITIALIZER
14765 (struct cmd_vf_allmulti_result,
14766 allmulti, "allmulti");
14767 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14768 TOKEN_NUM_INITIALIZER
14769 (struct cmd_vf_allmulti_result,
14771 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14772 TOKEN_NUM_INITIALIZER
14773 (struct cmd_vf_allmulti_result,
14775 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14776 TOKEN_STRING_INITIALIZER
14777 (struct cmd_vf_allmulti_result,
14781 cmd_set_vf_allmulti_parsed(
14782 void *parsed_result,
14783 __rte_unused struct cmdline *cl,
14784 __rte_unused void *data)
14786 struct cmd_vf_allmulti_result *res = parsed_result;
14787 int ret = -ENOTSUP;
14789 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14791 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14794 #ifdef RTE_LIBRTE_I40E_PMD
14795 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14796 res->vf_id, is_on);
14803 printf("invalid vf_id %d\n", res->vf_id);
14806 printf("invalid port_id %d\n", res->port_id);
14809 printf("function not implemented\n");
14812 printf("programming error: (%s)\n", strerror(-ret));
14816 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14817 .f = cmd_set_vf_allmulti_parsed,
14819 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14820 "Set multicast promiscuous mode for a VF from the PF",
14822 (void *)&cmd_vf_allmulti_set,
14823 (void *)&cmd_vf_allmulti_vf,
14824 (void *)&cmd_vf_allmulti_allmulti,
14825 (void *)&cmd_vf_allmulti_port_id,
14826 (void *)&cmd_vf_allmulti_vf_id,
14827 (void *)&cmd_vf_allmulti_on_off,
14832 /* vf broadcast mode configuration */
14834 /* Common result structure for vf broadcast */
14835 struct cmd_set_vf_broadcast_result {
14836 cmdline_fixed_string_t set;
14837 cmdline_fixed_string_t vf;
14838 cmdline_fixed_string_t broadcast;
14841 cmdline_fixed_string_t on_off;
14844 /* Common CLI fields for vf broadcast enable disable */
14845 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14846 TOKEN_STRING_INITIALIZER
14847 (struct cmd_set_vf_broadcast_result,
14849 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14850 TOKEN_STRING_INITIALIZER
14851 (struct cmd_set_vf_broadcast_result,
14853 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14854 TOKEN_STRING_INITIALIZER
14855 (struct cmd_set_vf_broadcast_result,
14856 broadcast, "broadcast");
14857 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14858 TOKEN_NUM_INITIALIZER
14859 (struct cmd_set_vf_broadcast_result,
14861 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14862 TOKEN_NUM_INITIALIZER
14863 (struct cmd_set_vf_broadcast_result,
14865 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14866 TOKEN_STRING_INITIALIZER
14867 (struct cmd_set_vf_broadcast_result,
14871 cmd_set_vf_broadcast_parsed(
14872 void *parsed_result,
14873 __rte_unused struct cmdline *cl,
14874 __rte_unused void *data)
14876 struct cmd_set_vf_broadcast_result *res = parsed_result;
14877 int ret = -ENOTSUP;
14879 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14881 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14884 #ifdef RTE_LIBRTE_I40E_PMD
14885 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14886 res->vf_id, is_on);
14893 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14896 printf("invalid port_id %d\n", res->port_id);
14899 printf("function not implemented\n");
14902 printf("programming error: (%s)\n", strerror(-ret));
14906 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14907 .f = cmd_set_vf_broadcast_parsed,
14909 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14911 (void *)&cmd_set_vf_broadcast_set,
14912 (void *)&cmd_set_vf_broadcast_vf,
14913 (void *)&cmd_set_vf_broadcast_broadcast,
14914 (void *)&cmd_set_vf_broadcast_port_id,
14915 (void *)&cmd_set_vf_broadcast_vf_id,
14916 (void *)&cmd_set_vf_broadcast_on_off,
14921 /* vf vlan tag configuration */
14923 /* Common result structure for vf vlan tag */
14924 struct cmd_set_vf_vlan_tag_result {
14925 cmdline_fixed_string_t set;
14926 cmdline_fixed_string_t vf;
14927 cmdline_fixed_string_t vlan;
14928 cmdline_fixed_string_t tag;
14931 cmdline_fixed_string_t on_off;
14934 /* Common CLI fields for vf vlan tag enable disable */
14935 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14936 TOKEN_STRING_INITIALIZER
14937 (struct cmd_set_vf_vlan_tag_result,
14939 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14940 TOKEN_STRING_INITIALIZER
14941 (struct cmd_set_vf_vlan_tag_result,
14943 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14944 TOKEN_STRING_INITIALIZER
14945 (struct cmd_set_vf_vlan_tag_result,
14947 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14948 TOKEN_STRING_INITIALIZER
14949 (struct cmd_set_vf_vlan_tag_result,
14951 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14952 TOKEN_NUM_INITIALIZER
14953 (struct cmd_set_vf_vlan_tag_result,
14955 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14956 TOKEN_NUM_INITIALIZER
14957 (struct cmd_set_vf_vlan_tag_result,
14959 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14960 TOKEN_STRING_INITIALIZER
14961 (struct cmd_set_vf_vlan_tag_result,
14965 cmd_set_vf_vlan_tag_parsed(
14966 void *parsed_result,
14967 __rte_unused struct cmdline *cl,
14968 __rte_unused void *data)
14970 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14971 int ret = -ENOTSUP;
14973 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14975 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14978 #ifdef RTE_LIBRTE_I40E_PMD
14979 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14980 res->vf_id, is_on);
14987 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14990 printf("invalid port_id %d\n", res->port_id);
14993 printf("function not implemented\n");
14996 printf("programming error: (%s)\n", strerror(-ret));
15000 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15001 .f = cmd_set_vf_vlan_tag_parsed,
15003 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15005 (void *)&cmd_set_vf_vlan_tag_set,
15006 (void *)&cmd_set_vf_vlan_tag_vf,
15007 (void *)&cmd_set_vf_vlan_tag_vlan,
15008 (void *)&cmd_set_vf_vlan_tag_tag,
15009 (void *)&cmd_set_vf_vlan_tag_port_id,
15010 (void *)&cmd_set_vf_vlan_tag_vf_id,
15011 (void *)&cmd_set_vf_vlan_tag_on_off,
15016 /* Common definition of VF and TC TX bandwidth configuration */
15017 struct cmd_vf_tc_bw_result {
15018 cmdline_fixed_string_t set;
15019 cmdline_fixed_string_t vf;
15020 cmdline_fixed_string_t tc;
15021 cmdline_fixed_string_t tx;
15022 cmdline_fixed_string_t min_bw;
15023 cmdline_fixed_string_t max_bw;
15024 cmdline_fixed_string_t strict_link_prio;
15029 cmdline_fixed_string_t bw_list;
15033 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15034 TOKEN_STRING_INITIALIZER
15035 (struct cmd_vf_tc_bw_result,
15037 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15038 TOKEN_STRING_INITIALIZER
15039 (struct cmd_vf_tc_bw_result,
15041 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15042 TOKEN_STRING_INITIALIZER
15043 (struct cmd_vf_tc_bw_result,
15045 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15046 TOKEN_STRING_INITIALIZER
15047 (struct cmd_vf_tc_bw_result,
15049 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15050 TOKEN_STRING_INITIALIZER
15051 (struct cmd_vf_tc_bw_result,
15052 strict_link_prio, "strict-link-priority");
15053 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15054 TOKEN_STRING_INITIALIZER
15055 (struct cmd_vf_tc_bw_result,
15056 min_bw, "min-bandwidth");
15057 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15058 TOKEN_STRING_INITIALIZER
15059 (struct cmd_vf_tc_bw_result,
15060 max_bw, "max-bandwidth");
15061 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15062 TOKEN_NUM_INITIALIZER
15063 (struct cmd_vf_tc_bw_result,
15065 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15066 TOKEN_NUM_INITIALIZER
15067 (struct cmd_vf_tc_bw_result,
15069 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15070 TOKEN_NUM_INITIALIZER
15071 (struct cmd_vf_tc_bw_result,
15073 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15074 TOKEN_NUM_INITIALIZER
15075 (struct cmd_vf_tc_bw_result,
15077 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15078 TOKEN_STRING_INITIALIZER
15079 (struct cmd_vf_tc_bw_result,
15081 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15082 TOKEN_NUM_INITIALIZER
15083 (struct cmd_vf_tc_bw_result,
15086 /* VF max bandwidth setting */
15088 cmd_vf_max_bw_parsed(
15089 void *parsed_result,
15090 __rte_unused struct cmdline *cl,
15091 __rte_unused void *data)
15093 struct cmd_vf_tc_bw_result *res = parsed_result;
15094 int ret = -ENOTSUP;
15096 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15099 #ifdef RTE_LIBRTE_I40E_PMD
15100 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15101 res->vf_id, res->bw);
15108 printf("invalid vf_id %d or bandwidth %d\n",
15109 res->vf_id, res->bw);
15112 printf("invalid port_id %d\n", res->port_id);
15115 printf("function not implemented\n");
15118 printf("programming error: (%s)\n", strerror(-ret));
15122 cmdline_parse_inst_t cmd_vf_max_bw = {
15123 .f = cmd_vf_max_bw_parsed,
15125 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15127 (void *)&cmd_vf_tc_bw_set,
15128 (void *)&cmd_vf_tc_bw_vf,
15129 (void *)&cmd_vf_tc_bw_tx,
15130 (void *)&cmd_vf_tc_bw_max_bw,
15131 (void *)&cmd_vf_tc_bw_port_id,
15132 (void *)&cmd_vf_tc_bw_vf_id,
15133 (void *)&cmd_vf_tc_bw_bw,
15139 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15144 const char *p, *p0 = str;
15151 p = strchr(p0, '(');
15153 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15157 p0 = strchr(p, ')');
15159 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15163 if (size >= sizeof(s)) {
15164 printf("The string size exceeds the internal buffer size\n");
15167 snprintf(s, sizeof(s), "%.*s", size, p);
15168 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15170 printf("Failed to get the bandwidth list. ");
15174 for (i = 0; i < ret; i++)
15175 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15180 /* TC min bandwidth setting */
15182 cmd_vf_tc_min_bw_parsed(
15183 void *parsed_result,
15184 __rte_unused struct cmdline *cl,
15185 __rte_unused void *data)
15187 struct cmd_vf_tc_bw_result *res = parsed_result;
15190 int ret = -ENOTSUP;
15192 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15195 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15199 #ifdef RTE_LIBRTE_I40E_PMD
15200 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15208 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15211 printf("invalid port_id %d\n", res->port_id);
15214 printf("function not implemented\n");
15217 printf("programming error: (%s)\n", strerror(-ret));
15221 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15222 .f = cmd_vf_tc_min_bw_parsed,
15224 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15225 " <bw1, bw2, ...>",
15227 (void *)&cmd_vf_tc_bw_set,
15228 (void *)&cmd_vf_tc_bw_vf,
15229 (void *)&cmd_vf_tc_bw_tc,
15230 (void *)&cmd_vf_tc_bw_tx,
15231 (void *)&cmd_vf_tc_bw_min_bw,
15232 (void *)&cmd_vf_tc_bw_port_id,
15233 (void *)&cmd_vf_tc_bw_vf_id,
15234 (void *)&cmd_vf_tc_bw_bw_list,
15240 cmd_tc_min_bw_parsed(
15241 void *parsed_result,
15242 __rte_unused struct cmdline *cl,
15243 __rte_unused void *data)
15245 struct cmd_vf_tc_bw_result *res = parsed_result;
15246 struct rte_port *port;
15249 int ret = -ENOTSUP;
15251 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15254 port = &ports[res->port_id];
15255 /** Check if the port is not started **/
15256 if (port->port_status != RTE_PORT_STOPPED) {
15257 printf("Please stop port %d first\n", res->port_id);
15261 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15265 #ifdef RTE_LIBRTE_IXGBE_PMD
15266 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15273 printf("invalid bandwidth\n");
15276 printf("invalid port_id %d\n", res->port_id);
15279 printf("function not implemented\n");
15282 printf("programming error: (%s)\n", strerror(-ret));
15286 cmdline_parse_inst_t cmd_tc_min_bw = {
15287 .f = cmd_tc_min_bw_parsed,
15289 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15291 (void *)&cmd_vf_tc_bw_set,
15292 (void *)&cmd_vf_tc_bw_tc,
15293 (void *)&cmd_vf_tc_bw_tx,
15294 (void *)&cmd_vf_tc_bw_min_bw,
15295 (void *)&cmd_vf_tc_bw_port_id,
15296 (void *)&cmd_vf_tc_bw_bw_list,
15301 /* TC max bandwidth setting */
15303 cmd_vf_tc_max_bw_parsed(
15304 void *parsed_result,
15305 __rte_unused struct cmdline *cl,
15306 __rte_unused void *data)
15308 struct cmd_vf_tc_bw_result *res = parsed_result;
15309 int ret = -ENOTSUP;
15311 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15314 #ifdef RTE_LIBRTE_I40E_PMD
15315 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15316 res->tc_no, res->bw);
15323 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15324 res->vf_id, res->tc_no, res->bw);
15327 printf("invalid port_id %d\n", res->port_id);
15330 printf("function not implemented\n");
15333 printf("programming error: (%s)\n", strerror(-ret));
15337 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15338 .f = cmd_vf_tc_max_bw_parsed,
15340 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15343 (void *)&cmd_vf_tc_bw_set,
15344 (void *)&cmd_vf_tc_bw_vf,
15345 (void *)&cmd_vf_tc_bw_tc,
15346 (void *)&cmd_vf_tc_bw_tx,
15347 (void *)&cmd_vf_tc_bw_max_bw,
15348 (void *)&cmd_vf_tc_bw_port_id,
15349 (void *)&cmd_vf_tc_bw_vf_id,
15350 (void *)&cmd_vf_tc_bw_tc_no,
15351 (void *)&cmd_vf_tc_bw_bw,
15357 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15359 /* *** Set Port default Traffic Management Hierarchy *** */
15360 struct cmd_set_port_tm_hierarchy_default_result {
15361 cmdline_fixed_string_t set;
15362 cmdline_fixed_string_t port;
15363 cmdline_fixed_string_t tm;
15364 cmdline_fixed_string_t hierarchy;
15365 cmdline_fixed_string_t def;
15369 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15370 TOKEN_STRING_INITIALIZER(
15371 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15372 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15373 TOKEN_STRING_INITIALIZER(
15374 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15375 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15376 TOKEN_STRING_INITIALIZER(
15377 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15378 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15379 TOKEN_STRING_INITIALIZER(
15380 struct cmd_set_port_tm_hierarchy_default_result,
15381 hierarchy, "hierarchy");
15382 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15383 TOKEN_STRING_INITIALIZER(
15384 struct cmd_set_port_tm_hierarchy_default_result,
15386 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15387 TOKEN_NUM_INITIALIZER(
15388 struct cmd_set_port_tm_hierarchy_default_result,
15391 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15392 __rte_unused struct cmdline *cl,
15393 __rte_unused void *data)
15395 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15396 struct rte_port *p;
15397 portid_t port_id = res->port_id;
15399 if (port_id_is_invalid(port_id, ENABLED_WARN))
15402 p = &ports[port_id];
15404 /* Forward mode: tm */
15405 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15406 printf(" softnicfwd mode not enabled(error)\n");
15410 /* Set the default tm hierarchy */
15411 p->softport.default_tm_hierarchy_enable = 1;
15414 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15415 .f = cmd_set_port_tm_hierarchy_default_parsed,
15417 .help_str = "set port tm hierarchy default <port_id>",
15419 (void *)&cmd_set_port_tm_hierarchy_default_set,
15420 (void *)&cmd_set_port_tm_hierarchy_default_port,
15421 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15422 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15423 (void *)&cmd_set_port_tm_hierarchy_default_default,
15424 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15430 /** Set VXLAN encapsulation details */
15431 struct cmd_set_vxlan_result {
15432 cmdline_fixed_string_t set;
15433 cmdline_fixed_string_t vxlan;
15434 cmdline_fixed_string_t pos_token;
15435 cmdline_fixed_string_t ip_version;
15436 uint32_t vlan_present:1;
15440 cmdline_ipaddr_t ip_src;
15441 cmdline_ipaddr_t ip_dst;
15445 struct rte_ether_addr eth_src;
15446 struct rte_ether_addr eth_dst;
15449 cmdline_parse_token_string_t cmd_set_vxlan_set =
15450 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15451 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15452 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15453 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15454 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15456 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15457 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15458 "vxlan-with-vlan");
15459 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15460 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15462 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15463 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15465 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15466 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15468 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15469 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15470 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15471 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15473 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15474 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15475 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15476 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15478 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15479 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15480 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15481 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15483 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15484 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15485 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15486 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15488 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15489 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15490 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15491 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15493 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15494 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15495 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15496 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15498 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15499 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15500 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15501 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15503 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15504 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15505 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15506 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15508 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15509 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15510 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15511 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15513 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15514 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15516 static void cmd_set_vxlan_parsed(void *parsed_result,
15517 __rte_unused struct cmdline *cl,
15518 __rte_unused void *data)
15520 struct cmd_set_vxlan_result *res = parsed_result;
15525 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15528 vxlan_encap_conf.select_tos_ttl = 0;
15529 if (strcmp(res->vxlan, "vxlan") == 0)
15530 vxlan_encap_conf.select_vlan = 0;
15531 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15532 vxlan_encap_conf.select_vlan = 1;
15533 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15534 vxlan_encap_conf.select_vlan = 0;
15535 vxlan_encap_conf.select_tos_ttl = 1;
15537 if (strcmp(res->ip_version, "ipv4") == 0)
15538 vxlan_encap_conf.select_ipv4 = 1;
15539 else if (strcmp(res->ip_version, "ipv6") == 0)
15540 vxlan_encap_conf.select_ipv4 = 0;
15543 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15544 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15545 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15546 vxlan_encap_conf.ip_tos = res->tos;
15547 vxlan_encap_conf.ip_ttl = res->ttl;
15548 if (vxlan_encap_conf.select_ipv4) {
15549 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15550 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15552 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15553 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15555 if (vxlan_encap_conf.select_vlan)
15556 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15557 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15558 RTE_ETHER_ADDR_LEN);
15559 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15560 RTE_ETHER_ADDR_LEN);
15563 cmdline_parse_inst_t cmd_set_vxlan = {
15564 .f = cmd_set_vxlan_parsed,
15566 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15567 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15568 " eth-src <eth-src> eth-dst <eth-dst>",
15570 (void *)&cmd_set_vxlan_set,
15571 (void *)&cmd_set_vxlan_vxlan,
15572 (void *)&cmd_set_vxlan_ip_version,
15573 (void *)&cmd_set_vxlan_ip_version_value,
15574 (void *)&cmd_set_vxlan_vni,
15575 (void *)&cmd_set_vxlan_vni_value,
15576 (void *)&cmd_set_vxlan_udp_src,
15577 (void *)&cmd_set_vxlan_udp_src_value,
15578 (void *)&cmd_set_vxlan_udp_dst,
15579 (void *)&cmd_set_vxlan_udp_dst_value,
15580 (void *)&cmd_set_vxlan_ip_src,
15581 (void *)&cmd_set_vxlan_ip_src_value,
15582 (void *)&cmd_set_vxlan_ip_dst,
15583 (void *)&cmd_set_vxlan_ip_dst_value,
15584 (void *)&cmd_set_vxlan_eth_src,
15585 (void *)&cmd_set_vxlan_eth_src_value,
15586 (void *)&cmd_set_vxlan_eth_dst,
15587 (void *)&cmd_set_vxlan_eth_dst_value,
15592 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15593 .f = cmd_set_vxlan_parsed,
15595 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15596 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15597 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15598 " eth-dst <eth-dst>",
15600 (void *)&cmd_set_vxlan_set,
15601 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15602 (void *)&cmd_set_vxlan_ip_version,
15603 (void *)&cmd_set_vxlan_ip_version_value,
15604 (void *)&cmd_set_vxlan_vni,
15605 (void *)&cmd_set_vxlan_vni_value,
15606 (void *)&cmd_set_vxlan_udp_src,
15607 (void *)&cmd_set_vxlan_udp_src_value,
15608 (void *)&cmd_set_vxlan_udp_dst,
15609 (void *)&cmd_set_vxlan_udp_dst_value,
15610 (void *)&cmd_set_vxlan_ip_tos,
15611 (void *)&cmd_set_vxlan_ip_tos_value,
15612 (void *)&cmd_set_vxlan_ip_ttl,
15613 (void *)&cmd_set_vxlan_ip_ttl_value,
15614 (void *)&cmd_set_vxlan_ip_src,
15615 (void *)&cmd_set_vxlan_ip_src_value,
15616 (void *)&cmd_set_vxlan_ip_dst,
15617 (void *)&cmd_set_vxlan_ip_dst_value,
15618 (void *)&cmd_set_vxlan_eth_src,
15619 (void *)&cmd_set_vxlan_eth_src_value,
15620 (void *)&cmd_set_vxlan_eth_dst,
15621 (void *)&cmd_set_vxlan_eth_dst_value,
15626 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15627 .f = cmd_set_vxlan_parsed,
15629 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15630 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15631 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15634 (void *)&cmd_set_vxlan_set,
15635 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15636 (void *)&cmd_set_vxlan_ip_version,
15637 (void *)&cmd_set_vxlan_ip_version_value,
15638 (void *)&cmd_set_vxlan_vni,
15639 (void *)&cmd_set_vxlan_vni_value,
15640 (void *)&cmd_set_vxlan_udp_src,
15641 (void *)&cmd_set_vxlan_udp_src_value,
15642 (void *)&cmd_set_vxlan_udp_dst,
15643 (void *)&cmd_set_vxlan_udp_dst_value,
15644 (void *)&cmd_set_vxlan_ip_src,
15645 (void *)&cmd_set_vxlan_ip_src_value,
15646 (void *)&cmd_set_vxlan_ip_dst,
15647 (void *)&cmd_set_vxlan_ip_dst_value,
15648 (void *)&cmd_set_vxlan_vlan,
15649 (void *)&cmd_set_vxlan_vlan_value,
15650 (void *)&cmd_set_vxlan_eth_src,
15651 (void *)&cmd_set_vxlan_eth_src_value,
15652 (void *)&cmd_set_vxlan_eth_dst,
15653 (void *)&cmd_set_vxlan_eth_dst_value,
15658 /** Set NVGRE encapsulation details */
15659 struct cmd_set_nvgre_result {
15660 cmdline_fixed_string_t set;
15661 cmdline_fixed_string_t nvgre;
15662 cmdline_fixed_string_t pos_token;
15663 cmdline_fixed_string_t ip_version;
15665 cmdline_ipaddr_t ip_src;
15666 cmdline_ipaddr_t ip_dst;
15668 struct rte_ether_addr eth_src;
15669 struct rte_ether_addr eth_dst;
15672 cmdline_parse_token_string_t cmd_set_nvgre_set =
15673 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15674 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15675 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15676 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15677 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15678 "nvgre-with-vlan");
15679 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15680 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15682 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15683 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15685 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15686 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15688 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15689 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15690 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15691 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15693 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15694 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15695 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15696 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15698 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15699 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15700 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15701 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15703 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15704 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15705 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15706 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15708 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15709 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15710 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15711 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15713 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15714 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15716 static void cmd_set_nvgre_parsed(void *parsed_result,
15717 __rte_unused struct cmdline *cl,
15718 __rte_unused void *data)
15720 struct cmd_set_nvgre_result *res = parsed_result;
15722 uint32_t nvgre_tni;
15725 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15728 if (strcmp(res->nvgre, "nvgre") == 0)
15729 nvgre_encap_conf.select_vlan = 0;
15730 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15731 nvgre_encap_conf.select_vlan = 1;
15732 if (strcmp(res->ip_version, "ipv4") == 0)
15733 nvgre_encap_conf.select_ipv4 = 1;
15734 else if (strcmp(res->ip_version, "ipv6") == 0)
15735 nvgre_encap_conf.select_ipv4 = 0;
15738 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15739 if (nvgre_encap_conf.select_ipv4) {
15740 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15741 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15743 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15744 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15746 if (nvgre_encap_conf.select_vlan)
15747 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15748 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15749 RTE_ETHER_ADDR_LEN);
15750 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15751 RTE_ETHER_ADDR_LEN);
15754 cmdline_parse_inst_t cmd_set_nvgre = {
15755 .f = cmd_set_nvgre_parsed,
15757 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15758 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15759 " eth-dst <eth-dst>",
15761 (void *)&cmd_set_nvgre_set,
15762 (void *)&cmd_set_nvgre_nvgre,
15763 (void *)&cmd_set_nvgre_ip_version,
15764 (void *)&cmd_set_nvgre_ip_version_value,
15765 (void *)&cmd_set_nvgre_tni,
15766 (void *)&cmd_set_nvgre_tni_value,
15767 (void *)&cmd_set_nvgre_ip_src,
15768 (void *)&cmd_set_nvgre_ip_src_value,
15769 (void *)&cmd_set_nvgre_ip_dst,
15770 (void *)&cmd_set_nvgre_ip_dst_value,
15771 (void *)&cmd_set_nvgre_eth_src,
15772 (void *)&cmd_set_nvgre_eth_src_value,
15773 (void *)&cmd_set_nvgre_eth_dst,
15774 (void *)&cmd_set_nvgre_eth_dst_value,
15779 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15780 .f = cmd_set_nvgre_parsed,
15782 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15783 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15784 " eth-src <eth-src> eth-dst <eth-dst>",
15786 (void *)&cmd_set_nvgre_set,
15787 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15788 (void *)&cmd_set_nvgre_ip_version,
15789 (void *)&cmd_set_nvgre_ip_version_value,
15790 (void *)&cmd_set_nvgre_tni,
15791 (void *)&cmd_set_nvgre_tni_value,
15792 (void *)&cmd_set_nvgre_ip_src,
15793 (void *)&cmd_set_nvgre_ip_src_value,
15794 (void *)&cmd_set_nvgre_ip_dst,
15795 (void *)&cmd_set_nvgre_ip_dst_value,
15796 (void *)&cmd_set_nvgre_vlan,
15797 (void *)&cmd_set_nvgre_vlan_value,
15798 (void *)&cmd_set_nvgre_eth_src,
15799 (void *)&cmd_set_nvgre_eth_src_value,
15800 (void *)&cmd_set_nvgre_eth_dst,
15801 (void *)&cmd_set_nvgre_eth_dst_value,
15806 /** Set L2 encapsulation details */
15807 struct cmd_set_l2_encap_result {
15808 cmdline_fixed_string_t set;
15809 cmdline_fixed_string_t l2_encap;
15810 cmdline_fixed_string_t pos_token;
15811 cmdline_fixed_string_t ip_version;
15812 uint32_t vlan_present:1;
15814 struct rte_ether_addr eth_src;
15815 struct rte_ether_addr eth_dst;
15818 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15819 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15820 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15821 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15822 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15823 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15824 "l2_encap-with-vlan");
15825 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15826 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15828 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15829 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15831 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15832 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15834 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15835 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15836 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15837 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15839 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15840 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15841 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15842 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15844 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15845 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15847 static void cmd_set_l2_encap_parsed(void *parsed_result,
15848 __rte_unused struct cmdline *cl,
15849 __rte_unused void *data)
15851 struct cmd_set_l2_encap_result *res = parsed_result;
15853 if (strcmp(res->l2_encap, "l2_encap") == 0)
15854 l2_encap_conf.select_vlan = 0;
15855 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15856 l2_encap_conf.select_vlan = 1;
15857 if (strcmp(res->ip_version, "ipv4") == 0)
15858 l2_encap_conf.select_ipv4 = 1;
15859 else if (strcmp(res->ip_version, "ipv6") == 0)
15860 l2_encap_conf.select_ipv4 = 0;
15863 if (l2_encap_conf.select_vlan)
15864 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15865 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15866 RTE_ETHER_ADDR_LEN);
15867 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15868 RTE_ETHER_ADDR_LEN);
15871 cmdline_parse_inst_t cmd_set_l2_encap = {
15872 .f = cmd_set_l2_encap_parsed,
15874 .help_str = "set l2_encap ip-version ipv4|ipv6"
15875 " eth-src <eth-src> eth-dst <eth-dst>",
15877 (void *)&cmd_set_l2_encap_set,
15878 (void *)&cmd_set_l2_encap_l2_encap,
15879 (void *)&cmd_set_l2_encap_ip_version,
15880 (void *)&cmd_set_l2_encap_ip_version_value,
15881 (void *)&cmd_set_l2_encap_eth_src,
15882 (void *)&cmd_set_l2_encap_eth_src_value,
15883 (void *)&cmd_set_l2_encap_eth_dst,
15884 (void *)&cmd_set_l2_encap_eth_dst_value,
15889 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15890 .f = cmd_set_l2_encap_parsed,
15892 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15893 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15895 (void *)&cmd_set_l2_encap_set,
15896 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15897 (void *)&cmd_set_l2_encap_ip_version,
15898 (void *)&cmd_set_l2_encap_ip_version_value,
15899 (void *)&cmd_set_l2_encap_vlan,
15900 (void *)&cmd_set_l2_encap_vlan_value,
15901 (void *)&cmd_set_l2_encap_eth_src,
15902 (void *)&cmd_set_l2_encap_eth_src_value,
15903 (void *)&cmd_set_l2_encap_eth_dst,
15904 (void *)&cmd_set_l2_encap_eth_dst_value,
15909 /** Set L2 decapsulation details */
15910 struct cmd_set_l2_decap_result {
15911 cmdline_fixed_string_t set;
15912 cmdline_fixed_string_t l2_decap;
15913 cmdline_fixed_string_t pos_token;
15914 uint32_t vlan_present:1;
15917 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15918 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15919 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15920 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15922 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15923 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15924 "l2_decap-with-vlan");
15926 static void cmd_set_l2_decap_parsed(void *parsed_result,
15927 __rte_unused struct cmdline *cl,
15928 __rte_unused void *data)
15930 struct cmd_set_l2_decap_result *res = parsed_result;
15932 if (strcmp(res->l2_decap, "l2_decap") == 0)
15933 l2_decap_conf.select_vlan = 0;
15934 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15935 l2_decap_conf.select_vlan = 1;
15938 cmdline_parse_inst_t cmd_set_l2_decap = {
15939 .f = cmd_set_l2_decap_parsed,
15941 .help_str = "set l2_decap",
15943 (void *)&cmd_set_l2_decap_set,
15944 (void *)&cmd_set_l2_decap_l2_decap,
15949 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15950 .f = cmd_set_l2_decap_parsed,
15952 .help_str = "set l2_decap-with-vlan",
15954 (void *)&cmd_set_l2_decap_set,
15955 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15960 /** Set MPLSoGRE encapsulation details */
15961 struct cmd_set_mplsogre_encap_result {
15962 cmdline_fixed_string_t set;
15963 cmdline_fixed_string_t mplsogre;
15964 cmdline_fixed_string_t pos_token;
15965 cmdline_fixed_string_t ip_version;
15966 uint32_t vlan_present:1;
15968 cmdline_ipaddr_t ip_src;
15969 cmdline_ipaddr_t ip_dst;
15971 struct rte_ether_addr eth_src;
15972 struct rte_ether_addr eth_dst;
15975 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15976 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15978 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15979 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15981 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15982 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15983 mplsogre, "mplsogre_encap-with-vlan");
15984 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15985 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15986 pos_token, "ip-version");
15987 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15988 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15989 ip_version, "ipv4#ipv6");
15990 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15991 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15992 pos_token, "label");
15993 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15994 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15996 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15997 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15998 pos_token, "ip-src");
15999 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16000 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16001 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16002 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16003 pos_token, "ip-dst");
16004 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16005 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16006 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16007 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16008 pos_token, "vlan-tci");
16009 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16010 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16012 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16013 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16014 pos_token, "eth-src");
16015 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16016 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16018 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16019 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16020 pos_token, "eth-dst");
16021 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16022 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16025 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16026 __rte_unused struct cmdline *cl,
16027 __rte_unused void *data)
16029 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16031 uint32_t mplsogre_label;
16034 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16037 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16038 mplsogre_encap_conf.select_vlan = 0;
16039 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16040 mplsogre_encap_conf.select_vlan = 1;
16041 if (strcmp(res->ip_version, "ipv4") == 0)
16042 mplsogre_encap_conf.select_ipv4 = 1;
16043 else if (strcmp(res->ip_version, "ipv6") == 0)
16044 mplsogre_encap_conf.select_ipv4 = 0;
16047 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16048 if (mplsogre_encap_conf.select_ipv4) {
16049 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16050 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16052 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16053 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16055 if (mplsogre_encap_conf.select_vlan)
16056 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16057 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16058 RTE_ETHER_ADDR_LEN);
16059 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16060 RTE_ETHER_ADDR_LEN);
16063 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16064 .f = cmd_set_mplsogre_encap_parsed,
16066 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16067 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16068 " eth-dst <eth-dst>",
16070 (void *)&cmd_set_mplsogre_encap_set,
16071 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16072 (void *)&cmd_set_mplsogre_encap_ip_version,
16073 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16074 (void *)&cmd_set_mplsogre_encap_label,
16075 (void *)&cmd_set_mplsogre_encap_label_value,
16076 (void *)&cmd_set_mplsogre_encap_ip_src,
16077 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16078 (void *)&cmd_set_mplsogre_encap_ip_dst,
16079 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16080 (void *)&cmd_set_mplsogre_encap_eth_src,
16081 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16082 (void *)&cmd_set_mplsogre_encap_eth_dst,
16083 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16088 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16089 .f = cmd_set_mplsogre_encap_parsed,
16091 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16092 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16093 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16095 (void *)&cmd_set_mplsogre_encap_set,
16096 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16097 (void *)&cmd_set_mplsogre_encap_ip_version,
16098 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16099 (void *)&cmd_set_mplsogre_encap_label,
16100 (void *)&cmd_set_mplsogre_encap_label_value,
16101 (void *)&cmd_set_mplsogre_encap_ip_src,
16102 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16103 (void *)&cmd_set_mplsogre_encap_ip_dst,
16104 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16105 (void *)&cmd_set_mplsogre_encap_vlan,
16106 (void *)&cmd_set_mplsogre_encap_vlan_value,
16107 (void *)&cmd_set_mplsogre_encap_eth_src,
16108 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16109 (void *)&cmd_set_mplsogre_encap_eth_dst,
16110 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16115 /** Set MPLSoGRE decapsulation details */
16116 struct cmd_set_mplsogre_decap_result {
16117 cmdline_fixed_string_t set;
16118 cmdline_fixed_string_t mplsogre;
16119 cmdline_fixed_string_t pos_token;
16120 cmdline_fixed_string_t ip_version;
16121 uint32_t vlan_present:1;
16124 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16125 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16127 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16128 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16130 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16131 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16132 mplsogre, "mplsogre_decap-with-vlan");
16133 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16134 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16135 pos_token, "ip-version");
16136 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16137 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16138 ip_version, "ipv4#ipv6");
16140 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16141 __rte_unused struct cmdline *cl,
16142 __rte_unused void *data)
16144 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16146 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16147 mplsogre_decap_conf.select_vlan = 0;
16148 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16149 mplsogre_decap_conf.select_vlan = 1;
16150 if (strcmp(res->ip_version, "ipv4") == 0)
16151 mplsogre_decap_conf.select_ipv4 = 1;
16152 else if (strcmp(res->ip_version, "ipv6") == 0)
16153 mplsogre_decap_conf.select_ipv4 = 0;
16156 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16157 .f = cmd_set_mplsogre_decap_parsed,
16159 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16161 (void *)&cmd_set_mplsogre_decap_set,
16162 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16163 (void *)&cmd_set_mplsogre_decap_ip_version,
16164 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16169 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16170 .f = cmd_set_mplsogre_decap_parsed,
16172 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16174 (void *)&cmd_set_mplsogre_decap_set,
16175 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16176 (void *)&cmd_set_mplsogre_decap_ip_version,
16177 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16182 /** Set MPLSoUDP encapsulation details */
16183 struct cmd_set_mplsoudp_encap_result {
16184 cmdline_fixed_string_t set;
16185 cmdline_fixed_string_t mplsoudp;
16186 cmdline_fixed_string_t pos_token;
16187 cmdline_fixed_string_t ip_version;
16188 uint32_t vlan_present:1;
16192 cmdline_ipaddr_t ip_src;
16193 cmdline_ipaddr_t ip_dst;
16195 struct rte_ether_addr eth_src;
16196 struct rte_ether_addr eth_dst;
16199 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16200 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16202 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16203 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16205 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16206 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16207 mplsoudp, "mplsoudp_encap-with-vlan");
16208 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16209 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16210 pos_token, "ip-version");
16211 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16212 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16213 ip_version, "ipv4#ipv6");
16214 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16215 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16216 pos_token, "label");
16217 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16218 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16220 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16221 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16222 pos_token, "udp-src");
16223 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16224 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16226 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16227 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16228 pos_token, "udp-dst");
16229 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16230 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16232 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16233 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16234 pos_token, "ip-src");
16235 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16236 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16237 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16238 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16239 pos_token, "ip-dst");
16240 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16241 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16242 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16243 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16244 pos_token, "vlan-tci");
16245 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16246 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16248 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16249 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16250 pos_token, "eth-src");
16251 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16252 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16254 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16255 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16256 pos_token, "eth-dst");
16257 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16258 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16261 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16262 __rte_unused struct cmdline *cl,
16263 __rte_unused void *data)
16265 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16267 uint32_t mplsoudp_label;
16270 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16273 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16274 mplsoudp_encap_conf.select_vlan = 0;
16275 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16276 mplsoudp_encap_conf.select_vlan = 1;
16277 if (strcmp(res->ip_version, "ipv4") == 0)
16278 mplsoudp_encap_conf.select_ipv4 = 1;
16279 else if (strcmp(res->ip_version, "ipv6") == 0)
16280 mplsoudp_encap_conf.select_ipv4 = 0;
16283 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16284 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16285 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16286 if (mplsoudp_encap_conf.select_ipv4) {
16287 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16288 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16290 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16291 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16293 if (mplsoudp_encap_conf.select_vlan)
16294 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16295 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16296 RTE_ETHER_ADDR_LEN);
16297 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16298 RTE_ETHER_ADDR_LEN);
16301 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16302 .f = cmd_set_mplsoudp_encap_parsed,
16304 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16305 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16306 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16308 (void *)&cmd_set_mplsoudp_encap_set,
16309 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16310 (void *)&cmd_set_mplsoudp_encap_ip_version,
16311 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16312 (void *)&cmd_set_mplsoudp_encap_label,
16313 (void *)&cmd_set_mplsoudp_encap_label_value,
16314 (void *)&cmd_set_mplsoudp_encap_udp_src,
16315 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16316 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16317 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16318 (void *)&cmd_set_mplsoudp_encap_ip_src,
16319 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16320 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16321 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16322 (void *)&cmd_set_mplsoudp_encap_eth_src,
16323 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16324 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16325 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16330 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16331 .f = cmd_set_mplsoudp_encap_parsed,
16333 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16334 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16335 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16336 " eth-src <eth-src> eth-dst <eth-dst>",
16338 (void *)&cmd_set_mplsoudp_encap_set,
16339 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16340 (void *)&cmd_set_mplsoudp_encap_ip_version,
16341 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16342 (void *)&cmd_set_mplsoudp_encap_label,
16343 (void *)&cmd_set_mplsoudp_encap_label_value,
16344 (void *)&cmd_set_mplsoudp_encap_udp_src,
16345 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16346 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16347 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16348 (void *)&cmd_set_mplsoudp_encap_ip_src,
16349 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16350 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16351 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16352 (void *)&cmd_set_mplsoudp_encap_vlan,
16353 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16354 (void *)&cmd_set_mplsoudp_encap_eth_src,
16355 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16356 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16357 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16362 /** Set MPLSoUDP decapsulation details */
16363 struct cmd_set_mplsoudp_decap_result {
16364 cmdline_fixed_string_t set;
16365 cmdline_fixed_string_t mplsoudp;
16366 cmdline_fixed_string_t pos_token;
16367 cmdline_fixed_string_t ip_version;
16368 uint32_t vlan_present:1;
16371 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16372 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16374 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16375 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16377 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16378 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16379 mplsoudp, "mplsoudp_decap-with-vlan");
16380 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16381 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16382 pos_token, "ip-version");
16383 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16384 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16385 ip_version, "ipv4#ipv6");
16387 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16388 __rte_unused struct cmdline *cl,
16389 __rte_unused void *data)
16391 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16393 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16394 mplsoudp_decap_conf.select_vlan = 0;
16395 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16396 mplsoudp_decap_conf.select_vlan = 1;
16397 if (strcmp(res->ip_version, "ipv4") == 0)
16398 mplsoudp_decap_conf.select_ipv4 = 1;
16399 else if (strcmp(res->ip_version, "ipv6") == 0)
16400 mplsoudp_decap_conf.select_ipv4 = 0;
16403 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16404 .f = cmd_set_mplsoudp_decap_parsed,
16406 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16408 (void *)&cmd_set_mplsoudp_decap_set,
16409 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16410 (void *)&cmd_set_mplsoudp_decap_ip_version,
16411 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16416 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16417 .f = cmd_set_mplsoudp_decap_parsed,
16419 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16421 (void *)&cmd_set_mplsoudp_decap_set,
16422 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16423 (void *)&cmd_set_mplsoudp_decap_ip_version,
16424 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16429 /* Strict link priority scheduling mode setting */
16431 cmd_strict_link_prio_parsed(
16432 void *parsed_result,
16433 __rte_unused struct cmdline *cl,
16434 __rte_unused void *data)
16436 struct cmd_vf_tc_bw_result *res = parsed_result;
16437 int ret = -ENOTSUP;
16439 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16442 #ifdef RTE_LIBRTE_I40E_PMD
16443 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16450 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16453 printf("invalid port_id %d\n", res->port_id);
16456 printf("function not implemented\n");
16459 printf("programming error: (%s)\n", strerror(-ret));
16463 cmdline_parse_inst_t cmd_strict_link_prio = {
16464 .f = cmd_strict_link_prio_parsed,
16466 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16468 (void *)&cmd_vf_tc_bw_set,
16469 (void *)&cmd_vf_tc_bw_tx,
16470 (void *)&cmd_vf_tc_bw_strict_link_prio,
16471 (void *)&cmd_vf_tc_bw_port_id,
16472 (void *)&cmd_vf_tc_bw_tc_map,
16477 /* Load dynamic device personalization*/
16478 struct cmd_ddp_add_result {
16479 cmdline_fixed_string_t ddp;
16480 cmdline_fixed_string_t add;
16485 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16486 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16487 cmdline_parse_token_string_t cmd_ddp_add_add =
16488 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16489 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16490 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16491 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16492 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16495 cmd_ddp_add_parsed(
16496 void *parsed_result,
16497 __rte_unused struct cmdline *cl,
16498 __rte_unused void *data)
16500 struct cmd_ddp_add_result *res = parsed_result;
16506 int ret = -ENOTSUP;
16508 if (!all_ports_stopped()) {
16509 printf("Please stop all ports first\n");
16513 filepath = strdup(res->filepath);
16514 if (filepath == NULL) {
16515 printf("Failed to allocate memory\n");
16518 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16520 buff = open_file(file_fld[0], &size);
16522 free((void *)filepath);
16526 #ifdef RTE_LIBRTE_I40E_PMD
16527 if (ret == -ENOTSUP)
16528 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16530 RTE_PMD_I40E_PKG_OP_WR_ADD);
16533 if (ret == -EEXIST)
16534 printf("Profile has already existed.\n");
16536 printf("Failed to load profile.\n");
16537 else if (file_num == 2)
16538 save_file(file_fld[1], buff, size);
16541 free((void *)filepath);
16544 cmdline_parse_inst_t cmd_ddp_add = {
16545 .f = cmd_ddp_add_parsed,
16547 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16549 (void *)&cmd_ddp_add_ddp,
16550 (void *)&cmd_ddp_add_add,
16551 (void *)&cmd_ddp_add_port_id,
16552 (void *)&cmd_ddp_add_filepath,
16557 /* Delete dynamic device personalization*/
16558 struct cmd_ddp_del_result {
16559 cmdline_fixed_string_t ddp;
16560 cmdline_fixed_string_t del;
16565 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16566 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16567 cmdline_parse_token_string_t cmd_ddp_del_del =
16568 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16569 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16570 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16571 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16572 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16575 cmd_ddp_del_parsed(
16576 void *parsed_result,
16577 __rte_unused struct cmdline *cl,
16578 __rte_unused void *data)
16580 struct cmd_ddp_del_result *res = parsed_result;
16583 int ret = -ENOTSUP;
16585 if (!all_ports_stopped()) {
16586 printf("Please stop all ports first\n");
16590 buff = open_file(res->filepath, &size);
16594 #ifdef RTE_LIBRTE_I40E_PMD
16595 if (ret == -ENOTSUP)
16596 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16598 RTE_PMD_I40E_PKG_OP_WR_DEL);
16601 if (ret == -EACCES)
16602 printf("Profile does not exist.\n");
16604 printf("Failed to delete profile.\n");
16609 cmdline_parse_inst_t cmd_ddp_del = {
16610 .f = cmd_ddp_del_parsed,
16612 .help_str = "ddp del <port_id> <backup_profile_path>",
16614 (void *)&cmd_ddp_del_ddp,
16615 (void *)&cmd_ddp_del_del,
16616 (void *)&cmd_ddp_del_port_id,
16617 (void *)&cmd_ddp_del_filepath,
16622 /* Get dynamic device personalization profile info */
16623 struct cmd_ddp_info_result {
16624 cmdline_fixed_string_t ddp;
16625 cmdline_fixed_string_t get;
16626 cmdline_fixed_string_t info;
16630 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16631 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16632 cmdline_parse_token_string_t cmd_ddp_info_get =
16633 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16634 cmdline_parse_token_string_t cmd_ddp_info_info =
16635 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16636 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16637 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16640 cmd_ddp_info_parsed(
16641 void *parsed_result,
16642 __rte_unused struct cmdline *cl,
16643 __rte_unused void *data)
16645 struct cmd_ddp_info_result *res = parsed_result;
16648 int ret = -ENOTSUP;
16649 #ifdef RTE_LIBRTE_I40E_PMD
16652 uint32_t buff_size = 0;
16653 struct rte_pmd_i40e_profile_info info;
16654 uint32_t dev_num = 0;
16655 struct rte_pmd_i40e_ddp_device_id *devs;
16656 uint32_t proto_num = 0;
16657 struct rte_pmd_i40e_proto_info *proto = NULL;
16658 uint32_t pctype_num = 0;
16659 struct rte_pmd_i40e_ptype_info *pctype;
16660 uint32_t ptype_num = 0;
16661 struct rte_pmd_i40e_ptype_info *ptype;
16666 pkg = open_file(res->filepath, &pkg_size);
16670 #ifdef RTE_LIBRTE_I40E_PMD
16671 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16672 (uint8_t *)&info, sizeof(info),
16673 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16675 printf("Global Track id: 0x%x\n", info.track_id);
16676 printf("Global Version: %d.%d.%d.%d\n",
16677 info.version.major,
16678 info.version.minor,
16679 info.version.update,
16680 info.version.draft);
16681 printf("Global Package name: %s\n\n", info.name);
16684 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16685 (uint8_t *)&info, sizeof(info),
16686 RTE_PMD_I40E_PKG_INFO_HEADER);
16688 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16689 printf("i40e Profile Version: %d.%d.%d.%d\n",
16690 info.version.major,
16691 info.version.minor,
16692 info.version.update,
16693 info.version.draft);
16694 printf("i40e Profile name: %s\n\n", info.name);
16697 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16698 (uint8_t *)&buff_size, sizeof(buff_size),
16699 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16700 if (!ret && buff_size) {
16701 buff = (uint8_t *)malloc(buff_size);
16703 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16705 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16707 printf("Package Notes:\n%s\n\n", buff);
16712 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16713 (uint8_t *)&dev_num, sizeof(dev_num),
16714 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16715 if (!ret && dev_num) {
16716 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16717 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16719 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16720 (uint8_t *)devs, buff_size,
16721 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16723 printf("List of supported devices:\n");
16724 for (i = 0; i < dev_num; i++) {
16725 printf(" %04X:%04X %04X:%04X\n",
16726 devs[i].vendor_dev_id >> 16,
16727 devs[i].vendor_dev_id & 0xFFFF,
16728 devs[i].sub_vendor_dev_id >> 16,
16729 devs[i].sub_vendor_dev_id & 0xFFFF);
16737 /* get information about protocols and packet types */
16738 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16739 (uint8_t *)&proto_num, sizeof(proto_num),
16740 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16741 if (ret || !proto_num)
16742 goto no_print_return;
16744 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16745 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16747 goto no_print_return;
16749 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16751 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16753 printf("List of used protocols:\n");
16754 for (i = 0; i < proto_num; i++)
16755 printf(" %2u: %s\n", proto[i].proto_id,
16759 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16760 (uint8_t *)&pctype_num, sizeof(pctype_num),
16761 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16762 if (ret || !pctype_num)
16763 goto no_print_pctypes;
16765 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16766 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16768 goto no_print_pctypes;
16770 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16772 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16775 goto no_print_pctypes;
16778 printf("List of defined packet classification types:\n");
16779 for (i = 0; i < pctype_num; i++) {
16780 printf(" %2u:", pctype[i].ptype_id);
16781 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16782 proto_id = pctype[i].protocols[j];
16783 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16784 for (n = 0; n < proto_num; n++) {
16785 if (proto[n].proto_id == proto_id) {
16786 printf(" %s", proto[n].name);
16799 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16801 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16802 if (ret || !ptype_num)
16803 goto no_print_return;
16805 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16806 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16808 goto no_print_return;
16810 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16812 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16815 goto no_print_return;
16817 printf("List of defined packet types:\n");
16818 for (i = 0; i < ptype_num; i++) {
16819 printf(" %2u:", ptype[i].ptype_id);
16820 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16821 proto_id = ptype[i].protocols[j];
16822 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16823 for (n = 0; n < proto_num; n++) {
16824 if (proto[n].proto_id == proto_id) {
16825 printf(" %s", proto[n].name);
16841 if (ret == -ENOTSUP)
16842 printf("Function not supported in PMD driver\n");
16846 cmdline_parse_inst_t cmd_ddp_get_info = {
16847 .f = cmd_ddp_info_parsed,
16849 .help_str = "ddp get info <profile_path>",
16851 (void *)&cmd_ddp_info_ddp,
16852 (void *)&cmd_ddp_info_get,
16853 (void *)&cmd_ddp_info_info,
16854 (void *)&cmd_ddp_info_filepath,
16859 /* Get dynamic device personalization profile info list*/
16860 #define PROFILE_INFO_SIZE 48
16861 #define MAX_PROFILE_NUM 16
16863 struct cmd_ddp_get_list_result {
16864 cmdline_fixed_string_t ddp;
16865 cmdline_fixed_string_t get;
16866 cmdline_fixed_string_t list;
16870 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16871 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16872 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16873 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16874 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16875 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16876 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16877 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16880 cmd_ddp_get_list_parsed(
16881 __rte_unused void *parsed_result,
16882 __rte_unused struct cmdline *cl,
16883 __rte_unused void *data)
16885 #ifdef RTE_LIBRTE_I40E_PMD
16886 struct cmd_ddp_get_list_result *res = parsed_result;
16887 struct rte_pmd_i40e_profile_list *p_list;
16888 struct rte_pmd_i40e_profile_info *p_info;
16893 int ret = -ENOTSUP;
16895 #ifdef RTE_LIBRTE_I40E_PMD
16896 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16897 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16899 printf("%s: Failed to malloc buffer\n", __func__);
16903 if (ret == -ENOTSUP)
16904 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16905 (uint8_t *)p_list, size);
16908 p_num = p_list->p_count;
16909 printf("Profile number is: %d\n\n", p_num);
16911 for (i = 0; i < p_num; i++) {
16912 p_info = &p_list->p_info[i];
16913 printf("Profile %d:\n", i);
16914 printf("Track id: 0x%x\n", p_info->track_id);
16915 printf("Version: %d.%d.%d.%d\n",
16916 p_info->version.major,
16917 p_info->version.minor,
16918 p_info->version.update,
16919 p_info->version.draft);
16920 printf("Profile name: %s\n\n", p_info->name);
16928 printf("Failed to get ddp list\n");
16931 cmdline_parse_inst_t cmd_ddp_get_list = {
16932 .f = cmd_ddp_get_list_parsed,
16934 .help_str = "ddp get list <port_id>",
16936 (void *)&cmd_ddp_get_list_ddp,
16937 (void *)&cmd_ddp_get_list_get,
16938 (void *)&cmd_ddp_get_list_list,
16939 (void *)&cmd_ddp_get_list_port_id,
16944 /* Configure input set */
16945 struct cmd_cfg_input_set_result {
16946 cmdline_fixed_string_t port;
16947 cmdline_fixed_string_t cfg;
16949 cmdline_fixed_string_t pctype;
16951 cmdline_fixed_string_t inset_type;
16952 cmdline_fixed_string_t opt;
16953 cmdline_fixed_string_t field;
16958 cmd_cfg_input_set_parsed(
16959 __rte_unused void *parsed_result,
16960 __rte_unused struct cmdline *cl,
16961 __rte_unused void *data)
16963 #ifdef RTE_LIBRTE_I40E_PMD
16964 struct cmd_cfg_input_set_result *res = parsed_result;
16965 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16966 struct rte_pmd_i40e_inset inset;
16968 int ret = -ENOTSUP;
16970 if (!all_ports_stopped()) {
16971 printf("Please stop all ports first\n");
16975 #ifdef RTE_LIBRTE_I40E_PMD
16976 if (!strcmp(res->inset_type, "hash_inset"))
16977 inset_type = INSET_HASH;
16978 else if (!strcmp(res->inset_type, "fdir_inset"))
16979 inset_type = INSET_FDIR;
16980 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16981 inset_type = INSET_FDIR_FLX;
16982 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16983 &inset, inset_type);
16985 printf("Failed to get input set.\n");
16989 if (!strcmp(res->opt, "get")) {
16990 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16993 printf("Field index %d is enabled.\n", res->field_idx);
16995 printf("Field index %d is disabled.\n", res->field_idx);
16997 } else if (!strcmp(res->opt, "set"))
16998 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17000 else if (!strcmp(res->opt, "clear"))
17001 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17004 printf("Failed to configure input set field.\n");
17008 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17009 &inset, inset_type);
17011 printf("Failed to set input set.\n");
17016 if (ret == -ENOTSUP)
17017 printf("Function not supported\n");
17020 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17021 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17023 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17024 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17026 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17027 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17029 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17030 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17032 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17033 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17035 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17036 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17038 "hash_inset#fdir_inset#fdir_flx_inset");
17039 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17040 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17041 opt, "get#set#clear");
17042 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17043 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17045 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17046 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17049 cmdline_parse_inst_t cmd_cfg_input_set = {
17050 .f = cmd_cfg_input_set_parsed,
17052 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17053 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17055 (void *)&cmd_cfg_input_set_port,
17056 (void *)&cmd_cfg_input_set_cfg,
17057 (void *)&cmd_cfg_input_set_port_id,
17058 (void *)&cmd_cfg_input_set_pctype,
17059 (void *)&cmd_cfg_input_set_pctype_id,
17060 (void *)&cmd_cfg_input_set_inset_type,
17061 (void *)&cmd_cfg_input_set_opt,
17062 (void *)&cmd_cfg_input_set_field,
17063 (void *)&cmd_cfg_input_set_field_idx,
17068 /* Clear input set */
17069 struct cmd_clear_input_set_result {
17070 cmdline_fixed_string_t port;
17071 cmdline_fixed_string_t cfg;
17073 cmdline_fixed_string_t pctype;
17075 cmdline_fixed_string_t inset_type;
17076 cmdline_fixed_string_t clear;
17077 cmdline_fixed_string_t all;
17081 cmd_clear_input_set_parsed(
17082 __rte_unused void *parsed_result,
17083 __rte_unused struct cmdline *cl,
17084 __rte_unused void *data)
17086 #ifdef RTE_LIBRTE_I40E_PMD
17087 struct cmd_clear_input_set_result *res = parsed_result;
17088 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17089 struct rte_pmd_i40e_inset inset;
17091 int ret = -ENOTSUP;
17093 if (!all_ports_stopped()) {
17094 printf("Please stop all ports first\n");
17098 #ifdef RTE_LIBRTE_I40E_PMD
17099 if (!strcmp(res->inset_type, "hash_inset"))
17100 inset_type = INSET_HASH;
17101 else if (!strcmp(res->inset_type, "fdir_inset"))
17102 inset_type = INSET_FDIR;
17103 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17104 inset_type = INSET_FDIR_FLX;
17106 memset(&inset, 0, sizeof(inset));
17108 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17109 &inset, inset_type);
17111 printf("Failed to clear input set.\n");
17117 if (ret == -ENOTSUP)
17118 printf("Function not supported\n");
17121 cmdline_parse_token_string_t cmd_clear_input_set_port =
17122 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17124 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17125 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17127 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17128 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17130 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17131 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17133 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17134 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17136 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17137 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17139 "hash_inset#fdir_inset#fdir_flx_inset");
17140 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17141 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17143 cmdline_parse_token_string_t cmd_clear_input_set_all =
17144 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17147 cmdline_parse_inst_t cmd_clear_input_set = {
17148 .f = cmd_clear_input_set_parsed,
17150 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17151 "fdir_inset|fdir_flx_inset clear all",
17153 (void *)&cmd_clear_input_set_port,
17154 (void *)&cmd_clear_input_set_cfg,
17155 (void *)&cmd_clear_input_set_port_id,
17156 (void *)&cmd_clear_input_set_pctype,
17157 (void *)&cmd_clear_input_set_pctype_id,
17158 (void *)&cmd_clear_input_set_inset_type,
17159 (void *)&cmd_clear_input_set_clear,
17160 (void *)&cmd_clear_input_set_all,
17165 /* show vf stats */
17167 /* Common result structure for show vf stats */
17168 struct cmd_show_vf_stats_result {
17169 cmdline_fixed_string_t show;
17170 cmdline_fixed_string_t vf;
17171 cmdline_fixed_string_t stats;
17176 /* Common CLI fields show vf stats*/
17177 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17178 TOKEN_STRING_INITIALIZER
17179 (struct cmd_show_vf_stats_result,
17181 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17182 TOKEN_STRING_INITIALIZER
17183 (struct cmd_show_vf_stats_result,
17185 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17186 TOKEN_STRING_INITIALIZER
17187 (struct cmd_show_vf_stats_result,
17189 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17190 TOKEN_NUM_INITIALIZER
17191 (struct cmd_show_vf_stats_result,
17193 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17194 TOKEN_NUM_INITIALIZER
17195 (struct cmd_show_vf_stats_result,
17199 cmd_show_vf_stats_parsed(
17200 void *parsed_result,
17201 __rte_unused struct cmdline *cl,
17202 __rte_unused void *data)
17204 struct cmd_show_vf_stats_result *res = parsed_result;
17205 struct rte_eth_stats stats;
17206 int ret = -ENOTSUP;
17207 static const char *nic_stats_border = "########################";
17209 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17212 memset(&stats, 0, sizeof(stats));
17214 #ifdef RTE_LIBRTE_I40E_PMD
17215 if (ret == -ENOTSUP)
17216 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17220 #ifdef RTE_LIBRTE_BNXT_PMD
17221 if (ret == -ENOTSUP)
17222 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17231 printf("invalid vf_id %d\n", res->vf_id);
17234 printf("invalid port_id %d\n", res->port_id);
17237 printf("function not implemented\n");
17240 printf("programming error: (%s)\n", strerror(-ret));
17243 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17244 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17246 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17248 stats.ipackets, stats.imissed, stats.ibytes);
17249 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17250 printf(" RX-nombuf: %-10"PRIu64"\n",
17252 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17254 stats.opackets, stats.oerrors, stats.obytes);
17256 printf(" %s############################%s\n",
17257 nic_stats_border, nic_stats_border);
17260 cmdline_parse_inst_t cmd_show_vf_stats = {
17261 .f = cmd_show_vf_stats_parsed,
17263 .help_str = "show vf stats <port_id> <vf_id>",
17265 (void *)&cmd_show_vf_stats_show,
17266 (void *)&cmd_show_vf_stats_vf,
17267 (void *)&cmd_show_vf_stats_stats,
17268 (void *)&cmd_show_vf_stats_port_id,
17269 (void *)&cmd_show_vf_stats_vf_id,
17274 /* clear vf stats */
17276 /* Common result structure for clear vf stats */
17277 struct cmd_clear_vf_stats_result {
17278 cmdline_fixed_string_t clear;
17279 cmdline_fixed_string_t vf;
17280 cmdline_fixed_string_t stats;
17285 /* Common CLI fields clear vf stats*/
17286 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17287 TOKEN_STRING_INITIALIZER
17288 (struct cmd_clear_vf_stats_result,
17290 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17291 TOKEN_STRING_INITIALIZER
17292 (struct cmd_clear_vf_stats_result,
17294 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17295 TOKEN_STRING_INITIALIZER
17296 (struct cmd_clear_vf_stats_result,
17298 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17299 TOKEN_NUM_INITIALIZER
17300 (struct cmd_clear_vf_stats_result,
17302 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17303 TOKEN_NUM_INITIALIZER
17304 (struct cmd_clear_vf_stats_result,
17308 cmd_clear_vf_stats_parsed(
17309 void *parsed_result,
17310 __rte_unused struct cmdline *cl,
17311 __rte_unused void *data)
17313 struct cmd_clear_vf_stats_result *res = parsed_result;
17314 int ret = -ENOTSUP;
17316 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17319 #ifdef RTE_LIBRTE_I40E_PMD
17320 if (ret == -ENOTSUP)
17321 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17324 #ifdef RTE_LIBRTE_BNXT_PMD
17325 if (ret == -ENOTSUP)
17326 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17334 printf("invalid vf_id %d\n", res->vf_id);
17337 printf("invalid port_id %d\n", res->port_id);
17340 printf("function not implemented\n");
17343 printf("programming error: (%s)\n", strerror(-ret));
17347 cmdline_parse_inst_t cmd_clear_vf_stats = {
17348 .f = cmd_clear_vf_stats_parsed,
17350 .help_str = "clear vf stats <port_id> <vf_id>",
17352 (void *)&cmd_clear_vf_stats_clear,
17353 (void *)&cmd_clear_vf_stats_vf,
17354 (void *)&cmd_clear_vf_stats_stats,
17355 (void *)&cmd_clear_vf_stats_port_id,
17356 (void *)&cmd_clear_vf_stats_vf_id,
17361 /* port config pctype mapping reset */
17363 /* Common result structure for port config pctype mapping reset */
17364 struct cmd_pctype_mapping_reset_result {
17365 cmdline_fixed_string_t port;
17366 cmdline_fixed_string_t config;
17368 cmdline_fixed_string_t pctype;
17369 cmdline_fixed_string_t mapping;
17370 cmdline_fixed_string_t reset;
17373 /* Common CLI fields for port config pctype mapping reset*/
17374 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17375 TOKEN_STRING_INITIALIZER
17376 (struct cmd_pctype_mapping_reset_result,
17378 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17379 TOKEN_STRING_INITIALIZER
17380 (struct cmd_pctype_mapping_reset_result,
17382 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17383 TOKEN_NUM_INITIALIZER
17384 (struct cmd_pctype_mapping_reset_result,
17386 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17387 TOKEN_STRING_INITIALIZER
17388 (struct cmd_pctype_mapping_reset_result,
17390 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17391 TOKEN_STRING_INITIALIZER
17392 (struct cmd_pctype_mapping_reset_result,
17393 mapping, "mapping");
17394 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17395 TOKEN_STRING_INITIALIZER
17396 (struct cmd_pctype_mapping_reset_result,
17400 cmd_pctype_mapping_reset_parsed(
17401 void *parsed_result,
17402 __rte_unused struct cmdline *cl,
17403 __rte_unused void *data)
17405 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17406 int ret = -ENOTSUP;
17408 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17411 #ifdef RTE_LIBRTE_I40E_PMD
17412 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17419 printf("invalid port_id %d\n", res->port_id);
17422 printf("function not implemented\n");
17425 printf("programming error: (%s)\n", strerror(-ret));
17429 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17430 .f = cmd_pctype_mapping_reset_parsed,
17432 .help_str = "port config <port_id> pctype mapping reset",
17434 (void *)&cmd_pctype_mapping_reset_port,
17435 (void *)&cmd_pctype_mapping_reset_config,
17436 (void *)&cmd_pctype_mapping_reset_port_id,
17437 (void *)&cmd_pctype_mapping_reset_pctype,
17438 (void *)&cmd_pctype_mapping_reset_mapping,
17439 (void *)&cmd_pctype_mapping_reset_reset,
17444 /* show port pctype mapping */
17446 /* Common result structure for show port pctype mapping */
17447 struct cmd_pctype_mapping_get_result {
17448 cmdline_fixed_string_t show;
17449 cmdline_fixed_string_t port;
17451 cmdline_fixed_string_t pctype;
17452 cmdline_fixed_string_t mapping;
17455 /* Common CLI fields for pctype mapping get */
17456 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17457 TOKEN_STRING_INITIALIZER
17458 (struct cmd_pctype_mapping_get_result,
17460 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17461 TOKEN_STRING_INITIALIZER
17462 (struct cmd_pctype_mapping_get_result,
17464 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17465 TOKEN_NUM_INITIALIZER
17466 (struct cmd_pctype_mapping_get_result,
17468 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17469 TOKEN_STRING_INITIALIZER
17470 (struct cmd_pctype_mapping_get_result,
17472 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17473 TOKEN_STRING_INITIALIZER
17474 (struct cmd_pctype_mapping_get_result,
17475 mapping, "mapping");
17478 cmd_pctype_mapping_get_parsed(
17479 void *parsed_result,
17480 __rte_unused struct cmdline *cl,
17481 __rte_unused void *data)
17483 struct cmd_pctype_mapping_get_result *res = parsed_result;
17484 int ret = -ENOTSUP;
17485 #ifdef RTE_LIBRTE_I40E_PMD
17486 struct rte_pmd_i40e_flow_type_mapping
17487 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17488 int i, j, first_pctype;
17491 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17494 #ifdef RTE_LIBRTE_I40E_PMD
17495 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17502 printf("invalid port_id %d\n", res->port_id);
17505 printf("function not implemented\n");
17508 printf("programming error: (%s)\n", strerror(-ret));
17512 #ifdef RTE_LIBRTE_I40E_PMD
17513 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17514 if (mapping[i].pctype != 0ULL) {
17517 printf("pctype: ");
17518 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17519 if (mapping[i].pctype & (1ULL << j)) {
17520 printf(first_pctype ?
17521 "%02d" : ",%02d", j);
17525 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17531 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17532 .f = cmd_pctype_mapping_get_parsed,
17534 .help_str = "show port <port_id> pctype mapping",
17536 (void *)&cmd_pctype_mapping_get_show,
17537 (void *)&cmd_pctype_mapping_get_port,
17538 (void *)&cmd_pctype_mapping_get_port_id,
17539 (void *)&cmd_pctype_mapping_get_pctype,
17540 (void *)&cmd_pctype_mapping_get_mapping,
17545 /* port config pctype mapping update */
17547 /* Common result structure for port config pctype mapping update */
17548 struct cmd_pctype_mapping_update_result {
17549 cmdline_fixed_string_t port;
17550 cmdline_fixed_string_t config;
17552 cmdline_fixed_string_t pctype;
17553 cmdline_fixed_string_t mapping;
17554 cmdline_fixed_string_t update;
17555 cmdline_fixed_string_t pctype_list;
17556 uint16_t flow_type;
17559 /* Common CLI fields for pctype mapping update*/
17560 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17561 TOKEN_STRING_INITIALIZER
17562 (struct cmd_pctype_mapping_update_result,
17564 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17565 TOKEN_STRING_INITIALIZER
17566 (struct cmd_pctype_mapping_update_result,
17568 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17569 TOKEN_NUM_INITIALIZER
17570 (struct cmd_pctype_mapping_update_result,
17572 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17573 TOKEN_STRING_INITIALIZER
17574 (struct cmd_pctype_mapping_update_result,
17576 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17577 TOKEN_STRING_INITIALIZER
17578 (struct cmd_pctype_mapping_update_result,
17579 mapping, "mapping");
17580 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17581 TOKEN_STRING_INITIALIZER
17582 (struct cmd_pctype_mapping_update_result,
17584 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17585 TOKEN_STRING_INITIALIZER
17586 (struct cmd_pctype_mapping_update_result,
17587 pctype_list, NULL);
17588 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17589 TOKEN_NUM_INITIALIZER
17590 (struct cmd_pctype_mapping_update_result,
17591 flow_type, UINT16);
17594 cmd_pctype_mapping_update_parsed(
17595 void *parsed_result,
17596 __rte_unused struct cmdline *cl,
17597 __rte_unused void *data)
17599 struct cmd_pctype_mapping_update_result *res = parsed_result;
17600 int ret = -ENOTSUP;
17601 #ifdef RTE_LIBRTE_I40E_PMD
17602 struct rte_pmd_i40e_flow_type_mapping mapping;
17604 unsigned int nb_item;
17605 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17608 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17611 #ifdef RTE_LIBRTE_I40E_PMD
17612 nb_item = parse_item_list(res->pctype_list, "pctypes",
17613 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17614 mapping.flow_type = res->flow_type;
17615 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17616 mapping.pctype |= (1ULL << pctype_list[i]);
17617 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17627 printf("invalid pctype or flow type\n");
17630 printf("invalid port_id %d\n", res->port_id);
17633 printf("function not implemented\n");
17636 printf("programming error: (%s)\n", strerror(-ret));
17640 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17641 .f = cmd_pctype_mapping_update_parsed,
17643 .help_str = "port config <port_id> pctype mapping update"
17644 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17646 (void *)&cmd_pctype_mapping_update_port,
17647 (void *)&cmd_pctype_mapping_update_config,
17648 (void *)&cmd_pctype_mapping_update_port_id,
17649 (void *)&cmd_pctype_mapping_update_pctype,
17650 (void *)&cmd_pctype_mapping_update_mapping,
17651 (void *)&cmd_pctype_mapping_update_update,
17652 (void *)&cmd_pctype_mapping_update_pc_type,
17653 (void *)&cmd_pctype_mapping_update_flow_type,
17658 /* ptype mapping get */
17660 /* Common result structure for ptype mapping get */
17661 struct cmd_ptype_mapping_get_result {
17662 cmdline_fixed_string_t ptype;
17663 cmdline_fixed_string_t mapping;
17664 cmdline_fixed_string_t get;
17666 uint8_t valid_only;
17669 /* Common CLI fields for ptype mapping get */
17670 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17671 TOKEN_STRING_INITIALIZER
17672 (struct cmd_ptype_mapping_get_result,
17674 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17675 TOKEN_STRING_INITIALIZER
17676 (struct cmd_ptype_mapping_get_result,
17677 mapping, "mapping");
17678 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17679 TOKEN_STRING_INITIALIZER
17680 (struct cmd_ptype_mapping_get_result,
17682 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17683 TOKEN_NUM_INITIALIZER
17684 (struct cmd_ptype_mapping_get_result,
17686 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17687 TOKEN_NUM_INITIALIZER
17688 (struct cmd_ptype_mapping_get_result,
17689 valid_only, UINT8);
17692 cmd_ptype_mapping_get_parsed(
17693 void *parsed_result,
17694 __rte_unused struct cmdline *cl,
17695 __rte_unused void *data)
17697 struct cmd_ptype_mapping_get_result *res = parsed_result;
17698 int ret = -ENOTSUP;
17699 #ifdef RTE_LIBRTE_I40E_PMD
17700 int max_ptype_num = 256;
17701 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17706 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17709 #ifdef RTE_LIBRTE_I40E_PMD
17710 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17721 printf("invalid port_id %d\n", res->port_id);
17724 printf("function not implemented\n");
17727 printf("programming error: (%s)\n", strerror(-ret));
17730 #ifdef RTE_LIBRTE_I40E_PMD
17732 for (i = 0; i < count; i++)
17733 printf("%3d\t0x%08x\n",
17734 mapping[i].hw_ptype, mapping[i].sw_ptype);
17739 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17740 .f = cmd_ptype_mapping_get_parsed,
17742 .help_str = "ptype mapping get <port_id> <valid_only>",
17744 (void *)&cmd_ptype_mapping_get_ptype,
17745 (void *)&cmd_ptype_mapping_get_mapping,
17746 (void *)&cmd_ptype_mapping_get_get,
17747 (void *)&cmd_ptype_mapping_get_port_id,
17748 (void *)&cmd_ptype_mapping_get_valid_only,
17753 /* ptype mapping replace */
17755 /* Common result structure for ptype mapping replace */
17756 struct cmd_ptype_mapping_replace_result {
17757 cmdline_fixed_string_t ptype;
17758 cmdline_fixed_string_t mapping;
17759 cmdline_fixed_string_t replace;
17766 /* Common CLI fields for ptype mapping replace */
17767 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17768 TOKEN_STRING_INITIALIZER
17769 (struct cmd_ptype_mapping_replace_result,
17771 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17772 TOKEN_STRING_INITIALIZER
17773 (struct cmd_ptype_mapping_replace_result,
17774 mapping, "mapping");
17775 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17776 TOKEN_STRING_INITIALIZER
17777 (struct cmd_ptype_mapping_replace_result,
17778 replace, "replace");
17779 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17780 TOKEN_NUM_INITIALIZER
17781 (struct cmd_ptype_mapping_replace_result,
17783 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17784 TOKEN_NUM_INITIALIZER
17785 (struct cmd_ptype_mapping_replace_result,
17787 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17788 TOKEN_NUM_INITIALIZER
17789 (struct cmd_ptype_mapping_replace_result,
17791 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17792 TOKEN_NUM_INITIALIZER
17793 (struct cmd_ptype_mapping_replace_result,
17797 cmd_ptype_mapping_replace_parsed(
17798 void *parsed_result,
17799 __rte_unused struct cmdline *cl,
17800 __rte_unused void *data)
17802 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17803 int ret = -ENOTSUP;
17805 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17808 #ifdef RTE_LIBRTE_I40E_PMD
17809 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17819 printf("invalid ptype 0x%8x or 0x%8x\n",
17820 res->target, res->pkt_type);
17823 printf("invalid port_id %d\n", res->port_id);
17826 printf("function not implemented\n");
17829 printf("programming error: (%s)\n", strerror(-ret));
17833 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17834 .f = cmd_ptype_mapping_replace_parsed,
17837 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17839 (void *)&cmd_ptype_mapping_replace_ptype,
17840 (void *)&cmd_ptype_mapping_replace_mapping,
17841 (void *)&cmd_ptype_mapping_replace_replace,
17842 (void *)&cmd_ptype_mapping_replace_port_id,
17843 (void *)&cmd_ptype_mapping_replace_target,
17844 (void *)&cmd_ptype_mapping_replace_mask,
17845 (void *)&cmd_ptype_mapping_replace_pkt_type,
17850 /* ptype mapping reset */
17852 /* Common result structure for ptype mapping reset */
17853 struct cmd_ptype_mapping_reset_result {
17854 cmdline_fixed_string_t ptype;
17855 cmdline_fixed_string_t mapping;
17856 cmdline_fixed_string_t reset;
17860 /* Common CLI fields for ptype mapping reset*/
17861 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17862 TOKEN_STRING_INITIALIZER
17863 (struct cmd_ptype_mapping_reset_result,
17865 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17866 TOKEN_STRING_INITIALIZER
17867 (struct cmd_ptype_mapping_reset_result,
17868 mapping, "mapping");
17869 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17870 TOKEN_STRING_INITIALIZER
17871 (struct cmd_ptype_mapping_reset_result,
17873 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17874 TOKEN_NUM_INITIALIZER
17875 (struct cmd_ptype_mapping_reset_result,
17879 cmd_ptype_mapping_reset_parsed(
17880 void *parsed_result,
17881 __rte_unused struct cmdline *cl,
17882 __rte_unused void *data)
17884 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17885 int ret = -ENOTSUP;
17887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17890 #ifdef RTE_LIBRTE_I40E_PMD
17891 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17898 printf("invalid port_id %d\n", res->port_id);
17901 printf("function not implemented\n");
17904 printf("programming error: (%s)\n", strerror(-ret));
17908 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17909 .f = cmd_ptype_mapping_reset_parsed,
17911 .help_str = "ptype mapping reset <port_id>",
17913 (void *)&cmd_ptype_mapping_reset_ptype,
17914 (void *)&cmd_ptype_mapping_reset_mapping,
17915 (void *)&cmd_ptype_mapping_reset_reset,
17916 (void *)&cmd_ptype_mapping_reset_port_id,
17921 /* ptype mapping update */
17923 /* Common result structure for ptype mapping update */
17924 struct cmd_ptype_mapping_update_result {
17925 cmdline_fixed_string_t ptype;
17926 cmdline_fixed_string_t mapping;
17927 cmdline_fixed_string_t reset;
17933 /* Common CLI fields for ptype mapping update*/
17934 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17935 TOKEN_STRING_INITIALIZER
17936 (struct cmd_ptype_mapping_update_result,
17938 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17939 TOKEN_STRING_INITIALIZER
17940 (struct cmd_ptype_mapping_update_result,
17941 mapping, "mapping");
17942 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17943 TOKEN_STRING_INITIALIZER
17944 (struct cmd_ptype_mapping_update_result,
17946 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17947 TOKEN_NUM_INITIALIZER
17948 (struct cmd_ptype_mapping_update_result,
17950 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17951 TOKEN_NUM_INITIALIZER
17952 (struct cmd_ptype_mapping_update_result,
17954 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17955 TOKEN_NUM_INITIALIZER
17956 (struct cmd_ptype_mapping_update_result,
17960 cmd_ptype_mapping_update_parsed(
17961 void *parsed_result,
17962 __rte_unused struct cmdline *cl,
17963 __rte_unused void *data)
17965 struct cmd_ptype_mapping_update_result *res = parsed_result;
17966 int ret = -ENOTSUP;
17967 #ifdef RTE_LIBRTE_I40E_PMD
17968 struct rte_pmd_i40e_ptype_mapping mapping;
17970 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17973 #ifdef RTE_LIBRTE_I40E_PMD
17974 mapping.hw_ptype = res->hw_ptype;
17975 mapping.sw_ptype = res->sw_ptype;
17976 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17986 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17989 printf("invalid port_id %d\n", res->port_id);
17992 printf("function not implemented\n");
17995 printf("programming error: (%s)\n", strerror(-ret));
17999 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18000 .f = cmd_ptype_mapping_update_parsed,
18002 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18004 (void *)&cmd_ptype_mapping_update_ptype,
18005 (void *)&cmd_ptype_mapping_update_mapping,
18006 (void *)&cmd_ptype_mapping_update_update,
18007 (void *)&cmd_ptype_mapping_update_port_id,
18008 (void *)&cmd_ptype_mapping_update_hw_ptype,
18009 (void *)&cmd_ptype_mapping_update_sw_ptype,
18014 /* Common result structure for file commands */
18015 struct cmd_cmdfile_result {
18016 cmdline_fixed_string_t load;
18017 cmdline_fixed_string_t filename;
18020 /* Common CLI fields for file commands */
18021 cmdline_parse_token_string_t cmd_load_cmdfile =
18022 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18023 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18024 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18027 cmd_load_from_file_parsed(
18028 void *parsed_result,
18029 __rte_unused struct cmdline *cl,
18030 __rte_unused void *data)
18032 struct cmd_cmdfile_result *res = parsed_result;
18034 cmdline_read_from_file(res->filename);
18037 cmdline_parse_inst_t cmd_load_from_file = {
18038 .f = cmd_load_from_file_parsed,
18040 .help_str = "load <filename>",
18042 (void *)&cmd_load_cmdfile,
18043 (void *)&cmd_load_cmdfile_filename,
18048 /* Get Rx offloads capabilities */
18049 struct cmd_rx_offload_get_capa_result {
18050 cmdline_fixed_string_t show;
18051 cmdline_fixed_string_t port;
18053 cmdline_fixed_string_t rx_offload;
18054 cmdline_fixed_string_t capabilities;
18057 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18058 TOKEN_STRING_INITIALIZER
18059 (struct cmd_rx_offload_get_capa_result,
18061 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18062 TOKEN_STRING_INITIALIZER
18063 (struct cmd_rx_offload_get_capa_result,
18065 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18066 TOKEN_NUM_INITIALIZER
18067 (struct cmd_rx_offload_get_capa_result,
18069 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18070 TOKEN_STRING_INITIALIZER
18071 (struct cmd_rx_offload_get_capa_result,
18072 rx_offload, "rx_offload");
18073 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18074 TOKEN_STRING_INITIALIZER
18075 (struct cmd_rx_offload_get_capa_result,
18076 capabilities, "capabilities");
18079 print_rx_offloads(uint64_t offloads)
18081 uint64_t single_offload;
18089 begin = __builtin_ctzll(offloads);
18090 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18092 single_offload = 1ULL << begin;
18093 for (bit = begin; bit < end; bit++) {
18094 if (offloads & single_offload)
18096 rte_eth_dev_rx_offload_name(single_offload));
18097 single_offload <<= 1;
18102 cmd_rx_offload_get_capa_parsed(
18103 void *parsed_result,
18104 __rte_unused struct cmdline *cl,
18105 __rte_unused void *data)
18107 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18108 struct rte_eth_dev_info dev_info;
18109 portid_t port_id = res->port_id;
18110 uint64_t queue_offloads;
18111 uint64_t port_offloads;
18114 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18118 queue_offloads = dev_info.rx_queue_offload_capa;
18119 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18121 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18122 printf(" Per Queue :");
18123 print_rx_offloads(queue_offloads);
18126 printf(" Per Port :");
18127 print_rx_offloads(port_offloads);
18131 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18132 .f = cmd_rx_offload_get_capa_parsed,
18134 .help_str = "show port <port_id> rx_offload capabilities",
18136 (void *)&cmd_rx_offload_get_capa_show,
18137 (void *)&cmd_rx_offload_get_capa_port,
18138 (void *)&cmd_rx_offload_get_capa_port_id,
18139 (void *)&cmd_rx_offload_get_capa_rx_offload,
18140 (void *)&cmd_rx_offload_get_capa_capabilities,
18145 /* Get Rx offloads configuration */
18146 struct cmd_rx_offload_get_configuration_result {
18147 cmdline_fixed_string_t show;
18148 cmdline_fixed_string_t port;
18150 cmdline_fixed_string_t rx_offload;
18151 cmdline_fixed_string_t configuration;
18154 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18155 TOKEN_STRING_INITIALIZER
18156 (struct cmd_rx_offload_get_configuration_result,
18158 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18159 TOKEN_STRING_INITIALIZER
18160 (struct cmd_rx_offload_get_configuration_result,
18162 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18163 TOKEN_NUM_INITIALIZER
18164 (struct cmd_rx_offload_get_configuration_result,
18166 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18167 TOKEN_STRING_INITIALIZER
18168 (struct cmd_rx_offload_get_configuration_result,
18169 rx_offload, "rx_offload");
18170 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18171 TOKEN_STRING_INITIALIZER
18172 (struct cmd_rx_offload_get_configuration_result,
18173 configuration, "configuration");
18176 cmd_rx_offload_get_configuration_parsed(
18177 void *parsed_result,
18178 __rte_unused struct cmdline *cl,
18179 __rte_unused void *data)
18181 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18182 struct rte_eth_dev_info dev_info;
18183 portid_t port_id = res->port_id;
18184 struct rte_port *port = &ports[port_id];
18185 uint64_t port_offloads;
18186 uint64_t queue_offloads;
18187 uint16_t nb_rx_queues;
18191 printf("Rx Offloading Configuration of port %d :\n", port_id);
18193 port_offloads = port->dev_conf.rxmode.offloads;
18195 print_rx_offloads(port_offloads);
18198 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18202 nb_rx_queues = dev_info.nb_rx_queues;
18203 for (q = 0; q < nb_rx_queues; q++) {
18204 queue_offloads = port->rx_conf[q].offloads;
18205 printf(" Queue[%2d] :", q);
18206 print_rx_offloads(queue_offloads);
18212 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18213 .f = cmd_rx_offload_get_configuration_parsed,
18215 .help_str = "show port <port_id> rx_offload configuration",
18217 (void *)&cmd_rx_offload_get_configuration_show,
18218 (void *)&cmd_rx_offload_get_configuration_port,
18219 (void *)&cmd_rx_offload_get_configuration_port_id,
18220 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18221 (void *)&cmd_rx_offload_get_configuration_configuration,
18226 /* Enable/Disable a per port offloading */
18227 struct cmd_config_per_port_rx_offload_result {
18228 cmdline_fixed_string_t port;
18229 cmdline_fixed_string_t config;
18231 cmdline_fixed_string_t rx_offload;
18232 cmdline_fixed_string_t offload;
18233 cmdline_fixed_string_t on_off;
18236 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18237 TOKEN_STRING_INITIALIZER
18238 (struct cmd_config_per_port_rx_offload_result,
18240 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18241 TOKEN_STRING_INITIALIZER
18242 (struct cmd_config_per_port_rx_offload_result,
18244 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18245 TOKEN_NUM_INITIALIZER
18246 (struct cmd_config_per_port_rx_offload_result,
18248 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18249 TOKEN_STRING_INITIALIZER
18250 (struct cmd_config_per_port_rx_offload_result,
18251 rx_offload, "rx_offload");
18252 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18253 TOKEN_STRING_INITIALIZER
18254 (struct cmd_config_per_port_rx_offload_result,
18255 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18256 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18257 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18258 "scatter#timestamp#security#keep_crc#rss_hash");
18259 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18260 TOKEN_STRING_INITIALIZER
18261 (struct cmd_config_per_port_rx_offload_result,
18265 search_rx_offload(const char *name)
18267 uint64_t single_offload;
18268 const char *single_name;
18272 single_offload = 1;
18273 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18274 single_name = rte_eth_dev_rx_offload_name(single_offload);
18275 if (!strcasecmp(single_name, name)) {
18279 single_offload <<= 1;
18283 return single_offload;
18289 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18290 __rte_unused struct cmdline *cl,
18291 __rte_unused void *data)
18293 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18294 portid_t port_id = res->port_id;
18295 struct rte_eth_dev_info dev_info;
18296 struct rte_port *port = &ports[port_id];
18297 uint64_t single_offload;
18298 uint16_t nb_rx_queues;
18302 if (port->port_status != RTE_PORT_STOPPED) {
18303 printf("Error: Can't config offload when Port %d "
18304 "is not stopped\n", port_id);
18308 single_offload = search_rx_offload(res->offload);
18309 if (single_offload == 0) {
18310 printf("Unknown offload name: %s\n", res->offload);
18314 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18318 nb_rx_queues = dev_info.nb_rx_queues;
18319 if (!strcmp(res->on_off, "on")) {
18320 port->dev_conf.rxmode.offloads |= single_offload;
18321 for (q = 0; q < nb_rx_queues; q++)
18322 port->rx_conf[q].offloads |= single_offload;
18324 port->dev_conf.rxmode.offloads &= ~single_offload;
18325 for (q = 0; q < nb_rx_queues; q++)
18326 port->rx_conf[q].offloads &= ~single_offload;
18329 cmd_reconfig_device_queue(port_id, 1, 1);
18332 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18333 .f = cmd_config_per_port_rx_offload_parsed,
18335 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18336 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18337 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18338 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18341 (void *)&cmd_config_per_port_rx_offload_result_port,
18342 (void *)&cmd_config_per_port_rx_offload_result_config,
18343 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18344 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18345 (void *)&cmd_config_per_port_rx_offload_result_offload,
18346 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18351 /* Enable/Disable a per queue offloading */
18352 struct cmd_config_per_queue_rx_offload_result {
18353 cmdline_fixed_string_t port;
18355 cmdline_fixed_string_t rxq;
18357 cmdline_fixed_string_t rx_offload;
18358 cmdline_fixed_string_t offload;
18359 cmdline_fixed_string_t on_off;
18362 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18363 TOKEN_STRING_INITIALIZER
18364 (struct cmd_config_per_queue_rx_offload_result,
18366 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18367 TOKEN_NUM_INITIALIZER
18368 (struct cmd_config_per_queue_rx_offload_result,
18370 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18371 TOKEN_STRING_INITIALIZER
18372 (struct cmd_config_per_queue_rx_offload_result,
18374 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18375 TOKEN_NUM_INITIALIZER
18376 (struct cmd_config_per_queue_rx_offload_result,
18378 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18379 TOKEN_STRING_INITIALIZER
18380 (struct cmd_config_per_queue_rx_offload_result,
18381 rx_offload, "rx_offload");
18382 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18383 TOKEN_STRING_INITIALIZER
18384 (struct cmd_config_per_queue_rx_offload_result,
18385 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18386 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18387 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18388 "scatter#timestamp#security#keep_crc");
18389 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18390 TOKEN_STRING_INITIALIZER
18391 (struct cmd_config_per_queue_rx_offload_result,
18395 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18396 __rte_unused struct cmdline *cl,
18397 __rte_unused void *data)
18399 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18400 struct rte_eth_dev_info dev_info;
18401 portid_t port_id = res->port_id;
18402 uint16_t queue_id = res->queue_id;
18403 struct rte_port *port = &ports[port_id];
18404 uint64_t single_offload;
18407 if (port->port_status != RTE_PORT_STOPPED) {
18408 printf("Error: Can't config offload when Port %d "
18409 "is not stopped\n", port_id);
18413 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18417 if (queue_id >= dev_info.nb_rx_queues) {
18418 printf("Error: input queue_id should be 0 ... "
18419 "%d\n", dev_info.nb_rx_queues - 1);
18423 single_offload = search_rx_offload(res->offload);
18424 if (single_offload == 0) {
18425 printf("Unknown offload name: %s\n", res->offload);
18429 if (!strcmp(res->on_off, "on"))
18430 port->rx_conf[queue_id].offloads |= single_offload;
18432 port->rx_conf[queue_id].offloads &= ~single_offload;
18434 cmd_reconfig_device_queue(port_id, 1, 1);
18437 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18438 .f = cmd_config_per_queue_rx_offload_parsed,
18440 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18441 "vlan_strip|ipv4_cksum|"
18442 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18443 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18444 "jumbo_frame|scatter|timestamp|security|keep_crc "
18447 (void *)&cmd_config_per_queue_rx_offload_result_port,
18448 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18449 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18450 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18451 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18452 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18453 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18458 /* Get Tx offloads capabilities */
18459 struct cmd_tx_offload_get_capa_result {
18460 cmdline_fixed_string_t show;
18461 cmdline_fixed_string_t port;
18463 cmdline_fixed_string_t tx_offload;
18464 cmdline_fixed_string_t capabilities;
18467 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18468 TOKEN_STRING_INITIALIZER
18469 (struct cmd_tx_offload_get_capa_result,
18471 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18472 TOKEN_STRING_INITIALIZER
18473 (struct cmd_tx_offload_get_capa_result,
18475 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18476 TOKEN_NUM_INITIALIZER
18477 (struct cmd_tx_offload_get_capa_result,
18479 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18480 TOKEN_STRING_INITIALIZER
18481 (struct cmd_tx_offload_get_capa_result,
18482 tx_offload, "tx_offload");
18483 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18484 TOKEN_STRING_INITIALIZER
18485 (struct cmd_tx_offload_get_capa_result,
18486 capabilities, "capabilities");
18489 print_tx_offloads(uint64_t offloads)
18491 uint64_t single_offload;
18499 begin = __builtin_ctzll(offloads);
18500 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18502 single_offload = 1ULL << begin;
18503 for (bit = begin; bit < end; bit++) {
18504 if (offloads & single_offload)
18506 rte_eth_dev_tx_offload_name(single_offload));
18507 single_offload <<= 1;
18512 cmd_tx_offload_get_capa_parsed(
18513 void *parsed_result,
18514 __rte_unused struct cmdline *cl,
18515 __rte_unused void *data)
18517 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18518 struct rte_eth_dev_info dev_info;
18519 portid_t port_id = res->port_id;
18520 uint64_t queue_offloads;
18521 uint64_t port_offloads;
18524 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18528 queue_offloads = dev_info.tx_queue_offload_capa;
18529 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18531 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18532 printf(" Per Queue :");
18533 print_tx_offloads(queue_offloads);
18536 printf(" Per Port :");
18537 print_tx_offloads(port_offloads);
18541 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18542 .f = cmd_tx_offload_get_capa_parsed,
18544 .help_str = "show port <port_id> tx_offload capabilities",
18546 (void *)&cmd_tx_offload_get_capa_show,
18547 (void *)&cmd_tx_offload_get_capa_port,
18548 (void *)&cmd_tx_offload_get_capa_port_id,
18549 (void *)&cmd_tx_offload_get_capa_tx_offload,
18550 (void *)&cmd_tx_offload_get_capa_capabilities,
18555 /* Get Tx offloads configuration */
18556 struct cmd_tx_offload_get_configuration_result {
18557 cmdline_fixed_string_t show;
18558 cmdline_fixed_string_t port;
18560 cmdline_fixed_string_t tx_offload;
18561 cmdline_fixed_string_t configuration;
18564 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18565 TOKEN_STRING_INITIALIZER
18566 (struct cmd_tx_offload_get_configuration_result,
18568 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18569 TOKEN_STRING_INITIALIZER
18570 (struct cmd_tx_offload_get_configuration_result,
18572 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18573 TOKEN_NUM_INITIALIZER
18574 (struct cmd_tx_offload_get_configuration_result,
18576 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18577 TOKEN_STRING_INITIALIZER
18578 (struct cmd_tx_offload_get_configuration_result,
18579 tx_offload, "tx_offload");
18580 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18581 TOKEN_STRING_INITIALIZER
18582 (struct cmd_tx_offload_get_configuration_result,
18583 configuration, "configuration");
18586 cmd_tx_offload_get_configuration_parsed(
18587 void *parsed_result,
18588 __rte_unused struct cmdline *cl,
18589 __rte_unused void *data)
18591 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18592 struct rte_eth_dev_info dev_info;
18593 portid_t port_id = res->port_id;
18594 struct rte_port *port = &ports[port_id];
18595 uint64_t port_offloads;
18596 uint64_t queue_offloads;
18597 uint16_t nb_tx_queues;
18601 printf("Tx Offloading Configuration of port %d :\n", port_id);
18603 port_offloads = port->dev_conf.txmode.offloads;
18605 print_tx_offloads(port_offloads);
18608 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18612 nb_tx_queues = dev_info.nb_tx_queues;
18613 for (q = 0; q < nb_tx_queues; q++) {
18614 queue_offloads = port->tx_conf[q].offloads;
18615 printf(" Queue[%2d] :", q);
18616 print_tx_offloads(queue_offloads);
18622 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18623 .f = cmd_tx_offload_get_configuration_parsed,
18625 .help_str = "show port <port_id> tx_offload configuration",
18627 (void *)&cmd_tx_offload_get_configuration_show,
18628 (void *)&cmd_tx_offload_get_configuration_port,
18629 (void *)&cmd_tx_offload_get_configuration_port_id,
18630 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18631 (void *)&cmd_tx_offload_get_configuration_configuration,
18636 /* Enable/Disable a per port offloading */
18637 struct cmd_config_per_port_tx_offload_result {
18638 cmdline_fixed_string_t port;
18639 cmdline_fixed_string_t config;
18641 cmdline_fixed_string_t tx_offload;
18642 cmdline_fixed_string_t offload;
18643 cmdline_fixed_string_t on_off;
18646 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18647 TOKEN_STRING_INITIALIZER
18648 (struct cmd_config_per_port_tx_offload_result,
18650 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18651 TOKEN_STRING_INITIALIZER
18652 (struct cmd_config_per_port_tx_offload_result,
18654 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18655 TOKEN_NUM_INITIALIZER
18656 (struct cmd_config_per_port_tx_offload_result,
18658 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18659 TOKEN_STRING_INITIALIZER
18660 (struct cmd_config_per_port_tx_offload_result,
18661 tx_offload, "tx_offload");
18662 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18663 TOKEN_STRING_INITIALIZER
18664 (struct cmd_config_per_port_tx_offload_result,
18665 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18666 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18667 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18668 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18669 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18670 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18671 TOKEN_STRING_INITIALIZER
18672 (struct cmd_config_per_port_tx_offload_result,
18676 search_tx_offload(const char *name)
18678 uint64_t single_offload;
18679 const char *single_name;
18683 single_offload = 1;
18684 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18685 single_name = rte_eth_dev_tx_offload_name(single_offload);
18686 if (single_name == NULL)
18688 if (!strcasecmp(single_name, name)) {
18691 } else if (!strcasecmp(single_name, "UNKNOWN"))
18693 single_offload <<= 1;
18697 return single_offload;
18703 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18704 __rte_unused struct cmdline *cl,
18705 __rte_unused void *data)
18707 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18708 portid_t port_id = res->port_id;
18709 struct rte_eth_dev_info dev_info;
18710 struct rte_port *port = &ports[port_id];
18711 uint64_t single_offload;
18712 uint16_t nb_tx_queues;
18716 if (port->port_status != RTE_PORT_STOPPED) {
18717 printf("Error: Can't config offload when Port %d "
18718 "is not stopped\n", port_id);
18722 single_offload = search_tx_offload(res->offload);
18723 if (single_offload == 0) {
18724 printf("Unknown offload name: %s\n", res->offload);
18728 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18732 nb_tx_queues = dev_info.nb_tx_queues;
18733 if (!strcmp(res->on_off, "on")) {
18734 port->dev_conf.txmode.offloads |= single_offload;
18735 for (q = 0; q < nb_tx_queues; q++)
18736 port->tx_conf[q].offloads |= single_offload;
18738 port->dev_conf.txmode.offloads &= ~single_offload;
18739 for (q = 0; q < nb_tx_queues; q++)
18740 port->tx_conf[q].offloads &= ~single_offload;
18743 cmd_reconfig_device_queue(port_id, 1, 1);
18746 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18747 .f = cmd_config_per_port_tx_offload_parsed,
18749 .help_str = "port config <port_id> tx_offload "
18750 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18751 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18752 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18753 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18754 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18756 (void *)&cmd_config_per_port_tx_offload_result_port,
18757 (void *)&cmd_config_per_port_tx_offload_result_config,
18758 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18759 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18760 (void *)&cmd_config_per_port_tx_offload_result_offload,
18761 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18766 /* Enable/Disable a per queue offloading */
18767 struct cmd_config_per_queue_tx_offload_result {
18768 cmdline_fixed_string_t port;
18770 cmdline_fixed_string_t txq;
18772 cmdline_fixed_string_t tx_offload;
18773 cmdline_fixed_string_t offload;
18774 cmdline_fixed_string_t on_off;
18777 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18778 TOKEN_STRING_INITIALIZER
18779 (struct cmd_config_per_queue_tx_offload_result,
18781 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18782 TOKEN_NUM_INITIALIZER
18783 (struct cmd_config_per_queue_tx_offload_result,
18785 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18786 TOKEN_STRING_INITIALIZER
18787 (struct cmd_config_per_queue_tx_offload_result,
18789 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18790 TOKEN_NUM_INITIALIZER
18791 (struct cmd_config_per_queue_tx_offload_result,
18793 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18794 TOKEN_STRING_INITIALIZER
18795 (struct cmd_config_per_queue_tx_offload_result,
18796 tx_offload, "tx_offload");
18797 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18798 TOKEN_STRING_INITIALIZER
18799 (struct cmd_config_per_queue_tx_offload_result,
18800 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18801 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18802 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18803 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18804 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18805 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18806 TOKEN_STRING_INITIALIZER
18807 (struct cmd_config_per_queue_tx_offload_result,
18811 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18812 __rte_unused struct cmdline *cl,
18813 __rte_unused void *data)
18815 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18816 struct rte_eth_dev_info dev_info;
18817 portid_t port_id = res->port_id;
18818 uint16_t queue_id = res->queue_id;
18819 struct rte_port *port = &ports[port_id];
18820 uint64_t single_offload;
18823 if (port->port_status != RTE_PORT_STOPPED) {
18824 printf("Error: Can't config offload when Port %d "
18825 "is not stopped\n", port_id);
18829 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18833 if (queue_id >= dev_info.nb_tx_queues) {
18834 printf("Error: input queue_id should be 0 ... "
18835 "%d\n", dev_info.nb_tx_queues - 1);
18839 single_offload = search_tx_offload(res->offload);
18840 if (single_offload == 0) {
18841 printf("Unknown offload name: %s\n", res->offload);
18845 if (!strcmp(res->on_off, "on"))
18846 port->tx_conf[queue_id].offloads |= single_offload;
18848 port->tx_conf[queue_id].offloads &= ~single_offload;
18850 cmd_reconfig_device_queue(port_id, 1, 1);
18853 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18854 .f = cmd_config_per_queue_tx_offload_parsed,
18856 .help_str = "port <port_id> txq <queue_id> tx_offload "
18857 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18858 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18859 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18860 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18861 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18864 (void *)&cmd_config_per_queue_tx_offload_result_port,
18865 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18866 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18867 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18868 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18869 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18870 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18875 /* *** configure tx_metadata for specific port *** */
18876 struct cmd_config_tx_metadata_specific_result {
18877 cmdline_fixed_string_t port;
18878 cmdline_fixed_string_t keyword;
18880 cmdline_fixed_string_t item;
18885 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18886 __rte_unused struct cmdline *cl,
18887 __rte_unused void *data)
18889 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18891 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18893 ports[res->port_id].tx_metadata = res->value;
18894 /* Add/remove callback to insert valid metadata in every Tx packet. */
18895 if (ports[res->port_id].tx_metadata)
18896 add_tx_md_callback(res->port_id);
18898 remove_tx_md_callback(res->port_id);
18899 rte_flow_dynf_metadata_register();
18902 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18903 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18905 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18906 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18907 keyword, "config");
18908 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18909 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18911 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18912 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18913 item, "tx_metadata");
18914 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18915 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18918 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18919 .f = cmd_config_tx_metadata_specific_parsed,
18921 .help_str = "port config <port_id> tx_metadata <value>",
18923 (void *)&cmd_config_tx_metadata_specific_port,
18924 (void *)&cmd_config_tx_metadata_specific_keyword,
18925 (void *)&cmd_config_tx_metadata_specific_id,
18926 (void *)&cmd_config_tx_metadata_specific_item,
18927 (void *)&cmd_config_tx_metadata_specific_value,
18932 /* *** set dynf *** */
18933 struct cmd_config_tx_dynf_specific_result {
18934 cmdline_fixed_string_t port;
18935 cmdline_fixed_string_t keyword;
18937 cmdline_fixed_string_t item;
18938 cmdline_fixed_string_t name;
18939 cmdline_fixed_string_t value;
18943 cmd_config_dynf_specific_parsed(void *parsed_result,
18944 __rte_unused struct cmdline *cl,
18945 __rte_unused void *data)
18947 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18948 struct rte_mbuf_dynflag desc_flag;
18950 uint64_t old_port_flags;
18952 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18954 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18956 if (strlcpy(desc_flag.name, res->name,
18957 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18958 printf("Flag name too long\n");
18961 desc_flag.flags = 0;
18962 flag = rte_mbuf_dynflag_register(&desc_flag);
18964 printf("Can't register flag\n");
18967 strcpy(dynf_names[flag], desc_flag.name);
18969 old_port_flags = ports[res->port_id].mbuf_dynf;
18970 if (!strcmp(res->value, "set")) {
18971 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18972 if (old_port_flags == 0)
18973 add_tx_dynf_callback(res->port_id);
18975 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18976 if (ports[res->port_id].mbuf_dynf == 0)
18977 remove_tx_dynf_callback(res->port_id);
18981 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18982 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18984 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18985 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18986 keyword, "config");
18987 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18988 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18990 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18991 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18993 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18994 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18996 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18997 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18998 value, "set#clear");
19000 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19001 .f = cmd_config_dynf_specific_parsed,
19003 .help_str = "port config <port id> dynf <name> set|clear",
19005 (void *)&cmd_config_tx_dynf_specific_port,
19006 (void *)&cmd_config_tx_dynf_specific_keyword,
19007 (void *)&cmd_config_tx_dynf_specific_port_id,
19008 (void *)&cmd_config_tx_dynf_specific_item,
19009 (void *)&cmd_config_tx_dynf_specific_name,
19010 (void *)&cmd_config_tx_dynf_specific_value,
19015 /* *** display tx_metadata per port configuration *** */
19016 struct cmd_show_tx_metadata_result {
19017 cmdline_fixed_string_t cmd_show;
19018 cmdline_fixed_string_t cmd_port;
19019 cmdline_fixed_string_t cmd_keyword;
19024 cmd_show_tx_metadata_parsed(void *parsed_result,
19025 __rte_unused struct cmdline *cl,
19026 __rte_unused void *data)
19028 struct cmd_show_tx_metadata_result *res = parsed_result;
19030 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19031 printf("invalid port id %u\n", res->cmd_pid);
19034 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19035 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19036 ports[res->cmd_pid].tx_metadata);
19040 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19041 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19043 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19044 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19046 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19047 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19049 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19050 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19051 cmd_keyword, "tx_metadata");
19053 cmdline_parse_inst_t cmd_show_tx_metadata = {
19054 .f = cmd_show_tx_metadata_parsed,
19056 .help_str = "show port <port_id> tx_metadata",
19058 (void *)&cmd_show_tx_metadata_show,
19059 (void *)&cmd_show_tx_metadata_port,
19060 (void *)&cmd_show_tx_metadata_pid,
19061 (void *)&cmd_show_tx_metadata_keyword,
19066 /* show port supported ptypes */
19068 /* Common result structure for show port ptypes */
19069 struct cmd_show_port_supported_ptypes_result {
19070 cmdline_fixed_string_t show;
19071 cmdline_fixed_string_t port;
19073 cmdline_fixed_string_t ptypes;
19076 /* Common CLI fields for show port ptypes */
19077 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19078 TOKEN_STRING_INITIALIZER
19079 (struct cmd_show_port_supported_ptypes_result,
19081 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19082 TOKEN_STRING_INITIALIZER
19083 (struct cmd_show_port_supported_ptypes_result,
19085 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19086 TOKEN_NUM_INITIALIZER
19087 (struct cmd_show_port_supported_ptypes_result,
19089 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19090 TOKEN_STRING_INITIALIZER
19091 (struct cmd_show_port_supported_ptypes_result,
19095 cmd_show_port_supported_ptypes_parsed(
19096 void *parsed_result,
19097 __rte_unused struct cmdline *cl,
19098 __rte_unused void *data)
19100 #define RSVD_PTYPE_MASK 0xf0000000
19101 #define MAX_PTYPES_PER_LAYER 16
19102 #define LTYPE_NAMESIZE 32
19103 #define PTYPE_NAMESIZE 256
19104 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19105 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19106 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19107 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19108 uint16_t port_id = res->port_id;
19111 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19115 while (ptype_mask != RSVD_PTYPE_MASK) {
19117 switch (ptype_mask) {
19118 case RTE_PTYPE_L2_MASK:
19119 strlcpy(ltype, "L2", sizeof(ltype));
19121 case RTE_PTYPE_L3_MASK:
19122 strlcpy(ltype, "L3", sizeof(ltype));
19124 case RTE_PTYPE_L4_MASK:
19125 strlcpy(ltype, "L4", sizeof(ltype));
19127 case RTE_PTYPE_TUNNEL_MASK:
19128 strlcpy(ltype, "Tunnel", sizeof(ltype));
19130 case RTE_PTYPE_INNER_L2_MASK:
19131 strlcpy(ltype, "Inner L2", sizeof(ltype));
19133 case RTE_PTYPE_INNER_L3_MASK:
19134 strlcpy(ltype, "Inner L3", sizeof(ltype));
19136 case RTE_PTYPE_INNER_L4_MASK:
19137 strlcpy(ltype, "Inner L4", sizeof(ltype));
19143 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19144 ptype_mask, ptypes,
19145 MAX_PTYPES_PER_LAYER);
19148 printf("Supported %s ptypes:\n", ltype);
19150 printf("%s ptypes unsupported\n", ltype);
19152 for (i = 0; i < ret; ++i) {
19153 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19154 printf("%s\n", buf);
19161 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19162 .f = cmd_show_port_supported_ptypes_parsed,
19164 .help_str = "show port <port_id> ptypes",
19166 (void *)&cmd_show_port_supported_ptypes_show,
19167 (void *)&cmd_show_port_supported_ptypes_port,
19168 (void *)&cmd_show_port_supported_ptypes_port_id,
19169 (void *)&cmd_show_port_supported_ptypes_ptypes,
19174 /* *** display rx/tx descriptor status *** */
19175 struct cmd_show_rx_tx_desc_status_result {
19176 cmdline_fixed_string_t cmd_show;
19177 cmdline_fixed_string_t cmd_port;
19178 cmdline_fixed_string_t cmd_keyword;
19179 cmdline_fixed_string_t cmd_desc;
19180 cmdline_fixed_string_t cmd_status;
19187 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19188 __rte_unused struct cmdline *cl,
19189 __rte_unused void *data)
19191 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19194 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19195 printf("invalid port id %u\n", res->cmd_pid);
19199 if (!strcmp(res->cmd_keyword, "rxq")) {
19200 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19203 printf("Invalid queueid = %d\n", res->cmd_qid);
19206 if (rc == RTE_ETH_RX_DESC_AVAIL)
19207 printf("Desc status = AVAILABLE\n");
19208 else if (rc == RTE_ETH_RX_DESC_DONE)
19209 printf("Desc status = DONE\n");
19211 printf("Desc status = UNAVAILABLE\n");
19212 } else if (!strcmp(res->cmd_keyword, "txq")) {
19213 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19216 printf("Invalid queueid = %d\n", res->cmd_qid);
19219 if (rc == RTE_ETH_TX_DESC_FULL)
19220 printf("Desc status = FULL\n");
19221 else if (rc == RTE_ETH_TX_DESC_DONE)
19222 printf("Desc status = DONE\n");
19224 printf("Desc status = UNAVAILABLE\n");
19228 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19229 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19231 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19232 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19234 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19235 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19237 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19238 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19239 cmd_keyword, "rxq#txq");
19240 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19241 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19243 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19244 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19246 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19247 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19249 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19250 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19251 cmd_status, "status");
19252 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19253 .f = cmd_show_rx_tx_desc_status_parsed,
19255 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19258 (void *)&cmd_show_rx_tx_desc_status_show,
19259 (void *)&cmd_show_rx_tx_desc_status_port,
19260 (void *)&cmd_show_rx_tx_desc_status_pid,
19261 (void *)&cmd_show_rx_tx_desc_status_keyword,
19262 (void *)&cmd_show_rx_tx_desc_status_qid,
19263 (void *)&cmd_show_rx_tx_desc_status_desc,
19264 (void *)&cmd_show_rx_tx_desc_status_did,
19265 (void *)&cmd_show_rx_tx_desc_status_status,
19270 /* Common result structure for set port ptypes */
19271 struct cmd_set_port_ptypes_result {
19272 cmdline_fixed_string_t set;
19273 cmdline_fixed_string_t port;
19275 cmdline_fixed_string_t ptype_mask;
19279 /* Common CLI fields for set port ptypes */
19280 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19281 TOKEN_STRING_INITIALIZER
19282 (struct cmd_set_port_ptypes_result,
19284 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19285 TOKEN_STRING_INITIALIZER
19286 (struct cmd_set_port_ptypes_result,
19288 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19289 TOKEN_NUM_INITIALIZER
19290 (struct cmd_set_port_ptypes_result,
19292 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19293 TOKEN_STRING_INITIALIZER
19294 (struct cmd_set_port_ptypes_result,
19295 ptype_mask, "ptype_mask");
19296 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19297 TOKEN_NUM_INITIALIZER
19298 (struct cmd_set_port_ptypes_result,
19302 cmd_set_port_ptypes_parsed(
19303 void *parsed_result,
19304 __rte_unused struct cmdline *cl,
19305 __rte_unused void *data)
19307 struct cmd_set_port_ptypes_result *res = parsed_result;
19308 #define PTYPE_NAMESIZE 256
19309 char ptype_name[PTYPE_NAMESIZE];
19310 uint16_t port_id = res->port_id;
19311 uint32_t ptype_mask = res->mask;
19314 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19317 printf("Port %d doesn't support any ptypes.\n", port_id);
19321 uint32_t ptypes[ret];
19323 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19325 printf("Unable to set requested ptypes for Port %d\n", port_id);
19329 printf("Successfully set following ptypes for Port %d\n", port_id);
19330 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19331 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19332 printf("%s\n", ptype_name);
19335 clear_ptypes = false;
19338 cmdline_parse_inst_t cmd_set_port_ptypes = {
19339 .f = cmd_set_port_ptypes_parsed,
19341 .help_str = "set port <port_id> ptype_mask <mask>",
19343 (void *)&cmd_set_port_ptypes_set,
19344 (void *)&cmd_set_port_ptypes_port,
19345 (void *)&cmd_set_port_ptypes_port_id,
19346 (void *)&cmd_set_port_ptypes_mask_str,
19347 (void *)&cmd_set_port_ptypes_mask_u32,
19352 /* *** display mac addresses added to a port *** */
19353 struct cmd_showport_macs_result {
19354 cmdline_fixed_string_t cmd_show;
19355 cmdline_fixed_string_t cmd_port;
19356 cmdline_fixed_string_t cmd_keyword;
19361 cmd_showport_macs_parsed(void *parsed_result,
19362 __rte_unused struct cmdline *cl,
19363 __rte_unused void *data)
19365 struct cmd_showport_macs_result *res = parsed_result;
19367 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19370 if (!strcmp(res->cmd_keyword, "macs"))
19371 show_macs(res->cmd_pid);
19372 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19373 show_mcast_macs(res->cmd_pid);
19376 cmdline_parse_token_string_t cmd_showport_macs_show =
19377 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19379 cmdline_parse_token_string_t cmd_showport_macs_port =
19380 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19382 cmdline_parse_token_num_t cmd_showport_macs_pid =
19383 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19385 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19386 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19387 cmd_keyword, "macs#mcast_macs");
19389 cmdline_parse_inst_t cmd_showport_macs = {
19390 .f = cmd_showport_macs_parsed,
19392 .help_str = "show port <port_id> macs|mcast_macs",
19394 (void *)&cmd_showport_macs_show,
19395 (void *)&cmd_showport_macs_port,
19396 (void *)&cmd_showport_macs_pid,
19397 (void *)&cmd_showport_macs_keyword,
19402 /* ******************************************************************************** */
19404 /* list of instructions */
19405 cmdline_parse_ctx_t main_ctx[] = {
19406 (cmdline_parse_inst_t *)&cmd_help_brief,
19407 (cmdline_parse_inst_t *)&cmd_help_long,
19408 (cmdline_parse_inst_t *)&cmd_quit,
19409 (cmdline_parse_inst_t *)&cmd_load_from_file,
19410 (cmdline_parse_inst_t *)&cmd_showport,
19411 (cmdline_parse_inst_t *)&cmd_showqueue,
19412 (cmdline_parse_inst_t *)&cmd_showportall,
19413 (cmdline_parse_inst_t *)&cmd_showdevice,
19414 (cmdline_parse_inst_t *)&cmd_showcfg,
19415 (cmdline_parse_inst_t *)&cmd_showfwdall,
19416 (cmdline_parse_inst_t *)&cmd_start,
19417 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19418 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19419 (cmdline_parse_inst_t *)&cmd_set_link_up,
19420 (cmdline_parse_inst_t *)&cmd_set_link_down,
19421 (cmdline_parse_inst_t *)&cmd_reset,
19422 (cmdline_parse_inst_t *)&cmd_set_numbers,
19423 (cmdline_parse_inst_t *)&cmd_set_log,
19424 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19425 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19426 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19427 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19428 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19429 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19430 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19431 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19432 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19433 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19434 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19435 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19436 (cmdline_parse_inst_t *)&cmd_set_link_check,
19437 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19438 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19439 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19440 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19441 #ifdef RTE_LIBRTE_PMD_BOND
19442 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19443 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19444 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19445 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19446 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19447 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19448 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19449 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19450 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19451 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19452 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19454 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19455 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19456 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19457 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19458 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19459 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19460 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19461 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19462 (cmdline_parse_inst_t *)&cmd_csum_set,
19463 (cmdline_parse_inst_t *)&cmd_csum_show,
19464 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19465 (cmdline_parse_inst_t *)&cmd_tso_set,
19466 (cmdline_parse_inst_t *)&cmd_tso_show,
19467 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19468 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19469 (cmdline_parse_inst_t *)&cmd_gro_enable,
19470 (cmdline_parse_inst_t *)&cmd_gro_flush,
19471 (cmdline_parse_inst_t *)&cmd_gro_show,
19472 (cmdline_parse_inst_t *)&cmd_gso_enable,
19473 (cmdline_parse_inst_t *)&cmd_gso_size,
19474 (cmdline_parse_inst_t *)&cmd_gso_show,
19475 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19476 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19477 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19478 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19479 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19480 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19481 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19482 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19483 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19484 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19485 (cmdline_parse_inst_t *)&cmd_config_dcb,
19486 (cmdline_parse_inst_t *)&cmd_read_reg,
19487 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19488 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19489 (cmdline_parse_inst_t *)&cmd_write_reg,
19490 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19491 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19492 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19493 (cmdline_parse_inst_t *)&cmd_stop,
19494 (cmdline_parse_inst_t *)&cmd_mac_addr,
19495 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19496 (cmdline_parse_inst_t *)&cmd_set_qmap,
19497 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19498 (cmdline_parse_inst_t *)&cmd_operate_port,
19499 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19500 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19501 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19502 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19503 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19504 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19505 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19506 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19507 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19508 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19509 (cmdline_parse_inst_t *)&cmd_config_mtu,
19510 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19511 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19512 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19513 (cmdline_parse_inst_t *)&cmd_config_rss,
19514 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19515 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19516 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19517 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19518 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19519 (cmdline_parse_inst_t *)&cmd_showport_reta,
19520 (cmdline_parse_inst_t *)&cmd_showport_macs,
19521 (cmdline_parse_inst_t *)&cmd_config_burst,
19522 (cmdline_parse_inst_t *)&cmd_config_thresh,
19523 (cmdline_parse_inst_t *)&cmd_config_threshold,
19524 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19525 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19526 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19527 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19528 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19529 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19530 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19531 (cmdline_parse_inst_t *)&cmd_global_config,
19532 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19533 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19534 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19535 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19536 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19537 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19538 (cmdline_parse_inst_t *)&cmd_dump,
19539 (cmdline_parse_inst_t *)&cmd_dump_one,
19540 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19541 (cmdline_parse_inst_t *)&cmd_syn_filter,
19542 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19543 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19544 (cmdline_parse_inst_t *)&cmd_flex_filter,
19545 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19546 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19547 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19548 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19549 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19550 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19551 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19552 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19553 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19554 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19555 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19556 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19557 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19558 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19559 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19560 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19561 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19562 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19563 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19564 (cmdline_parse_inst_t *)&cmd_flow,
19565 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19566 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19567 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19568 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19569 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19570 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19571 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19572 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19573 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19574 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19575 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19576 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19577 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19578 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19579 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19580 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19581 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19582 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19583 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19584 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19585 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19586 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19587 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19588 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19589 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19590 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19591 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19592 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19593 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19594 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19595 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19596 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19597 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19598 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19599 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19600 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19601 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19602 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19603 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19604 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19605 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19606 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19607 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19608 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19609 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19610 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19611 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19612 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19613 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19614 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19615 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19617 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19618 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19619 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19620 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19621 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19622 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19623 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19624 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19625 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19626 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19627 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19628 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19629 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19630 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19631 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19632 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19633 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19634 (cmdline_parse_inst_t *)&cmd_ddp_add,
19635 (cmdline_parse_inst_t *)&cmd_ddp_del,
19636 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19637 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19638 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19639 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19640 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19641 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19642 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19643 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19644 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19645 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19646 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19647 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19649 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19650 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19651 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19652 (cmdline_parse_inst_t *)&cmd_queue_region,
19653 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19654 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19655 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19656 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19657 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19658 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19659 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19660 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19661 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19662 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19663 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19664 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19665 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19666 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19667 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19668 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19669 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19670 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19671 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19672 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19673 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19674 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19675 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19676 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19677 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19678 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19679 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19680 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19681 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19682 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19683 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19684 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19685 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19686 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19687 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19688 #ifdef RTE_LIBRTE_BPF
19689 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19690 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19692 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19693 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19694 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19695 (cmdline_parse_inst_t *)&cmd_set_raw,
19696 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19697 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19698 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19702 /* read cmdline commands from file */
19704 cmdline_read_from_file(const char *filename)
19706 struct cmdline *cl;
19708 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19710 printf("Failed to create file based cmdline context: %s\n",
19715 cmdline_interact(cl);
19720 printf("Read CLI commands from %s\n", filename);
19723 /* prompt function, called from main on MASTER lcore */
19727 /* initialize non-constant commands */
19728 cmd_set_fwd_mode_init();
19729 cmd_set_fwd_retry_mode_init();
19731 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19732 if (testpmd_cl == NULL)
19734 cmdline_interact(testpmd_cl);
19735 cmdline_stdin_exit(testpmd_cl);
19741 if (testpmd_cl != NULL)
19742 cmdline_quit(testpmd_cl);
19746 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19748 if (id == (portid_t)RTE_PORT_ALL) {
19751 RTE_ETH_FOREACH_DEV(pid) {
19752 /* check if need_reconfig has been set to 1 */
19753 if (ports[pid].need_reconfig == 0)
19754 ports[pid].need_reconfig = dev;
19755 /* check if need_reconfig_queues has been set to 1 */
19756 if (ports[pid].need_reconfig_queues == 0)
19757 ports[pid].need_reconfig_queues = queue;
19759 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19760 /* check if need_reconfig has been set to 1 */
19761 if (ports[id].need_reconfig == 0)
19762 ports[id].need_reconfig = dev;
19763 /* check if need_reconfig_queues has been set to 1 */
19764 if (ports[id].need_reconfig_queues == 0)
19765 ports[id].need_reconfig_queues = queue;