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-pre32"))
2301 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2302 else if (!strcmp(res->value, "l3-pre40"))
2303 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2304 else if (!strcmp(res->value, "l3-pre48"))
2305 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2306 else if (!strcmp(res->value, "l3-pre56"))
2307 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2308 else if (!strcmp(res->value, "l3-pre64"))
2309 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2310 else if (!strcmp(res->value, "l3-pre96"))
2311 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2312 else if (!strcmp(res->value, "l3-src-only"))
2313 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2314 else if (!strcmp(res->value, "l3-dst-only"))
2315 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2316 else if (!strcmp(res->value, "l4-src-only"))
2317 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2318 else if (!strcmp(res->value, "l4-dst-only"))
2319 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2320 else if (!strcmp(res->value, "l2-src-only"))
2321 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2322 else if (!strcmp(res->value, "l2-dst-only"))
2323 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2324 else if (!strcmp(res->value, "l2tpv3"))
2325 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2326 else if (!strcmp(res->value, "esp"))
2327 rss_conf.rss_hf = ETH_RSS_ESP;
2328 else if (!strcmp(res->value, "ah"))
2329 rss_conf.rss_hf = ETH_RSS_AH;
2330 else if (!strcmp(res->value, "pfcp"))
2331 rss_conf.rss_hf = ETH_RSS_PFCP;
2332 else if (!strcmp(res->value, "pppoe"))
2333 rss_conf.rss_hf = ETH_RSS_PPPOE;
2334 else if (!strcmp(res->value, "gtpu"))
2335 rss_conf.rss_hf = ETH_RSS_GTPU;
2336 else if (!strcmp(res->value, "none"))
2337 rss_conf.rss_hf = 0;
2338 else if (!strcmp(res->value, "default"))
2340 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2341 atoi(res->value) < 64)
2342 rss_conf.rss_hf = 1ULL << atoi(res->value);
2344 printf("Unknown parameter\n");
2347 rss_conf.rss_key = NULL;
2348 /* Update global configuration for RSS types. */
2349 RTE_ETH_FOREACH_DEV(i) {
2350 struct rte_eth_rss_conf local_rss_conf;
2352 ret = eth_dev_info_get_print_err(i, &dev_info);
2357 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2359 local_rss_conf = rss_conf;
2360 local_rss_conf.rss_hf = rss_conf.rss_hf &
2361 dev_info.flow_type_rss_offloads;
2362 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2363 printf("Port %u modified RSS hash function based on hardware support,"
2364 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2365 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2367 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2370 printf("Configuration of RSS hash at ethernet port %d "
2371 "failed with error (%d): %s.\n",
2372 i, -diag, strerror(-diag));
2375 if (all_updated && !use_default) {
2376 rss_hf = rss_conf.rss_hf;
2377 printf("rss_hf %#"PRIx64"\n", rss_hf);
2381 cmdline_parse_token_string_t cmd_config_rss_port =
2382 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2383 cmdline_parse_token_string_t cmd_config_rss_keyword =
2384 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2385 cmdline_parse_token_string_t cmd_config_rss_all =
2386 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2387 cmdline_parse_token_string_t cmd_config_rss_name =
2388 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2389 cmdline_parse_token_string_t cmd_config_rss_value =
2390 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2392 cmdline_parse_inst_t cmd_config_rss = {
2393 .f = cmd_config_rss_parsed,
2395 .help_str = "port config all rss "
2396 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2397 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|<flowtype_id>",
2399 (void *)&cmd_config_rss_port,
2400 (void *)&cmd_config_rss_keyword,
2401 (void *)&cmd_config_rss_all,
2402 (void *)&cmd_config_rss_name,
2403 (void *)&cmd_config_rss_value,
2408 /* *** configure rss hash key *** */
2409 struct cmd_config_rss_hash_key {
2410 cmdline_fixed_string_t port;
2411 cmdline_fixed_string_t config;
2413 cmdline_fixed_string_t rss_hash_key;
2414 cmdline_fixed_string_t rss_type;
2415 cmdline_fixed_string_t key;
2419 hexa_digit_to_value(char hexa_digit)
2421 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2422 return (uint8_t) (hexa_digit - '0');
2423 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2424 return (uint8_t) ((hexa_digit - 'a') + 10);
2425 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2426 return (uint8_t) ((hexa_digit - 'A') + 10);
2427 /* Invalid hexa digit */
2432 parse_and_check_key_hexa_digit(char *key, int idx)
2436 hexa_v = hexa_digit_to_value(key[idx]);
2438 printf("invalid key: character %c at position %d is not a "
2439 "valid hexa digit\n", key[idx], idx);
2444 cmd_config_rss_hash_key_parsed(void *parsed_result,
2445 __rte_unused struct cmdline *cl,
2446 __rte_unused void *data)
2448 struct cmd_config_rss_hash_key *res = parsed_result;
2449 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2453 struct rte_eth_dev_info dev_info;
2454 uint8_t hash_key_size;
2458 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2462 if (dev_info.hash_key_size > 0 &&
2463 dev_info.hash_key_size <= sizeof(hash_key))
2464 hash_key_size = dev_info.hash_key_size;
2466 printf("dev_info did not provide a valid hash key size\n");
2469 /* Check the length of the RSS hash key */
2470 key_len = strlen(res->key);
2471 if (key_len != (hash_key_size * 2)) {
2472 printf("key length: %d invalid - key must be a string of %d"
2473 " hexa-decimal numbers\n",
2474 (int) key_len, hash_key_size * 2);
2477 /* Translate RSS hash key into binary representation */
2478 for (i = 0; i < hash_key_size; i++) {
2479 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2482 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2485 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2487 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2491 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2492 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2493 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2494 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2496 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2497 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2498 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2499 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2500 rss_hash_key, "rss-hash-key");
2501 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2502 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2503 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2504 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2505 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2506 "ipv6-tcp-ex#ipv6-udp-ex#"
2507 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2508 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2509 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2510 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2511 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2513 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2514 .f = cmd_config_rss_hash_key_parsed,
2516 .help_str = "port config <port_id> rss-hash-key "
2517 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2518 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2519 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2520 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2521 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2522 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2523 "<string of hex digits (variable length, NIC dependent)>",
2525 (void *)&cmd_config_rss_hash_key_port,
2526 (void *)&cmd_config_rss_hash_key_config,
2527 (void *)&cmd_config_rss_hash_key_port_id,
2528 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2529 (void *)&cmd_config_rss_hash_key_rss_type,
2530 (void *)&cmd_config_rss_hash_key_value,
2535 /* *** configure port rxq/txq ring size *** */
2536 struct cmd_config_rxtx_ring_size {
2537 cmdline_fixed_string_t port;
2538 cmdline_fixed_string_t config;
2540 cmdline_fixed_string_t rxtxq;
2542 cmdline_fixed_string_t rsize;
2547 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2548 __rte_unused struct cmdline *cl,
2549 __rte_unused void *data)
2551 struct cmd_config_rxtx_ring_size *res = parsed_result;
2552 struct rte_port *port;
2555 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2558 if (res->portid == (portid_t)RTE_PORT_ALL) {
2559 printf("Invalid port id\n");
2563 port = &ports[res->portid];
2565 if (!strcmp(res->rxtxq, "rxq"))
2567 else if (!strcmp(res->rxtxq, "txq"))
2570 printf("Unknown parameter\n");
2574 if (isrx && rx_queue_id_is_invalid(res->qid))
2576 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2579 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2580 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2586 port->nb_rx_desc[res->qid] = res->size;
2588 port->nb_tx_desc[res->qid] = res->size;
2590 cmd_reconfig_device_queue(res->portid, 0, 1);
2593 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2594 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2596 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2597 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2599 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2600 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2602 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2603 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2605 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2606 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2608 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2609 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2610 rsize, "ring_size");
2611 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2612 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2615 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2616 .f = cmd_config_rxtx_ring_size_parsed,
2618 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2620 (void *)&cmd_config_rxtx_ring_size_port,
2621 (void *)&cmd_config_rxtx_ring_size_config,
2622 (void *)&cmd_config_rxtx_ring_size_portid,
2623 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2624 (void *)&cmd_config_rxtx_ring_size_qid,
2625 (void *)&cmd_config_rxtx_ring_size_rsize,
2626 (void *)&cmd_config_rxtx_ring_size_size,
2631 /* *** configure port rxq/txq start/stop *** */
2632 struct cmd_config_rxtx_queue {
2633 cmdline_fixed_string_t port;
2635 cmdline_fixed_string_t rxtxq;
2637 cmdline_fixed_string_t opname;
2641 cmd_config_rxtx_queue_parsed(void *parsed_result,
2642 __rte_unused struct cmdline *cl,
2643 __rte_unused void *data)
2645 struct cmd_config_rxtx_queue *res = parsed_result;
2650 if (test_done == 0) {
2651 printf("Please stop forwarding first\n");
2655 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2658 if (port_is_started(res->portid) != 1) {
2659 printf("Please start port %u first\n", res->portid);
2663 if (!strcmp(res->rxtxq, "rxq"))
2665 else if (!strcmp(res->rxtxq, "txq"))
2668 printf("Unknown parameter\n");
2672 if (isrx && rx_queue_id_is_invalid(res->qid))
2674 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2677 if (!strcmp(res->opname, "start"))
2679 else if (!strcmp(res->opname, "stop"))
2682 printf("Unknown parameter\n");
2686 if (isstart && isrx)
2687 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2688 else if (!isstart && isrx)
2689 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2690 else if (isstart && !isrx)
2691 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2693 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2695 if (ret == -ENOTSUP)
2696 printf("Function not supported in PMD driver\n");
2699 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2700 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2701 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2702 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2703 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2704 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2705 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2706 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2707 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2708 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2711 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2712 .f = cmd_config_rxtx_queue_parsed,
2714 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2716 (void *)&cmd_config_rxtx_queue_port,
2717 (void *)&cmd_config_rxtx_queue_portid,
2718 (void *)&cmd_config_rxtx_queue_rxtxq,
2719 (void *)&cmd_config_rxtx_queue_qid,
2720 (void *)&cmd_config_rxtx_queue_opname,
2725 /* *** configure port rxq/txq deferred start on/off *** */
2726 struct cmd_config_deferred_start_rxtx_queue {
2727 cmdline_fixed_string_t port;
2729 cmdline_fixed_string_t rxtxq;
2731 cmdline_fixed_string_t opname;
2732 cmdline_fixed_string_t state;
2736 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2737 __rte_unused struct cmdline *cl,
2738 __rte_unused void *data)
2740 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2741 struct rte_port *port;
2744 uint8_t needreconfig = 0;
2746 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2749 if (port_is_started(res->port_id) != 0) {
2750 printf("Please stop port %u first\n", res->port_id);
2754 port = &ports[res->port_id];
2756 isrx = !strcmp(res->rxtxq, "rxq");
2758 if (isrx && rx_queue_id_is_invalid(res->qid))
2760 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2763 ison = !strcmp(res->state, "on");
2765 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2766 port->rx_conf[res->qid].rx_deferred_start = ison;
2768 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2769 port->tx_conf[res->qid].tx_deferred_start = ison;
2774 cmd_reconfig_device_queue(res->port_id, 0, 1);
2777 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2778 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2780 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2781 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2783 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2784 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2786 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2787 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2789 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2790 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2791 opname, "deferred_start");
2792 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2793 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2796 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2797 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2799 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2801 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2802 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2803 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2804 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2805 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2806 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2811 /* *** configure port rxq/txq setup *** */
2812 struct cmd_setup_rxtx_queue {
2813 cmdline_fixed_string_t port;
2815 cmdline_fixed_string_t rxtxq;
2817 cmdline_fixed_string_t setup;
2820 /* Common CLI fields for queue setup */
2821 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2822 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2823 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2824 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2825 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2826 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2827 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2828 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2829 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2830 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2833 cmd_setup_rxtx_queue_parsed(
2834 void *parsed_result,
2835 __rte_unused struct cmdline *cl,
2836 __rte_unused void *data)
2838 struct cmd_setup_rxtx_queue *res = parsed_result;
2839 struct rte_port *port;
2840 struct rte_mempool *mp;
2841 unsigned int socket_id;
2845 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2848 if (res->portid == (portid_t)RTE_PORT_ALL) {
2849 printf("Invalid port id\n");
2853 if (!strcmp(res->rxtxq, "rxq"))
2855 else if (!strcmp(res->rxtxq, "txq"))
2858 printf("Unknown parameter\n");
2862 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2863 printf("Invalid rx queue\n");
2865 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2866 printf("Invalid tx queue\n");
2870 port = &ports[res->portid];
2872 socket_id = rxring_numa[res->portid];
2873 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2874 socket_id = port->socket_id;
2876 mp = mbuf_pool_find(socket_id);
2878 printf("Failed to setup RX queue: "
2879 "No mempool allocation"
2880 " on the socket %d\n",
2881 rxring_numa[res->portid]);
2884 ret = rte_eth_rx_queue_setup(res->portid,
2886 port->nb_rx_desc[res->qid],
2888 &port->rx_conf[res->qid],
2891 printf("Failed to setup RX queue\n");
2893 socket_id = txring_numa[res->portid];
2894 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2895 socket_id = port->socket_id;
2897 ret = rte_eth_tx_queue_setup(res->portid,
2899 port->nb_tx_desc[res->qid],
2901 &port->tx_conf[res->qid]);
2903 printf("Failed to setup TX queue\n");
2907 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2908 .f = cmd_setup_rxtx_queue_parsed,
2910 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2912 (void *)&cmd_setup_rxtx_queue_port,
2913 (void *)&cmd_setup_rxtx_queue_portid,
2914 (void *)&cmd_setup_rxtx_queue_rxtxq,
2915 (void *)&cmd_setup_rxtx_queue_qid,
2916 (void *)&cmd_setup_rxtx_queue_setup,
2922 /* *** Configure RSS RETA *** */
2923 struct cmd_config_rss_reta {
2924 cmdline_fixed_string_t port;
2925 cmdline_fixed_string_t keyword;
2927 cmdline_fixed_string_t name;
2928 cmdline_fixed_string_t list_name;
2929 cmdline_fixed_string_t list_of_items;
2933 parse_reta_config(const char *str,
2934 struct rte_eth_rss_reta_entry64 *reta_conf,
2935 uint16_t nb_entries)
2939 uint16_t hash_index, idx, shift;
2942 const char *p, *p0 = str;
2949 unsigned long int_fld[_NUM_FLD];
2950 char *str_fld[_NUM_FLD];
2952 while ((p = strchr(p0,'(')) != NULL) {
2954 if((p0 = strchr(p,')')) == NULL)
2958 if(size >= sizeof(s))
2961 snprintf(s, sizeof(s), "%.*s", size, p);
2962 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2964 for (i = 0; i < _NUM_FLD; i++) {
2966 int_fld[i] = strtoul(str_fld[i], &end, 0);
2967 if (errno != 0 || end == str_fld[i] ||
2972 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2973 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2975 if (hash_index >= nb_entries) {
2976 printf("Invalid RETA hash index=%d\n", hash_index);
2980 idx = hash_index / RTE_RETA_GROUP_SIZE;
2981 shift = hash_index % RTE_RETA_GROUP_SIZE;
2982 reta_conf[idx].mask |= (1ULL << shift);
2983 reta_conf[idx].reta[shift] = nb_queue;
2990 cmd_set_rss_reta_parsed(void *parsed_result,
2991 __rte_unused struct cmdline *cl,
2992 __rte_unused void *data)
2995 struct rte_eth_dev_info dev_info;
2996 struct rte_eth_rss_reta_entry64 reta_conf[8];
2997 struct cmd_config_rss_reta *res = parsed_result;
2999 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3003 if (dev_info.reta_size == 0) {
3004 printf("Redirection table size is 0 which is "
3005 "invalid for RSS\n");
3008 printf("The reta size of port %d is %u\n",
3009 res->port_id, dev_info.reta_size);
3010 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3011 printf("Currently do not support more than %u entries of "
3012 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3016 memset(reta_conf, 0, sizeof(reta_conf));
3017 if (!strcmp(res->list_name, "reta")) {
3018 if (parse_reta_config(res->list_of_items, reta_conf,
3019 dev_info.reta_size)) {
3020 printf("Invalid RSS Redirection Table "
3021 "config entered\n");
3024 ret = rte_eth_dev_rss_reta_update(res->port_id,
3025 reta_conf, dev_info.reta_size);
3027 printf("Bad redirection table parameter, "
3028 "return code = %d \n", ret);
3032 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3033 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3034 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3035 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3036 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3037 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3038 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3039 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3040 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3041 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3042 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3043 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3045 cmdline_parse_inst_t cmd_config_rss_reta = {
3046 .f = cmd_set_rss_reta_parsed,
3048 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3050 (void *)&cmd_config_rss_reta_port,
3051 (void *)&cmd_config_rss_reta_keyword,
3052 (void *)&cmd_config_rss_reta_port_id,
3053 (void *)&cmd_config_rss_reta_name,
3054 (void *)&cmd_config_rss_reta_list_name,
3055 (void *)&cmd_config_rss_reta_list_of_items,
3060 /* *** SHOW PORT RETA INFO *** */
3061 struct cmd_showport_reta {
3062 cmdline_fixed_string_t show;
3063 cmdline_fixed_string_t port;
3065 cmdline_fixed_string_t rss;
3066 cmdline_fixed_string_t reta;
3068 cmdline_fixed_string_t list_of_items;
3072 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3073 uint16_t nb_entries,
3077 const char *p, *p0 = str;
3082 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3083 RTE_RETA_GROUP_SIZE;
3086 p = strchr(p0, '(');
3090 p0 = strchr(p, ')');
3094 if (size >= sizeof(s)) {
3095 printf("The string size exceeds the internal buffer size\n");
3098 snprintf(s, sizeof(s), "%.*s", size, p);
3099 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3100 if (ret <= 0 || ret != num) {
3101 printf("The bits of masks do not match the number of "
3102 "reta entries: %u\n", num);
3105 for (i = 0; i < ret; i++)
3106 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3112 cmd_showport_reta_parsed(void *parsed_result,
3113 __rte_unused struct cmdline *cl,
3114 __rte_unused void *data)
3116 struct cmd_showport_reta *res = parsed_result;
3117 struct rte_eth_rss_reta_entry64 reta_conf[8];
3118 struct rte_eth_dev_info dev_info;
3119 uint16_t max_reta_size;
3122 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3126 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3127 if (res->size == 0 || res->size > max_reta_size) {
3128 printf("Invalid redirection table size: %u (1-%u)\n",
3129 res->size, max_reta_size);
3133 memset(reta_conf, 0, sizeof(reta_conf));
3134 if (showport_parse_reta_config(reta_conf, res->size,
3135 res->list_of_items) < 0) {
3136 printf("Invalid string: %s for reta masks\n",
3137 res->list_of_items);
3140 port_rss_reta_info(res->port_id, reta_conf, res->size);
3143 cmdline_parse_token_string_t cmd_showport_reta_show =
3144 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3145 cmdline_parse_token_string_t cmd_showport_reta_port =
3146 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3147 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3148 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3149 cmdline_parse_token_string_t cmd_showport_reta_rss =
3150 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3151 cmdline_parse_token_string_t cmd_showport_reta_reta =
3152 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3153 cmdline_parse_token_num_t cmd_showport_reta_size =
3154 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3155 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3156 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3157 list_of_items, NULL);
3159 cmdline_parse_inst_t cmd_showport_reta = {
3160 .f = cmd_showport_reta_parsed,
3162 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3164 (void *)&cmd_showport_reta_show,
3165 (void *)&cmd_showport_reta_port,
3166 (void *)&cmd_showport_reta_port_id,
3167 (void *)&cmd_showport_reta_rss,
3168 (void *)&cmd_showport_reta_reta,
3169 (void *)&cmd_showport_reta_size,
3170 (void *)&cmd_showport_reta_list_of_items,
3175 /* *** Show RSS hash configuration *** */
3176 struct cmd_showport_rss_hash {
3177 cmdline_fixed_string_t show;
3178 cmdline_fixed_string_t port;
3180 cmdline_fixed_string_t rss_hash;
3181 cmdline_fixed_string_t rss_type;
3182 cmdline_fixed_string_t key; /* optional argument */
3185 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3186 __rte_unused struct cmdline *cl,
3189 struct cmd_showport_rss_hash *res = parsed_result;
3191 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3194 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3195 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3196 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3197 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3198 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3199 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3200 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3201 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3203 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3204 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3206 cmdline_parse_inst_t cmd_showport_rss_hash = {
3207 .f = cmd_showport_rss_hash_parsed,
3209 .help_str = "show port <port_id> rss-hash",
3211 (void *)&cmd_showport_rss_hash_show,
3212 (void *)&cmd_showport_rss_hash_port,
3213 (void *)&cmd_showport_rss_hash_port_id,
3214 (void *)&cmd_showport_rss_hash_rss_hash,
3219 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3220 .f = cmd_showport_rss_hash_parsed,
3222 .help_str = "show port <port_id> rss-hash key",
3224 (void *)&cmd_showport_rss_hash_show,
3225 (void *)&cmd_showport_rss_hash_port,
3226 (void *)&cmd_showport_rss_hash_port_id,
3227 (void *)&cmd_showport_rss_hash_rss_hash,
3228 (void *)&cmd_showport_rss_hash_rss_key,
3233 /* *** Configure DCB *** */
3234 struct cmd_config_dcb {
3235 cmdline_fixed_string_t port;
3236 cmdline_fixed_string_t config;
3238 cmdline_fixed_string_t dcb;
3239 cmdline_fixed_string_t vt;
3240 cmdline_fixed_string_t vt_en;
3242 cmdline_fixed_string_t pfc;
3243 cmdline_fixed_string_t pfc_en;
3247 cmd_config_dcb_parsed(void *parsed_result,
3248 __rte_unused struct cmdline *cl,
3249 __rte_unused void *data)
3251 struct cmd_config_dcb *res = parsed_result;
3252 portid_t port_id = res->port_id;
3253 struct rte_port *port;
3257 port = &ports[port_id];
3258 /** Check if the port is not started **/
3259 if (port->port_status != RTE_PORT_STOPPED) {
3260 printf("Please stop port %d first\n", port_id);
3264 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3265 printf("The invalid number of traffic class,"
3266 " only 4 or 8 allowed.\n");
3270 if (nb_fwd_lcores < res->num_tcs) {
3271 printf("nb_cores shouldn't be less than number of TCs.\n");
3274 if (!strncmp(res->pfc_en, "on", 2))
3279 /* DCB in VT mode */
3280 if (!strncmp(res->vt_en, "on", 2))
3281 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3282 (enum rte_eth_nb_tcs)res->num_tcs,
3285 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3286 (enum rte_eth_nb_tcs)res->num_tcs,
3291 printf("Cannot initialize network ports.\n");
3295 cmd_reconfig_device_queue(port_id, 1, 1);
3298 cmdline_parse_token_string_t cmd_config_dcb_port =
3299 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3300 cmdline_parse_token_string_t cmd_config_dcb_config =
3301 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3302 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3303 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3304 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3305 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3306 cmdline_parse_token_string_t cmd_config_dcb_vt =
3307 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3308 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3309 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3310 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3311 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3312 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3313 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3314 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3315 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3317 cmdline_parse_inst_t cmd_config_dcb = {
3318 .f = cmd_config_dcb_parsed,
3320 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3322 (void *)&cmd_config_dcb_port,
3323 (void *)&cmd_config_dcb_config,
3324 (void *)&cmd_config_dcb_port_id,
3325 (void *)&cmd_config_dcb_dcb,
3326 (void *)&cmd_config_dcb_vt,
3327 (void *)&cmd_config_dcb_vt_en,
3328 (void *)&cmd_config_dcb_num_tcs,
3329 (void *)&cmd_config_dcb_pfc,
3330 (void *)&cmd_config_dcb_pfc_en,
3335 /* *** configure number of packets per burst *** */
3336 struct cmd_config_burst {
3337 cmdline_fixed_string_t port;
3338 cmdline_fixed_string_t keyword;
3339 cmdline_fixed_string_t all;
3340 cmdline_fixed_string_t name;
3345 cmd_config_burst_parsed(void *parsed_result,
3346 __rte_unused struct cmdline *cl,
3347 __rte_unused void *data)
3349 struct cmd_config_burst *res = parsed_result;
3350 struct rte_eth_dev_info dev_info;
3351 uint16_t rec_nb_pkts;
3354 if (!all_ports_stopped()) {
3355 printf("Please stop all ports first\n");
3359 if (!strcmp(res->name, "burst")) {
3360 if (res->value == 0) {
3361 /* If user gives a value of zero, query the PMD for
3362 * its recommended Rx burst size. Testpmd uses a single
3363 * size for all ports, so assume all ports are the same
3364 * NIC model and use the values from Port 0.
3366 ret = eth_dev_info_get_print_err(0, &dev_info);
3370 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3372 if (rec_nb_pkts == 0) {
3373 printf("PMD does not recommend a burst size.\n"
3374 "User provided value must be between"
3375 " 1 and %d\n", MAX_PKT_BURST);
3377 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3378 printf("PMD recommended burst size of %d"
3379 " exceeds maximum value of %d\n",
3380 rec_nb_pkts, MAX_PKT_BURST);
3383 printf("Using PMD-provided burst value of %d\n",
3385 nb_pkt_per_burst = rec_nb_pkts;
3386 } else if (res->value > MAX_PKT_BURST) {
3387 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3390 nb_pkt_per_burst = res->value;
3392 printf("Unknown parameter\n");
3398 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3401 cmdline_parse_token_string_t cmd_config_burst_port =
3402 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3403 cmdline_parse_token_string_t cmd_config_burst_keyword =
3404 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3405 cmdline_parse_token_string_t cmd_config_burst_all =
3406 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3407 cmdline_parse_token_string_t cmd_config_burst_name =
3408 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3409 cmdline_parse_token_num_t cmd_config_burst_value =
3410 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3412 cmdline_parse_inst_t cmd_config_burst = {
3413 .f = cmd_config_burst_parsed,
3415 .help_str = "port config all burst <value>",
3417 (void *)&cmd_config_burst_port,
3418 (void *)&cmd_config_burst_keyword,
3419 (void *)&cmd_config_burst_all,
3420 (void *)&cmd_config_burst_name,
3421 (void *)&cmd_config_burst_value,
3426 /* *** configure rx/tx queues *** */
3427 struct cmd_config_thresh {
3428 cmdline_fixed_string_t port;
3429 cmdline_fixed_string_t keyword;
3430 cmdline_fixed_string_t all;
3431 cmdline_fixed_string_t name;
3436 cmd_config_thresh_parsed(void *parsed_result,
3437 __rte_unused struct cmdline *cl,
3438 __rte_unused void *data)
3440 struct cmd_config_thresh *res = parsed_result;
3442 if (!all_ports_stopped()) {
3443 printf("Please stop all ports first\n");
3447 if (!strcmp(res->name, "txpt"))
3448 tx_pthresh = res->value;
3449 else if(!strcmp(res->name, "txht"))
3450 tx_hthresh = res->value;
3451 else if(!strcmp(res->name, "txwt"))
3452 tx_wthresh = res->value;
3453 else if(!strcmp(res->name, "rxpt"))
3454 rx_pthresh = res->value;
3455 else if(!strcmp(res->name, "rxht"))
3456 rx_hthresh = res->value;
3457 else if(!strcmp(res->name, "rxwt"))
3458 rx_wthresh = res->value;
3460 printf("Unknown parameter\n");
3466 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3469 cmdline_parse_token_string_t cmd_config_thresh_port =
3470 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3471 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3472 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3473 cmdline_parse_token_string_t cmd_config_thresh_all =
3474 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3475 cmdline_parse_token_string_t cmd_config_thresh_name =
3476 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3477 "txpt#txht#txwt#rxpt#rxht#rxwt");
3478 cmdline_parse_token_num_t cmd_config_thresh_value =
3479 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3481 cmdline_parse_inst_t cmd_config_thresh = {
3482 .f = cmd_config_thresh_parsed,
3484 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3486 (void *)&cmd_config_thresh_port,
3487 (void *)&cmd_config_thresh_keyword,
3488 (void *)&cmd_config_thresh_all,
3489 (void *)&cmd_config_thresh_name,
3490 (void *)&cmd_config_thresh_value,
3495 /* *** configure free/rs threshold *** */
3496 struct cmd_config_threshold {
3497 cmdline_fixed_string_t port;
3498 cmdline_fixed_string_t keyword;
3499 cmdline_fixed_string_t all;
3500 cmdline_fixed_string_t name;
3505 cmd_config_threshold_parsed(void *parsed_result,
3506 __rte_unused struct cmdline *cl,
3507 __rte_unused void *data)
3509 struct cmd_config_threshold *res = parsed_result;
3511 if (!all_ports_stopped()) {
3512 printf("Please stop all ports first\n");
3516 if (!strcmp(res->name, "txfreet"))
3517 tx_free_thresh = res->value;
3518 else if (!strcmp(res->name, "txrst"))
3519 tx_rs_thresh = res->value;
3520 else if (!strcmp(res->name, "rxfreet"))
3521 rx_free_thresh = res->value;
3523 printf("Unknown parameter\n");
3529 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3532 cmdline_parse_token_string_t cmd_config_threshold_port =
3533 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3534 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3535 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3537 cmdline_parse_token_string_t cmd_config_threshold_all =
3538 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3539 cmdline_parse_token_string_t cmd_config_threshold_name =
3540 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3541 "txfreet#txrst#rxfreet");
3542 cmdline_parse_token_num_t cmd_config_threshold_value =
3543 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3545 cmdline_parse_inst_t cmd_config_threshold = {
3546 .f = cmd_config_threshold_parsed,
3548 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3550 (void *)&cmd_config_threshold_port,
3551 (void *)&cmd_config_threshold_keyword,
3552 (void *)&cmd_config_threshold_all,
3553 (void *)&cmd_config_threshold_name,
3554 (void *)&cmd_config_threshold_value,
3560 struct cmd_stop_result {
3561 cmdline_fixed_string_t stop;
3564 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3565 __rte_unused struct cmdline *cl,
3566 __rte_unused void *data)
3568 stop_packet_forwarding();
3571 cmdline_parse_token_string_t cmd_stop_stop =
3572 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3574 cmdline_parse_inst_t cmd_stop = {
3575 .f = cmd_stop_parsed,
3577 .help_str = "stop: Stop packet forwarding",
3579 (void *)&cmd_stop_stop,
3584 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3587 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3588 unsigned int *parsed_items, int check_unique_values)
3590 unsigned int nb_item;
3598 * First parse all items in the list and store their value.
3603 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3605 if ((c >= '0') && (c <= '9')) {
3606 value = (unsigned int) (value * 10 + (c - '0'));
3611 printf("character %c is not a decimal digit\n", c);
3615 printf("No valid value before comma\n");
3618 if (nb_item < max_items) {
3619 parsed_items[nb_item] = value;
3625 if (nb_item >= max_items) {
3626 printf("Number of %s = %u > %u (maximum items)\n",
3627 item_name, nb_item + 1, max_items);
3630 parsed_items[nb_item++] = value;
3631 if (! check_unique_values)
3635 * Then, check that all values in the list are differents.
3636 * No optimization here...
3638 for (i = 0; i < nb_item; i++) {
3639 for (j = i + 1; j < nb_item; j++) {
3640 if (parsed_items[j] == parsed_items[i]) {
3641 printf("duplicated %s %u at index %u and %u\n",
3642 item_name, parsed_items[i], i, j);
3650 struct cmd_set_list_result {
3651 cmdline_fixed_string_t cmd_keyword;
3652 cmdline_fixed_string_t list_name;
3653 cmdline_fixed_string_t list_of_items;
3656 static void cmd_set_list_parsed(void *parsed_result,
3657 __rte_unused struct cmdline *cl,
3658 __rte_unused void *data)
3660 struct cmd_set_list_result *res;
3662 unsigned int lcorelist[RTE_MAX_LCORE];
3663 unsigned int portlist[RTE_MAX_ETHPORTS];
3665 unsigned int nb_item;
3667 if (test_done == 0) {
3668 printf("Please stop forwarding first\n");
3672 res = parsed_result;
3673 if (!strcmp(res->list_name, "corelist")) {
3674 nb_item = parse_item_list(res->list_of_items, "core",
3676 parsed_items.lcorelist, 1);
3678 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3683 if (!strcmp(res->list_name, "portlist")) {
3684 nb_item = parse_item_list(res->list_of_items, "port",
3686 parsed_items.portlist, 1);
3688 set_fwd_ports_list(parsed_items.portlist, nb_item);
3694 cmdline_parse_token_string_t cmd_set_list_keyword =
3695 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3697 cmdline_parse_token_string_t cmd_set_list_name =
3698 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3699 "corelist#portlist");
3700 cmdline_parse_token_string_t cmd_set_list_of_items =
3701 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3704 cmdline_parse_inst_t cmd_set_fwd_list = {
3705 .f = cmd_set_list_parsed,
3707 .help_str = "set corelist|portlist <list0[,list1]*>",
3709 (void *)&cmd_set_list_keyword,
3710 (void *)&cmd_set_list_name,
3711 (void *)&cmd_set_list_of_items,
3716 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3718 struct cmd_setmask_result {
3719 cmdline_fixed_string_t set;
3720 cmdline_fixed_string_t mask;
3724 static void cmd_set_mask_parsed(void *parsed_result,
3725 __rte_unused struct cmdline *cl,
3726 __rte_unused void *data)
3728 struct cmd_setmask_result *res = parsed_result;
3730 if (test_done == 0) {
3731 printf("Please stop forwarding first\n");
3734 if (!strcmp(res->mask, "coremask")) {
3735 set_fwd_lcores_mask(res->hexavalue);
3737 } else if (!strcmp(res->mask, "portmask")) {
3738 set_fwd_ports_mask(res->hexavalue);
3743 cmdline_parse_token_string_t cmd_setmask_set =
3744 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3745 cmdline_parse_token_string_t cmd_setmask_mask =
3746 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3747 "coremask#portmask");
3748 cmdline_parse_token_num_t cmd_setmask_value =
3749 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3751 cmdline_parse_inst_t cmd_set_fwd_mask = {
3752 .f = cmd_set_mask_parsed,
3754 .help_str = "set coremask|portmask <hexadecimal value>",
3756 (void *)&cmd_setmask_set,
3757 (void *)&cmd_setmask_mask,
3758 (void *)&cmd_setmask_value,
3764 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3766 struct cmd_set_result {
3767 cmdline_fixed_string_t set;
3768 cmdline_fixed_string_t what;
3772 static void cmd_set_parsed(void *parsed_result,
3773 __rte_unused struct cmdline *cl,
3774 __rte_unused void *data)
3776 struct cmd_set_result *res = parsed_result;
3777 if (!strcmp(res->what, "nbport")) {
3778 set_fwd_ports_number(res->value);
3780 } else if (!strcmp(res->what, "nbcore")) {
3781 set_fwd_lcores_number(res->value);
3783 } else if (!strcmp(res->what, "burst"))
3784 set_nb_pkt_per_burst(res->value);
3785 else if (!strcmp(res->what, "verbose"))
3786 set_verbose_level(res->value);
3789 cmdline_parse_token_string_t cmd_set_set =
3790 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3791 cmdline_parse_token_string_t cmd_set_what =
3792 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3793 "nbport#nbcore#burst#verbose");
3794 cmdline_parse_token_num_t cmd_set_value =
3795 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3797 cmdline_parse_inst_t cmd_set_numbers = {
3798 .f = cmd_set_parsed,
3800 .help_str = "set nbport|nbcore|burst|verbose <value>",
3802 (void *)&cmd_set_set,
3803 (void *)&cmd_set_what,
3804 (void *)&cmd_set_value,
3809 /* *** SET LOG LEVEL CONFIGURATION *** */
3811 struct cmd_set_log_result {
3812 cmdline_fixed_string_t set;
3813 cmdline_fixed_string_t log;
3814 cmdline_fixed_string_t type;
3819 cmd_set_log_parsed(void *parsed_result,
3820 __rte_unused struct cmdline *cl,
3821 __rte_unused void *data)
3823 struct cmd_set_log_result *res;
3826 res = parsed_result;
3827 if (!strcmp(res->type, "global"))
3828 rte_log_set_global_level(res->level);
3830 ret = rte_log_set_level_regexp(res->type, res->level);
3832 printf("Unable to set log level\n");
3836 cmdline_parse_token_string_t cmd_set_log_set =
3837 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3838 cmdline_parse_token_string_t cmd_set_log_log =
3839 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3840 cmdline_parse_token_string_t cmd_set_log_type =
3841 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3842 cmdline_parse_token_num_t cmd_set_log_level =
3843 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3845 cmdline_parse_inst_t cmd_set_log = {
3846 .f = cmd_set_log_parsed,
3848 .help_str = "set log global|<type> <level>",
3850 (void *)&cmd_set_log_set,
3851 (void *)&cmd_set_log_log,
3852 (void *)&cmd_set_log_type,
3853 (void *)&cmd_set_log_level,
3858 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3860 struct cmd_set_txpkts_result {
3861 cmdline_fixed_string_t cmd_keyword;
3862 cmdline_fixed_string_t txpkts;
3863 cmdline_fixed_string_t seg_lengths;
3867 cmd_set_txpkts_parsed(void *parsed_result,
3868 __rte_unused struct cmdline *cl,
3869 __rte_unused void *data)
3871 struct cmd_set_txpkts_result *res;
3872 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3873 unsigned int nb_segs;
3875 res = parsed_result;
3876 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3877 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3879 set_tx_pkt_segments(seg_lengths, nb_segs);
3882 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3883 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3884 cmd_keyword, "set");
3885 cmdline_parse_token_string_t cmd_set_txpkts_name =
3886 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3888 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3889 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3892 cmdline_parse_inst_t cmd_set_txpkts = {
3893 .f = cmd_set_txpkts_parsed,
3895 .help_str = "set txpkts <len0[,len1]*>",
3897 (void *)&cmd_set_txpkts_keyword,
3898 (void *)&cmd_set_txpkts_name,
3899 (void *)&cmd_set_txpkts_lengths,
3904 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3906 struct cmd_set_txsplit_result {
3907 cmdline_fixed_string_t cmd_keyword;
3908 cmdline_fixed_string_t txsplit;
3909 cmdline_fixed_string_t mode;
3913 cmd_set_txsplit_parsed(void *parsed_result,
3914 __rte_unused struct cmdline *cl,
3915 __rte_unused void *data)
3917 struct cmd_set_txsplit_result *res;
3919 res = parsed_result;
3920 set_tx_pkt_split(res->mode);
3923 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3924 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3925 cmd_keyword, "set");
3926 cmdline_parse_token_string_t cmd_set_txsplit_name =
3927 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3928 txsplit, "txsplit");
3929 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3930 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3933 cmdline_parse_inst_t cmd_set_txsplit = {
3934 .f = cmd_set_txsplit_parsed,
3936 .help_str = "set txsplit on|off|rand",
3938 (void *)&cmd_set_txsplit_keyword,
3939 (void *)&cmd_set_txsplit_name,
3940 (void *)&cmd_set_txsplit_mode,
3945 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3946 struct cmd_rx_vlan_filter_all_result {
3947 cmdline_fixed_string_t rx_vlan;
3948 cmdline_fixed_string_t what;
3949 cmdline_fixed_string_t all;
3954 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3955 __rte_unused struct cmdline *cl,
3956 __rte_unused void *data)
3958 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3960 if (!strcmp(res->what, "add"))
3961 rx_vlan_all_filter_set(res->port_id, 1);
3963 rx_vlan_all_filter_set(res->port_id, 0);
3966 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3967 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3968 rx_vlan, "rx_vlan");
3969 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3970 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3972 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3973 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3975 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3976 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3979 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3980 .f = cmd_rx_vlan_filter_all_parsed,
3982 .help_str = "rx_vlan add|rm all <port_id>: "
3983 "Add/Remove all identifiers to/from the set of VLAN "
3984 "identifiers filtered by a port",
3986 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3987 (void *)&cmd_rx_vlan_filter_all_what,
3988 (void *)&cmd_rx_vlan_filter_all_all,
3989 (void *)&cmd_rx_vlan_filter_all_portid,
3994 /* *** VLAN OFFLOAD SET ON A PORT *** */
3995 struct cmd_vlan_offload_result {
3996 cmdline_fixed_string_t vlan;
3997 cmdline_fixed_string_t set;
3998 cmdline_fixed_string_t vlan_type;
3999 cmdline_fixed_string_t what;
4000 cmdline_fixed_string_t on;
4001 cmdline_fixed_string_t port_id;
4005 cmd_vlan_offload_parsed(void *parsed_result,
4006 __rte_unused struct cmdline *cl,
4007 __rte_unused void *data)
4010 struct cmd_vlan_offload_result *res = parsed_result;
4013 portid_t port_id = 0;
4017 len = strnlen(str, STR_TOKEN_SIZE);
4019 /* Get port_id first */
4027 tmp = strtoul(str, NULL, 0);
4028 /* If port_id greater that what portid_t can represent, return */
4029 if(tmp >= RTE_MAX_ETHPORTS)
4031 port_id = (portid_t)tmp;
4033 if (!strcmp(res->on, "on"))
4038 if (!strcmp(res->what, "strip"))
4039 rx_vlan_strip_set(port_id, on);
4040 else if(!strcmp(res->what, "stripq")){
4041 uint16_t queue_id = 0;
4043 /* No queue_id, return */
4045 printf("must specify (port,queue_id)\n");
4048 tmp = strtoul(str + i + 1, NULL, 0);
4049 /* If queue_id greater that what 16-bits can represent, return */
4053 queue_id = (uint16_t)tmp;
4054 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4056 else if (!strcmp(res->what, "filter"))
4057 rx_vlan_filter_set(port_id, on);
4058 else if (!strcmp(res->what, "qinq_strip"))
4059 rx_vlan_qinq_strip_set(port_id, on);
4061 vlan_extend_set(port_id, on);
4066 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4067 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4069 cmdline_parse_token_string_t cmd_vlan_offload_set =
4070 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4072 cmdline_parse_token_string_t cmd_vlan_offload_what =
4073 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4074 what, "strip#filter#qinq_strip#extend#stripq");
4075 cmdline_parse_token_string_t cmd_vlan_offload_on =
4076 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4078 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4079 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4082 cmdline_parse_inst_t cmd_vlan_offload = {
4083 .f = cmd_vlan_offload_parsed,
4085 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4086 "<port_id[,queue_id]>: "
4087 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4089 (void *)&cmd_vlan_offload_vlan,
4090 (void *)&cmd_vlan_offload_set,
4091 (void *)&cmd_vlan_offload_what,
4092 (void *)&cmd_vlan_offload_on,
4093 (void *)&cmd_vlan_offload_portid,
4098 /* *** VLAN TPID SET ON A PORT *** */
4099 struct cmd_vlan_tpid_result {
4100 cmdline_fixed_string_t vlan;
4101 cmdline_fixed_string_t set;
4102 cmdline_fixed_string_t vlan_type;
4103 cmdline_fixed_string_t what;
4109 cmd_vlan_tpid_parsed(void *parsed_result,
4110 __rte_unused struct cmdline *cl,
4111 __rte_unused void *data)
4113 struct cmd_vlan_tpid_result *res = parsed_result;
4114 enum rte_vlan_type vlan_type;
4116 if (!strcmp(res->vlan_type, "inner"))
4117 vlan_type = ETH_VLAN_TYPE_INNER;
4118 else if (!strcmp(res->vlan_type, "outer"))
4119 vlan_type = ETH_VLAN_TYPE_OUTER;
4121 printf("Unknown vlan type\n");
4124 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4127 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4128 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4130 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4131 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4133 cmdline_parse_token_string_t cmd_vlan_type =
4134 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4135 vlan_type, "inner#outer");
4136 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4137 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4139 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4140 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4142 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4143 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4146 cmdline_parse_inst_t cmd_vlan_tpid = {
4147 .f = cmd_vlan_tpid_parsed,
4149 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4150 "Set the VLAN Ether type",
4152 (void *)&cmd_vlan_tpid_vlan,
4153 (void *)&cmd_vlan_tpid_set,
4154 (void *)&cmd_vlan_type,
4155 (void *)&cmd_vlan_tpid_what,
4156 (void *)&cmd_vlan_tpid_tpid,
4157 (void *)&cmd_vlan_tpid_portid,
4162 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4163 struct cmd_rx_vlan_filter_result {
4164 cmdline_fixed_string_t rx_vlan;
4165 cmdline_fixed_string_t what;
4171 cmd_rx_vlan_filter_parsed(void *parsed_result,
4172 __rte_unused struct cmdline *cl,
4173 __rte_unused void *data)
4175 struct cmd_rx_vlan_filter_result *res = parsed_result;
4177 if (!strcmp(res->what, "add"))
4178 rx_vft_set(res->port_id, res->vlan_id, 1);
4180 rx_vft_set(res->port_id, res->vlan_id, 0);
4183 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4184 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4185 rx_vlan, "rx_vlan");
4186 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4187 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4189 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4190 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4192 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4193 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4196 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4197 .f = cmd_rx_vlan_filter_parsed,
4199 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4200 "Add/Remove a VLAN identifier to/from the set of VLAN "
4201 "identifiers filtered by a port",
4203 (void *)&cmd_rx_vlan_filter_rx_vlan,
4204 (void *)&cmd_rx_vlan_filter_what,
4205 (void *)&cmd_rx_vlan_filter_vlanid,
4206 (void *)&cmd_rx_vlan_filter_portid,
4211 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4212 struct cmd_tx_vlan_set_result {
4213 cmdline_fixed_string_t tx_vlan;
4214 cmdline_fixed_string_t set;
4220 cmd_tx_vlan_set_parsed(void *parsed_result,
4221 __rte_unused struct cmdline *cl,
4222 __rte_unused void *data)
4224 struct cmd_tx_vlan_set_result *res = parsed_result;
4226 if (!port_is_stopped(res->port_id)) {
4227 printf("Please stop port %d first\n", res->port_id);
4231 tx_vlan_set(res->port_id, res->vlan_id);
4233 cmd_reconfig_device_queue(res->port_id, 1, 1);
4236 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4237 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4238 tx_vlan, "tx_vlan");
4239 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4240 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4242 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4243 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4245 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4246 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4249 cmdline_parse_inst_t cmd_tx_vlan_set = {
4250 .f = cmd_tx_vlan_set_parsed,
4252 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4253 "Enable hardware insertion of a single VLAN header "
4254 "with a given TAG Identifier in packets sent on a port",
4256 (void *)&cmd_tx_vlan_set_tx_vlan,
4257 (void *)&cmd_tx_vlan_set_set,
4258 (void *)&cmd_tx_vlan_set_portid,
4259 (void *)&cmd_tx_vlan_set_vlanid,
4264 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4265 struct cmd_tx_vlan_set_qinq_result {
4266 cmdline_fixed_string_t tx_vlan;
4267 cmdline_fixed_string_t set;
4270 uint16_t vlan_id_outer;
4274 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4275 __rte_unused struct cmdline *cl,
4276 __rte_unused void *data)
4278 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4280 if (!port_is_stopped(res->port_id)) {
4281 printf("Please stop port %d first\n", res->port_id);
4285 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4287 cmd_reconfig_device_queue(res->port_id, 1, 1);
4290 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4291 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4292 tx_vlan, "tx_vlan");
4293 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4294 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4296 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4297 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4299 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4300 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4302 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4303 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4304 vlan_id_outer, UINT16);
4306 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4307 .f = cmd_tx_vlan_set_qinq_parsed,
4309 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4310 "Enable hardware insertion of double VLAN header "
4311 "with given TAG Identifiers in packets sent on a port",
4313 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4314 (void *)&cmd_tx_vlan_set_qinq_set,
4315 (void *)&cmd_tx_vlan_set_qinq_portid,
4316 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4317 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4322 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4323 struct cmd_tx_vlan_set_pvid_result {
4324 cmdline_fixed_string_t tx_vlan;
4325 cmdline_fixed_string_t set;
4326 cmdline_fixed_string_t pvid;
4329 cmdline_fixed_string_t mode;
4333 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4334 __rte_unused struct cmdline *cl,
4335 __rte_unused void *data)
4337 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4339 if (strcmp(res->mode, "on") == 0)
4340 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4342 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4345 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4346 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4347 tx_vlan, "tx_vlan");
4348 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4349 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4351 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4352 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4354 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4355 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4357 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4358 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4360 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4361 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4364 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4365 .f = cmd_tx_vlan_set_pvid_parsed,
4367 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4369 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4370 (void *)&cmd_tx_vlan_set_pvid_set,
4371 (void *)&cmd_tx_vlan_set_pvid_pvid,
4372 (void *)&cmd_tx_vlan_set_pvid_port_id,
4373 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4374 (void *)&cmd_tx_vlan_set_pvid_mode,
4379 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4380 struct cmd_tx_vlan_reset_result {
4381 cmdline_fixed_string_t tx_vlan;
4382 cmdline_fixed_string_t reset;
4387 cmd_tx_vlan_reset_parsed(void *parsed_result,
4388 __rte_unused struct cmdline *cl,
4389 __rte_unused void *data)
4391 struct cmd_tx_vlan_reset_result *res = parsed_result;
4393 if (!port_is_stopped(res->port_id)) {
4394 printf("Please stop port %d first\n", res->port_id);
4398 tx_vlan_reset(res->port_id);
4400 cmd_reconfig_device_queue(res->port_id, 1, 1);
4403 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4404 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4405 tx_vlan, "tx_vlan");
4406 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4407 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4409 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4410 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4413 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4414 .f = cmd_tx_vlan_reset_parsed,
4416 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4417 "VLAN header in packets sent on a port",
4419 (void *)&cmd_tx_vlan_reset_tx_vlan,
4420 (void *)&cmd_tx_vlan_reset_reset,
4421 (void *)&cmd_tx_vlan_reset_portid,
4427 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4428 struct cmd_csum_result {
4429 cmdline_fixed_string_t csum;
4430 cmdline_fixed_string_t mode;
4431 cmdline_fixed_string_t proto;
4432 cmdline_fixed_string_t hwsw;
4437 csum_show(int port_id)
4439 struct rte_eth_dev_info dev_info;
4440 uint64_t tx_offloads;
4443 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4444 printf("Parse tunnel is %s\n",
4445 (ports[port_id].parse_tunnel) ? "on" : "off");
4446 printf("IP checksum offload is %s\n",
4447 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4448 printf("UDP checksum offload is %s\n",
4449 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4450 printf("TCP checksum offload is %s\n",
4451 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4452 printf("SCTP checksum offload is %s\n",
4453 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4454 printf("Outer-Ip checksum offload is %s\n",
4455 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4456 printf("Outer-Udp checksum offload is %s\n",
4457 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4459 /* display warnings if configuration is not supported by the NIC */
4460 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4464 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4465 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4466 printf("Warning: hardware IP checksum enabled but not "
4467 "supported by port %d\n", port_id);
4469 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4470 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4471 printf("Warning: hardware UDP checksum enabled but not "
4472 "supported by port %d\n", port_id);
4474 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4475 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4476 printf("Warning: hardware TCP checksum enabled but not "
4477 "supported by port %d\n", port_id);
4479 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4480 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4481 printf("Warning: hardware SCTP checksum enabled but not "
4482 "supported by port %d\n", port_id);
4484 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4485 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4486 printf("Warning: hardware outer IP checksum enabled but not "
4487 "supported by port %d\n", port_id);
4489 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4490 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4492 printf("Warning: hardware outer UDP checksum enabled but not "
4493 "supported by port %d\n", port_id);
4498 cmd_config_queue_tx_offloads(struct rte_port *port)
4502 /* Apply queue tx offloads configuration */
4503 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4504 port->tx_conf[k].offloads =
4505 port->dev_conf.txmode.offloads;
4509 cmd_csum_parsed(void *parsed_result,
4510 __rte_unused struct cmdline *cl,
4511 __rte_unused void *data)
4513 struct cmd_csum_result *res = parsed_result;
4515 uint64_t csum_offloads = 0;
4516 struct rte_eth_dev_info dev_info;
4519 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4520 printf("invalid port %d\n", res->port_id);
4523 if (!port_is_stopped(res->port_id)) {
4524 printf("Please stop port %d first\n", res->port_id);
4528 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4532 if (!strcmp(res->mode, "set")) {
4534 if (!strcmp(res->hwsw, "hw"))
4537 if (!strcmp(res->proto, "ip")) {
4538 if (hw == 0 || (dev_info.tx_offload_capa &
4539 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4540 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4542 printf("IP checksum offload is not supported "
4543 "by port %u\n", res->port_id);
4545 } else if (!strcmp(res->proto, "udp")) {
4546 if (hw == 0 || (dev_info.tx_offload_capa &
4547 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4548 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4550 printf("UDP checksum offload is not supported "
4551 "by port %u\n", res->port_id);
4553 } else if (!strcmp(res->proto, "tcp")) {
4554 if (hw == 0 || (dev_info.tx_offload_capa &
4555 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4556 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4558 printf("TCP checksum offload is not supported "
4559 "by port %u\n", res->port_id);
4561 } else if (!strcmp(res->proto, "sctp")) {
4562 if (hw == 0 || (dev_info.tx_offload_capa &
4563 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4564 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4566 printf("SCTP checksum offload is not supported "
4567 "by port %u\n", res->port_id);
4569 } else if (!strcmp(res->proto, "outer-ip")) {
4570 if (hw == 0 || (dev_info.tx_offload_capa &
4571 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4573 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4575 printf("Outer IP checksum offload is not "
4576 "supported by port %u\n", res->port_id);
4578 } else if (!strcmp(res->proto, "outer-udp")) {
4579 if (hw == 0 || (dev_info.tx_offload_capa &
4580 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4582 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4584 printf("Outer UDP checksum offload is not "
4585 "supported by port %u\n", res->port_id);
4590 ports[res->port_id].dev_conf.txmode.offloads |=
4593 ports[res->port_id].dev_conf.txmode.offloads &=
4596 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4598 csum_show(res->port_id);
4600 cmd_reconfig_device_queue(res->port_id, 1, 1);
4603 cmdline_parse_token_string_t cmd_csum_csum =
4604 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4606 cmdline_parse_token_string_t cmd_csum_mode =
4607 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4609 cmdline_parse_token_string_t cmd_csum_proto =
4610 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4611 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4612 cmdline_parse_token_string_t cmd_csum_hwsw =
4613 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4615 cmdline_parse_token_num_t cmd_csum_portid =
4616 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4619 cmdline_parse_inst_t cmd_csum_set = {
4620 .f = cmd_csum_parsed,
4622 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4623 "Enable/Disable hardware calculation of L3/L4 checksum when "
4624 "using csum forward engine",
4626 (void *)&cmd_csum_csum,
4627 (void *)&cmd_csum_mode,
4628 (void *)&cmd_csum_proto,
4629 (void *)&cmd_csum_hwsw,
4630 (void *)&cmd_csum_portid,
4635 cmdline_parse_token_string_t cmd_csum_mode_show =
4636 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4639 cmdline_parse_inst_t cmd_csum_show = {
4640 .f = cmd_csum_parsed,
4642 .help_str = "csum show <port_id>: Show checksum offload configuration",
4644 (void *)&cmd_csum_csum,
4645 (void *)&cmd_csum_mode_show,
4646 (void *)&cmd_csum_portid,
4651 /* Enable/disable tunnel parsing */
4652 struct cmd_csum_tunnel_result {
4653 cmdline_fixed_string_t csum;
4654 cmdline_fixed_string_t parse;
4655 cmdline_fixed_string_t onoff;
4660 cmd_csum_tunnel_parsed(void *parsed_result,
4661 __rte_unused struct cmdline *cl,
4662 __rte_unused void *data)
4664 struct cmd_csum_tunnel_result *res = parsed_result;
4666 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4669 if (!strcmp(res->onoff, "on"))
4670 ports[res->port_id].parse_tunnel = 1;
4672 ports[res->port_id].parse_tunnel = 0;
4674 csum_show(res->port_id);
4677 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4678 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4680 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4681 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4682 parse, "parse-tunnel");
4683 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4684 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4686 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4687 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4690 cmdline_parse_inst_t cmd_csum_tunnel = {
4691 .f = cmd_csum_tunnel_parsed,
4693 .help_str = "csum parse-tunnel on|off <port_id>: "
4694 "Enable/Disable parsing of tunnels for csum engine",
4696 (void *)&cmd_csum_tunnel_csum,
4697 (void *)&cmd_csum_tunnel_parse,
4698 (void *)&cmd_csum_tunnel_onoff,
4699 (void *)&cmd_csum_tunnel_portid,
4704 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4705 struct cmd_tso_set_result {
4706 cmdline_fixed_string_t tso;
4707 cmdline_fixed_string_t mode;
4713 cmd_tso_set_parsed(void *parsed_result,
4714 __rte_unused struct cmdline *cl,
4715 __rte_unused void *data)
4717 struct cmd_tso_set_result *res = parsed_result;
4718 struct rte_eth_dev_info dev_info;
4721 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4723 if (!port_is_stopped(res->port_id)) {
4724 printf("Please stop port %d first\n", res->port_id);
4728 if (!strcmp(res->mode, "set"))
4729 ports[res->port_id].tso_segsz = res->tso_segsz;
4731 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4735 if ((ports[res->port_id].tso_segsz != 0) &&
4736 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4737 printf("Error: TSO is not supported by port %d\n",
4742 if (ports[res->port_id].tso_segsz == 0) {
4743 ports[res->port_id].dev_conf.txmode.offloads &=
4744 ~DEV_TX_OFFLOAD_TCP_TSO;
4745 printf("TSO for non-tunneled packets is disabled\n");
4747 ports[res->port_id].dev_conf.txmode.offloads |=
4748 DEV_TX_OFFLOAD_TCP_TSO;
4749 printf("TSO segment size for non-tunneled packets is %d\n",
4750 ports[res->port_id].tso_segsz);
4752 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4754 /* display warnings if configuration is not supported by the NIC */
4755 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4759 if ((ports[res->port_id].tso_segsz != 0) &&
4760 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4761 printf("Warning: TSO enabled but not "
4762 "supported by port %d\n", res->port_id);
4765 cmd_reconfig_device_queue(res->port_id, 1, 1);
4768 cmdline_parse_token_string_t cmd_tso_set_tso =
4769 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4771 cmdline_parse_token_string_t cmd_tso_set_mode =
4772 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4774 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4775 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4777 cmdline_parse_token_num_t cmd_tso_set_portid =
4778 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4781 cmdline_parse_inst_t cmd_tso_set = {
4782 .f = cmd_tso_set_parsed,
4784 .help_str = "tso set <tso_segsz> <port_id>: "
4785 "Set TSO segment size of non-tunneled packets for csum engine "
4788 (void *)&cmd_tso_set_tso,
4789 (void *)&cmd_tso_set_mode,
4790 (void *)&cmd_tso_set_tso_segsz,
4791 (void *)&cmd_tso_set_portid,
4796 cmdline_parse_token_string_t cmd_tso_show_mode =
4797 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4801 cmdline_parse_inst_t cmd_tso_show = {
4802 .f = cmd_tso_set_parsed,
4804 .help_str = "tso show <port_id>: "
4805 "Show TSO segment size of non-tunneled packets for csum engine",
4807 (void *)&cmd_tso_set_tso,
4808 (void *)&cmd_tso_show_mode,
4809 (void *)&cmd_tso_set_portid,
4814 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4815 struct cmd_tunnel_tso_set_result {
4816 cmdline_fixed_string_t tso;
4817 cmdline_fixed_string_t mode;
4822 static struct rte_eth_dev_info
4823 check_tunnel_tso_nic_support(portid_t port_id)
4825 struct rte_eth_dev_info dev_info;
4827 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4830 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4831 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4832 "not enabled for port %d\n", port_id);
4833 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4834 printf("Warning: GRE TUNNEL TSO not supported therefore "
4835 "not enabled for port %d\n", port_id);
4836 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4837 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4838 "not enabled for port %d\n", port_id);
4839 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4840 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4841 "not enabled for port %d\n", port_id);
4842 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4843 printf("Warning: IP TUNNEL TSO not supported therefore "
4844 "not enabled for port %d\n", port_id);
4845 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4846 printf("Warning: UDP TUNNEL TSO not supported therefore "
4847 "not enabled for port %d\n", port_id);
4852 cmd_tunnel_tso_set_parsed(void *parsed_result,
4853 __rte_unused struct cmdline *cl,
4854 __rte_unused void *data)
4856 struct cmd_tunnel_tso_set_result *res = parsed_result;
4857 struct rte_eth_dev_info dev_info;
4859 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4861 if (!port_is_stopped(res->port_id)) {
4862 printf("Please stop port %d first\n", res->port_id);
4866 if (!strcmp(res->mode, "set"))
4867 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4869 dev_info = check_tunnel_tso_nic_support(res->port_id);
4870 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4871 ports[res->port_id].dev_conf.txmode.offloads &=
4872 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4873 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4874 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4875 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4876 DEV_TX_OFFLOAD_IP_TNL_TSO |
4877 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4878 printf("TSO for tunneled packets is disabled\n");
4880 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4881 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4882 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4883 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4884 DEV_TX_OFFLOAD_IP_TNL_TSO |
4885 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4887 ports[res->port_id].dev_conf.txmode.offloads |=
4888 (tso_offloads & dev_info.tx_offload_capa);
4889 printf("TSO segment size for tunneled packets is %d\n",
4890 ports[res->port_id].tunnel_tso_segsz);
4892 /* Below conditions are needed to make it work:
4893 * (1) tunnel TSO is supported by the NIC;
4894 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4896 * (3) for tunneled pkts with outer L3 of IPv4,
4897 * "csum set outer-ip" must be set to hw, because after tso,
4898 * total_len of outer IP header is changed, and the checksum
4899 * of outer IP header calculated by sw should be wrong; that
4900 * is not necessary for IPv6 tunneled pkts because there's no
4901 * checksum in IP header anymore.
4904 if (!ports[res->port_id].parse_tunnel)
4905 printf("Warning: csum parse_tunnel must be set "
4906 "so that tunneled packets are recognized\n");
4907 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4908 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4909 printf("Warning: csum set outer-ip must be set to hw "
4910 "if outer L3 is IPv4; not necessary for IPv6\n");
4913 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4914 cmd_reconfig_device_queue(res->port_id, 1, 1);
4917 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4918 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4920 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4921 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4923 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4924 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4926 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4927 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4930 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4931 .f = cmd_tunnel_tso_set_parsed,
4933 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4934 "Set TSO segment size of tunneled packets for csum engine "
4937 (void *)&cmd_tunnel_tso_set_tso,
4938 (void *)&cmd_tunnel_tso_set_mode,
4939 (void *)&cmd_tunnel_tso_set_tso_segsz,
4940 (void *)&cmd_tunnel_tso_set_portid,
4945 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4946 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4950 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4951 .f = cmd_tunnel_tso_set_parsed,
4953 .help_str = "tunnel_tso show <port_id> "
4954 "Show TSO segment size of tunneled packets for csum engine",
4956 (void *)&cmd_tunnel_tso_set_tso,
4957 (void *)&cmd_tunnel_tso_show_mode,
4958 (void *)&cmd_tunnel_tso_set_portid,
4963 /* *** SET GRO FOR A PORT *** */
4964 struct cmd_gro_enable_result {
4965 cmdline_fixed_string_t cmd_set;
4966 cmdline_fixed_string_t cmd_port;
4967 cmdline_fixed_string_t cmd_keyword;
4968 cmdline_fixed_string_t cmd_onoff;
4973 cmd_gro_enable_parsed(void *parsed_result,
4974 __rte_unused struct cmdline *cl,
4975 __rte_unused void *data)
4977 struct cmd_gro_enable_result *res;
4979 res = parsed_result;
4980 if (!strcmp(res->cmd_keyword, "gro"))
4981 setup_gro(res->cmd_onoff, res->cmd_pid);
4984 cmdline_parse_token_string_t cmd_gro_enable_set =
4985 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4987 cmdline_parse_token_string_t cmd_gro_enable_port =
4988 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4989 cmd_keyword, "port");
4990 cmdline_parse_token_num_t cmd_gro_enable_pid =
4991 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4993 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4994 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4995 cmd_keyword, "gro");
4996 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4997 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4998 cmd_onoff, "on#off");
5000 cmdline_parse_inst_t cmd_gro_enable = {
5001 .f = cmd_gro_enable_parsed,
5003 .help_str = "set port <port_id> gro on|off",
5005 (void *)&cmd_gro_enable_set,
5006 (void *)&cmd_gro_enable_port,
5007 (void *)&cmd_gro_enable_pid,
5008 (void *)&cmd_gro_enable_keyword,
5009 (void *)&cmd_gro_enable_onoff,
5014 /* *** DISPLAY GRO CONFIGURATION *** */
5015 struct cmd_gro_show_result {
5016 cmdline_fixed_string_t cmd_show;
5017 cmdline_fixed_string_t cmd_port;
5018 cmdline_fixed_string_t cmd_keyword;
5023 cmd_gro_show_parsed(void *parsed_result,
5024 __rte_unused struct cmdline *cl,
5025 __rte_unused void *data)
5027 struct cmd_gro_show_result *res;
5029 res = parsed_result;
5030 if (!strcmp(res->cmd_keyword, "gro"))
5031 show_gro(res->cmd_pid);
5034 cmdline_parse_token_string_t cmd_gro_show_show =
5035 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5037 cmdline_parse_token_string_t cmd_gro_show_port =
5038 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5040 cmdline_parse_token_num_t cmd_gro_show_pid =
5041 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5043 cmdline_parse_token_string_t cmd_gro_show_keyword =
5044 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5045 cmd_keyword, "gro");
5047 cmdline_parse_inst_t cmd_gro_show = {
5048 .f = cmd_gro_show_parsed,
5050 .help_str = "show port <port_id> gro",
5052 (void *)&cmd_gro_show_show,
5053 (void *)&cmd_gro_show_port,
5054 (void *)&cmd_gro_show_pid,
5055 (void *)&cmd_gro_show_keyword,
5060 /* *** SET FLUSH CYCLES FOR GRO *** */
5061 struct cmd_gro_flush_result {
5062 cmdline_fixed_string_t cmd_set;
5063 cmdline_fixed_string_t cmd_keyword;
5064 cmdline_fixed_string_t cmd_flush;
5069 cmd_gro_flush_parsed(void *parsed_result,
5070 __rte_unused struct cmdline *cl,
5071 __rte_unused void *data)
5073 struct cmd_gro_flush_result *res;
5075 res = parsed_result;
5076 if ((!strcmp(res->cmd_keyword, "gro")) &&
5077 (!strcmp(res->cmd_flush, "flush")))
5078 setup_gro_flush_cycles(res->cmd_cycles);
5081 cmdline_parse_token_string_t cmd_gro_flush_set =
5082 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5084 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5085 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5086 cmd_keyword, "gro");
5087 cmdline_parse_token_string_t cmd_gro_flush_flush =
5088 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5089 cmd_flush, "flush");
5090 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5091 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5094 cmdline_parse_inst_t cmd_gro_flush = {
5095 .f = cmd_gro_flush_parsed,
5097 .help_str = "set gro flush <cycles>",
5099 (void *)&cmd_gro_flush_set,
5100 (void *)&cmd_gro_flush_keyword,
5101 (void *)&cmd_gro_flush_flush,
5102 (void *)&cmd_gro_flush_cycles,
5107 /* *** ENABLE/DISABLE GSO *** */
5108 struct cmd_gso_enable_result {
5109 cmdline_fixed_string_t cmd_set;
5110 cmdline_fixed_string_t cmd_port;
5111 cmdline_fixed_string_t cmd_keyword;
5112 cmdline_fixed_string_t cmd_mode;
5117 cmd_gso_enable_parsed(void *parsed_result,
5118 __rte_unused struct cmdline *cl,
5119 __rte_unused void *data)
5121 struct cmd_gso_enable_result *res;
5123 res = parsed_result;
5124 if (!strcmp(res->cmd_keyword, "gso"))
5125 setup_gso(res->cmd_mode, res->cmd_pid);
5128 cmdline_parse_token_string_t cmd_gso_enable_set =
5129 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5131 cmdline_parse_token_string_t cmd_gso_enable_port =
5132 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5134 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5135 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5136 cmd_keyword, "gso");
5137 cmdline_parse_token_string_t cmd_gso_enable_mode =
5138 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5139 cmd_mode, "on#off");
5140 cmdline_parse_token_num_t cmd_gso_enable_pid =
5141 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5144 cmdline_parse_inst_t cmd_gso_enable = {
5145 .f = cmd_gso_enable_parsed,
5147 .help_str = "set port <port_id> gso on|off",
5149 (void *)&cmd_gso_enable_set,
5150 (void *)&cmd_gso_enable_port,
5151 (void *)&cmd_gso_enable_pid,
5152 (void *)&cmd_gso_enable_keyword,
5153 (void *)&cmd_gso_enable_mode,
5158 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5159 struct cmd_gso_size_result {
5160 cmdline_fixed_string_t cmd_set;
5161 cmdline_fixed_string_t cmd_keyword;
5162 cmdline_fixed_string_t cmd_segsz;
5167 cmd_gso_size_parsed(void *parsed_result,
5168 __rte_unused struct cmdline *cl,
5169 __rte_unused void *data)
5171 struct cmd_gso_size_result *res = parsed_result;
5173 if (test_done == 0) {
5174 printf("Before setting GSO segsz, please first"
5175 " stop forwarding\n");
5179 if (!strcmp(res->cmd_keyword, "gso") &&
5180 !strcmp(res->cmd_segsz, "segsz")) {
5181 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5182 printf("gso_size should be larger than %zu."
5183 " Please input a legal value\n",
5184 RTE_GSO_SEG_SIZE_MIN);
5186 gso_max_segment_size = res->cmd_size;
5190 cmdline_parse_token_string_t cmd_gso_size_set =
5191 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5193 cmdline_parse_token_string_t cmd_gso_size_keyword =
5194 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5195 cmd_keyword, "gso");
5196 cmdline_parse_token_string_t cmd_gso_size_segsz =
5197 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5198 cmd_segsz, "segsz");
5199 cmdline_parse_token_num_t cmd_gso_size_size =
5200 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5203 cmdline_parse_inst_t cmd_gso_size = {
5204 .f = cmd_gso_size_parsed,
5206 .help_str = "set gso segsz <length>",
5208 (void *)&cmd_gso_size_set,
5209 (void *)&cmd_gso_size_keyword,
5210 (void *)&cmd_gso_size_segsz,
5211 (void *)&cmd_gso_size_size,
5216 /* *** SHOW GSO CONFIGURATION *** */
5217 struct cmd_gso_show_result {
5218 cmdline_fixed_string_t cmd_show;
5219 cmdline_fixed_string_t cmd_port;
5220 cmdline_fixed_string_t cmd_keyword;
5225 cmd_gso_show_parsed(void *parsed_result,
5226 __rte_unused struct cmdline *cl,
5227 __rte_unused void *data)
5229 struct cmd_gso_show_result *res = parsed_result;
5231 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5232 printf("invalid port id %u\n", res->cmd_pid);
5235 if (!strcmp(res->cmd_keyword, "gso")) {
5236 if (gso_ports[res->cmd_pid].enable) {
5237 printf("Max GSO'd packet size: %uB\n"
5238 "Supported GSO types: TCP/IPv4, "
5239 "UDP/IPv4, VxLAN with inner "
5240 "TCP/IPv4 packet, GRE with inner "
5241 "TCP/IPv4 packet\n",
5242 gso_max_segment_size);
5244 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5248 cmdline_parse_token_string_t cmd_gso_show_show =
5249 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5251 cmdline_parse_token_string_t cmd_gso_show_port =
5252 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5254 cmdline_parse_token_string_t cmd_gso_show_keyword =
5255 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5256 cmd_keyword, "gso");
5257 cmdline_parse_token_num_t cmd_gso_show_pid =
5258 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5261 cmdline_parse_inst_t cmd_gso_show = {
5262 .f = cmd_gso_show_parsed,
5264 .help_str = "show port <port_id> gso",
5266 (void *)&cmd_gso_show_show,
5267 (void *)&cmd_gso_show_port,
5268 (void *)&cmd_gso_show_pid,
5269 (void *)&cmd_gso_show_keyword,
5274 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5275 struct cmd_set_flush_rx {
5276 cmdline_fixed_string_t set;
5277 cmdline_fixed_string_t flush_rx;
5278 cmdline_fixed_string_t mode;
5282 cmd_set_flush_rx_parsed(void *parsed_result,
5283 __rte_unused struct cmdline *cl,
5284 __rte_unused void *data)
5286 struct cmd_set_flush_rx *res = parsed_result;
5287 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5290 cmdline_parse_token_string_t cmd_setflushrx_set =
5291 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5293 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5294 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5295 flush_rx, "flush_rx");
5296 cmdline_parse_token_string_t cmd_setflushrx_mode =
5297 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5301 cmdline_parse_inst_t cmd_set_flush_rx = {
5302 .f = cmd_set_flush_rx_parsed,
5303 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5306 (void *)&cmd_setflushrx_set,
5307 (void *)&cmd_setflushrx_flush_rx,
5308 (void *)&cmd_setflushrx_mode,
5313 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5314 struct cmd_set_link_check {
5315 cmdline_fixed_string_t set;
5316 cmdline_fixed_string_t link_check;
5317 cmdline_fixed_string_t mode;
5321 cmd_set_link_check_parsed(void *parsed_result,
5322 __rte_unused struct cmdline *cl,
5323 __rte_unused void *data)
5325 struct cmd_set_link_check *res = parsed_result;
5326 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5329 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5330 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5332 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5333 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5334 link_check, "link_check");
5335 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5336 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5340 cmdline_parse_inst_t cmd_set_link_check = {
5341 .f = cmd_set_link_check_parsed,
5342 .help_str = "set link_check on|off: Enable/Disable link status check "
5343 "when starting/stopping a port",
5346 (void *)&cmd_setlinkcheck_set,
5347 (void *)&cmd_setlinkcheck_link_check,
5348 (void *)&cmd_setlinkcheck_mode,
5353 /* *** SET NIC BYPASS MODE *** */
5354 struct cmd_set_bypass_mode_result {
5355 cmdline_fixed_string_t set;
5356 cmdline_fixed_string_t bypass;
5357 cmdline_fixed_string_t mode;
5358 cmdline_fixed_string_t value;
5363 cmd_set_bypass_mode_parsed(void *parsed_result,
5364 __rte_unused struct cmdline *cl,
5365 __rte_unused void *data)
5367 struct cmd_set_bypass_mode_result *res = parsed_result;
5368 portid_t port_id = res->port_id;
5369 int32_t rc = -EINVAL;
5371 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5372 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5374 if (!strcmp(res->value, "bypass"))
5375 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5376 else if (!strcmp(res->value, "isolate"))
5377 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5379 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5381 /* Set the bypass mode for the relevant port. */
5382 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5385 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5388 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5389 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5391 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5392 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5394 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5395 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5397 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5398 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5399 value, "normal#bypass#isolate");
5400 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5401 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5404 cmdline_parse_inst_t cmd_set_bypass_mode = {
5405 .f = cmd_set_bypass_mode_parsed,
5406 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5407 "Set the NIC bypass mode for port_id",
5410 (void *)&cmd_setbypass_mode_set,
5411 (void *)&cmd_setbypass_mode_bypass,
5412 (void *)&cmd_setbypass_mode_mode,
5413 (void *)&cmd_setbypass_mode_value,
5414 (void *)&cmd_setbypass_mode_port,
5419 /* *** SET NIC BYPASS EVENT *** */
5420 struct cmd_set_bypass_event_result {
5421 cmdline_fixed_string_t set;
5422 cmdline_fixed_string_t bypass;
5423 cmdline_fixed_string_t event;
5424 cmdline_fixed_string_t event_value;
5425 cmdline_fixed_string_t mode;
5426 cmdline_fixed_string_t mode_value;
5431 cmd_set_bypass_event_parsed(void *parsed_result,
5432 __rte_unused struct cmdline *cl,
5433 __rte_unused void *data)
5435 int32_t rc = -EINVAL;
5436 struct cmd_set_bypass_event_result *res = parsed_result;
5437 portid_t port_id = res->port_id;
5439 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5440 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5441 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5443 if (!strcmp(res->event_value, "timeout"))
5444 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5445 else if (!strcmp(res->event_value, "os_on"))
5446 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5447 else if (!strcmp(res->event_value, "os_off"))
5448 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5449 else if (!strcmp(res->event_value, "power_on"))
5450 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5451 else if (!strcmp(res->event_value, "power_off"))
5452 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5454 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5456 if (!strcmp(res->mode_value, "bypass"))
5457 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5458 else if (!strcmp(res->mode_value, "isolate"))
5459 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5461 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5463 /* Set the watchdog timeout. */
5464 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5467 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5468 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5472 printf("Failed to set timeout value %u "
5473 "for port %d, errto code: %d.\n",
5474 bypass_timeout, port_id, rc);
5478 /* Set the bypass event to transition to bypass mode. */
5479 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5484 printf("\t Failed to set bypass event for port = %d.\n",
5488 cmdline_parse_token_string_t cmd_setbypass_event_set =
5489 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5491 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5492 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5494 cmdline_parse_token_string_t cmd_setbypass_event_event =
5495 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5497 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5498 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5499 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5500 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5501 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5503 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5504 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5505 mode_value, "normal#bypass#isolate");
5506 cmdline_parse_token_num_t cmd_setbypass_event_port =
5507 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5510 cmdline_parse_inst_t cmd_set_bypass_event = {
5511 .f = cmd_set_bypass_event_parsed,
5512 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5513 "power_off mode normal|bypass|isolate <port_id>: "
5514 "Set the NIC bypass event mode for port_id",
5517 (void *)&cmd_setbypass_event_set,
5518 (void *)&cmd_setbypass_event_bypass,
5519 (void *)&cmd_setbypass_event_event,
5520 (void *)&cmd_setbypass_event_event_value,
5521 (void *)&cmd_setbypass_event_mode,
5522 (void *)&cmd_setbypass_event_mode_value,
5523 (void *)&cmd_setbypass_event_port,
5529 /* *** SET NIC BYPASS TIMEOUT *** */
5530 struct cmd_set_bypass_timeout_result {
5531 cmdline_fixed_string_t set;
5532 cmdline_fixed_string_t bypass;
5533 cmdline_fixed_string_t timeout;
5534 cmdline_fixed_string_t value;
5538 cmd_set_bypass_timeout_parsed(void *parsed_result,
5539 __rte_unused struct cmdline *cl,
5540 __rte_unused void *data)
5542 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5544 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5545 if (!strcmp(res->value, "1.5"))
5546 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5547 else if (!strcmp(res->value, "2"))
5548 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5549 else if (!strcmp(res->value, "3"))
5550 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5551 else if (!strcmp(res->value, "4"))
5552 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5553 else if (!strcmp(res->value, "8"))
5554 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5555 else if (!strcmp(res->value, "16"))
5556 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5557 else if (!strcmp(res->value, "32"))
5558 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5560 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5564 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5565 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5567 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5568 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5570 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5571 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5572 timeout, "timeout");
5573 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5574 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5575 value, "0#1.5#2#3#4#8#16#32");
5577 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5578 .f = cmd_set_bypass_timeout_parsed,
5579 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5580 "Set the NIC bypass watchdog timeout in seconds",
5583 (void *)&cmd_setbypass_timeout_set,
5584 (void *)&cmd_setbypass_timeout_bypass,
5585 (void *)&cmd_setbypass_timeout_timeout,
5586 (void *)&cmd_setbypass_timeout_value,
5591 /* *** SHOW NIC BYPASS MODE *** */
5592 struct cmd_show_bypass_config_result {
5593 cmdline_fixed_string_t show;
5594 cmdline_fixed_string_t bypass;
5595 cmdline_fixed_string_t config;
5600 cmd_show_bypass_config_parsed(void *parsed_result,
5601 __rte_unused struct cmdline *cl,
5602 __rte_unused void *data)
5604 struct cmd_show_bypass_config_result *res = parsed_result;
5605 portid_t port_id = res->port_id;
5607 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5608 uint32_t event_mode;
5609 uint32_t bypass_mode;
5610 uint32_t timeout = bypass_timeout;
5613 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5614 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5615 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5616 {"UNKNOWN", "normal", "bypass", "isolate"};
5617 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5625 /* Display the bypass mode.*/
5626 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5627 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5631 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5632 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5634 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5637 /* Display the bypass timeout.*/
5638 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5639 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5641 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5643 /* Display the bypass events and associated modes. */
5644 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5646 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5647 printf("\tFailed to get bypass mode for event = %s\n",
5650 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5651 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5653 printf("\tbypass event: %-16s = %s\n", events[i],
5659 printf("\tFailed to get bypass configuration for port = %d\n",
5663 cmdline_parse_token_string_t cmd_showbypass_config_show =
5664 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5666 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5667 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5669 cmdline_parse_token_string_t cmd_showbypass_config_config =
5670 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5672 cmdline_parse_token_num_t cmd_showbypass_config_port =
5673 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5676 cmdline_parse_inst_t cmd_show_bypass_config = {
5677 .f = cmd_show_bypass_config_parsed,
5678 .help_str = "show bypass config <port_id>: "
5679 "Show the NIC bypass config for port_id",
5682 (void *)&cmd_showbypass_config_show,
5683 (void *)&cmd_showbypass_config_bypass,
5684 (void *)&cmd_showbypass_config_config,
5685 (void *)&cmd_showbypass_config_port,
5690 #ifdef RTE_LIBRTE_PMD_BOND
5691 /* *** SET BONDING MODE *** */
5692 struct cmd_set_bonding_mode_result {
5693 cmdline_fixed_string_t set;
5694 cmdline_fixed_string_t bonding;
5695 cmdline_fixed_string_t mode;
5700 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5701 __rte_unused struct cmdline *cl,
5702 __rte_unused void *data)
5704 struct cmd_set_bonding_mode_result *res = parsed_result;
5705 portid_t port_id = res->port_id;
5707 /* Set the bonding mode for the relevant port. */
5708 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5709 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5712 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5713 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5715 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5716 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5717 bonding, "bonding");
5718 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5719 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5721 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5722 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5724 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5725 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5728 cmdline_parse_inst_t cmd_set_bonding_mode = {
5729 .f = cmd_set_bonding_mode_parsed,
5730 .help_str = "set bonding mode <mode_value> <port_id>: "
5731 "Set the bonding mode for port_id",
5734 (void *) &cmd_setbonding_mode_set,
5735 (void *) &cmd_setbonding_mode_bonding,
5736 (void *) &cmd_setbonding_mode_mode,
5737 (void *) &cmd_setbonding_mode_value,
5738 (void *) &cmd_setbonding_mode_port,
5743 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5744 struct cmd_set_bonding_lacp_dedicated_queues_result {
5745 cmdline_fixed_string_t set;
5746 cmdline_fixed_string_t bonding;
5747 cmdline_fixed_string_t lacp;
5748 cmdline_fixed_string_t dedicated_queues;
5750 cmdline_fixed_string_t mode;
5753 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5754 __rte_unused struct cmdline *cl,
5755 __rte_unused void *data)
5757 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5758 portid_t port_id = res->port_id;
5759 struct rte_port *port;
5761 port = &ports[port_id];
5763 /** Check if the port is not started **/
5764 if (port->port_status != RTE_PORT_STOPPED) {
5765 printf("Please stop port %d first\n", port_id);
5769 if (!strcmp(res->mode, "enable")) {
5770 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5771 printf("Dedicate queues for LACP control packets"
5774 printf("Enabling dedicate queues for LACP control "
5775 "packets on port %d failed\n", port_id);
5776 } else if (!strcmp(res->mode, "disable")) {
5777 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5778 printf("Dedicated queues for LACP control packets "
5781 printf("Disabling dedicated queues for LACP control "
5782 "traffic on port %d failed\n", port_id);
5786 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5787 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5789 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5790 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5791 bonding, "bonding");
5792 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5793 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5795 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5796 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5797 dedicated_queues, "dedicated_queues");
5798 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5799 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5801 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5802 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5803 mode, "enable#disable");
5805 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5806 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5807 .help_str = "set bonding lacp dedicated_queues <port_id> "
5809 "Enable/disable dedicated queues for LACP control traffic for port_id",
5812 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5813 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5814 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5815 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5816 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5817 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5822 /* *** SET BALANCE XMIT POLICY *** */
5823 struct cmd_set_bonding_balance_xmit_policy_result {
5824 cmdline_fixed_string_t set;
5825 cmdline_fixed_string_t bonding;
5826 cmdline_fixed_string_t balance_xmit_policy;
5828 cmdline_fixed_string_t policy;
5831 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5832 __rte_unused struct cmdline *cl,
5833 __rte_unused void *data)
5835 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5836 portid_t port_id = res->port_id;
5839 if (!strcmp(res->policy, "l2")) {
5840 policy = BALANCE_XMIT_POLICY_LAYER2;
5841 } else if (!strcmp(res->policy, "l23")) {
5842 policy = BALANCE_XMIT_POLICY_LAYER23;
5843 } else if (!strcmp(res->policy, "l34")) {
5844 policy = BALANCE_XMIT_POLICY_LAYER34;
5846 printf("\t Invalid xmit policy selection");
5850 /* Set the bonding mode for the relevant port. */
5851 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5852 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5857 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5858 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5860 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5861 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5862 bonding, "bonding");
5863 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5864 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5865 balance_xmit_policy, "balance_xmit_policy");
5866 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5867 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5869 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5870 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5871 policy, "l2#l23#l34");
5873 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5874 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5875 .help_str = "set bonding balance_xmit_policy <port_id> "
5877 "Set the bonding balance_xmit_policy for port_id",
5880 (void *)&cmd_setbonding_balance_xmit_policy_set,
5881 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5882 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5883 (void *)&cmd_setbonding_balance_xmit_policy_port,
5884 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5889 /* *** SHOW NIC BONDING CONFIGURATION *** */
5890 struct cmd_show_bonding_config_result {
5891 cmdline_fixed_string_t show;
5892 cmdline_fixed_string_t bonding;
5893 cmdline_fixed_string_t config;
5897 static void cmd_show_bonding_config_parsed(void *parsed_result,
5898 __rte_unused struct cmdline *cl,
5899 __rte_unused void *data)
5901 struct cmd_show_bonding_config_result *res = parsed_result;
5902 int bonding_mode, agg_mode;
5903 portid_t slaves[RTE_MAX_ETHPORTS];
5904 int num_slaves, num_active_slaves;
5907 portid_t port_id = res->port_id;
5909 /* Display the bonding mode.*/
5910 bonding_mode = rte_eth_bond_mode_get(port_id);
5911 if (bonding_mode < 0) {
5912 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5915 printf("\tBonding mode: %d\n", bonding_mode);
5917 if (bonding_mode == BONDING_MODE_BALANCE) {
5918 int balance_xmit_policy;
5920 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5921 if (balance_xmit_policy < 0) {
5922 printf("\tFailed to get balance xmit policy for port = %d\n",
5926 printf("\tBalance Xmit Policy: ");
5928 switch (balance_xmit_policy) {
5929 case BALANCE_XMIT_POLICY_LAYER2:
5930 printf("BALANCE_XMIT_POLICY_LAYER2");
5932 case BALANCE_XMIT_POLICY_LAYER23:
5933 printf("BALANCE_XMIT_POLICY_LAYER23");
5935 case BALANCE_XMIT_POLICY_LAYER34:
5936 printf("BALANCE_XMIT_POLICY_LAYER34");
5943 if (bonding_mode == BONDING_MODE_8023AD) {
5944 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5945 printf("\tIEEE802.3AD Aggregator Mode: ");
5948 printf("bandwidth");
5960 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5962 if (num_slaves < 0) {
5963 printf("\tFailed to get slave list for port = %d\n", port_id);
5966 if (num_slaves > 0) {
5967 printf("\tSlaves (%d): [", num_slaves);
5968 for (i = 0; i < num_slaves - 1; i++)
5969 printf("%d ", slaves[i]);
5971 printf("%d]\n", slaves[num_slaves - 1]);
5973 printf("\tSlaves: []\n");
5977 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5980 if (num_active_slaves < 0) {
5981 printf("\tFailed to get active slave list for port = %d\n", port_id);
5984 if (num_active_slaves > 0) {
5985 printf("\tActive Slaves (%d): [", num_active_slaves);
5986 for (i = 0; i < num_active_slaves - 1; i++)
5987 printf("%d ", slaves[i]);
5989 printf("%d]\n", slaves[num_active_slaves - 1]);
5992 printf("\tActive Slaves: []\n");
5996 primary_id = rte_eth_bond_primary_get(port_id);
5997 if (primary_id < 0) {
5998 printf("\tFailed to get primary slave for port = %d\n", port_id);
6001 printf("\tPrimary: [%d]\n", primary_id);
6005 cmdline_parse_token_string_t cmd_showbonding_config_show =
6006 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6008 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6009 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6010 bonding, "bonding");
6011 cmdline_parse_token_string_t cmd_showbonding_config_config =
6012 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6014 cmdline_parse_token_num_t cmd_showbonding_config_port =
6015 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6018 cmdline_parse_inst_t cmd_show_bonding_config = {
6019 .f = cmd_show_bonding_config_parsed,
6020 .help_str = "show bonding config <port_id>: "
6021 "Show the bonding config for port_id",
6024 (void *)&cmd_showbonding_config_show,
6025 (void *)&cmd_showbonding_config_bonding,
6026 (void *)&cmd_showbonding_config_config,
6027 (void *)&cmd_showbonding_config_port,
6032 /* *** SET BONDING PRIMARY *** */
6033 struct cmd_set_bonding_primary_result {
6034 cmdline_fixed_string_t set;
6035 cmdline_fixed_string_t bonding;
6036 cmdline_fixed_string_t primary;
6041 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6042 __rte_unused struct cmdline *cl,
6043 __rte_unused void *data)
6045 struct cmd_set_bonding_primary_result *res = parsed_result;
6046 portid_t master_port_id = res->port_id;
6047 portid_t slave_port_id = res->slave_id;
6049 /* Set the primary slave for a bonded device. */
6050 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6051 printf("\t Failed to set primary slave for port = %d.\n",
6058 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6059 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6061 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6062 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6063 bonding, "bonding");
6064 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6065 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6066 primary, "primary");
6067 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6068 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6070 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6071 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6074 cmdline_parse_inst_t cmd_set_bonding_primary = {
6075 .f = cmd_set_bonding_primary_parsed,
6076 .help_str = "set bonding primary <slave_id> <port_id>: "
6077 "Set the primary slave for port_id",
6080 (void *)&cmd_setbonding_primary_set,
6081 (void *)&cmd_setbonding_primary_bonding,
6082 (void *)&cmd_setbonding_primary_primary,
6083 (void *)&cmd_setbonding_primary_slave,
6084 (void *)&cmd_setbonding_primary_port,
6089 /* *** ADD SLAVE *** */
6090 struct cmd_add_bonding_slave_result {
6091 cmdline_fixed_string_t add;
6092 cmdline_fixed_string_t bonding;
6093 cmdline_fixed_string_t slave;
6098 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6099 __rte_unused struct cmdline *cl,
6100 __rte_unused void *data)
6102 struct cmd_add_bonding_slave_result *res = parsed_result;
6103 portid_t master_port_id = res->port_id;
6104 portid_t slave_port_id = res->slave_id;
6106 /* add the slave for a bonded device. */
6107 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6108 printf("\t Failed to add slave %d to master port = %d.\n",
6109 slave_port_id, master_port_id);
6113 set_port_slave_flag(slave_port_id);
6116 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6117 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6119 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6120 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6121 bonding, "bonding");
6122 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6123 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6125 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6126 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6128 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6129 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6132 cmdline_parse_inst_t cmd_add_bonding_slave = {
6133 .f = cmd_add_bonding_slave_parsed,
6134 .help_str = "add bonding slave <slave_id> <port_id>: "
6135 "Add a slave device to a bonded device",
6138 (void *)&cmd_addbonding_slave_add,
6139 (void *)&cmd_addbonding_slave_bonding,
6140 (void *)&cmd_addbonding_slave_slave,
6141 (void *)&cmd_addbonding_slave_slaveid,
6142 (void *)&cmd_addbonding_slave_port,
6147 /* *** REMOVE SLAVE *** */
6148 struct cmd_remove_bonding_slave_result {
6149 cmdline_fixed_string_t remove;
6150 cmdline_fixed_string_t bonding;
6151 cmdline_fixed_string_t slave;
6156 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6157 __rte_unused struct cmdline *cl,
6158 __rte_unused void *data)
6160 struct cmd_remove_bonding_slave_result *res = parsed_result;
6161 portid_t master_port_id = res->port_id;
6162 portid_t slave_port_id = res->slave_id;
6164 /* remove the slave from a bonded device. */
6165 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6166 printf("\t Failed to remove slave %d from master port = %d.\n",
6167 slave_port_id, master_port_id);
6171 clear_port_slave_flag(slave_port_id);
6174 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6175 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6177 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6178 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6179 bonding, "bonding");
6180 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6181 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6183 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6184 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6186 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6187 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6190 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6191 .f = cmd_remove_bonding_slave_parsed,
6192 .help_str = "remove bonding slave <slave_id> <port_id>: "
6193 "Remove a slave device from a bonded device",
6196 (void *)&cmd_removebonding_slave_remove,
6197 (void *)&cmd_removebonding_slave_bonding,
6198 (void *)&cmd_removebonding_slave_slave,
6199 (void *)&cmd_removebonding_slave_slaveid,
6200 (void *)&cmd_removebonding_slave_port,
6205 /* *** CREATE BONDED DEVICE *** */
6206 struct cmd_create_bonded_device_result {
6207 cmdline_fixed_string_t create;
6208 cmdline_fixed_string_t bonded;
6209 cmdline_fixed_string_t device;
6214 static int bond_dev_num = 0;
6216 static void cmd_create_bonded_device_parsed(void *parsed_result,
6217 __rte_unused struct cmdline *cl,
6218 __rte_unused void *data)
6220 struct cmd_create_bonded_device_result *res = parsed_result;
6221 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6225 if (test_done == 0) {
6226 printf("Please stop forwarding first\n");
6230 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6233 /* Create a new bonded device. */
6234 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6236 printf("\t Failed to create bonded device.\n");
6239 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6242 /* Update number of ports */
6243 nb_ports = rte_eth_dev_count_avail();
6244 reconfig(port_id, res->socket);
6245 ret = rte_eth_promiscuous_enable(port_id);
6247 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6248 port_id, rte_strerror(-ret));
6250 ports[port_id].need_setup = 0;
6251 ports[port_id].port_status = RTE_PORT_STOPPED;
6256 cmdline_parse_token_string_t cmd_createbonded_device_create =
6257 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6259 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6260 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6262 cmdline_parse_token_string_t cmd_createbonded_device_device =
6263 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6265 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6266 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6268 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6269 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6272 cmdline_parse_inst_t cmd_create_bonded_device = {
6273 .f = cmd_create_bonded_device_parsed,
6274 .help_str = "create bonded device <mode> <socket>: "
6275 "Create a new bonded device with specific bonding mode and socket",
6278 (void *)&cmd_createbonded_device_create,
6279 (void *)&cmd_createbonded_device_bonded,
6280 (void *)&cmd_createbonded_device_device,
6281 (void *)&cmd_createbonded_device_mode,
6282 (void *)&cmd_createbonded_device_socket,
6287 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6288 struct cmd_set_bond_mac_addr_result {
6289 cmdline_fixed_string_t set;
6290 cmdline_fixed_string_t bonding;
6291 cmdline_fixed_string_t mac_addr;
6293 struct rte_ether_addr address;
6296 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6297 __rte_unused struct cmdline *cl,
6298 __rte_unused void *data)
6300 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6303 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6306 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6308 /* check the return value and print it if is < 0 */
6310 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6313 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6314 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6315 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6316 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6318 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6319 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6321 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6322 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6324 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6325 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6327 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6328 .f = cmd_set_bond_mac_addr_parsed,
6330 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6332 (void *)&cmd_set_bond_mac_addr_set,
6333 (void *)&cmd_set_bond_mac_addr_bonding,
6334 (void *)&cmd_set_bond_mac_addr_mac,
6335 (void *)&cmd_set_bond_mac_addr_portnum,
6336 (void *)&cmd_set_bond_mac_addr_addr,
6342 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6343 struct cmd_set_bond_mon_period_result {
6344 cmdline_fixed_string_t set;
6345 cmdline_fixed_string_t bonding;
6346 cmdline_fixed_string_t mon_period;
6351 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6352 __rte_unused struct cmdline *cl,
6353 __rte_unused void *data)
6355 struct cmd_set_bond_mon_period_result *res = parsed_result;
6358 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6360 /* check the return value and print it if is < 0 */
6362 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6365 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6366 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6368 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6369 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6370 bonding, "bonding");
6371 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6372 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6373 mon_period, "mon_period");
6374 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6375 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6377 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6378 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6381 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6382 .f = cmd_set_bond_mon_period_parsed,
6384 .help_str = "set bonding mon_period <port_id> <period_ms>",
6386 (void *)&cmd_set_bond_mon_period_set,
6387 (void *)&cmd_set_bond_mon_period_bonding,
6388 (void *)&cmd_set_bond_mon_period_mon_period,
6389 (void *)&cmd_set_bond_mon_period_portnum,
6390 (void *)&cmd_set_bond_mon_period_period_ms,
6397 struct cmd_set_bonding_agg_mode_policy_result {
6398 cmdline_fixed_string_t set;
6399 cmdline_fixed_string_t bonding;
6400 cmdline_fixed_string_t agg_mode;
6402 cmdline_fixed_string_t policy;
6407 cmd_set_bonding_agg_mode(void *parsed_result,
6408 __rte_unused struct cmdline *cl,
6409 __rte_unused void *data)
6411 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6412 uint8_t policy = AGG_BANDWIDTH;
6414 if (!strcmp(res->policy, "bandwidth"))
6415 policy = AGG_BANDWIDTH;
6416 else if (!strcmp(res->policy, "stable"))
6417 policy = AGG_STABLE;
6418 else if (!strcmp(res->policy, "count"))
6421 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6425 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6426 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6428 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6429 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6430 bonding, "bonding");
6432 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6433 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6434 agg_mode, "agg_mode");
6436 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6437 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6440 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6441 TOKEN_STRING_INITIALIZER(
6442 struct cmd_set_bonding_balance_xmit_policy_result,
6443 policy, "stable#bandwidth#count");
6445 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6446 .f = cmd_set_bonding_agg_mode,
6448 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6450 (void *)&cmd_set_bonding_agg_mode_set,
6451 (void *)&cmd_set_bonding_agg_mode_bonding,
6452 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6453 (void *)&cmd_set_bonding_agg_mode_portnum,
6454 (void *)&cmd_set_bonding_agg_mode_policy_string,
6460 #endif /* RTE_LIBRTE_PMD_BOND */
6462 /* *** SET FORWARDING MODE *** */
6463 struct cmd_set_fwd_mode_result {
6464 cmdline_fixed_string_t set;
6465 cmdline_fixed_string_t fwd;
6466 cmdline_fixed_string_t mode;
6469 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6470 __rte_unused struct cmdline *cl,
6471 __rte_unused void *data)
6473 struct cmd_set_fwd_mode_result *res = parsed_result;
6476 set_pkt_forwarding_mode(res->mode);
6479 cmdline_parse_token_string_t cmd_setfwd_set =
6480 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6481 cmdline_parse_token_string_t cmd_setfwd_fwd =
6482 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6483 cmdline_parse_token_string_t cmd_setfwd_mode =
6484 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6485 "" /* defined at init */);
6487 cmdline_parse_inst_t cmd_set_fwd_mode = {
6488 .f = cmd_set_fwd_mode_parsed,
6490 .help_str = NULL, /* defined at init */
6492 (void *)&cmd_setfwd_set,
6493 (void *)&cmd_setfwd_fwd,
6494 (void *)&cmd_setfwd_mode,
6499 static void cmd_set_fwd_mode_init(void)
6502 static char token[128];
6503 static char help[256];
6504 cmdline_parse_token_string_t *token_struct;
6506 modes = list_pkt_forwarding_modes();
6507 snprintf(help, sizeof(help), "set fwd %s: "
6508 "Set packet forwarding mode", modes);
6509 cmd_set_fwd_mode.help_str = help;
6511 /* string token separator is # */
6512 for (c = token; *modes != '\0'; modes++)
6517 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6518 token_struct->string_data.str = token;
6521 /* *** SET RETRY FORWARDING MODE *** */
6522 struct cmd_set_fwd_retry_mode_result {
6523 cmdline_fixed_string_t set;
6524 cmdline_fixed_string_t fwd;
6525 cmdline_fixed_string_t mode;
6526 cmdline_fixed_string_t retry;
6529 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6530 __rte_unused struct cmdline *cl,
6531 __rte_unused void *data)
6533 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6536 set_pkt_forwarding_mode(res->mode);
6539 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6540 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6542 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6543 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6545 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6546 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6548 "" /* defined at init */);
6549 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6550 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6553 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6554 .f = cmd_set_fwd_retry_mode_parsed,
6556 .help_str = NULL, /* defined at init */
6558 (void *)&cmd_setfwd_retry_set,
6559 (void *)&cmd_setfwd_retry_fwd,
6560 (void *)&cmd_setfwd_retry_mode,
6561 (void *)&cmd_setfwd_retry_retry,
6566 static void cmd_set_fwd_retry_mode_init(void)
6569 static char token[128];
6570 static char help[256];
6571 cmdline_parse_token_string_t *token_struct;
6573 modes = list_pkt_forwarding_retry_modes();
6574 snprintf(help, sizeof(help), "set fwd %s retry: "
6575 "Set packet forwarding mode with retry", modes);
6576 cmd_set_fwd_retry_mode.help_str = help;
6578 /* string token separator is # */
6579 for (c = token; *modes != '\0'; modes++)
6584 token_struct = (cmdline_parse_token_string_t *)
6585 cmd_set_fwd_retry_mode.tokens[2];
6586 token_struct->string_data.str = token;
6589 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6590 struct cmd_set_burst_tx_retry_result {
6591 cmdline_fixed_string_t set;
6592 cmdline_fixed_string_t burst;
6593 cmdline_fixed_string_t tx;
6594 cmdline_fixed_string_t delay;
6596 cmdline_fixed_string_t retry;
6600 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6601 __rte_unused struct cmdline *cl,
6602 __rte_unused void *data)
6604 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6606 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6607 && !strcmp(res->tx, "tx")) {
6608 if (!strcmp(res->delay, "delay"))
6609 burst_tx_delay_time = res->time;
6610 if (!strcmp(res->retry, "retry"))
6611 burst_tx_retry_num = res->retry_num;
6616 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6617 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6618 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6619 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6621 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6622 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6623 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6624 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6625 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6626 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6627 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6628 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6629 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6630 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6632 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6633 .f = cmd_set_burst_tx_retry_parsed,
6634 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6636 (void *)&cmd_set_burst_tx_retry_set,
6637 (void *)&cmd_set_burst_tx_retry_burst,
6638 (void *)&cmd_set_burst_tx_retry_tx,
6639 (void *)&cmd_set_burst_tx_retry_delay,
6640 (void *)&cmd_set_burst_tx_retry_time,
6641 (void *)&cmd_set_burst_tx_retry_retry,
6642 (void *)&cmd_set_burst_tx_retry_retry_num,
6647 /* *** SET PROMISC MODE *** */
6648 struct cmd_set_promisc_mode_result {
6649 cmdline_fixed_string_t set;
6650 cmdline_fixed_string_t promisc;
6651 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6652 uint16_t port_num; /* valid if "allports" argument == 0 */
6653 cmdline_fixed_string_t mode;
6656 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6657 __rte_unused struct cmdline *cl,
6660 struct cmd_set_promisc_mode_result *res = parsed_result;
6664 if (!strcmp(res->mode, "on"))
6671 RTE_ETH_FOREACH_DEV(i)
6672 eth_set_promisc_mode(i, enable);
6674 eth_set_promisc_mode(res->port_num, enable);
6678 cmdline_parse_token_string_t cmd_setpromisc_set =
6679 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6680 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6681 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6683 cmdline_parse_token_string_t cmd_setpromisc_portall =
6684 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6686 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6687 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6689 cmdline_parse_token_string_t cmd_setpromisc_mode =
6690 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6693 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6694 .f = cmd_set_promisc_mode_parsed,
6696 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6698 (void *)&cmd_setpromisc_set,
6699 (void *)&cmd_setpromisc_promisc,
6700 (void *)&cmd_setpromisc_portall,
6701 (void *)&cmd_setpromisc_mode,
6706 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6707 .f = cmd_set_promisc_mode_parsed,
6709 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6711 (void *)&cmd_setpromisc_set,
6712 (void *)&cmd_setpromisc_promisc,
6713 (void *)&cmd_setpromisc_portnum,
6714 (void *)&cmd_setpromisc_mode,
6719 /* *** SET ALLMULTI MODE *** */
6720 struct cmd_set_allmulti_mode_result {
6721 cmdline_fixed_string_t set;
6722 cmdline_fixed_string_t allmulti;
6723 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6724 uint16_t port_num; /* valid if "allports" argument == 0 */
6725 cmdline_fixed_string_t mode;
6728 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6729 __rte_unused struct cmdline *cl,
6732 struct cmd_set_allmulti_mode_result *res = parsed_result;
6736 if (!strcmp(res->mode, "on"))
6743 RTE_ETH_FOREACH_DEV(i) {
6744 eth_set_allmulticast_mode(i, enable);
6748 eth_set_allmulticast_mode(res->port_num, enable);
6752 cmdline_parse_token_string_t cmd_setallmulti_set =
6753 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6754 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6755 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6757 cmdline_parse_token_string_t cmd_setallmulti_portall =
6758 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6760 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6761 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6763 cmdline_parse_token_string_t cmd_setallmulti_mode =
6764 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6767 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6768 .f = cmd_set_allmulti_mode_parsed,
6770 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6772 (void *)&cmd_setallmulti_set,
6773 (void *)&cmd_setallmulti_allmulti,
6774 (void *)&cmd_setallmulti_portall,
6775 (void *)&cmd_setallmulti_mode,
6780 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6781 .f = cmd_set_allmulti_mode_parsed,
6783 .help_str = "set allmulti <port_id> on|off: "
6784 "Set allmulti mode on port_id",
6786 (void *)&cmd_setallmulti_set,
6787 (void *)&cmd_setallmulti_allmulti,
6788 (void *)&cmd_setallmulti_portnum,
6789 (void *)&cmd_setallmulti_mode,
6794 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6795 struct cmd_link_flow_ctrl_set_result {
6796 cmdline_fixed_string_t set;
6797 cmdline_fixed_string_t flow_ctrl;
6798 cmdline_fixed_string_t rx;
6799 cmdline_fixed_string_t rx_lfc_mode;
6800 cmdline_fixed_string_t tx;
6801 cmdline_fixed_string_t tx_lfc_mode;
6802 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6803 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6804 cmdline_fixed_string_t autoneg_str;
6805 cmdline_fixed_string_t autoneg;
6806 cmdline_fixed_string_t hw_str;
6807 uint32_t high_water;
6808 cmdline_fixed_string_t lw_str;
6810 cmdline_fixed_string_t pt_str;
6811 uint16_t pause_time;
6812 cmdline_fixed_string_t xon_str;
6817 cmdline_parse_token_string_t cmd_lfc_set_set =
6818 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6820 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6821 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6822 flow_ctrl, "flow_ctrl");
6823 cmdline_parse_token_string_t cmd_lfc_set_rx =
6824 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6826 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6827 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6828 rx_lfc_mode, "on#off");
6829 cmdline_parse_token_string_t cmd_lfc_set_tx =
6830 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6832 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6833 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6834 tx_lfc_mode, "on#off");
6835 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6836 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6837 hw_str, "high_water");
6838 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6839 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6840 high_water, UINT32);
6841 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6842 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6843 lw_str, "low_water");
6844 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6845 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6847 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6848 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6849 pt_str, "pause_time");
6850 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6851 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6852 pause_time, UINT16);
6853 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6854 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6855 xon_str, "send_xon");
6856 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6857 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6859 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6860 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6861 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6862 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6863 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6864 mac_ctrl_frame_fwd_mode, "on#off");
6865 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6866 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6867 autoneg_str, "autoneg");
6868 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6869 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6871 cmdline_parse_token_num_t cmd_lfc_set_portid =
6872 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6875 /* forward declaration */
6877 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6880 cmdline_parse_inst_t cmd_link_flow_control_set = {
6881 .f = cmd_link_flow_ctrl_set_parsed,
6883 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6884 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6885 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6887 (void *)&cmd_lfc_set_set,
6888 (void *)&cmd_lfc_set_flow_ctrl,
6889 (void *)&cmd_lfc_set_rx,
6890 (void *)&cmd_lfc_set_rx_mode,
6891 (void *)&cmd_lfc_set_tx,
6892 (void *)&cmd_lfc_set_tx_mode,
6893 (void *)&cmd_lfc_set_high_water,
6894 (void *)&cmd_lfc_set_low_water,
6895 (void *)&cmd_lfc_set_pause_time,
6896 (void *)&cmd_lfc_set_send_xon,
6897 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6898 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6899 (void *)&cmd_lfc_set_autoneg_str,
6900 (void *)&cmd_lfc_set_autoneg,
6901 (void *)&cmd_lfc_set_portid,
6906 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6907 .f = cmd_link_flow_ctrl_set_parsed,
6908 .data = (void *)&cmd_link_flow_control_set_rx,
6909 .help_str = "set flow_ctrl rx on|off <port_id>: "
6910 "Change rx flow control parameter",
6912 (void *)&cmd_lfc_set_set,
6913 (void *)&cmd_lfc_set_flow_ctrl,
6914 (void *)&cmd_lfc_set_rx,
6915 (void *)&cmd_lfc_set_rx_mode,
6916 (void *)&cmd_lfc_set_portid,
6921 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6922 .f = cmd_link_flow_ctrl_set_parsed,
6923 .data = (void *)&cmd_link_flow_control_set_tx,
6924 .help_str = "set flow_ctrl tx on|off <port_id>: "
6925 "Change tx flow control parameter",
6927 (void *)&cmd_lfc_set_set,
6928 (void *)&cmd_lfc_set_flow_ctrl,
6929 (void *)&cmd_lfc_set_tx,
6930 (void *)&cmd_lfc_set_tx_mode,
6931 (void *)&cmd_lfc_set_portid,
6936 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6937 .f = cmd_link_flow_ctrl_set_parsed,
6938 .data = (void *)&cmd_link_flow_control_set_hw,
6939 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6940 "Change high water flow control parameter",
6942 (void *)&cmd_lfc_set_set,
6943 (void *)&cmd_lfc_set_flow_ctrl,
6944 (void *)&cmd_lfc_set_high_water_str,
6945 (void *)&cmd_lfc_set_high_water,
6946 (void *)&cmd_lfc_set_portid,
6951 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6952 .f = cmd_link_flow_ctrl_set_parsed,
6953 .data = (void *)&cmd_link_flow_control_set_lw,
6954 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6955 "Change low water flow control parameter",
6957 (void *)&cmd_lfc_set_set,
6958 (void *)&cmd_lfc_set_flow_ctrl,
6959 (void *)&cmd_lfc_set_low_water_str,
6960 (void *)&cmd_lfc_set_low_water,
6961 (void *)&cmd_lfc_set_portid,
6966 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6967 .f = cmd_link_flow_ctrl_set_parsed,
6968 .data = (void *)&cmd_link_flow_control_set_pt,
6969 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6970 "Change pause time flow control parameter",
6972 (void *)&cmd_lfc_set_set,
6973 (void *)&cmd_lfc_set_flow_ctrl,
6974 (void *)&cmd_lfc_set_pause_time_str,
6975 (void *)&cmd_lfc_set_pause_time,
6976 (void *)&cmd_lfc_set_portid,
6981 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6982 .f = cmd_link_flow_ctrl_set_parsed,
6983 .data = (void *)&cmd_link_flow_control_set_xon,
6984 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6985 "Change send_xon flow control parameter",
6987 (void *)&cmd_lfc_set_set,
6988 (void *)&cmd_lfc_set_flow_ctrl,
6989 (void *)&cmd_lfc_set_send_xon_str,
6990 (void *)&cmd_lfc_set_send_xon,
6991 (void *)&cmd_lfc_set_portid,
6996 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6997 .f = cmd_link_flow_ctrl_set_parsed,
6998 .data = (void *)&cmd_link_flow_control_set_macfwd,
6999 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7000 "Change mac ctrl fwd flow control parameter",
7002 (void *)&cmd_lfc_set_set,
7003 (void *)&cmd_lfc_set_flow_ctrl,
7004 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7005 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7006 (void *)&cmd_lfc_set_portid,
7011 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7012 .f = cmd_link_flow_ctrl_set_parsed,
7013 .data = (void *)&cmd_link_flow_control_set_autoneg,
7014 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7015 "Change autoneg flow control parameter",
7017 (void *)&cmd_lfc_set_set,
7018 (void *)&cmd_lfc_set_flow_ctrl,
7019 (void *)&cmd_lfc_set_autoneg_str,
7020 (void *)&cmd_lfc_set_autoneg,
7021 (void *)&cmd_lfc_set_portid,
7027 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7028 __rte_unused struct cmdline *cl,
7031 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7032 cmdline_parse_inst_t *cmd = data;
7033 struct rte_eth_fc_conf fc_conf;
7039 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7040 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7041 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7042 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7044 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7045 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7048 /* Partial command line, retrieve current configuration */
7050 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7052 printf("cannot get current flow ctrl parameters, return"
7053 "code = %d\n", ret);
7057 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7058 (fc_conf.mode == RTE_FC_FULL))
7060 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7061 (fc_conf.mode == RTE_FC_FULL))
7065 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7066 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7068 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7069 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7071 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7073 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7074 fc_conf.high_water = res->high_water;
7076 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7077 fc_conf.low_water = res->low_water;
7079 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7080 fc_conf.pause_time = res->pause_time;
7082 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7083 fc_conf.send_xon = res->send_xon;
7085 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7086 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7087 fc_conf.mac_ctrl_frame_fwd = 1;
7089 fc_conf.mac_ctrl_frame_fwd = 0;
7092 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7093 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7095 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7097 printf("bad flow contrl parameter, return code = %d \n", ret);
7100 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7101 struct cmd_priority_flow_ctrl_set_result {
7102 cmdline_fixed_string_t set;
7103 cmdline_fixed_string_t pfc_ctrl;
7104 cmdline_fixed_string_t rx;
7105 cmdline_fixed_string_t rx_pfc_mode;
7106 cmdline_fixed_string_t tx;
7107 cmdline_fixed_string_t tx_pfc_mode;
7108 uint32_t high_water;
7110 uint16_t pause_time;
7116 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7117 __rte_unused struct cmdline *cl,
7118 __rte_unused void *data)
7120 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7121 struct rte_eth_pfc_conf pfc_conf;
7122 int rx_fc_enable, tx_fc_enable;
7126 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7127 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7128 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7129 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7131 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7132 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7135 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7136 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7137 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7138 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7139 pfc_conf.fc.high_water = res->high_water;
7140 pfc_conf.fc.low_water = res->low_water;
7141 pfc_conf.fc.pause_time = res->pause_time;
7142 pfc_conf.priority = res->priority;
7144 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7146 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7149 cmdline_parse_token_string_t cmd_pfc_set_set =
7150 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7152 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7153 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7154 pfc_ctrl, "pfc_ctrl");
7155 cmdline_parse_token_string_t cmd_pfc_set_rx =
7156 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7158 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7159 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7160 rx_pfc_mode, "on#off");
7161 cmdline_parse_token_string_t cmd_pfc_set_tx =
7162 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7164 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7165 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7166 tx_pfc_mode, "on#off");
7167 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7168 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7169 high_water, UINT32);
7170 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7171 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7173 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7174 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7175 pause_time, UINT16);
7176 cmdline_parse_token_num_t cmd_pfc_set_priority =
7177 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7179 cmdline_parse_token_num_t cmd_pfc_set_portid =
7180 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7183 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7184 .f = cmd_priority_flow_ctrl_set_parsed,
7186 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7187 "<pause_time> <priority> <port_id>: "
7188 "Configure the Ethernet priority flow control",
7190 (void *)&cmd_pfc_set_set,
7191 (void *)&cmd_pfc_set_flow_ctrl,
7192 (void *)&cmd_pfc_set_rx,
7193 (void *)&cmd_pfc_set_rx_mode,
7194 (void *)&cmd_pfc_set_tx,
7195 (void *)&cmd_pfc_set_tx_mode,
7196 (void *)&cmd_pfc_set_high_water,
7197 (void *)&cmd_pfc_set_low_water,
7198 (void *)&cmd_pfc_set_pause_time,
7199 (void *)&cmd_pfc_set_priority,
7200 (void *)&cmd_pfc_set_portid,
7205 /* *** RESET CONFIGURATION *** */
7206 struct cmd_reset_result {
7207 cmdline_fixed_string_t reset;
7208 cmdline_fixed_string_t def;
7211 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7213 __rte_unused void *data)
7215 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7216 set_def_fwd_config();
7219 cmdline_parse_token_string_t cmd_reset_set =
7220 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7221 cmdline_parse_token_string_t cmd_reset_def =
7222 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7225 cmdline_parse_inst_t cmd_reset = {
7226 .f = cmd_reset_parsed,
7228 .help_str = "set default: Reset default forwarding configuration",
7230 (void *)&cmd_reset_set,
7231 (void *)&cmd_reset_def,
7236 /* *** START FORWARDING *** */
7237 struct cmd_start_result {
7238 cmdline_fixed_string_t start;
7241 cmdline_parse_token_string_t cmd_start_start =
7242 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7244 static void cmd_start_parsed(__rte_unused void *parsed_result,
7245 __rte_unused struct cmdline *cl,
7246 __rte_unused void *data)
7248 start_packet_forwarding(0);
7251 cmdline_parse_inst_t cmd_start = {
7252 .f = cmd_start_parsed,
7254 .help_str = "start: Start packet forwarding",
7256 (void *)&cmd_start_start,
7261 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7262 struct cmd_start_tx_first_result {
7263 cmdline_fixed_string_t start;
7264 cmdline_fixed_string_t tx_first;
7268 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7269 __rte_unused struct cmdline *cl,
7270 __rte_unused void *data)
7272 start_packet_forwarding(1);
7275 cmdline_parse_token_string_t cmd_start_tx_first_start =
7276 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7278 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7279 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7280 tx_first, "tx_first");
7282 cmdline_parse_inst_t cmd_start_tx_first = {
7283 .f = cmd_start_tx_first_parsed,
7285 .help_str = "start tx_first: Start packet forwarding, "
7286 "after sending 1 burst of packets",
7288 (void *)&cmd_start_tx_first_start,
7289 (void *)&cmd_start_tx_first_tx_first,
7294 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7295 struct cmd_start_tx_first_n_result {
7296 cmdline_fixed_string_t start;
7297 cmdline_fixed_string_t tx_first;
7302 cmd_start_tx_first_n_parsed(void *parsed_result,
7303 __rte_unused struct cmdline *cl,
7304 __rte_unused void *data)
7306 struct cmd_start_tx_first_n_result *res = parsed_result;
7308 start_packet_forwarding(res->tx_num);
7311 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7312 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7314 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7315 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7316 tx_first, "tx_first");
7317 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7318 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7321 cmdline_parse_inst_t cmd_start_tx_first_n = {
7322 .f = cmd_start_tx_first_n_parsed,
7324 .help_str = "start tx_first <num>: "
7325 "packet forwarding, after sending <num> bursts of packets",
7327 (void *)&cmd_start_tx_first_n_start,
7328 (void *)&cmd_start_tx_first_n_tx_first,
7329 (void *)&cmd_start_tx_first_n_tx_num,
7334 /* *** SET LINK UP *** */
7335 struct cmd_set_link_up_result {
7336 cmdline_fixed_string_t set;
7337 cmdline_fixed_string_t link_up;
7338 cmdline_fixed_string_t port;
7342 cmdline_parse_token_string_t cmd_set_link_up_set =
7343 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7344 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7345 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7347 cmdline_parse_token_string_t cmd_set_link_up_port =
7348 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7349 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7350 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7352 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7353 __rte_unused struct cmdline *cl,
7354 __rte_unused void *data)
7356 struct cmd_set_link_up_result *res = parsed_result;
7357 dev_set_link_up(res->port_id);
7360 cmdline_parse_inst_t cmd_set_link_up = {
7361 .f = cmd_set_link_up_parsed,
7363 .help_str = "set link-up port <port id>",
7365 (void *)&cmd_set_link_up_set,
7366 (void *)&cmd_set_link_up_link_up,
7367 (void *)&cmd_set_link_up_port,
7368 (void *)&cmd_set_link_up_port_id,
7373 /* *** SET LINK DOWN *** */
7374 struct cmd_set_link_down_result {
7375 cmdline_fixed_string_t set;
7376 cmdline_fixed_string_t link_down;
7377 cmdline_fixed_string_t port;
7381 cmdline_parse_token_string_t cmd_set_link_down_set =
7382 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7383 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7384 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7386 cmdline_parse_token_string_t cmd_set_link_down_port =
7387 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7388 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7389 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7391 static void cmd_set_link_down_parsed(
7392 __rte_unused void *parsed_result,
7393 __rte_unused struct cmdline *cl,
7394 __rte_unused void *data)
7396 struct cmd_set_link_down_result *res = parsed_result;
7397 dev_set_link_down(res->port_id);
7400 cmdline_parse_inst_t cmd_set_link_down = {
7401 .f = cmd_set_link_down_parsed,
7403 .help_str = "set link-down port <port id>",
7405 (void *)&cmd_set_link_down_set,
7406 (void *)&cmd_set_link_down_link_down,
7407 (void *)&cmd_set_link_down_port,
7408 (void *)&cmd_set_link_down_port_id,
7413 /* *** SHOW CFG *** */
7414 struct cmd_showcfg_result {
7415 cmdline_fixed_string_t show;
7416 cmdline_fixed_string_t cfg;
7417 cmdline_fixed_string_t what;
7420 static void cmd_showcfg_parsed(void *parsed_result,
7421 __rte_unused struct cmdline *cl,
7422 __rte_unused void *data)
7424 struct cmd_showcfg_result *res = parsed_result;
7425 if (!strcmp(res->what, "rxtx"))
7426 rxtx_config_display();
7427 else if (!strcmp(res->what, "cores"))
7428 fwd_lcores_config_display();
7429 else if (!strcmp(res->what, "fwd"))
7430 pkt_fwd_config_display(&cur_fwd_config);
7431 else if (!strcmp(res->what, "txpkts"))
7432 show_tx_pkt_segments();
7435 cmdline_parse_token_string_t cmd_showcfg_show =
7436 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7437 cmdline_parse_token_string_t cmd_showcfg_port =
7438 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7439 cmdline_parse_token_string_t cmd_showcfg_what =
7440 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7441 "rxtx#cores#fwd#txpkts");
7443 cmdline_parse_inst_t cmd_showcfg = {
7444 .f = cmd_showcfg_parsed,
7446 .help_str = "show config rxtx|cores|fwd|txpkts",
7448 (void *)&cmd_showcfg_show,
7449 (void *)&cmd_showcfg_port,
7450 (void *)&cmd_showcfg_what,
7455 /* *** SHOW ALL PORT INFO *** */
7456 struct cmd_showportall_result {
7457 cmdline_fixed_string_t show;
7458 cmdline_fixed_string_t port;
7459 cmdline_fixed_string_t what;
7460 cmdline_fixed_string_t all;
7463 static void cmd_showportall_parsed(void *parsed_result,
7464 __rte_unused struct cmdline *cl,
7465 __rte_unused void *data)
7469 struct cmd_showportall_result *res = parsed_result;
7470 if (!strcmp(res->show, "clear")) {
7471 if (!strcmp(res->what, "stats"))
7472 RTE_ETH_FOREACH_DEV(i)
7474 else if (!strcmp(res->what, "xstats"))
7475 RTE_ETH_FOREACH_DEV(i)
7476 nic_xstats_clear(i);
7477 } else if (!strcmp(res->what, "info"))
7478 RTE_ETH_FOREACH_DEV(i)
7479 port_infos_display(i);
7480 else if (!strcmp(res->what, "summary")) {
7481 port_summary_header_display();
7482 RTE_ETH_FOREACH_DEV(i)
7483 port_summary_display(i);
7485 else if (!strcmp(res->what, "stats"))
7486 RTE_ETH_FOREACH_DEV(i)
7487 nic_stats_display(i);
7488 else if (!strcmp(res->what, "xstats"))
7489 RTE_ETH_FOREACH_DEV(i)
7490 nic_xstats_display(i);
7491 else if (!strcmp(res->what, "fdir"))
7492 RTE_ETH_FOREACH_DEV(i)
7494 else if (!strcmp(res->what, "stat_qmap"))
7495 RTE_ETH_FOREACH_DEV(i)
7496 nic_stats_mapping_display(i);
7497 else if (!strcmp(res->what, "dcb_tc"))
7498 RTE_ETH_FOREACH_DEV(i)
7499 port_dcb_info_display(i);
7500 else if (!strcmp(res->what, "cap"))
7501 RTE_ETH_FOREACH_DEV(i)
7502 port_offload_cap_display(i);
7505 cmdline_parse_token_string_t cmd_showportall_show =
7506 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7508 cmdline_parse_token_string_t cmd_showportall_port =
7509 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7510 cmdline_parse_token_string_t cmd_showportall_what =
7511 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7512 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7513 cmdline_parse_token_string_t cmd_showportall_all =
7514 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7515 cmdline_parse_inst_t cmd_showportall = {
7516 .f = cmd_showportall_parsed,
7518 .help_str = "show|clear port "
7519 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7521 (void *)&cmd_showportall_show,
7522 (void *)&cmd_showportall_port,
7523 (void *)&cmd_showportall_what,
7524 (void *)&cmd_showportall_all,
7529 /* *** SHOW PORT INFO *** */
7530 struct cmd_showport_result {
7531 cmdline_fixed_string_t show;
7532 cmdline_fixed_string_t port;
7533 cmdline_fixed_string_t what;
7537 static void cmd_showport_parsed(void *parsed_result,
7538 __rte_unused struct cmdline *cl,
7539 __rte_unused void *data)
7541 struct cmd_showport_result *res = parsed_result;
7542 if (!strcmp(res->show, "clear")) {
7543 if (!strcmp(res->what, "stats"))
7544 nic_stats_clear(res->portnum);
7545 else if (!strcmp(res->what, "xstats"))
7546 nic_xstats_clear(res->portnum);
7547 } else if (!strcmp(res->what, "info"))
7548 port_infos_display(res->portnum);
7549 else if (!strcmp(res->what, "summary")) {
7550 port_summary_header_display();
7551 port_summary_display(res->portnum);
7553 else if (!strcmp(res->what, "stats"))
7554 nic_stats_display(res->portnum);
7555 else if (!strcmp(res->what, "xstats"))
7556 nic_xstats_display(res->portnum);
7557 else if (!strcmp(res->what, "fdir"))
7558 fdir_get_infos(res->portnum);
7559 else if (!strcmp(res->what, "stat_qmap"))
7560 nic_stats_mapping_display(res->portnum);
7561 else if (!strcmp(res->what, "dcb_tc"))
7562 port_dcb_info_display(res->portnum);
7563 else if (!strcmp(res->what, "cap"))
7564 port_offload_cap_display(res->portnum);
7567 cmdline_parse_token_string_t cmd_showport_show =
7568 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7570 cmdline_parse_token_string_t cmd_showport_port =
7571 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7572 cmdline_parse_token_string_t cmd_showport_what =
7573 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7574 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7575 cmdline_parse_token_num_t cmd_showport_portnum =
7576 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7578 cmdline_parse_inst_t cmd_showport = {
7579 .f = cmd_showport_parsed,
7581 .help_str = "show|clear port "
7582 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7585 (void *)&cmd_showport_show,
7586 (void *)&cmd_showport_port,
7587 (void *)&cmd_showport_what,
7588 (void *)&cmd_showport_portnum,
7593 /* *** SHOW DEVICE INFO *** */
7594 struct cmd_showdevice_result {
7595 cmdline_fixed_string_t show;
7596 cmdline_fixed_string_t device;
7597 cmdline_fixed_string_t what;
7598 cmdline_fixed_string_t identifier;
7601 static void cmd_showdevice_parsed(void *parsed_result,
7602 __rte_unused struct cmdline *cl,
7603 __rte_unused void *data)
7605 struct cmd_showdevice_result *res = parsed_result;
7606 if (!strcmp(res->what, "info")) {
7607 if (!strcmp(res->identifier, "all"))
7608 device_infos_display(NULL);
7610 device_infos_display(res->identifier);
7614 cmdline_parse_token_string_t cmd_showdevice_show =
7615 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7617 cmdline_parse_token_string_t cmd_showdevice_device =
7618 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7619 cmdline_parse_token_string_t cmd_showdevice_what =
7620 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7622 cmdline_parse_token_string_t cmd_showdevice_identifier =
7623 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7626 cmdline_parse_inst_t cmd_showdevice = {
7627 .f = cmd_showdevice_parsed,
7629 .help_str = "show device info <identifier>|all",
7631 (void *)&cmd_showdevice_show,
7632 (void *)&cmd_showdevice_device,
7633 (void *)&cmd_showdevice_what,
7634 (void *)&cmd_showdevice_identifier,
7638 /* *** SHOW QUEUE INFO *** */
7639 struct cmd_showqueue_result {
7640 cmdline_fixed_string_t show;
7641 cmdline_fixed_string_t type;
7642 cmdline_fixed_string_t what;
7648 cmd_showqueue_parsed(void *parsed_result,
7649 __rte_unused struct cmdline *cl,
7650 __rte_unused void *data)
7652 struct cmd_showqueue_result *res = parsed_result;
7654 if (!strcmp(res->type, "rxq"))
7655 rx_queue_infos_display(res->portnum, res->queuenum);
7656 else if (!strcmp(res->type, "txq"))
7657 tx_queue_infos_display(res->portnum, res->queuenum);
7660 cmdline_parse_token_string_t cmd_showqueue_show =
7661 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7662 cmdline_parse_token_string_t cmd_showqueue_type =
7663 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7664 cmdline_parse_token_string_t cmd_showqueue_what =
7665 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7666 cmdline_parse_token_num_t cmd_showqueue_portnum =
7667 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7668 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7669 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7671 cmdline_parse_inst_t cmd_showqueue = {
7672 .f = cmd_showqueue_parsed,
7674 .help_str = "show rxq|txq info <port_id> <queue_id>",
7676 (void *)&cmd_showqueue_show,
7677 (void *)&cmd_showqueue_type,
7678 (void *)&cmd_showqueue_what,
7679 (void *)&cmd_showqueue_portnum,
7680 (void *)&cmd_showqueue_queuenum,
7685 /* show/clear fwd engine statistics */
7687 cmdline_fixed_string_t action;
7688 cmdline_fixed_string_t fwd;
7689 cmdline_fixed_string_t stats;
7690 cmdline_fixed_string_t all;
7693 cmdline_parse_token_string_t cmd_fwd_action =
7694 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7695 cmdline_parse_token_string_t cmd_fwd_fwd =
7696 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7697 cmdline_parse_token_string_t cmd_fwd_stats =
7698 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7699 cmdline_parse_token_string_t cmd_fwd_all =
7700 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7703 cmd_showfwdall_parsed(void *parsed_result,
7704 __rte_unused struct cmdline *cl,
7705 __rte_unused void *data)
7707 struct fwd_result *res = parsed_result;
7709 if (!strcmp(res->action, "show"))
7710 fwd_stats_display();
7715 static cmdline_parse_inst_t cmd_showfwdall = {
7716 .f = cmd_showfwdall_parsed,
7718 .help_str = "show|clear fwd stats all",
7720 (void *)&cmd_fwd_action,
7721 (void *)&cmd_fwd_fwd,
7722 (void *)&cmd_fwd_stats,
7723 (void *)&cmd_fwd_all,
7728 /* *** READ PORT REGISTER *** */
7729 struct cmd_read_reg_result {
7730 cmdline_fixed_string_t read;
7731 cmdline_fixed_string_t reg;
7737 cmd_read_reg_parsed(void *parsed_result,
7738 __rte_unused struct cmdline *cl,
7739 __rte_unused void *data)
7741 struct cmd_read_reg_result *res = parsed_result;
7742 port_reg_display(res->port_id, res->reg_off);
7745 cmdline_parse_token_string_t cmd_read_reg_read =
7746 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7747 cmdline_parse_token_string_t cmd_read_reg_reg =
7748 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7749 cmdline_parse_token_num_t cmd_read_reg_port_id =
7750 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7751 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7752 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7754 cmdline_parse_inst_t cmd_read_reg = {
7755 .f = cmd_read_reg_parsed,
7757 .help_str = "read reg <port_id> <reg_off>",
7759 (void *)&cmd_read_reg_read,
7760 (void *)&cmd_read_reg_reg,
7761 (void *)&cmd_read_reg_port_id,
7762 (void *)&cmd_read_reg_reg_off,
7767 /* *** READ PORT REGISTER BIT FIELD *** */
7768 struct cmd_read_reg_bit_field_result {
7769 cmdline_fixed_string_t read;
7770 cmdline_fixed_string_t regfield;
7778 cmd_read_reg_bit_field_parsed(void *parsed_result,
7779 __rte_unused struct cmdline *cl,
7780 __rte_unused void *data)
7782 struct cmd_read_reg_bit_field_result *res = parsed_result;
7783 port_reg_bit_field_display(res->port_id, res->reg_off,
7784 res->bit1_pos, res->bit2_pos);
7787 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7788 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7790 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7791 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7792 regfield, "regfield");
7793 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7794 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7796 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7797 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7799 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7800 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7802 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7803 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7806 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7807 .f = cmd_read_reg_bit_field_parsed,
7809 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7810 "Read register bit field between bit_x and bit_y included",
7812 (void *)&cmd_read_reg_bit_field_read,
7813 (void *)&cmd_read_reg_bit_field_regfield,
7814 (void *)&cmd_read_reg_bit_field_port_id,
7815 (void *)&cmd_read_reg_bit_field_reg_off,
7816 (void *)&cmd_read_reg_bit_field_bit1_pos,
7817 (void *)&cmd_read_reg_bit_field_bit2_pos,
7822 /* *** READ PORT REGISTER BIT *** */
7823 struct cmd_read_reg_bit_result {
7824 cmdline_fixed_string_t read;
7825 cmdline_fixed_string_t regbit;
7832 cmd_read_reg_bit_parsed(void *parsed_result,
7833 __rte_unused struct cmdline *cl,
7834 __rte_unused void *data)
7836 struct cmd_read_reg_bit_result *res = parsed_result;
7837 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7840 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7841 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7842 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7843 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7845 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7846 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7847 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7848 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7849 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7850 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7852 cmdline_parse_inst_t cmd_read_reg_bit = {
7853 .f = cmd_read_reg_bit_parsed,
7855 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7857 (void *)&cmd_read_reg_bit_read,
7858 (void *)&cmd_read_reg_bit_regbit,
7859 (void *)&cmd_read_reg_bit_port_id,
7860 (void *)&cmd_read_reg_bit_reg_off,
7861 (void *)&cmd_read_reg_bit_bit_pos,
7866 /* *** WRITE PORT REGISTER *** */
7867 struct cmd_write_reg_result {
7868 cmdline_fixed_string_t write;
7869 cmdline_fixed_string_t reg;
7876 cmd_write_reg_parsed(void *parsed_result,
7877 __rte_unused struct cmdline *cl,
7878 __rte_unused void *data)
7880 struct cmd_write_reg_result *res = parsed_result;
7881 port_reg_set(res->port_id, res->reg_off, res->value);
7884 cmdline_parse_token_string_t cmd_write_reg_write =
7885 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7886 cmdline_parse_token_string_t cmd_write_reg_reg =
7887 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7888 cmdline_parse_token_num_t cmd_write_reg_port_id =
7889 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7890 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7891 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7892 cmdline_parse_token_num_t cmd_write_reg_value =
7893 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7895 cmdline_parse_inst_t cmd_write_reg = {
7896 .f = cmd_write_reg_parsed,
7898 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7900 (void *)&cmd_write_reg_write,
7901 (void *)&cmd_write_reg_reg,
7902 (void *)&cmd_write_reg_port_id,
7903 (void *)&cmd_write_reg_reg_off,
7904 (void *)&cmd_write_reg_value,
7909 /* *** WRITE PORT REGISTER BIT FIELD *** */
7910 struct cmd_write_reg_bit_field_result {
7911 cmdline_fixed_string_t write;
7912 cmdline_fixed_string_t regfield;
7921 cmd_write_reg_bit_field_parsed(void *parsed_result,
7922 __rte_unused struct cmdline *cl,
7923 __rte_unused void *data)
7925 struct cmd_write_reg_bit_field_result *res = parsed_result;
7926 port_reg_bit_field_set(res->port_id, res->reg_off,
7927 res->bit1_pos, res->bit2_pos, res->value);
7930 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7931 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7933 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7934 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7935 regfield, "regfield");
7936 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7937 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7939 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7940 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7942 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7943 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7945 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7946 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7948 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7949 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7952 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7953 .f = cmd_write_reg_bit_field_parsed,
7955 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7957 "Set register bit field between bit_x and bit_y included",
7959 (void *)&cmd_write_reg_bit_field_write,
7960 (void *)&cmd_write_reg_bit_field_regfield,
7961 (void *)&cmd_write_reg_bit_field_port_id,
7962 (void *)&cmd_write_reg_bit_field_reg_off,
7963 (void *)&cmd_write_reg_bit_field_bit1_pos,
7964 (void *)&cmd_write_reg_bit_field_bit2_pos,
7965 (void *)&cmd_write_reg_bit_field_value,
7970 /* *** WRITE PORT REGISTER BIT *** */
7971 struct cmd_write_reg_bit_result {
7972 cmdline_fixed_string_t write;
7973 cmdline_fixed_string_t regbit;
7981 cmd_write_reg_bit_parsed(void *parsed_result,
7982 __rte_unused struct cmdline *cl,
7983 __rte_unused void *data)
7985 struct cmd_write_reg_bit_result *res = parsed_result;
7986 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7989 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7990 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7992 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7993 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7995 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7996 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7997 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7998 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7999 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8000 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8001 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8002 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8004 cmdline_parse_inst_t cmd_write_reg_bit = {
8005 .f = cmd_write_reg_bit_parsed,
8007 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8010 (void *)&cmd_write_reg_bit_write,
8011 (void *)&cmd_write_reg_bit_regbit,
8012 (void *)&cmd_write_reg_bit_port_id,
8013 (void *)&cmd_write_reg_bit_reg_off,
8014 (void *)&cmd_write_reg_bit_bit_pos,
8015 (void *)&cmd_write_reg_bit_value,
8020 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8021 struct cmd_read_rxd_txd_result {
8022 cmdline_fixed_string_t read;
8023 cmdline_fixed_string_t rxd_txd;
8030 cmd_read_rxd_txd_parsed(void *parsed_result,
8031 __rte_unused struct cmdline *cl,
8032 __rte_unused void *data)
8034 struct cmd_read_rxd_txd_result *res = parsed_result;
8036 if (!strcmp(res->rxd_txd, "rxd"))
8037 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8038 else if (!strcmp(res->rxd_txd, "txd"))
8039 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8042 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8043 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8044 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8045 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8047 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8048 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8049 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8050 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8051 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8052 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8054 cmdline_parse_inst_t cmd_read_rxd_txd = {
8055 .f = cmd_read_rxd_txd_parsed,
8057 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8059 (void *)&cmd_read_rxd_txd_read,
8060 (void *)&cmd_read_rxd_txd_rxd_txd,
8061 (void *)&cmd_read_rxd_txd_port_id,
8062 (void *)&cmd_read_rxd_txd_queue_id,
8063 (void *)&cmd_read_rxd_txd_desc_id,
8069 struct cmd_quit_result {
8070 cmdline_fixed_string_t quit;
8073 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8075 __rte_unused void *data)
8080 cmdline_parse_token_string_t cmd_quit_quit =
8081 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8083 cmdline_parse_inst_t cmd_quit = {
8084 .f = cmd_quit_parsed,
8086 .help_str = "quit: Exit application",
8088 (void *)&cmd_quit_quit,
8093 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8094 struct cmd_mac_addr_result {
8095 cmdline_fixed_string_t mac_addr_cmd;
8096 cmdline_fixed_string_t what;
8098 struct rte_ether_addr address;
8101 static void cmd_mac_addr_parsed(void *parsed_result,
8102 __rte_unused struct cmdline *cl,
8103 __rte_unused void *data)
8105 struct cmd_mac_addr_result *res = parsed_result;
8108 if (strcmp(res->what, "add") == 0)
8109 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8110 else if (strcmp(res->what, "set") == 0)
8111 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8114 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8116 /* check the return value and print it if is < 0 */
8118 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8122 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8123 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8125 cmdline_parse_token_string_t cmd_mac_addr_what =
8126 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8128 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8129 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8131 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8132 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8134 cmdline_parse_inst_t cmd_mac_addr = {
8135 .f = cmd_mac_addr_parsed,
8137 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8138 "Add/Remove/Set MAC address on port_id",
8140 (void *)&cmd_mac_addr_cmd,
8141 (void *)&cmd_mac_addr_what,
8142 (void *)&cmd_mac_addr_portnum,
8143 (void *)&cmd_mac_addr_addr,
8148 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8149 struct cmd_eth_peer_result {
8150 cmdline_fixed_string_t set;
8151 cmdline_fixed_string_t eth_peer;
8153 cmdline_fixed_string_t peer_addr;
8156 static void cmd_set_eth_peer_parsed(void *parsed_result,
8157 __rte_unused struct cmdline *cl,
8158 __rte_unused void *data)
8160 struct cmd_eth_peer_result *res = parsed_result;
8162 if (test_done == 0) {
8163 printf("Please stop forwarding first\n");
8166 if (!strcmp(res->eth_peer, "eth-peer")) {
8167 set_fwd_eth_peer(res->port_id, res->peer_addr);
8171 cmdline_parse_token_string_t cmd_eth_peer_set =
8172 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8173 cmdline_parse_token_string_t cmd_eth_peer =
8174 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8175 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8176 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8177 cmdline_parse_token_string_t cmd_eth_peer_addr =
8178 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8180 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8181 .f = cmd_set_eth_peer_parsed,
8183 .help_str = "set eth-peer <port_id> <peer_mac>",
8185 (void *)&cmd_eth_peer_set,
8186 (void *)&cmd_eth_peer,
8187 (void *)&cmd_eth_peer_port_id,
8188 (void *)&cmd_eth_peer_addr,
8193 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8194 struct cmd_set_qmap_result {
8195 cmdline_fixed_string_t set;
8196 cmdline_fixed_string_t qmap;
8197 cmdline_fixed_string_t what;
8204 cmd_set_qmap_parsed(void *parsed_result,
8205 __rte_unused struct cmdline *cl,
8206 __rte_unused void *data)
8208 struct cmd_set_qmap_result *res = parsed_result;
8209 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8211 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8214 cmdline_parse_token_string_t cmd_setqmap_set =
8215 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8217 cmdline_parse_token_string_t cmd_setqmap_qmap =
8218 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8220 cmdline_parse_token_string_t cmd_setqmap_what =
8221 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8223 cmdline_parse_token_num_t cmd_setqmap_portid =
8224 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8226 cmdline_parse_token_num_t cmd_setqmap_queueid =
8227 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8229 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8230 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8233 cmdline_parse_inst_t cmd_set_qmap = {
8234 .f = cmd_set_qmap_parsed,
8236 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8237 "Set statistics mapping value on tx|rx queue_id of port_id",
8239 (void *)&cmd_setqmap_set,
8240 (void *)&cmd_setqmap_qmap,
8241 (void *)&cmd_setqmap_what,
8242 (void *)&cmd_setqmap_portid,
8243 (void *)&cmd_setqmap_queueid,
8244 (void *)&cmd_setqmap_mapvalue,
8249 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8250 struct cmd_set_xstats_hide_zero_result {
8251 cmdline_fixed_string_t keyword;
8252 cmdline_fixed_string_t name;
8253 cmdline_fixed_string_t on_off;
8257 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8258 __rte_unused struct cmdline *cl,
8259 __rte_unused void *data)
8261 struct cmd_set_xstats_hide_zero_result *res;
8262 uint16_t on_off = 0;
8264 res = parsed_result;
8265 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8266 set_xstats_hide_zero(on_off);
8269 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8270 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8272 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8273 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8274 name, "xstats-hide-zero");
8275 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8276 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8279 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8280 .f = cmd_set_xstats_hide_zero_parsed,
8282 .help_str = "set xstats-hide-zero on|off",
8284 (void *)&cmd_set_xstats_hide_zero_keyword,
8285 (void *)&cmd_set_xstats_hide_zero_name,
8286 (void *)&cmd_set_xstats_hide_zero_on_off,
8291 /* *** CONFIGURE UNICAST HASH TABLE *** */
8292 struct cmd_set_uc_hash_table {
8293 cmdline_fixed_string_t set;
8294 cmdline_fixed_string_t port;
8296 cmdline_fixed_string_t what;
8297 struct rte_ether_addr address;
8298 cmdline_fixed_string_t mode;
8302 cmd_set_uc_hash_parsed(void *parsed_result,
8303 __rte_unused struct cmdline *cl,
8304 __rte_unused void *data)
8307 struct cmd_set_uc_hash_table *res = parsed_result;
8309 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8311 if (strcmp(res->what, "uta") == 0)
8312 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8313 &res->address,(uint8_t)is_on);
8315 printf("bad unicast hash table parameter, return code = %d \n", ret);
8319 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8320 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8322 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8323 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8325 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8326 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8328 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8329 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8331 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8332 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8334 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8335 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8338 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8339 .f = cmd_set_uc_hash_parsed,
8341 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8343 (void *)&cmd_set_uc_hash_set,
8344 (void *)&cmd_set_uc_hash_port,
8345 (void *)&cmd_set_uc_hash_portid,
8346 (void *)&cmd_set_uc_hash_what,
8347 (void *)&cmd_set_uc_hash_mac,
8348 (void *)&cmd_set_uc_hash_mode,
8353 struct cmd_set_uc_all_hash_table {
8354 cmdline_fixed_string_t set;
8355 cmdline_fixed_string_t port;
8357 cmdline_fixed_string_t what;
8358 cmdline_fixed_string_t value;
8359 cmdline_fixed_string_t mode;
8363 cmd_set_uc_all_hash_parsed(void *parsed_result,
8364 __rte_unused struct cmdline *cl,
8365 __rte_unused void *data)
8368 struct cmd_set_uc_all_hash_table *res = parsed_result;
8370 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8372 if ((strcmp(res->what, "uta") == 0) &&
8373 (strcmp(res->value, "all") == 0))
8374 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8376 printf("bad unicast hash table parameter,"
8377 "return code = %d \n", ret);
8380 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8381 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8383 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8384 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8386 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8387 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8389 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8390 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8392 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8393 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8395 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8396 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8399 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8400 .f = cmd_set_uc_all_hash_parsed,
8402 .help_str = "set port <port_id> uta all on|off",
8404 (void *)&cmd_set_uc_all_hash_set,
8405 (void *)&cmd_set_uc_all_hash_port,
8406 (void *)&cmd_set_uc_all_hash_portid,
8407 (void *)&cmd_set_uc_all_hash_what,
8408 (void *)&cmd_set_uc_all_hash_value,
8409 (void *)&cmd_set_uc_all_hash_mode,
8414 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8415 struct cmd_set_vf_macvlan_filter {
8416 cmdline_fixed_string_t set;
8417 cmdline_fixed_string_t port;
8419 cmdline_fixed_string_t vf;
8421 struct rte_ether_addr address;
8422 cmdline_fixed_string_t filter_type;
8423 cmdline_fixed_string_t mode;
8427 cmd_set_vf_macvlan_parsed(void *parsed_result,
8428 __rte_unused struct cmdline *cl,
8429 __rte_unused void *data)
8432 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8433 struct rte_eth_mac_filter filter;
8435 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8437 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8439 /* set VF MAC filter */
8443 filter.dst_id = res->vf_id;
8445 if (!strcmp(res->filter_type, "exact-mac"))
8446 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8447 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8448 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8449 else if (!strcmp(res->filter_type, "hashmac"))
8450 filter.filter_type = RTE_MAC_HASH_MATCH;
8451 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8452 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8454 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8457 ret = rte_eth_dev_filter_ctrl(res->port_id,
8458 RTE_ETH_FILTER_MACVLAN,
8462 ret = rte_eth_dev_filter_ctrl(res->port_id,
8463 RTE_ETH_FILTER_MACVLAN,
8464 RTE_ETH_FILTER_DELETE,
8468 printf("bad set MAC hash parameter, return code = %d\n", ret);
8472 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8473 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8475 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8476 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8478 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8479 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8481 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8482 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8484 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8485 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8487 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8488 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8490 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8491 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8492 filter_type, "exact-mac#exact-mac-vlan"
8493 "#hashmac#hashmac-vlan");
8494 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8495 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8498 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8499 .f = cmd_set_vf_macvlan_parsed,
8501 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8502 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8503 "Exact match rule: exact match of MAC or MAC and VLAN; "
8504 "hash match rule: hash match of MAC and exact match of VLAN",
8506 (void *)&cmd_set_vf_macvlan_set,
8507 (void *)&cmd_set_vf_macvlan_port,
8508 (void *)&cmd_set_vf_macvlan_portid,
8509 (void *)&cmd_set_vf_macvlan_vf,
8510 (void *)&cmd_set_vf_macvlan_vf_id,
8511 (void *)&cmd_set_vf_macvlan_mac,
8512 (void *)&cmd_set_vf_macvlan_filter_type,
8513 (void *)&cmd_set_vf_macvlan_mode,
8518 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8519 struct cmd_set_vf_traffic {
8520 cmdline_fixed_string_t set;
8521 cmdline_fixed_string_t port;
8523 cmdline_fixed_string_t vf;
8525 cmdline_fixed_string_t what;
8526 cmdline_fixed_string_t mode;
8530 cmd_set_vf_traffic_parsed(void *parsed_result,
8531 __rte_unused struct cmdline *cl,
8532 __rte_unused void *data)
8534 struct cmd_set_vf_traffic *res = parsed_result;
8535 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8536 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8538 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8541 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8542 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8544 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8545 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8547 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8548 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8550 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8551 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8553 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8554 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8556 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8557 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8559 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8560 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8563 cmdline_parse_inst_t cmd_set_vf_traffic = {
8564 .f = cmd_set_vf_traffic_parsed,
8566 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8568 (void *)&cmd_setvf_traffic_set,
8569 (void *)&cmd_setvf_traffic_port,
8570 (void *)&cmd_setvf_traffic_portid,
8571 (void *)&cmd_setvf_traffic_vf,
8572 (void *)&cmd_setvf_traffic_vfid,
8573 (void *)&cmd_setvf_traffic_what,
8574 (void *)&cmd_setvf_traffic_mode,
8579 /* *** CONFIGURE VF RECEIVE MODE *** */
8580 struct cmd_set_vf_rxmode {
8581 cmdline_fixed_string_t set;
8582 cmdline_fixed_string_t port;
8584 cmdline_fixed_string_t vf;
8586 cmdline_fixed_string_t what;
8587 cmdline_fixed_string_t mode;
8588 cmdline_fixed_string_t on;
8592 cmd_set_vf_rxmode_parsed(void *parsed_result,
8593 __rte_unused struct cmdline *cl,
8594 __rte_unused void *data)
8597 uint16_t vf_rxmode = 0;
8598 struct cmd_set_vf_rxmode *res = parsed_result;
8600 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8601 if (!strcmp(res->what,"rxmode")) {
8602 if (!strcmp(res->mode, "AUPE"))
8603 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8604 else if (!strcmp(res->mode, "ROPE"))
8605 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8606 else if (!strcmp(res->mode, "BAM"))
8607 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8608 else if (!strncmp(res->mode, "MPE",3))
8609 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8612 RTE_SET_USED(is_on);
8614 #ifdef RTE_LIBRTE_IXGBE_PMD
8615 if (ret == -ENOTSUP)
8616 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8617 vf_rxmode, (uint8_t)is_on);
8619 #ifdef RTE_LIBRTE_BNXT_PMD
8620 if (ret == -ENOTSUP)
8621 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8622 vf_rxmode, (uint8_t)is_on);
8625 printf("bad VF receive mode parameter, return code = %d \n",
8629 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8630 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8632 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8633 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8635 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8636 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8638 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8639 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8641 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8642 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8644 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8645 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8647 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8648 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8649 mode, "AUPE#ROPE#BAM#MPE");
8650 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8651 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8654 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8655 .f = cmd_set_vf_rxmode_parsed,
8657 .help_str = "set port <port_id> vf <vf_id> rxmode "
8658 "AUPE|ROPE|BAM|MPE on|off",
8660 (void *)&cmd_set_vf_rxmode_set,
8661 (void *)&cmd_set_vf_rxmode_port,
8662 (void *)&cmd_set_vf_rxmode_portid,
8663 (void *)&cmd_set_vf_rxmode_vf,
8664 (void *)&cmd_set_vf_rxmode_vfid,
8665 (void *)&cmd_set_vf_rxmode_what,
8666 (void *)&cmd_set_vf_rxmode_mode,
8667 (void *)&cmd_set_vf_rxmode_on,
8672 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8673 struct cmd_vf_mac_addr_result {
8674 cmdline_fixed_string_t mac_addr_cmd;
8675 cmdline_fixed_string_t what;
8676 cmdline_fixed_string_t port;
8678 cmdline_fixed_string_t vf;
8680 struct rte_ether_addr address;
8683 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8684 __rte_unused struct cmdline *cl,
8685 __rte_unused void *data)
8687 struct cmd_vf_mac_addr_result *res = parsed_result;
8690 if (strcmp(res->what, "add") != 0)
8693 #ifdef RTE_LIBRTE_I40E_PMD
8694 if (ret == -ENOTSUP)
8695 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8698 #ifdef RTE_LIBRTE_BNXT_PMD
8699 if (ret == -ENOTSUP)
8700 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8705 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8709 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8710 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8711 mac_addr_cmd,"mac_addr");
8712 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8713 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8715 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8716 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8718 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8719 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8721 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8722 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8724 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8725 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8727 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8728 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8731 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8732 .f = cmd_vf_mac_addr_parsed,
8734 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8735 "Add MAC address filtering for a VF on port_id",
8737 (void *)&cmd_vf_mac_addr_cmd,
8738 (void *)&cmd_vf_mac_addr_what,
8739 (void *)&cmd_vf_mac_addr_port,
8740 (void *)&cmd_vf_mac_addr_portnum,
8741 (void *)&cmd_vf_mac_addr_vf,
8742 (void *)&cmd_vf_mac_addr_vfnum,
8743 (void *)&cmd_vf_mac_addr_addr,
8748 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8749 struct cmd_vf_rx_vlan_filter {
8750 cmdline_fixed_string_t rx_vlan;
8751 cmdline_fixed_string_t what;
8753 cmdline_fixed_string_t port;
8755 cmdline_fixed_string_t vf;
8760 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8761 __rte_unused struct cmdline *cl,
8762 __rte_unused void *data)
8764 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8767 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8769 #ifdef RTE_LIBRTE_IXGBE_PMD
8770 if (ret == -ENOTSUP)
8771 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8772 res->vlan_id, res->vf_mask, is_add);
8774 #ifdef RTE_LIBRTE_I40E_PMD
8775 if (ret == -ENOTSUP)
8776 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8777 res->vlan_id, res->vf_mask, is_add);
8779 #ifdef RTE_LIBRTE_BNXT_PMD
8780 if (ret == -ENOTSUP)
8781 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8782 res->vlan_id, res->vf_mask, is_add);
8789 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8790 res->vlan_id, res->vf_mask);
8793 printf("invalid port_id %d\n", res->port_id);
8796 printf("function not implemented or supported\n");
8799 printf("programming error: (%s)\n", strerror(-ret));
8803 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8804 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8805 rx_vlan, "rx_vlan");
8806 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8807 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8809 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8810 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8812 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8813 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8815 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8816 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8818 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8819 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8821 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8822 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8825 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8826 .f = cmd_vf_rx_vlan_filter_parsed,
8828 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8829 "(vf_mask = hexadecimal VF mask)",
8831 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8832 (void *)&cmd_vf_rx_vlan_filter_what,
8833 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8834 (void *)&cmd_vf_rx_vlan_filter_port,
8835 (void *)&cmd_vf_rx_vlan_filter_portid,
8836 (void *)&cmd_vf_rx_vlan_filter_vf,
8837 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8842 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8843 struct cmd_queue_rate_limit_result {
8844 cmdline_fixed_string_t set;
8845 cmdline_fixed_string_t port;
8847 cmdline_fixed_string_t queue;
8849 cmdline_fixed_string_t rate;
8853 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8854 __rte_unused struct cmdline *cl,
8855 __rte_unused void *data)
8857 struct cmd_queue_rate_limit_result *res = parsed_result;
8860 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8861 && (strcmp(res->queue, "queue") == 0)
8862 && (strcmp(res->rate, "rate") == 0))
8863 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8866 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8870 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8871 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8873 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8874 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8876 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8877 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8879 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8880 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8882 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8883 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8885 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8886 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8888 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8889 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8892 cmdline_parse_inst_t cmd_queue_rate_limit = {
8893 .f = cmd_queue_rate_limit_parsed,
8895 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8896 "Set rate limit for a queue on port_id",
8898 (void *)&cmd_queue_rate_limit_set,
8899 (void *)&cmd_queue_rate_limit_port,
8900 (void *)&cmd_queue_rate_limit_portnum,
8901 (void *)&cmd_queue_rate_limit_queue,
8902 (void *)&cmd_queue_rate_limit_queuenum,
8903 (void *)&cmd_queue_rate_limit_rate,
8904 (void *)&cmd_queue_rate_limit_ratenum,
8909 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8910 struct cmd_vf_rate_limit_result {
8911 cmdline_fixed_string_t set;
8912 cmdline_fixed_string_t port;
8914 cmdline_fixed_string_t vf;
8916 cmdline_fixed_string_t rate;
8918 cmdline_fixed_string_t q_msk;
8922 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8923 __rte_unused struct cmdline *cl,
8924 __rte_unused void *data)
8926 struct cmd_vf_rate_limit_result *res = parsed_result;
8929 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8930 && (strcmp(res->vf, "vf") == 0)
8931 && (strcmp(res->rate, "rate") == 0)
8932 && (strcmp(res->q_msk, "queue_mask") == 0))
8933 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8934 res->rate_num, res->q_msk_val);
8936 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8940 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8941 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8943 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8944 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8946 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8947 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8949 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8950 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8952 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8953 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8955 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8956 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8958 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8959 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8961 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8962 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8963 q_msk, "queue_mask");
8964 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8965 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8968 cmdline_parse_inst_t cmd_vf_rate_limit = {
8969 .f = cmd_vf_rate_limit_parsed,
8971 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8972 "queue_mask <queue_mask_value>: "
8973 "Set rate limit for queues of VF on port_id",
8975 (void *)&cmd_vf_rate_limit_set,
8976 (void *)&cmd_vf_rate_limit_port,
8977 (void *)&cmd_vf_rate_limit_portnum,
8978 (void *)&cmd_vf_rate_limit_vf,
8979 (void *)&cmd_vf_rate_limit_vfnum,
8980 (void *)&cmd_vf_rate_limit_rate,
8981 (void *)&cmd_vf_rate_limit_ratenum,
8982 (void *)&cmd_vf_rate_limit_q_msk,
8983 (void *)&cmd_vf_rate_limit_q_msk_val,
8988 /* *** ADD TUNNEL FILTER OF A PORT *** */
8989 struct cmd_tunnel_filter_result {
8990 cmdline_fixed_string_t cmd;
8991 cmdline_fixed_string_t what;
8993 struct rte_ether_addr outer_mac;
8994 struct rte_ether_addr inner_mac;
8995 cmdline_ipaddr_t ip_value;
8996 uint16_t inner_vlan;
8997 cmdline_fixed_string_t tunnel_type;
8998 cmdline_fixed_string_t filter_type;
9004 cmd_tunnel_filter_parsed(void *parsed_result,
9005 __rte_unused struct cmdline *cl,
9006 __rte_unused void *data)
9008 struct cmd_tunnel_filter_result *res = parsed_result;
9009 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9012 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9014 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9015 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9016 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9018 if (res->ip_value.family == AF_INET) {
9019 tunnel_filter_conf.ip_addr.ipv4_addr =
9020 res->ip_value.addr.ipv4.s_addr;
9021 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9023 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9024 &(res->ip_value.addr.ipv6),
9025 sizeof(struct in6_addr));
9026 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9029 if (!strcmp(res->filter_type, "imac-ivlan"))
9030 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9031 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9032 tunnel_filter_conf.filter_type =
9033 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9034 else if (!strcmp(res->filter_type, "imac-tenid"))
9035 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9036 else if (!strcmp(res->filter_type, "imac"))
9037 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9038 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9039 tunnel_filter_conf.filter_type =
9040 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9041 else if (!strcmp(res->filter_type, "oip"))
9042 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9043 else if (!strcmp(res->filter_type, "iip"))
9044 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9046 printf("The filter type is not supported");
9050 if (!strcmp(res->tunnel_type, "vxlan"))
9051 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9052 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9053 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9054 else if (!strcmp(res->tunnel_type, "nvgre"))
9055 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9056 else if (!strcmp(res->tunnel_type, "ipingre"))
9057 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9059 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9063 tunnel_filter_conf.tenant_id = res->tenant_id;
9064 tunnel_filter_conf.queue_id = res->queue_num;
9065 if (!strcmp(res->what, "add"))
9066 ret = rte_eth_dev_filter_ctrl(res->port_id,
9067 RTE_ETH_FILTER_TUNNEL,
9069 &tunnel_filter_conf);
9071 ret = rte_eth_dev_filter_ctrl(res->port_id,
9072 RTE_ETH_FILTER_TUNNEL,
9073 RTE_ETH_FILTER_DELETE,
9074 &tunnel_filter_conf);
9076 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9080 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9081 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9082 cmd, "tunnel_filter");
9083 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9084 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9086 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9087 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9089 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9090 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9092 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9093 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9095 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9096 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9097 inner_vlan, UINT16);
9098 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9099 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9101 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9102 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9103 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9105 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9106 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9107 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9108 "imac#omac-imac-tenid");
9109 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9110 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9112 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9113 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9116 cmdline_parse_inst_t cmd_tunnel_filter = {
9117 .f = cmd_tunnel_filter_parsed,
9119 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9120 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9121 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9122 "<queue_id>: Add/Rm tunnel filter of a port",
9124 (void *)&cmd_tunnel_filter_cmd,
9125 (void *)&cmd_tunnel_filter_what,
9126 (void *)&cmd_tunnel_filter_port_id,
9127 (void *)&cmd_tunnel_filter_outer_mac,
9128 (void *)&cmd_tunnel_filter_inner_mac,
9129 (void *)&cmd_tunnel_filter_ip_value,
9130 (void *)&cmd_tunnel_filter_innner_vlan,
9131 (void *)&cmd_tunnel_filter_tunnel_type,
9132 (void *)&cmd_tunnel_filter_filter_type,
9133 (void *)&cmd_tunnel_filter_tenant_id,
9134 (void *)&cmd_tunnel_filter_queue_num,
9139 /* *** CONFIGURE TUNNEL UDP PORT *** */
9140 struct cmd_tunnel_udp_config {
9141 cmdline_fixed_string_t cmd;
9142 cmdline_fixed_string_t what;
9148 cmd_tunnel_udp_config_parsed(void *parsed_result,
9149 __rte_unused struct cmdline *cl,
9150 __rte_unused void *data)
9152 struct cmd_tunnel_udp_config *res = parsed_result;
9153 struct rte_eth_udp_tunnel tunnel_udp;
9156 tunnel_udp.udp_port = res->udp_port;
9158 if (!strcmp(res->cmd, "rx_vxlan_port"))
9159 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9161 if (!strcmp(res->what, "add"))
9162 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9165 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9169 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9172 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9173 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9174 cmd, "rx_vxlan_port");
9175 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9176 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9178 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9179 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9181 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9182 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9185 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9186 .f = cmd_tunnel_udp_config_parsed,
9188 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9189 "Add/Remove a tunneling UDP port filter",
9191 (void *)&cmd_tunnel_udp_config_cmd,
9192 (void *)&cmd_tunnel_udp_config_what,
9193 (void *)&cmd_tunnel_udp_config_udp_port,
9194 (void *)&cmd_tunnel_udp_config_port_id,
9199 struct cmd_config_tunnel_udp_port {
9200 cmdline_fixed_string_t port;
9201 cmdline_fixed_string_t config;
9203 cmdline_fixed_string_t udp_tunnel_port;
9204 cmdline_fixed_string_t action;
9205 cmdline_fixed_string_t tunnel_type;
9210 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9211 __rte_unused struct cmdline *cl,
9212 __rte_unused void *data)
9214 struct cmd_config_tunnel_udp_port *res = parsed_result;
9215 struct rte_eth_udp_tunnel tunnel_udp;
9218 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9221 tunnel_udp.udp_port = res->udp_port;
9223 if (!strcmp(res->tunnel_type, "vxlan")) {
9224 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9225 } else if (!strcmp(res->tunnel_type, "geneve")) {
9226 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9227 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9228 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9230 printf("Invalid tunnel type\n");
9234 if (!strcmp(res->action, "add"))
9235 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9238 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9242 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9245 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9246 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9248 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9249 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9251 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9252 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9254 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9255 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9258 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9259 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9261 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9262 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9263 "vxlan#geneve#vxlan-gpe");
9264 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9265 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9268 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9269 .f = cmd_cfg_tunnel_udp_port_parsed,
9271 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9273 (void *)&cmd_config_tunnel_udp_port_port,
9274 (void *)&cmd_config_tunnel_udp_port_config,
9275 (void *)&cmd_config_tunnel_udp_port_port_id,
9276 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9277 (void *)&cmd_config_tunnel_udp_port_action,
9278 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9279 (void *)&cmd_config_tunnel_udp_port_value,
9284 /* *** GLOBAL CONFIG *** */
9285 struct cmd_global_config_result {
9286 cmdline_fixed_string_t cmd;
9288 cmdline_fixed_string_t cfg_type;
9293 cmd_global_config_parsed(void *parsed_result,
9294 __rte_unused struct cmdline *cl,
9295 __rte_unused void *data)
9297 struct cmd_global_config_result *res = parsed_result;
9298 struct rte_eth_global_cfg conf;
9301 memset(&conf, 0, sizeof(conf));
9302 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9303 conf.cfg.gre_key_len = res->len;
9304 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9305 RTE_ETH_FILTER_SET, &conf);
9306 #ifdef RTE_LIBRTE_I40E_PMD
9307 if (ret == -ENOTSUP)
9308 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9311 printf("Global config error\n");
9314 cmdline_parse_token_string_t cmd_global_config_cmd =
9315 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9317 cmdline_parse_token_num_t cmd_global_config_port_id =
9318 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9320 cmdline_parse_token_string_t cmd_global_config_type =
9321 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9322 cfg_type, "gre-key-len");
9323 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9324 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9327 cmdline_parse_inst_t cmd_global_config = {
9328 .f = cmd_global_config_parsed,
9329 .data = (void *)NULL,
9330 .help_str = "global_config <port_id> gre-key-len <key_len>",
9332 (void *)&cmd_global_config_cmd,
9333 (void *)&cmd_global_config_port_id,
9334 (void *)&cmd_global_config_type,
9335 (void *)&cmd_global_config_gre_key_len,
9340 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9341 struct cmd_set_mirror_mask_result {
9342 cmdline_fixed_string_t set;
9343 cmdline_fixed_string_t port;
9345 cmdline_fixed_string_t mirror;
9347 cmdline_fixed_string_t what;
9348 cmdline_fixed_string_t value;
9349 cmdline_fixed_string_t dstpool;
9351 cmdline_fixed_string_t on;
9354 cmdline_parse_token_string_t cmd_mirror_mask_set =
9355 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9357 cmdline_parse_token_string_t cmd_mirror_mask_port =
9358 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9360 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9361 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9363 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9364 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9365 mirror, "mirror-rule");
9366 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9367 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9369 cmdline_parse_token_string_t cmd_mirror_mask_what =
9370 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9371 what, "pool-mirror-up#pool-mirror-down"
9373 cmdline_parse_token_string_t cmd_mirror_mask_value =
9374 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9376 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9377 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9378 dstpool, "dst-pool");
9379 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9380 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9382 cmdline_parse_token_string_t cmd_mirror_mask_on =
9383 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9387 cmd_set_mirror_mask_parsed(void *parsed_result,
9388 __rte_unused struct cmdline *cl,
9389 __rte_unused void *data)
9392 struct cmd_set_mirror_mask_result *res = parsed_result;
9393 struct rte_eth_mirror_conf mr_conf;
9395 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9397 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9399 mr_conf.dst_pool = res->dstpool_id;
9401 if (!strcmp(res->what, "pool-mirror-up")) {
9402 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9403 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9404 } else if (!strcmp(res->what, "pool-mirror-down")) {
9405 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9406 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9407 } else if (!strcmp(res->what, "vlan-mirror")) {
9408 mr_conf.rule_type = ETH_MIRROR_VLAN;
9409 nb_item = parse_item_list(res->value, "vlan",
9410 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9414 for (i = 0; i < nb_item; i++) {
9415 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9416 printf("Invalid vlan_id: must be < 4096\n");
9420 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9421 mr_conf.vlan.vlan_mask |= 1ULL << i;
9425 if (!strcmp(res->on, "on"))
9426 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9429 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9432 printf("mirror rule add error: (%s)\n", strerror(-ret));
9435 cmdline_parse_inst_t cmd_set_mirror_mask = {
9436 .f = cmd_set_mirror_mask_parsed,
9438 .help_str = "set port <port_id> mirror-rule <rule_id> "
9439 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9440 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9442 (void *)&cmd_mirror_mask_set,
9443 (void *)&cmd_mirror_mask_port,
9444 (void *)&cmd_mirror_mask_portid,
9445 (void *)&cmd_mirror_mask_mirror,
9446 (void *)&cmd_mirror_mask_ruleid,
9447 (void *)&cmd_mirror_mask_what,
9448 (void *)&cmd_mirror_mask_value,
9449 (void *)&cmd_mirror_mask_dstpool,
9450 (void *)&cmd_mirror_mask_poolid,
9451 (void *)&cmd_mirror_mask_on,
9456 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9457 struct cmd_set_mirror_link_result {
9458 cmdline_fixed_string_t set;
9459 cmdline_fixed_string_t port;
9461 cmdline_fixed_string_t mirror;
9463 cmdline_fixed_string_t what;
9464 cmdline_fixed_string_t dstpool;
9466 cmdline_fixed_string_t on;
9469 cmdline_parse_token_string_t cmd_mirror_link_set =
9470 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9472 cmdline_parse_token_string_t cmd_mirror_link_port =
9473 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9475 cmdline_parse_token_num_t cmd_mirror_link_portid =
9476 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9478 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9479 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9480 mirror, "mirror-rule");
9481 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9482 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9484 cmdline_parse_token_string_t cmd_mirror_link_what =
9485 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9486 what, "uplink-mirror#downlink-mirror");
9487 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9488 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9489 dstpool, "dst-pool");
9490 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9491 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9493 cmdline_parse_token_string_t cmd_mirror_link_on =
9494 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9498 cmd_set_mirror_link_parsed(void *parsed_result,
9499 __rte_unused struct cmdline *cl,
9500 __rte_unused void *data)
9503 struct cmd_set_mirror_link_result *res = parsed_result;
9504 struct rte_eth_mirror_conf mr_conf;
9506 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9507 if (!strcmp(res->what, "uplink-mirror"))
9508 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9510 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9512 mr_conf.dst_pool = res->dstpool_id;
9514 if (!strcmp(res->on, "on"))
9515 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9518 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9521 /* check the return value and print it if is < 0 */
9523 printf("mirror rule add error: (%s)\n", strerror(-ret));
9527 cmdline_parse_inst_t cmd_set_mirror_link = {
9528 .f = cmd_set_mirror_link_parsed,
9530 .help_str = "set port <port_id> mirror-rule <rule_id> "
9531 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9533 (void *)&cmd_mirror_link_set,
9534 (void *)&cmd_mirror_link_port,
9535 (void *)&cmd_mirror_link_portid,
9536 (void *)&cmd_mirror_link_mirror,
9537 (void *)&cmd_mirror_link_ruleid,
9538 (void *)&cmd_mirror_link_what,
9539 (void *)&cmd_mirror_link_dstpool,
9540 (void *)&cmd_mirror_link_poolid,
9541 (void *)&cmd_mirror_link_on,
9546 /* *** RESET VM MIRROR RULE *** */
9547 struct cmd_rm_mirror_rule_result {
9548 cmdline_fixed_string_t reset;
9549 cmdline_fixed_string_t port;
9551 cmdline_fixed_string_t mirror;
9555 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9556 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9558 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9559 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9561 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9562 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9564 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9565 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9566 mirror, "mirror-rule");
9567 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9568 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9572 cmd_reset_mirror_rule_parsed(void *parsed_result,
9573 __rte_unused struct cmdline *cl,
9574 __rte_unused void *data)
9577 struct cmd_set_mirror_link_result *res = parsed_result;
9579 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9581 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9584 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9585 .f = cmd_reset_mirror_rule_parsed,
9587 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9589 (void *)&cmd_rm_mirror_rule_reset,
9590 (void *)&cmd_rm_mirror_rule_port,
9591 (void *)&cmd_rm_mirror_rule_portid,
9592 (void *)&cmd_rm_mirror_rule_mirror,
9593 (void *)&cmd_rm_mirror_rule_ruleid,
9598 /* ******************************************************************************** */
9600 struct cmd_dump_result {
9601 cmdline_fixed_string_t dump;
9605 dump_struct_sizes(void)
9607 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9608 DUMP_SIZE(struct rte_mbuf);
9609 DUMP_SIZE(struct rte_mempool);
9610 DUMP_SIZE(struct rte_ring);
9615 /* Dump the socket memory statistics on console */
9617 dump_socket_mem(FILE *f)
9619 struct rte_malloc_socket_stats socket_stats;
9624 unsigned int n_alloc = 0;
9625 unsigned int n_free = 0;
9626 static size_t last_allocs;
9627 static size_t last_total;
9630 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9631 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9632 !socket_stats.heap_totalsz_bytes)
9634 total += socket_stats.heap_totalsz_bytes;
9635 alloc += socket_stats.heap_allocsz_bytes;
9636 free += socket_stats.heap_freesz_bytes;
9637 n_alloc += socket_stats.alloc_count;
9638 n_free += socket_stats.free_count;
9640 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9642 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9643 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9644 (double)socket_stats.heap_allocsz_bytes * 100 /
9645 (double)socket_stats.heap_totalsz_bytes,
9646 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9647 socket_stats.alloc_count,
9648 socket_stats.free_count);
9651 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9652 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9653 (double)alloc * 100 / (double)total,
9654 (double)free / (1024 * 1024),
9657 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9658 ((double)total - (double)last_total) / (1024 * 1024),
9659 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9660 last_allocs = alloc;
9664 static void cmd_dump_parsed(void *parsed_result,
9665 __rte_unused struct cmdline *cl,
9666 __rte_unused void *data)
9668 struct cmd_dump_result *res = parsed_result;
9670 if (!strcmp(res->dump, "dump_physmem"))
9671 rte_dump_physmem_layout(stdout);
9672 else if (!strcmp(res->dump, "dump_socket_mem"))
9673 dump_socket_mem(stdout);
9674 else if (!strcmp(res->dump, "dump_memzone"))
9675 rte_memzone_dump(stdout);
9676 else if (!strcmp(res->dump, "dump_struct_sizes"))
9677 dump_struct_sizes();
9678 else if (!strcmp(res->dump, "dump_ring"))
9679 rte_ring_list_dump(stdout);
9680 else if (!strcmp(res->dump, "dump_mempool"))
9681 rte_mempool_list_dump(stdout);
9682 else if (!strcmp(res->dump, "dump_devargs"))
9683 rte_devargs_dump(stdout);
9684 else if (!strcmp(res->dump, "dump_log_types"))
9685 rte_log_dump(stdout);
9688 cmdline_parse_token_string_t cmd_dump_dump =
9689 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9693 "dump_struct_sizes#"
9699 cmdline_parse_inst_t cmd_dump = {
9700 .f = cmd_dump_parsed, /* function to call */
9701 .data = NULL, /* 2nd arg of func */
9702 .help_str = "Dump status",
9703 .tokens = { /* token list, NULL terminated */
9704 (void *)&cmd_dump_dump,
9709 /* ******************************************************************************** */
9711 struct cmd_dump_one_result {
9712 cmdline_fixed_string_t dump;
9713 cmdline_fixed_string_t name;
9716 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9717 __rte_unused void *data)
9719 struct cmd_dump_one_result *res = parsed_result;
9721 if (!strcmp(res->dump, "dump_ring")) {
9723 r = rte_ring_lookup(res->name);
9725 cmdline_printf(cl, "Cannot find ring\n");
9728 rte_ring_dump(stdout, r);
9729 } else if (!strcmp(res->dump, "dump_mempool")) {
9730 struct rte_mempool *mp;
9731 mp = rte_mempool_lookup(res->name);
9733 cmdline_printf(cl, "Cannot find mempool\n");
9736 rte_mempool_dump(stdout, mp);
9740 cmdline_parse_token_string_t cmd_dump_one_dump =
9741 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9742 "dump_ring#dump_mempool");
9744 cmdline_parse_token_string_t cmd_dump_one_name =
9745 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9747 cmdline_parse_inst_t cmd_dump_one = {
9748 .f = cmd_dump_one_parsed, /* function to call */
9749 .data = NULL, /* 2nd arg of func */
9750 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9751 .tokens = { /* token list, NULL terminated */
9752 (void *)&cmd_dump_one_dump,
9753 (void *)&cmd_dump_one_name,
9758 /* *** Add/Del syn filter *** */
9759 struct cmd_syn_filter_result {
9760 cmdline_fixed_string_t filter;
9762 cmdline_fixed_string_t ops;
9763 cmdline_fixed_string_t priority;
9764 cmdline_fixed_string_t high;
9765 cmdline_fixed_string_t queue;
9770 cmd_syn_filter_parsed(void *parsed_result,
9771 __rte_unused struct cmdline *cl,
9772 __rte_unused void *data)
9774 struct cmd_syn_filter_result *res = parsed_result;
9775 struct rte_eth_syn_filter syn_filter;
9778 ret = rte_eth_dev_filter_supported(res->port_id,
9779 RTE_ETH_FILTER_SYN);
9781 printf("syn filter is not supported on port %u.\n",
9786 memset(&syn_filter, 0, sizeof(syn_filter));
9788 if (!strcmp(res->ops, "add")) {
9789 if (!strcmp(res->high, "high"))
9790 syn_filter.hig_pri = 1;
9792 syn_filter.hig_pri = 0;
9794 syn_filter.queue = res->queue_id;
9795 ret = rte_eth_dev_filter_ctrl(res->port_id,
9800 ret = rte_eth_dev_filter_ctrl(res->port_id,
9802 RTE_ETH_FILTER_DELETE,
9806 printf("syn filter programming error: (%s)\n",
9810 cmdline_parse_token_string_t cmd_syn_filter_filter =
9811 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9812 filter, "syn_filter");
9813 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9814 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9816 cmdline_parse_token_string_t cmd_syn_filter_ops =
9817 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9819 cmdline_parse_token_string_t cmd_syn_filter_priority =
9820 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9821 priority, "priority");
9822 cmdline_parse_token_string_t cmd_syn_filter_high =
9823 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9825 cmdline_parse_token_string_t cmd_syn_filter_queue =
9826 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9828 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9829 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9832 cmdline_parse_inst_t cmd_syn_filter = {
9833 .f = cmd_syn_filter_parsed,
9835 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9836 "<queue_id>: Add/Delete syn filter",
9838 (void *)&cmd_syn_filter_filter,
9839 (void *)&cmd_syn_filter_port_id,
9840 (void *)&cmd_syn_filter_ops,
9841 (void *)&cmd_syn_filter_priority,
9842 (void *)&cmd_syn_filter_high,
9843 (void *)&cmd_syn_filter_queue,
9844 (void *)&cmd_syn_filter_queue_id,
9849 /* *** queue region set *** */
9850 struct cmd_queue_region_result {
9851 cmdline_fixed_string_t set;
9852 cmdline_fixed_string_t port;
9854 cmdline_fixed_string_t cmd;
9855 cmdline_fixed_string_t region;
9857 cmdline_fixed_string_t queue_start_index;
9859 cmdline_fixed_string_t queue_num;
9860 uint8_t queue_num_value;
9864 cmd_queue_region_parsed(void *parsed_result,
9865 __rte_unused struct cmdline *cl,
9866 __rte_unused void *data)
9868 struct cmd_queue_region_result *res = parsed_result;
9870 #ifdef RTE_LIBRTE_I40E_PMD
9871 struct rte_pmd_i40e_queue_region_conf region_conf;
9872 enum rte_pmd_i40e_queue_region_op op_type;
9875 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9878 #ifdef RTE_LIBRTE_I40E_PMD
9879 memset(®ion_conf, 0, sizeof(region_conf));
9880 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9881 region_conf.region_id = res->region_id;
9882 region_conf.queue_num = res->queue_num_value;
9883 region_conf.queue_start_index = res->queue_id;
9885 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9886 op_type, ®ion_conf);
9893 printf("function not implemented or supported\n");
9896 printf("queue region config error: (%s)\n", strerror(-ret));
9900 cmdline_parse_token_string_t cmd_queue_region_set =
9901 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9903 cmdline_parse_token_string_t cmd_queue_region_port =
9904 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9905 cmdline_parse_token_num_t cmd_queue_region_port_id =
9906 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9908 cmdline_parse_token_string_t cmd_queue_region_cmd =
9909 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9910 cmd, "queue-region");
9911 cmdline_parse_token_string_t cmd_queue_region_id =
9912 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9913 region, "region_id");
9914 cmdline_parse_token_num_t cmd_queue_region_index =
9915 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9917 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9918 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9919 queue_start_index, "queue_start_index");
9920 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9921 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9923 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9924 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9925 queue_num, "queue_num");
9926 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9927 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9928 queue_num_value, UINT8);
9930 cmdline_parse_inst_t cmd_queue_region = {
9931 .f = cmd_queue_region_parsed,
9933 .help_str = "set port <port_id> queue-region region_id <value> "
9934 "queue_start_index <value> queue_num <value>: Set a queue region",
9936 (void *)&cmd_queue_region_set,
9937 (void *)&cmd_queue_region_port,
9938 (void *)&cmd_queue_region_port_id,
9939 (void *)&cmd_queue_region_cmd,
9940 (void *)&cmd_queue_region_id,
9941 (void *)&cmd_queue_region_index,
9942 (void *)&cmd_queue_region_queue_start_index,
9943 (void *)&cmd_queue_region_queue_id,
9944 (void *)&cmd_queue_region_queue_num,
9945 (void *)&cmd_queue_region_queue_num_value,
9950 /* *** queue region and flowtype set *** */
9951 struct cmd_region_flowtype_result {
9952 cmdline_fixed_string_t set;
9953 cmdline_fixed_string_t port;
9955 cmdline_fixed_string_t cmd;
9956 cmdline_fixed_string_t region;
9958 cmdline_fixed_string_t flowtype;
9959 uint8_t flowtype_id;
9963 cmd_region_flowtype_parsed(void *parsed_result,
9964 __rte_unused struct cmdline *cl,
9965 __rte_unused void *data)
9967 struct cmd_region_flowtype_result *res = parsed_result;
9969 #ifdef RTE_LIBRTE_I40E_PMD
9970 struct rte_pmd_i40e_queue_region_conf region_conf;
9971 enum rte_pmd_i40e_queue_region_op op_type;
9974 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9977 #ifdef RTE_LIBRTE_I40E_PMD
9978 memset(®ion_conf, 0, sizeof(region_conf));
9980 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9981 region_conf.region_id = res->region_id;
9982 region_conf.hw_flowtype = res->flowtype_id;
9984 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9985 op_type, ®ion_conf);
9992 printf("function not implemented or supported\n");
9995 printf("region flowtype config error: (%s)\n", strerror(-ret));
9999 cmdline_parse_token_string_t cmd_region_flowtype_set =
10000 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10002 cmdline_parse_token_string_t cmd_region_flowtype_port =
10003 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10005 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10006 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10008 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10009 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10010 cmd, "queue-region");
10011 cmdline_parse_token_string_t cmd_region_flowtype_index =
10012 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10013 region, "region_id");
10014 cmdline_parse_token_num_t cmd_region_flowtype_id =
10015 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10017 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10018 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10019 flowtype, "flowtype");
10020 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10021 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10022 flowtype_id, UINT8);
10023 cmdline_parse_inst_t cmd_region_flowtype = {
10024 .f = cmd_region_flowtype_parsed,
10026 .help_str = "set port <port_id> queue-region region_id <value> "
10027 "flowtype <value>: Set a flowtype region index",
10029 (void *)&cmd_region_flowtype_set,
10030 (void *)&cmd_region_flowtype_port,
10031 (void *)&cmd_region_flowtype_port_index,
10032 (void *)&cmd_region_flowtype_cmd,
10033 (void *)&cmd_region_flowtype_index,
10034 (void *)&cmd_region_flowtype_id,
10035 (void *)&cmd_region_flowtype_flow_index,
10036 (void *)&cmd_region_flowtype_flow_id,
10041 /* *** User Priority (UP) to queue region (region_id) set *** */
10042 struct cmd_user_priority_region_result {
10043 cmdline_fixed_string_t set;
10044 cmdline_fixed_string_t port;
10046 cmdline_fixed_string_t cmd;
10047 cmdline_fixed_string_t user_priority;
10048 uint8_t user_priority_id;
10049 cmdline_fixed_string_t region;
10054 cmd_user_priority_region_parsed(void *parsed_result,
10055 __rte_unused struct cmdline *cl,
10056 __rte_unused void *data)
10058 struct cmd_user_priority_region_result *res = parsed_result;
10059 int ret = -ENOTSUP;
10060 #ifdef RTE_LIBRTE_I40E_PMD
10061 struct rte_pmd_i40e_queue_region_conf region_conf;
10062 enum rte_pmd_i40e_queue_region_op op_type;
10065 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10068 #ifdef RTE_LIBRTE_I40E_PMD
10069 memset(®ion_conf, 0, sizeof(region_conf));
10070 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10071 region_conf.user_priority = res->user_priority_id;
10072 region_conf.region_id = res->region_id;
10074 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10075 op_type, ®ion_conf);
10082 printf("function not implemented or supported\n");
10085 printf("user_priority region config error: (%s)\n",
10090 cmdline_parse_token_string_t cmd_user_priority_region_set =
10091 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10093 cmdline_parse_token_string_t cmd_user_priority_region_port =
10094 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10096 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10097 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10099 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10100 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10101 cmd, "queue-region");
10102 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10103 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10104 user_priority, "UP");
10105 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10106 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10107 user_priority_id, UINT8);
10108 cmdline_parse_token_string_t cmd_user_priority_region_region =
10109 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10110 region, "region_id");
10111 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10112 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10115 cmdline_parse_inst_t cmd_user_priority_region = {
10116 .f = cmd_user_priority_region_parsed,
10118 .help_str = "set port <port_id> queue-region UP <value> "
10119 "region_id <value>: Set the mapping of User Priority (UP) "
10120 "to queue region (region_id) ",
10122 (void *)&cmd_user_priority_region_set,
10123 (void *)&cmd_user_priority_region_port,
10124 (void *)&cmd_user_priority_region_port_index,
10125 (void *)&cmd_user_priority_region_cmd,
10126 (void *)&cmd_user_priority_region_UP,
10127 (void *)&cmd_user_priority_region_UP_id,
10128 (void *)&cmd_user_priority_region_region,
10129 (void *)&cmd_user_priority_region_region_id,
10134 /* *** flush all queue region related configuration *** */
10135 struct cmd_flush_queue_region_result {
10136 cmdline_fixed_string_t set;
10137 cmdline_fixed_string_t port;
10139 cmdline_fixed_string_t cmd;
10140 cmdline_fixed_string_t flush;
10141 cmdline_fixed_string_t what;
10145 cmd_flush_queue_region_parsed(void *parsed_result,
10146 __rte_unused struct cmdline *cl,
10147 __rte_unused void *data)
10149 struct cmd_flush_queue_region_result *res = parsed_result;
10150 int ret = -ENOTSUP;
10151 #ifdef RTE_LIBRTE_I40E_PMD
10152 struct rte_pmd_i40e_queue_region_conf region_conf;
10153 enum rte_pmd_i40e_queue_region_op op_type;
10156 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10159 #ifdef RTE_LIBRTE_I40E_PMD
10160 memset(®ion_conf, 0, sizeof(region_conf));
10162 if (strcmp(res->what, "on") == 0)
10163 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10165 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10167 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10168 op_type, ®ion_conf);
10175 printf("function not implemented or supported\n");
10178 printf("queue region config flush error: (%s)\n",
10183 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10184 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10186 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10187 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10189 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10190 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10192 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10193 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10194 cmd, "queue-region");
10195 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10196 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10198 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10199 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10202 cmdline_parse_inst_t cmd_flush_queue_region = {
10203 .f = cmd_flush_queue_region_parsed,
10205 .help_str = "set port <port_id> queue-region flush on|off"
10206 ": flush all queue region related configuration",
10208 (void *)&cmd_flush_queue_region_set,
10209 (void *)&cmd_flush_queue_region_port,
10210 (void *)&cmd_flush_queue_region_port_index,
10211 (void *)&cmd_flush_queue_region_cmd,
10212 (void *)&cmd_flush_queue_region_flush,
10213 (void *)&cmd_flush_queue_region_what,
10218 /* *** get all queue region related configuration info *** */
10219 struct cmd_show_queue_region_info {
10220 cmdline_fixed_string_t show;
10221 cmdline_fixed_string_t port;
10223 cmdline_fixed_string_t cmd;
10227 cmd_show_queue_region_info_parsed(void *parsed_result,
10228 __rte_unused struct cmdline *cl,
10229 __rte_unused void *data)
10231 struct cmd_show_queue_region_info *res = parsed_result;
10232 int ret = -ENOTSUP;
10233 #ifdef RTE_LIBRTE_I40E_PMD
10234 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10235 enum rte_pmd_i40e_queue_region_op op_type;
10238 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10241 #ifdef RTE_LIBRTE_I40E_PMD
10242 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10244 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10246 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10247 op_type, &rte_pmd_regions);
10249 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10256 printf("function not implemented or supported\n");
10259 printf("queue region config info show error: (%s)\n",
10264 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10265 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10267 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10268 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10270 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10271 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10273 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10274 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10275 cmd, "queue-region");
10277 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10278 .f = cmd_show_queue_region_info_parsed,
10280 .help_str = "show port <port_id> queue-region"
10281 ": show all queue region related configuration info",
10283 (void *)&cmd_show_queue_region_info_get,
10284 (void *)&cmd_show_queue_region_info_port,
10285 (void *)&cmd_show_queue_region_info_port_index,
10286 (void *)&cmd_show_queue_region_info_cmd,
10291 /* *** ADD/REMOVE A 2tuple FILTER *** */
10292 struct cmd_2tuple_filter_result {
10293 cmdline_fixed_string_t filter;
10295 cmdline_fixed_string_t ops;
10296 cmdline_fixed_string_t dst_port;
10297 uint16_t dst_port_value;
10298 cmdline_fixed_string_t protocol;
10299 uint8_t protocol_value;
10300 cmdline_fixed_string_t mask;
10301 uint8_t mask_value;
10302 cmdline_fixed_string_t tcp_flags;
10303 uint8_t tcp_flags_value;
10304 cmdline_fixed_string_t priority;
10305 uint8_t priority_value;
10306 cmdline_fixed_string_t queue;
10311 cmd_2tuple_filter_parsed(void *parsed_result,
10312 __rte_unused struct cmdline *cl,
10313 __rte_unused void *data)
10315 struct rte_eth_ntuple_filter filter;
10316 struct cmd_2tuple_filter_result *res = parsed_result;
10319 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10321 printf("ntuple filter is not supported on port %u.\n",
10326 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10328 filter.flags = RTE_2TUPLE_FLAGS;
10329 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10330 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10331 filter.proto = res->protocol_value;
10332 filter.priority = res->priority_value;
10333 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10334 printf("nonzero tcp_flags is only meaningful"
10335 " when protocol is TCP.\n");
10338 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10339 printf("invalid TCP flags.\n");
10343 if (res->tcp_flags_value != 0) {
10344 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10345 filter.tcp_flags = res->tcp_flags_value;
10348 /* need convert to big endian. */
10349 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10350 filter.queue = res->queue_id;
10352 if (!strcmp(res->ops, "add"))
10353 ret = rte_eth_dev_filter_ctrl(res->port_id,
10354 RTE_ETH_FILTER_NTUPLE,
10355 RTE_ETH_FILTER_ADD,
10358 ret = rte_eth_dev_filter_ctrl(res->port_id,
10359 RTE_ETH_FILTER_NTUPLE,
10360 RTE_ETH_FILTER_DELETE,
10363 printf("2tuple filter programming error: (%s)\n",
10368 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10369 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10370 filter, "2tuple_filter");
10371 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10372 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10374 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10375 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10377 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10378 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10379 dst_port, "dst_port");
10380 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10381 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10382 dst_port_value, UINT16);
10383 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10384 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10385 protocol, "protocol");
10386 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10387 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10388 protocol_value, UINT8);
10389 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10390 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10392 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10393 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10395 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10396 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10397 tcp_flags, "tcp_flags");
10398 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10399 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10400 tcp_flags_value, UINT8);
10401 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10402 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10403 priority, "priority");
10404 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10405 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10406 priority_value, UINT8);
10407 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10408 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10410 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10411 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10414 cmdline_parse_inst_t cmd_2tuple_filter = {
10415 .f = cmd_2tuple_filter_parsed,
10417 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10418 "<value> mask <value> tcp_flags <value> priority <value> queue "
10419 "<queue_id>: Add a 2tuple filter",
10421 (void *)&cmd_2tuple_filter_filter,
10422 (void *)&cmd_2tuple_filter_port_id,
10423 (void *)&cmd_2tuple_filter_ops,
10424 (void *)&cmd_2tuple_filter_dst_port,
10425 (void *)&cmd_2tuple_filter_dst_port_value,
10426 (void *)&cmd_2tuple_filter_protocol,
10427 (void *)&cmd_2tuple_filter_protocol_value,
10428 (void *)&cmd_2tuple_filter_mask,
10429 (void *)&cmd_2tuple_filter_mask_value,
10430 (void *)&cmd_2tuple_filter_tcp_flags,
10431 (void *)&cmd_2tuple_filter_tcp_flags_value,
10432 (void *)&cmd_2tuple_filter_priority,
10433 (void *)&cmd_2tuple_filter_priority_value,
10434 (void *)&cmd_2tuple_filter_queue,
10435 (void *)&cmd_2tuple_filter_queue_id,
10440 /* *** ADD/REMOVE A 5tuple FILTER *** */
10441 struct cmd_5tuple_filter_result {
10442 cmdline_fixed_string_t filter;
10444 cmdline_fixed_string_t ops;
10445 cmdline_fixed_string_t dst_ip;
10446 cmdline_ipaddr_t dst_ip_value;
10447 cmdline_fixed_string_t src_ip;
10448 cmdline_ipaddr_t src_ip_value;
10449 cmdline_fixed_string_t dst_port;
10450 uint16_t dst_port_value;
10451 cmdline_fixed_string_t src_port;
10452 uint16_t src_port_value;
10453 cmdline_fixed_string_t protocol;
10454 uint8_t protocol_value;
10455 cmdline_fixed_string_t mask;
10456 uint8_t mask_value;
10457 cmdline_fixed_string_t tcp_flags;
10458 uint8_t tcp_flags_value;
10459 cmdline_fixed_string_t priority;
10460 uint8_t priority_value;
10461 cmdline_fixed_string_t queue;
10466 cmd_5tuple_filter_parsed(void *parsed_result,
10467 __rte_unused struct cmdline *cl,
10468 __rte_unused void *data)
10470 struct rte_eth_ntuple_filter filter;
10471 struct cmd_5tuple_filter_result *res = parsed_result;
10474 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10476 printf("ntuple filter is not supported on port %u.\n",
10481 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10483 filter.flags = RTE_5TUPLE_FLAGS;
10484 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10485 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10486 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10487 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10488 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10489 filter.proto = res->protocol_value;
10490 filter.priority = res->priority_value;
10491 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10492 printf("nonzero tcp_flags is only meaningful"
10493 " when protocol is TCP.\n");
10496 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10497 printf("invalid TCP flags.\n");
10501 if (res->tcp_flags_value != 0) {
10502 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10503 filter.tcp_flags = res->tcp_flags_value;
10506 if (res->dst_ip_value.family == AF_INET)
10507 /* no need to convert, already big endian. */
10508 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10510 if (filter.dst_ip_mask == 0) {
10511 printf("can not support ipv6 involved compare.\n");
10517 if (res->src_ip_value.family == AF_INET)
10518 /* no need to convert, already big endian. */
10519 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10521 if (filter.src_ip_mask == 0) {
10522 printf("can not support ipv6 involved compare.\n");
10527 /* need convert to big endian. */
10528 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10529 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10530 filter.queue = res->queue_id;
10532 if (!strcmp(res->ops, "add"))
10533 ret = rte_eth_dev_filter_ctrl(res->port_id,
10534 RTE_ETH_FILTER_NTUPLE,
10535 RTE_ETH_FILTER_ADD,
10538 ret = rte_eth_dev_filter_ctrl(res->port_id,
10539 RTE_ETH_FILTER_NTUPLE,
10540 RTE_ETH_FILTER_DELETE,
10543 printf("5tuple filter programming error: (%s)\n",
10547 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10548 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10549 filter, "5tuple_filter");
10550 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10551 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10553 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10554 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10556 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10557 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10559 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10560 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10562 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10563 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10565 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10566 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10568 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10569 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10570 dst_port, "dst_port");
10571 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10572 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10573 dst_port_value, UINT16);
10574 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10575 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10576 src_port, "src_port");
10577 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10578 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10579 src_port_value, UINT16);
10580 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10581 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10582 protocol, "protocol");
10583 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10584 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10585 protocol_value, UINT8);
10586 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10587 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10589 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10590 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10592 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10593 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10594 tcp_flags, "tcp_flags");
10595 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10596 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10597 tcp_flags_value, UINT8);
10598 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10599 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10600 priority, "priority");
10601 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10602 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10603 priority_value, UINT8);
10604 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10605 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10607 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10608 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10611 cmdline_parse_inst_t cmd_5tuple_filter = {
10612 .f = cmd_5tuple_filter_parsed,
10614 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10615 "src_ip <value> dst_port <value> src_port <value> "
10616 "protocol <value> mask <value> tcp_flags <value> "
10617 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10619 (void *)&cmd_5tuple_filter_filter,
10620 (void *)&cmd_5tuple_filter_port_id,
10621 (void *)&cmd_5tuple_filter_ops,
10622 (void *)&cmd_5tuple_filter_dst_ip,
10623 (void *)&cmd_5tuple_filter_dst_ip_value,
10624 (void *)&cmd_5tuple_filter_src_ip,
10625 (void *)&cmd_5tuple_filter_src_ip_value,
10626 (void *)&cmd_5tuple_filter_dst_port,
10627 (void *)&cmd_5tuple_filter_dst_port_value,
10628 (void *)&cmd_5tuple_filter_src_port,
10629 (void *)&cmd_5tuple_filter_src_port_value,
10630 (void *)&cmd_5tuple_filter_protocol,
10631 (void *)&cmd_5tuple_filter_protocol_value,
10632 (void *)&cmd_5tuple_filter_mask,
10633 (void *)&cmd_5tuple_filter_mask_value,
10634 (void *)&cmd_5tuple_filter_tcp_flags,
10635 (void *)&cmd_5tuple_filter_tcp_flags_value,
10636 (void *)&cmd_5tuple_filter_priority,
10637 (void *)&cmd_5tuple_filter_priority_value,
10638 (void *)&cmd_5tuple_filter_queue,
10639 (void *)&cmd_5tuple_filter_queue_id,
10644 /* *** ADD/REMOVE A flex FILTER *** */
10645 struct cmd_flex_filter_result {
10646 cmdline_fixed_string_t filter;
10647 cmdline_fixed_string_t ops;
10649 cmdline_fixed_string_t len;
10651 cmdline_fixed_string_t bytes;
10652 cmdline_fixed_string_t bytes_value;
10653 cmdline_fixed_string_t mask;
10654 cmdline_fixed_string_t mask_value;
10655 cmdline_fixed_string_t priority;
10656 uint8_t priority_value;
10657 cmdline_fixed_string_t queue;
10661 static int xdigit2val(unsigned char c)
10666 else if (isupper(c))
10667 val = c - 'A' + 10;
10669 val = c - 'a' + 10;
10674 cmd_flex_filter_parsed(void *parsed_result,
10675 __rte_unused struct cmdline *cl,
10676 __rte_unused void *data)
10679 struct rte_eth_flex_filter filter;
10680 struct cmd_flex_filter_result *res = parsed_result;
10681 char *bytes_ptr, *mask_ptr;
10682 uint16_t len, i, j = 0;
10687 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10688 printf("the len exceed the max length 128\n");
10691 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10692 filter.len = res->len_value;
10693 filter.priority = res->priority_value;
10694 filter.queue = res->queue_id;
10695 bytes_ptr = res->bytes_value;
10696 mask_ptr = res->mask_value;
10698 /* translate bytes string to array. */
10699 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10700 (bytes_ptr[1] == 'X')))
10702 len = strnlen(bytes_ptr, res->len_value * 2);
10703 if (len == 0 || (len % 8 != 0)) {
10704 printf("please check len and bytes input\n");
10707 for (i = 0; i < len; i++) {
10709 if (isxdigit(c) == 0) {
10710 /* invalid characters. */
10711 printf("invalid input\n");
10714 val = xdigit2val(c);
10717 filter.bytes[j] = byte;
10718 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10725 /* translate mask string to uint8_t array. */
10726 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10727 (mask_ptr[1] == 'X')))
10729 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10731 printf("invalid input\n");
10736 for (i = 0; i < len; i++) {
10738 if (isxdigit(c) == 0) {
10739 /* invalid characters. */
10740 printf("invalid input\n");
10743 val = xdigit2val(c);
10746 filter.mask[j] = byte;
10747 printf("mask[%d]:%02x ", j, filter.mask[j]);
10755 if (!strcmp(res->ops, "add"))
10756 ret = rte_eth_dev_filter_ctrl(res->port_id,
10757 RTE_ETH_FILTER_FLEXIBLE,
10758 RTE_ETH_FILTER_ADD,
10761 ret = rte_eth_dev_filter_ctrl(res->port_id,
10762 RTE_ETH_FILTER_FLEXIBLE,
10763 RTE_ETH_FILTER_DELETE,
10767 printf("flex filter setting error: (%s)\n", strerror(-ret));
10770 cmdline_parse_token_string_t cmd_flex_filter_filter =
10771 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10772 filter, "flex_filter");
10773 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10774 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10776 cmdline_parse_token_string_t cmd_flex_filter_ops =
10777 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10779 cmdline_parse_token_string_t cmd_flex_filter_len =
10780 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10782 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10783 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10785 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10786 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10788 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10789 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10790 bytes_value, NULL);
10791 cmdline_parse_token_string_t cmd_flex_filter_mask =
10792 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10794 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10795 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10797 cmdline_parse_token_string_t cmd_flex_filter_priority =
10798 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10799 priority, "priority");
10800 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10801 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10802 priority_value, UINT8);
10803 cmdline_parse_token_string_t cmd_flex_filter_queue =
10804 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10806 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10807 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10809 cmdline_parse_inst_t cmd_flex_filter = {
10810 .f = cmd_flex_filter_parsed,
10812 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10813 "<value> mask <value> priority <value> queue <queue_id>: "
10814 "Add/Del a flex filter",
10816 (void *)&cmd_flex_filter_filter,
10817 (void *)&cmd_flex_filter_port_id,
10818 (void *)&cmd_flex_filter_ops,
10819 (void *)&cmd_flex_filter_len,
10820 (void *)&cmd_flex_filter_len_value,
10821 (void *)&cmd_flex_filter_bytes,
10822 (void *)&cmd_flex_filter_bytes_value,
10823 (void *)&cmd_flex_filter_mask,
10824 (void *)&cmd_flex_filter_mask_value,
10825 (void *)&cmd_flex_filter_priority,
10826 (void *)&cmd_flex_filter_priority_value,
10827 (void *)&cmd_flex_filter_queue,
10828 (void *)&cmd_flex_filter_queue_id,
10833 /* *** Filters Control *** */
10835 /* *** deal with ethertype filter *** */
10836 struct cmd_ethertype_filter_result {
10837 cmdline_fixed_string_t filter;
10839 cmdline_fixed_string_t ops;
10840 cmdline_fixed_string_t mac;
10841 struct rte_ether_addr mac_addr;
10842 cmdline_fixed_string_t ethertype;
10843 uint16_t ethertype_value;
10844 cmdline_fixed_string_t drop;
10845 cmdline_fixed_string_t queue;
10849 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10850 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10851 filter, "ethertype_filter");
10852 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10853 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10855 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10856 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10858 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10859 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10860 mac, "mac_addr#mac_ignr");
10861 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10862 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10864 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10865 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10866 ethertype, "ethertype");
10867 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10868 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10869 ethertype_value, UINT16);
10870 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10871 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10873 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10874 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10876 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10877 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10881 cmd_ethertype_filter_parsed(void *parsed_result,
10882 __rte_unused struct cmdline *cl,
10883 __rte_unused void *data)
10885 struct cmd_ethertype_filter_result *res = parsed_result;
10886 struct rte_eth_ethertype_filter filter;
10889 ret = rte_eth_dev_filter_supported(res->port_id,
10890 RTE_ETH_FILTER_ETHERTYPE);
10892 printf("ethertype filter is not supported on port %u.\n",
10897 memset(&filter, 0, sizeof(filter));
10898 if (!strcmp(res->mac, "mac_addr")) {
10899 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10900 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10901 sizeof(struct rte_ether_addr));
10903 if (!strcmp(res->drop, "drop"))
10904 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10905 filter.ether_type = res->ethertype_value;
10906 filter.queue = res->queue_id;
10908 if (!strcmp(res->ops, "add"))
10909 ret = rte_eth_dev_filter_ctrl(res->port_id,
10910 RTE_ETH_FILTER_ETHERTYPE,
10911 RTE_ETH_FILTER_ADD,
10914 ret = rte_eth_dev_filter_ctrl(res->port_id,
10915 RTE_ETH_FILTER_ETHERTYPE,
10916 RTE_ETH_FILTER_DELETE,
10919 printf("ethertype filter programming error: (%s)\n",
10923 cmdline_parse_inst_t cmd_ethertype_filter = {
10924 .f = cmd_ethertype_filter_parsed,
10926 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10927 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10928 "Add or delete an ethertype filter entry",
10930 (void *)&cmd_ethertype_filter_filter,
10931 (void *)&cmd_ethertype_filter_port_id,
10932 (void *)&cmd_ethertype_filter_ops,
10933 (void *)&cmd_ethertype_filter_mac,
10934 (void *)&cmd_ethertype_filter_mac_addr,
10935 (void *)&cmd_ethertype_filter_ethertype,
10936 (void *)&cmd_ethertype_filter_ethertype_value,
10937 (void *)&cmd_ethertype_filter_drop,
10938 (void *)&cmd_ethertype_filter_queue,
10939 (void *)&cmd_ethertype_filter_queue_id,
10944 /* *** deal with flow director filter *** */
10945 struct cmd_flow_director_result {
10946 cmdline_fixed_string_t flow_director_filter;
10948 cmdline_fixed_string_t mode;
10949 cmdline_fixed_string_t mode_value;
10950 cmdline_fixed_string_t ops;
10951 cmdline_fixed_string_t flow;
10952 cmdline_fixed_string_t flow_type;
10953 cmdline_fixed_string_t ether;
10954 uint16_t ether_type;
10955 cmdline_fixed_string_t src;
10956 cmdline_ipaddr_t ip_src;
10958 cmdline_fixed_string_t dst;
10959 cmdline_ipaddr_t ip_dst;
10961 cmdline_fixed_string_t verify_tag;
10962 uint32_t verify_tag_value;
10963 cmdline_fixed_string_t tos;
10965 cmdline_fixed_string_t proto;
10966 uint8_t proto_value;
10967 cmdline_fixed_string_t ttl;
10969 cmdline_fixed_string_t vlan;
10970 uint16_t vlan_value;
10971 cmdline_fixed_string_t flexbytes;
10972 cmdline_fixed_string_t flexbytes_value;
10973 cmdline_fixed_string_t pf_vf;
10974 cmdline_fixed_string_t drop;
10975 cmdline_fixed_string_t queue;
10977 cmdline_fixed_string_t fd_id;
10978 uint32_t fd_id_value;
10979 cmdline_fixed_string_t mac;
10980 struct rte_ether_addr mac_addr;
10981 cmdline_fixed_string_t tunnel;
10982 cmdline_fixed_string_t tunnel_type;
10983 cmdline_fixed_string_t tunnel_id;
10984 uint32_t tunnel_id_value;
10985 cmdline_fixed_string_t packet;
10990 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10993 const char *p, *p0 = q_arg;
10995 unsigned long int_fld;
10996 char *str_fld[max_num];
11001 p = strchr(p0, '(');
11005 p0 = strchr(p, ')');
11010 if (size >= sizeof(s))
11013 snprintf(s, sizeof(s), "%.*s", size, p);
11014 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11015 if (ret < 0 || ret > max_num)
11017 for (i = 0; i < ret; i++) {
11019 int_fld = strtoul(str_fld[i], &end, 0);
11020 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11022 flexbytes[i] = (uint8_t)int_fld;
11028 str2flowtype(char *string)
11031 static const struct {
11034 } flowtype_str[] = {
11035 {"raw", RTE_ETH_FLOW_RAW},
11036 {"ipv4", RTE_ETH_FLOW_IPV4},
11037 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11038 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11039 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11040 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11041 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11042 {"ipv6", RTE_ETH_FLOW_IPV6},
11043 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11044 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11045 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11046 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11047 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11048 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11051 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11052 if (!strcmp(flowtype_str[i].str, string))
11053 return flowtype_str[i].type;
11056 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11057 return (uint16_t)atoi(string);
11059 return RTE_ETH_FLOW_UNKNOWN;
11062 static enum rte_eth_fdir_tunnel_type
11063 str2fdir_tunneltype(char *string)
11067 static const struct {
11069 enum rte_eth_fdir_tunnel_type type;
11070 } tunneltype_str[] = {
11071 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11072 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11075 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11076 if (!strcmp(tunneltype_str[i].str, string))
11077 return tunneltype_str[i].type;
11079 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11082 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11084 if ((ip_addr).family == AF_INET) \
11085 (ip) = (ip_addr).addr.ipv4.s_addr; \
11087 printf("invalid parameter.\n"); \
11092 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11094 if ((ip_addr).family == AF_INET6) \
11095 rte_memcpy(&(ip), \
11096 &((ip_addr).addr.ipv6), \
11097 sizeof(struct in6_addr)); \
11099 printf("invalid parameter.\n"); \
11105 cmd_flow_director_filter_parsed(void *parsed_result,
11106 __rte_unused struct cmdline *cl,
11107 __rte_unused void *data)
11109 struct cmd_flow_director_result *res = parsed_result;
11110 struct rte_eth_fdir_filter entry;
11111 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11113 unsigned long vf_id;
11116 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11118 printf("flow director is not supported on port %u.\n",
11122 memset(flexbytes, 0, sizeof(flexbytes));
11123 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11125 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11126 if (strcmp(res->mode_value, "MAC-VLAN")) {
11127 printf("Please set mode to MAC-VLAN.\n");
11130 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11131 if (strcmp(res->mode_value, "Tunnel")) {
11132 printf("Please set mode to Tunnel.\n");
11136 if (!strcmp(res->mode_value, "raw")) {
11137 #ifdef RTE_LIBRTE_I40E_PMD
11138 struct rte_pmd_i40e_flow_type_mapping
11139 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11140 struct rte_pmd_i40e_pkt_template_conf conf;
11141 uint16_t flow_type = str2flowtype(res->flow_type);
11142 uint16_t i, port = res->port_id;
11145 memset(&conf, 0, sizeof(conf));
11147 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11148 printf("Invalid flow type specified.\n");
11151 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11155 if (mapping[flow_type].pctype == 0ULL) {
11156 printf("Invalid flow type specified.\n");
11159 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11160 if (mapping[flow_type].pctype & (1ULL << i)) {
11161 conf.input.pctype = i;
11166 conf.input.packet = open_file(res->filepath,
11167 &conf.input.length);
11168 if (!conf.input.packet)
11170 if (!strcmp(res->drop, "drop"))
11171 conf.action.behavior =
11172 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11174 conf.action.behavior =
11175 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11176 conf.action.report_status =
11177 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11178 conf.action.rx_queue = res->queue_id;
11179 conf.soft_id = res->fd_id_value;
11180 add = strcmp(res->ops, "del") ? 1 : 0;
11181 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11185 printf("flow director config error: (%s)\n",
11187 close_file(conf.input.packet);
11190 } else if (strcmp(res->mode_value, "IP")) {
11191 printf("Please set mode to IP or raw.\n");
11194 entry.input.flow_type = str2flowtype(res->flow_type);
11197 ret = parse_flexbytes(res->flexbytes_value,
11199 RTE_ETH_FDIR_MAX_FLEXLEN);
11201 printf("error: Cannot parse flexbytes input.\n");
11205 switch (entry.input.flow_type) {
11206 case RTE_ETH_FLOW_FRAG_IPV4:
11207 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11208 entry.input.flow.ip4_flow.proto = res->proto_value;
11210 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11211 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11212 IPV4_ADDR_TO_UINT(res->ip_dst,
11213 entry.input.flow.ip4_flow.dst_ip);
11214 IPV4_ADDR_TO_UINT(res->ip_src,
11215 entry.input.flow.ip4_flow.src_ip);
11216 entry.input.flow.ip4_flow.tos = res->tos_value;
11217 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11218 /* need convert to big endian. */
11219 entry.input.flow.udp4_flow.dst_port =
11220 rte_cpu_to_be_16(res->port_dst);
11221 entry.input.flow.udp4_flow.src_port =
11222 rte_cpu_to_be_16(res->port_src);
11224 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11225 IPV4_ADDR_TO_UINT(res->ip_dst,
11226 entry.input.flow.sctp4_flow.ip.dst_ip);
11227 IPV4_ADDR_TO_UINT(res->ip_src,
11228 entry.input.flow.sctp4_flow.ip.src_ip);
11229 entry.input.flow.ip4_flow.tos = res->tos_value;
11230 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11231 /* need convert to big endian. */
11232 entry.input.flow.sctp4_flow.dst_port =
11233 rte_cpu_to_be_16(res->port_dst);
11234 entry.input.flow.sctp4_flow.src_port =
11235 rte_cpu_to_be_16(res->port_src);
11236 entry.input.flow.sctp4_flow.verify_tag =
11237 rte_cpu_to_be_32(res->verify_tag_value);
11239 case RTE_ETH_FLOW_FRAG_IPV6:
11240 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11241 entry.input.flow.ipv6_flow.proto = res->proto_value;
11243 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11244 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11245 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11246 entry.input.flow.ipv6_flow.dst_ip);
11247 IPV6_ADDR_TO_ARRAY(res->ip_src,
11248 entry.input.flow.ipv6_flow.src_ip);
11249 entry.input.flow.ipv6_flow.tc = res->tos_value;
11250 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11251 /* need convert to big endian. */
11252 entry.input.flow.udp6_flow.dst_port =
11253 rte_cpu_to_be_16(res->port_dst);
11254 entry.input.flow.udp6_flow.src_port =
11255 rte_cpu_to_be_16(res->port_src);
11257 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11258 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11259 entry.input.flow.sctp6_flow.ip.dst_ip);
11260 IPV6_ADDR_TO_ARRAY(res->ip_src,
11261 entry.input.flow.sctp6_flow.ip.src_ip);
11262 entry.input.flow.ipv6_flow.tc = res->tos_value;
11263 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11264 /* need convert to big endian. */
11265 entry.input.flow.sctp6_flow.dst_port =
11266 rte_cpu_to_be_16(res->port_dst);
11267 entry.input.flow.sctp6_flow.src_port =
11268 rte_cpu_to_be_16(res->port_src);
11269 entry.input.flow.sctp6_flow.verify_tag =
11270 rte_cpu_to_be_32(res->verify_tag_value);
11272 case RTE_ETH_FLOW_L2_PAYLOAD:
11273 entry.input.flow.l2_flow.ether_type =
11274 rte_cpu_to_be_16(res->ether_type);
11280 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11281 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11283 sizeof(struct rte_ether_addr));
11285 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11286 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11288 sizeof(struct rte_ether_addr));
11289 entry.input.flow.tunnel_flow.tunnel_type =
11290 str2fdir_tunneltype(res->tunnel_type);
11291 entry.input.flow.tunnel_flow.tunnel_id =
11292 rte_cpu_to_be_32(res->tunnel_id_value);
11295 rte_memcpy(entry.input.flow_ext.flexbytes,
11297 RTE_ETH_FDIR_MAX_FLEXLEN);
11299 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11301 entry.action.flex_off = 0; /*use 0 by default */
11302 if (!strcmp(res->drop, "drop"))
11303 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11305 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11307 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11308 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11309 if (!strcmp(res->pf_vf, "pf"))
11310 entry.input.flow_ext.is_vf = 0;
11311 else if (!strncmp(res->pf_vf, "vf", 2)) {
11312 struct rte_eth_dev_info dev_info;
11314 ret = eth_dev_info_get_print_err(res->port_id,
11320 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11321 if (errno != 0 || *end != '\0' ||
11322 vf_id >= dev_info.max_vfs) {
11323 printf("invalid parameter %s.\n", res->pf_vf);
11326 entry.input.flow_ext.is_vf = 1;
11327 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11329 printf("invalid parameter %s.\n", res->pf_vf);
11334 /* set to report FD ID by default */
11335 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11336 entry.action.rx_queue = res->queue_id;
11337 entry.soft_id = res->fd_id_value;
11338 if (!strcmp(res->ops, "add"))
11339 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11340 RTE_ETH_FILTER_ADD, &entry);
11341 else if (!strcmp(res->ops, "del"))
11342 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11343 RTE_ETH_FILTER_DELETE, &entry);
11345 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11346 RTE_ETH_FILTER_UPDATE, &entry);
11348 printf("flow director programming error: (%s)\n",
11352 cmdline_parse_token_string_t cmd_flow_director_filter =
11353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11354 flow_director_filter, "flow_director_filter");
11355 cmdline_parse_token_num_t cmd_flow_director_port_id =
11356 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11358 cmdline_parse_token_string_t cmd_flow_director_ops =
11359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11360 ops, "add#del#update");
11361 cmdline_parse_token_string_t cmd_flow_director_flow =
11362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11364 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11367 cmdline_parse_token_string_t cmd_flow_director_ether =
11368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11370 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11371 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11372 ether_type, UINT16);
11373 cmdline_parse_token_string_t cmd_flow_director_src =
11374 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11376 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11377 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11379 cmdline_parse_token_num_t cmd_flow_director_port_src =
11380 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11382 cmdline_parse_token_string_t cmd_flow_director_dst =
11383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11385 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11386 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11388 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11389 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11391 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11392 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11393 verify_tag, "verify_tag");
11394 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11395 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11396 verify_tag_value, UINT32);
11397 cmdline_parse_token_string_t cmd_flow_director_tos =
11398 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11400 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11401 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11403 cmdline_parse_token_string_t cmd_flow_director_proto =
11404 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11406 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11407 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11408 proto_value, UINT8);
11409 cmdline_parse_token_string_t cmd_flow_director_ttl =
11410 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11412 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11413 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11415 cmdline_parse_token_string_t cmd_flow_director_vlan =
11416 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11418 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11419 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11420 vlan_value, UINT16);
11421 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11422 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11423 flexbytes, "flexbytes");
11424 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11425 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11426 flexbytes_value, NULL);
11427 cmdline_parse_token_string_t cmd_flow_director_drop =
11428 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11430 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11431 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11433 cmdline_parse_token_string_t cmd_flow_director_queue =
11434 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11436 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11437 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11439 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11442 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11443 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11444 fd_id_value, UINT32);
11446 cmdline_parse_token_string_t cmd_flow_director_mode =
11447 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11449 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11450 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11452 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11453 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11454 mode_value, "MAC-VLAN");
11455 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11456 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11457 mode_value, "Tunnel");
11458 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11459 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11460 mode_value, "raw");
11461 cmdline_parse_token_string_t cmd_flow_director_mac =
11462 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11464 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11465 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11467 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11468 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11470 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11471 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11472 tunnel_type, "NVGRE#VxLAN");
11473 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11474 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11475 tunnel_id, "tunnel-id");
11476 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11477 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11478 tunnel_id_value, UINT32);
11479 cmdline_parse_token_string_t cmd_flow_director_packet =
11480 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11482 cmdline_parse_token_string_t cmd_flow_director_filepath =
11483 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11486 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11487 .f = cmd_flow_director_filter_parsed,
11489 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11490 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11491 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11492 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11493 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11494 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11495 "fd_id <fd_id_value>: "
11496 "Add or delete an ip flow director entry on NIC",
11498 (void *)&cmd_flow_director_filter,
11499 (void *)&cmd_flow_director_port_id,
11500 (void *)&cmd_flow_director_mode,
11501 (void *)&cmd_flow_director_mode_ip,
11502 (void *)&cmd_flow_director_ops,
11503 (void *)&cmd_flow_director_flow,
11504 (void *)&cmd_flow_director_flow_type,
11505 (void *)&cmd_flow_director_src,
11506 (void *)&cmd_flow_director_ip_src,
11507 (void *)&cmd_flow_director_dst,
11508 (void *)&cmd_flow_director_ip_dst,
11509 (void *)&cmd_flow_director_tos,
11510 (void *)&cmd_flow_director_tos_value,
11511 (void *)&cmd_flow_director_proto,
11512 (void *)&cmd_flow_director_proto_value,
11513 (void *)&cmd_flow_director_ttl,
11514 (void *)&cmd_flow_director_ttl_value,
11515 (void *)&cmd_flow_director_vlan,
11516 (void *)&cmd_flow_director_vlan_value,
11517 (void *)&cmd_flow_director_flexbytes,
11518 (void *)&cmd_flow_director_flexbytes_value,
11519 (void *)&cmd_flow_director_drop,
11520 (void *)&cmd_flow_director_pf_vf,
11521 (void *)&cmd_flow_director_queue,
11522 (void *)&cmd_flow_director_queue_id,
11523 (void *)&cmd_flow_director_fd_id,
11524 (void *)&cmd_flow_director_fd_id_value,
11529 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11530 .f = cmd_flow_director_filter_parsed,
11532 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11533 "director entry on NIC",
11535 (void *)&cmd_flow_director_filter,
11536 (void *)&cmd_flow_director_port_id,
11537 (void *)&cmd_flow_director_mode,
11538 (void *)&cmd_flow_director_mode_ip,
11539 (void *)&cmd_flow_director_ops,
11540 (void *)&cmd_flow_director_flow,
11541 (void *)&cmd_flow_director_flow_type,
11542 (void *)&cmd_flow_director_src,
11543 (void *)&cmd_flow_director_ip_src,
11544 (void *)&cmd_flow_director_port_src,
11545 (void *)&cmd_flow_director_dst,
11546 (void *)&cmd_flow_director_ip_dst,
11547 (void *)&cmd_flow_director_port_dst,
11548 (void *)&cmd_flow_director_tos,
11549 (void *)&cmd_flow_director_tos_value,
11550 (void *)&cmd_flow_director_ttl,
11551 (void *)&cmd_flow_director_ttl_value,
11552 (void *)&cmd_flow_director_vlan,
11553 (void *)&cmd_flow_director_vlan_value,
11554 (void *)&cmd_flow_director_flexbytes,
11555 (void *)&cmd_flow_director_flexbytes_value,
11556 (void *)&cmd_flow_director_drop,
11557 (void *)&cmd_flow_director_pf_vf,
11558 (void *)&cmd_flow_director_queue,
11559 (void *)&cmd_flow_director_queue_id,
11560 (void *)&cmd_flow_director_fd_id,
11561 (void *)&cmd_flow_director_fd_id_value,
11566 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11567 .f = cmd_flow_director_filter_parsed,
11569 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11570 "director entry on NIC",
11572 (void *)&cmd_flow_director_filter,
11573 (void *)&cmd_flow_director_port_id,
11574 (void *)&cmd_flow_director_mode,
11575 (void *)&cmd_flow_director_mode_ip,
11576 (void *)&cmd_flow_director_ops,
11577 (void *)&cmd_flow_director_flow,
11578 (void *)&cmd_flow_director_flow_type,
11579 (void *)&cmd_flow_director_src,
11580 (void *)&cmd_flow_director_ip_src,
11581 (void *)&cmd_flow_director_port_src,
11582 (void *)&cmd_flow_director_dst,
11583 (void *)&cmd_flow_director_ip_dst,
11584 (void *)&cmd_flow_director_port_dst,
11585 (void *)&cmd_flow_director_verify_tag,
11586 (void *)&cmd_flow_director_verify_tag_value,
11587 (void *)&cmd_flow_director_tos,
11588 (void *)&cmd_flow_director_tos_value,
11589 (void *)&cmd_flow_director_ttl,
11590 (void *)&cmd_flow_director_ttl_value,
11591 (void *)&cmd_flow_director_vlan,
11592 (void *)&cmd_flow_director_vlan_value,
11593 (void *)&cmd_flow_director_flexbytes,
11594 (void *)&cmd_flow_director_flexbytes_value,
11595 (void *)&cmd_flow_director_drop,
11596 (void *)&cmd_flow_director_pf_vf,
11597 (void *)&cmd_flow_director_queue,
11598 (void *)&cmd_flow_director_queue_id,
11599 (void *)&cmd_flow_director_fd_id,
11600 (void *)&cmd_flow_director_fd_id_value,
11605 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11606 .f = cmd_flow_director_filter_parsed,
11608 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11609 "director entry on NIC",
11611 (void *)&cmd_flow_director_filter,
11612 (void *)&cmd_flow_director_port_id,
11613 (void *)&cmd_flow_director_mode,
11614 (void *)&cmd_flow_director_mode_ip,
11615 (void *)&cmd_flow_director_ops,
11616 (void *)&cmd_flow_director_flow,
11617 (void *)&cmd_flow_director_flow_type,
11618 (void *)&cmd_flow_director_ether,
11619 (void *)&cmd_flow_director_ether_type,
11620 (void *)&cmd_flow_director_flexbytes,
11621 (void *)&cmd_flow_director_flexbytes_value,
11622 (void *)&cmd_flow_director_drop,
11623 (void *)&cmd_flow_director_pf_vf,
11624 (void *)&cmd_flow_director_queue,
11625 (void *)&cmd_flow_director_queue_id,
11626 (void *)&cmd_flow_director_fd_id,
11627 (void *)&cmd_flow_director_fd_id_value,
11632 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11633 .f = cmd_flow_director_filter_parsed,
11635 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11636 "director entry on NIC",
11638 (void *)&cmd_flow_director_filter,
11639 (void *)&cmd_flow_director_port_id,
11640 (void *)&cmd_flow_director_mode,
11641 (void *)&cmd_flow_director_mode_mac_vlan,
11642 (void *)&cmd_flow_director_ops,
11643 (void *)&cmd_flow_director_mac,
11644 (void *)&cmd_flow_director_mac_addr,
11645 (void *)&cmd_flow_director_vlan,
11646 (void *)&cmd_flow_director_vlan_value,
11647 (void *)&cmd_flow_director_flexbytes,
11648 (void *)&cmd_flow_director_flexbytes_value,
11649 (void *)&cmd_flow_director_drop,
11650 (void *)&cmd_flow_director_queue,
11651 (void *)&cmd_flow_director_queue_id,
11652 (void *)&cmd_flow_director_fd_id,
11653 (void *)&cmd_flow_director_fd_id_value,
11658 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11659 .f = cmd_flow_director_filter_parsed,
11661 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11662 "director entry on NIC",
11664 (void *)&cmd_flow_director_filter,
11665 (void *)&cmd_flow_director_port_id,
11666 (void *)&cmd_flow_director_mode,
11667 (void *)&cmd_flow_director_mode_tunnel,
11668 (void *)&cmd_flow_director_ops,
11669 (void *)&cmd_flow_director_mac,
11670 (void *)&cmd_flow_director_mac_addr,
11671 (void *)&cmd_flow_director_vlan,
11672 (void *)&cmd_flow_director_vlan_value,
11673 (void *)&cmd_flow_director_tunnel,
11674 (void *)&cmd_flow_director_tunnel_type,
11675 (void *)&cmd_flow_director_tunnel_id,
11676 (void *)&cmd_flow_director_tunnel_id_value,
11677 (void *)&cmd_flow_director_flexbytes,
11678 (void *)&cmd_flow_director_flexbytes_value,
11679 (void *)&cmd_flow_director_drop,
11680 (void *)&cmd_flow_director_queue,
11681 (void *)&cmd_flow_director_queue_id,
11682 (void *)&cmd_flow_director_fd_id,
11683 (void *)&cmd_flow_director_fd_id_value,
11688 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11689 .f = cmd_flow_director_filter_parsed,
11691 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11692 "director entry on NIC",
11694 (void *)&cmd_flow_director_filter,
11695 (void *)&cmd_flow_director_port_id,
11696 (void *)&cmd_flow_director_mode,
11697 (void *)&cmd_flow_director_mode_raw,
11698 (void *)&cmd_flow_director_ops,
11699 (void *)&cmd_flow_director_flow,
11700 (void *)&cmd_flow_director_flow_type,
11701 (void *)&cmd_flow_director_drop,
11702 (void *)&cmd_flow_director_queue,
11703 (void *)&cmd_flow_director_queue_id,
11704 (void *)&cmd_flow_director_fd_id,
11705 (void *)&cmd_flow_director_fd_id_value,
11706 (void *)&cmd_flow_director_packet,
11707 (void *)&cmd_flow_director_filepath,
11712 struct cmd_flush_flow_director_result {
11713 cmdline_fixed_string_t flush_flow_director;
11717 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11718 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11719 flush_flow_director, "flush_flow_director");
11720 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11721 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11725 cmd_flush_flow_director_parsed(void *parsed_result,
11726 __rte_unused struct cmdline *cl,
11727 __rte_unused void *data)
11729 struct cmd_flow_director_result *res = parsed_result;
11732 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11734 printf("flow director is not supported on port %u.\n",
11739 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11740 RTE_ETH_FILTER_FLUSH, NULL);
11742 printf("flow director table flushing error: (%s)\n",
11746 cmdline_parse_inst_t cmd_flush_flow_director = {
11747 .f = cmd_flush_flow_director_parsed,
11749 .help_str = "flush_flow_director <port_id>: "
11750 "Flush all flow director entries of a device on NIC",
11752 (void *)&cmd_flush_flow_director_flush,
11753 (void *)&cmd_flush_flow_director_port_id,
11758 /* *** deal with flow director mask *** */
11759 struct cmd_flow_director_mask_result {
11760 cmdline_fixed_string_t flow_director_mask;
11762 cmdline_fixed_string_t mode;
11763 cmdline_fixed_string_t mode_value;
11764 cmdline_fixed_string_t vlan;
11765 uint16_t vlan_mask;
11766 cmdline_fixed_string_t src_mask;
11767 cmdline_ipaddr_t ipv4_src;
11768 cmdline_ipaddr_t ipv6_src;
11770 cmdline_fixed_string_t dst_mask;
11771 cmdline_ipaddr_t ipv4_dst;
11772 cmdline_ipaddr_t ipv6_dst;
11774 cmdline_fixed_string_t mac;
11775 uint8_t mac_addr_byte_mask;
11776 cmdline_fixed_string_t tunnel_id;
11777 uint32_t tunnel_id_mask;
11778 cmdline_fixed_string_t tunnel_type;
11779 uint8_t tunnel_type_mask;
11783 cmd_flow_director_mask_parsed(void *parsed_result,
11784 __rte_unused struct cmdline *cl,
11785 __rte_unused void *data)
11787 struct cmd_flow_director_mask_result *res = parsed_result;
11788 struct rte_eth_fdir_masks *mask;
11789 struct rte_port *port;
11791 port = &ports[res->port_id];
11792 /** Check if the port is not started **/
11793 if (port->port_status != RTE_PORT_STOPPED) {
11794 printf("Please stop port %d first\n", res->port_id);
11798 mask = &port->dev_conf.fdir_conf.mask;
11800 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11801 if (strcmp(res->mode_value, "MAC-VLAN")) {
11802 printf("Please set mode to MAC-VLAN.\n");
11806 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11807 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11808 if (strcmp(res->mode_value, "Tunnel")) {
11809 printf("Please set mode to Tunnel.\n");
11813 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11814 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11815 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11816 mask->tunnel_type_mask = res->tunnel_type_mask;
11818 if (strcmp(res->mode_value, "IP")) {
11819 printf("Please set mode to IP.\n");
11823 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11824 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11825 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11826 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11827 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11828 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11829 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11832 cmd_reconfig_device_queue(res->port_id, 1, 1);
11835 cmdline_parse_token_string_t cmd_flow_director_mask =
11836 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11837 flow_director_mask, "flow_director_mask");
11838 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11839 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11841 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11842 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11844 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11845 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11846 vlan_mask, UINT16);
11847 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11848 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11849 src_mask, "src_mask");
11850 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11851 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11853 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11854 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11856 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11857 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11859 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11860 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11861 dst_mask, "dst_mask");
11862 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11863 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11865 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11866 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11868 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11869 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11872 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11875 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11878 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11880 mode_value, "MAC-VLAN");
11881 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11883 mode_value, "Tunnel");
11884 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11887 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11888 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11889 mac_addr_byte_mask, UINT8);
11890 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11891 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11892 tunnel_type, "tunnel-type");
11893 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11894 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11895 tunnel_type_mask, UINT8);
11896 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11897 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11898 tunnel_id, "tunnel-id");
11899 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11900 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11901 tunnel_id_mask, UINT32);
11903 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11904 .f = cmd_flow_director_mask_parsed,
11906 .help_str = "flow_director_mask ... : "
11907 "Set IP mode flow director's mask on NIC",
11909 (void *)&cmd_flow_director_mask,
11910 (void *)&cmd_flow_director_mask_port_id,
11911 (void *)&cmd_flow_director_mask_mode,
11912 (void *)&cmd_flow_director_mask_mode_ip,
11913 (void *)&cmd_flow_director_mask_vlan,
11914 (void *)&cmd_flow_director_mask_vlan_value,
11915 (void *)&cmd_flow_director_mask_src,
11916 (void *)&cmd_flow_director_mask_ipv4_src,
11917 (void *)&cmd_flow_director_mask_ipv6_src,
11918 (void *)&cmd_flow_director_mask_port_src,
11919 (void *)&cmd_flow_director_mask_dst,
11920 (void *)&cmd_flow_director_mask_ipv4_dst,
11921 (void *)&cmd_flow_director_mask_ipv6_dst,
11922 (void *)&cmd_flow_director_mask_port_dst,
11927 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11928 .f = cmd_flow_director_mask_parsed,
11930 .help_str = "flow_director_mask ... : Set MAC VLAN 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_mac_vlan,
11937 (void *)&cmd_flow_director_mask_vlan,
11938 (void *)&cmd_flow_director_mask_vlan_value,
11943 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11944 .f = cmd_flow_director_mask_parsed,
11946 .help_str = "flow_director_mask ... : Set tunnel mode "
11947 "flow director's mask on NIC",
11949 (void *)&cmd_flow_director_mask,
11950 (void *)&cmd_flow_director_mask_port_id,
11951 (void *)&cmd_flow_director_mask_mode,
11952 (void *)&cmd_flow_director_mask_mode_tunnel,
11953 (void *)&cmd_flow_director_mask_vlan,
11954 (void *)&cmd_flow_director_mask_vlan_value,
11955 (void *)&cmd_flow_director_mask_mac,
11956 (void *)&cmd_flow_director_mask_mac_value,
11957 (void *)&cmd_flow_director_mask_tunnel_type,
11958 (void *)&cmd_flow_director_mask_tunnel_type_value,
11959 (void *)&cmd_flow_director_mask_tunnel_id,
11960 (void *)&cmd_flow_director_mask_tunnel_id_value,
11965 /* *** deal with flow director mask on flexible payload *** */
11966 struct cmd_flow_director_flex_mask_result {
11967 cmdline_fixed_string_t flow_director_flexmask;
11969 cmdline_fixed_string_t flow;
11970 cmdline_fixed_string_t flow_type;
11971 cmdline_fixed_string_t mask;
11975 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11976 __rte_unused struct cmdline *cl,
11977 __rte_unused void *data)
11979 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11980 struct rte_eth_fdir_info fdir_info;
11981 struct rte_eth_fdir_flex_mask flex_mask;
11982 struct rte_port *port;
11983 uint64_t flow_type_mask;
11987 port = &ports[res->port_id];
11988 /** Check if the port is not started **/
11989 if (port->port_status != RTE_PORT_STOPPED) {
11990 printf("Please stop port %d first\n", res->port_id);
11994 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11995 ret = parse_flexbytes(res->mask,
11997 RTE_ETH_FDIR_MAX_FLEXLEN);
11999 printf("error: Cannot parse mask input.\n");
12003 memset(&fdir_info, 0, sizeof(fdir_info));
12004 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12005 RTE_ETH_FILTER_INFO, &fdir_info);
12007 printf("Cannot get FDir filter info\n");
12011 if (!strcmp(res->flow_type, "none")) {
12012 /* means don't specify the flow type */
12013 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12014 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12015 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12016 0, sizeof(struct rte_eth_fdir_flex_mask));
12017 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12018 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12020 sizeof(struct rte_eth_fdir_flex_mask));
12021 cmd_reconfig_device_queue(res->port_id, 1, 1);
12024 flow_type_mask = fdir_info.flow_types_mask[0];
12025 if (!strcmp(res->flow_type, "all")) {
12026 if (!flow_type_mask) {
12027 printf("No flow type supported\n");
12030 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12031 if (flow_type_mask & (1ULL << i)) {
12032 flex_mask.flow_type = i;
12033 fdir_set_flex_mask(res->port_id, &flex_mask);
12036 cmd_reconfig_device_queue(res->port_id, 1, 1);
12039 flex_mask.flow_type = str2flowtype(res->flow_type);
12040 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12041 printf("Flow type %s not supported on port %d\n",
12042 res->flow_type, res->port_id);
12045 fdir_set_flex_mask(res->port_id, &flex_mask);
12046 cmd_reconfig_device_queue(res->port_id, 1, 1);
12049 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12050 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12051 flow_director_flexmask,
12052 "flow_director_flex_mask");
12053 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12054 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12056 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12057 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12059 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12060 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12061 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12062 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12063 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12064 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12067 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12068 .f = cmd_flow_director_flex_mask_parsed,
12070 .help_str = "flow_director_flex_mask ... : "
12071 "Set flow director's flex mask on NIC",
12073 (void *)&cmd_flow_director_flexmask,
12074 (void *)&cmd_flow_director_flexmask_port_id,
12075 (void *)&cmd_flow_director_flexmask_flow,
12076 (void *)&cmd_flow_director_flexmask_flow_type,
12077 (void *)&cmd_flow_director_flexmask_mask,
12082 /* *** deal with flow director flexible payload configuration *** */
12083 struct cmd_flow_director_flexpayload_result {
12084 cmdline_fixed_string_t flow_director_flexpayload;
12086 cmdline_fixed_string_t payload_layer;
12087 cmdline_fixed_string_t payload_cfg;
12091 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12094 const char *p, *p0 = q_arg;
12096 unsigned long int_fld;
12097 char *str_fld[max_num];
12102 p = strchr(p0, '(');
12106 p0 = strchr(p, ')');
12111 if (size >= sizeof(s))
12114 snprintf(s, sizeof(s), "%.*s", size, p);
12115 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12116 if (ret < 0 || ret > max_num)
12118 for (i = 0; i < ret; i++) {
12120 int_fld = strtoul(str_fld[i], &end, 0);
12121 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12123 offsets[i] = (uint16_t)int_fld;
12129 cmd_flow_director_flxpld_parsed(void *parsed_result,
12130 __rte_unused struct cmdline *cl,
12131 __rte_unused void *data)
12133 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12134 struct rte_eth_flex_payload_cfg flex_cfg;
12135 struct rte_port *port;
12138 port = &ports[res->port_id];
12139 /** Check if the port is not started **/
12140 if (port->port_status != RTE_PORT_STOPPED) {
12141 printf("Please stop port %d first\n", res->port_id);
12145 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12147 if (!strcmp(res->payload_layer, "raw"))
12148 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12149 else if (!strcmp(res->payload_layer, "l2"))
12150 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12151 else if (!strcmp(res->payload_layer, "l3"))
12152 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12153 else if (!strcmp(res->payload_layer, "l4"))
12154 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12156 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12157 RTE_ETH_FDIR_MAX_FLEXLEN);
12159 printf("error: Cannot parse flex payload input.\n");
12163 fdir_set_flex_payload(res->port_id, &flex_cfg);
12164 cmd_reconfig_device_queue(res->port_id, 1, 1);
12167 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12168 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12169 flow_director_flexpayload,
12170 "flow_director_flex_payload");
12171 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12172 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12174 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12175 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12176 payload_layer, "raw#l2#l3#l4");
12177 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12178 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12179 payload_cfg, NULL);
12181 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12182 .f = cmd_flow_director_flxpld_parsed,
12184 .help_str = "flow_director_flexpayload ... : "
12185 "Set flow director's flex payload on NIC",
12187 (void *)&cmd_flow_director_flexpayload,
12188 (void *)&cmd_flow_director_flexpayload_port_id,
12189 (void *)&cmd_flow_director_flexpayload_payload_layer,
12190 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12195 /* Generic flow interface command. */
12196 extern cmdline_parse_inst_t cmd_flow;
12198 /* *** Classification Filters Control *** */
12199 /* *** Get symmetric hash enable per port *** */
12200 struct cmd_get_sym_hash_ena_per_port_result {
12201 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12206 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12207 __rte_unused struct cmdline *cl,
12208 __rte_unused void *data)
12210 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12211 struct rte_eth_hash_filter_info info;
12214 if (rte_eth_dev_filter_supported(res->port_id,
12215 RTE_ETH_FILTER_HASH) < 0) {
12216 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12221 memset(&info, 0, sizeof(info));
12222 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12223 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12224 RTE_ETH_FILTER_GET, &info);
12227 printf("Cannot get symmetric hash enable per port "
12228 "on port %u\n", res->port_id);
12232 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12233 "enabled" : "disabled", res->port_id);
12236 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12237 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12238 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12239 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12240 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12243 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12244 .f = cmd_get_sym_hash_per_port_parsed,
12246 .help_str = "get_sym_hash_ena_per_port <port_id>",
12248 (void *)&cmd_get_sym_hash_ena_per_port_all,
12249 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12254 /* *** Set symmetric hash enable per port *** */
12255 struct cmd_set_sym_hash_ena_per_port_result {
12256 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12257 cmdline_fixed_string_t enable;
12262 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12263 __rte_unused struct cmdline *cl,
12264 __rte_unused void *data)
12266 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12267 struct rte_eth_hash_filter_info info;
12270 if (rte_eth_dev_filter_supported(res->port_id,
12271 RTE_ETH_FILTER_HASH) < 0) {
12272 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12277 memset(&info, 0, sizeof(info));
12278 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12279 if (!strcmp(res->enable, "enable"))
12280 info.info.enable = 1;
12281 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12282 RTE_ETH_FILTER_SET, &info);
12284 printf("Cannot set symmetric hash enable per port on "
12285 "port %u\n", res->port_id);
12288 printf("Symmetric hash has been set to %s on port %u\n",
12289 res->enable, res->port_id);
12292 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12293 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12294 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12295 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12296 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12298 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12299 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12300 enable, "enable#disable");
12302 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12303 .f = cmd_set_sym_hash_per_port_parsed,
12305 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12307 (void *)&cmd_set_sym_hash_ena_per_port_all,
12308 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12309 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12314 /* Get global config of hash function */
12315 struct cmd_get_hash_global_config_result {
12316 cmdline_fixed_string_t get_hash_global_config;
12321 flowtype_to_str(uint16_t ftype)
12327 } ftype_table[] = {
12328 {"ipv4", RTE_ETH_FLOW_IPV4},
12329 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12330 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12331 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12332 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12333 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12334 {"ipv6", RTE_ETH_FLOW_IPV6},
12335 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12336 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12337 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12338 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12339 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12340 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12341 {"port", RTE_ETH_FLOW_PORT},
12342 {"vxlan", RTE_ETH_FLOW_VXLAN},
12343 {"geneve", RTE_ETH_FLOW_GENEVE},
12344 {"nvgre", RTE_ETH_FLOW_NVGRE},
12345 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12348 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12349 if (ftype_table[i].ftype == ftype)
12350 return ftype_table[i].str;
12357 cmd_get_hash_global_config_parsed(void *parsed_result,
12358 __rte_unused struct cmdline *cl,
12359 __rte_unused void *data)
12361 struct cmd_get_hash_global_config_result *res = parsed_result;
12362 struct rte_eth_hash_filter_info info;
12363 uint32_t idx, offset;
12368 if (rte_eth_dev_filter_supported(res->port_id,
12369 RTE_ETH_FILTER_HASH) < 0) {
12370 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12375 memset(&info, 0, sizeof(info));
12376 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12377 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12378 RTE_ETH_FILTER_GET, &info);
12380 printf("Cannot get hash global configurations by port %d\n",
12385 switch (info.info.global_conf.hash_func) {
12386 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12387 printf("Hash function is Toeplitz\n");
12389 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12390 printf("Hash function is Simple XOR\n");
12392 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12393 printf("Hash function is Symmetric Toeplitz\n");
12396 printf("Unknown hash function\n");
12400 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12401 idx = i / UINT64_BIT;
12402 offset = i % UINT64_BIT;
12403 if (!(info.info.global_conf.valid_bit_mask[idx] &
12406 str = flowtype_to_str(i);
12409 printf("Symmetric hash is %s globally for flow type %s "
12411 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12412 (1ULL << offset)) ? "enabled" : "disabled"), str,
12417 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12418 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12419 get_hash_global_config, "get_hash_global_config");
12420 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12421 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12424 cmdline_parse_inst_t cmd_get_hash_global_config = {
12425 .f = cmd_get_hash_global_config_parsed,
12427 .help_str = "get_hash_global_config <port_id>",
12429 (void *)&cmd_get_hash_global_config_all,
12430 (void *)&cmd_get_hash_global_config_port_id,
12435 /* Set global config of hash function */
12436 struct cmd_set_hash_global_config_result {
12437 cmdline_fixed_string_t set_hash_global_config;
12439 cmdline_fixed_string_t hash_func;
12440 cmdline_fixed_string_t flow_type;
12441 cmdline_fixed_string_t enable;
12445 cmd_set_hash_global_config_parsed(void *parsed_result,
12446 __rte_unused struct cmdline *cl,
12447 __rte_unused void *data)
12449 struct cmd_set_hash_global_config_result *res = parsed_result;
12450 struct rte_eth_hash_filter_info info;
12451 uint32_t ftype, idx, offset;
12454 if (rte_eth_dev_filter_supported(res->port_id,
12455 RTE_ETH_FILTER_HASH) < 0) {
12456 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12460 memset(&info, 0, sizeof(info));
12461 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12462 if (!strcmp(res->hash_func, "toeplitz"))
12463 info.info.global_conf.hash_func =
12464 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12465 else if (!strcmp(res->hash_func, "simple_xor"))
12466 info.info.global_conf.hash_func =
12467 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12468 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12469 info.info.global_conf.hash_func =
12470 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12471 else if (!strcmp(res->hash_func, "default"))
12472 info.info.global_conf.hash_func =
12473 RTE_ETH_HASH_FUNCTION_DEFAULT;
12475 ftype = str2flowtype(res->flow_type);
12476 idx = ftype / UINT64_BIT;
12477 offset = ftype % UINT64_BIT;
12478 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12479 if (!strcmp(res->enable, "enable"))
12480 info.info.global_conf.sym_hash_enable_mask[idx] |=
12482 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12483 RTE_ETH_FILTER_SET, &info);
12485 printf("Cannot set global hash configurations by port %d\n",
12488 printf("Global hash configurations have been set "
12489 "successfully by port %d\n", res->port_id);
12492 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12493 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12494 set_hash_global_config, "set_hash_global_config");
12495 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12496 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12498 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12499 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12500 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12501 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12502 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12504 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12505 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12506 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12507 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12508 enable, "enable#disable");
12510 cmdline_parse_inst_t cmd_set_hash_global_config = {
12511 .f = cmd_set_hash_global_config_parsed,
12513 .help_str = "set_hash_global_config <port_id> "
12514 "toeplitz|simple_xor|symmetric_toeplitz|default "
12515 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12516 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12517 "l2_payload enable|disable",
12519 (void *)&cmd_set_hash_global_config_all,
12520 (void *)&cmd_set_hash_global_config_port_id,
12521 (void *)&cmd_set_hash_global_config_hash_func,
12522 (void *)&cmd_set_hash_global_config_flow_type,
12523 (void *)&cmd_set_hash_global_config_enable,
12528 /* Set hash input set */
12529 struct cmd_set_hash_input_set_result {
12530 cmdline_fixed_string_t set_hash_input_set;
12532 cmdline_fixed_string_t flow_type;
12533 cmdline_fixed_string_t inset_field;
12534 cmdline_fixed_string_t select;
12537 static enum rte_eth_input_set_field
12538 str2inset(char *string)
12542 static const struct {
12544 enum rte_eth_input_set_field inset;
12545 } inset_table[] = {
12546 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12547 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12548 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12549 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12550 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12551 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12552 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12553 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12554 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12555 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12556 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12557 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12558 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12559 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12560 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12561 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12562 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12563 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12564 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12565 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12566 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12567 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12568 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12569 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12570 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12571 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12572 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12573 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12574 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12575 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12576 {"none", RTE_ETH_INPUT_SET_NONE},
12579 for (i = 0; i < RTE_DIM(inset_table); i++) {
12580 if (!strcmp(string, inset_table[i].str))
12581 return inset_table[i].inset;
12584 return RTE_ETH_INPUT_SET_UNKNOWN;
12588 cmd_set_hash_input_set_parsed(void *parsed_result,
12589 __rte_unused struct cmdline *cl,
12590 __rte_unused void *data)
12592 struct cmd_set_hash_input_set_result *res = parsed_result;
12593 struct rte_eth_hash_filter_info info;
12595 memset(&info, 0, sizeof(info));
12596 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12597 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12598 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12599 info.info.input_set_conf.inset_size = 1;
12600 if (!strcmp(res->select, "select"))
12601 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12602 else if (!strcmp(res->select, "add"))
12603 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12604 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12605 RTE_ETH_FILTER_SET, &info);
12608 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12609 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12610 set_hash_input_set, "set_hash_input_set");
12611 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12612 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12614 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12615 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12617 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12618 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12620 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12621 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12622 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12623 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12624 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12626 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12627 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12628 select, "select#add");
12630 cmdline_parse_inst_t cmd_set_hash_input_set = {
12631 .f = cmd_set_hash_input_set_parsed,
12633 .help_str = "set_hash_input_set <port_id> "
12634 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12635 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12636 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12637 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12638 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12639 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12640 "fld-7th|fld-8th|none select|add",
12642 (void *)&cmd_set_hash_input_set_cmd,
12643 (void *)&cmd_set_hash_input_set_port_id,
12644 (void *)&cmd_set_hash_input_set_flow_type,
12645 (void *)&cmd_set_hash_input_set_field,
12646 (void *)&cmd_set_hash_input_set_select,
12651 /* Set flow director input set */
12652 struct cmd_set_fdir_input_set_result {
12653 cmdline_fixed_string_t set_fdir_input_set;
12655 cmdline_fixed_string_t flow_type;
12656 cmdline_fixed_string_t inset_field;
12657 cmdline_fixed_string_t select;
12661 cmd_set_fdir_input_set_parsed(void *parsed_result,
12662 __rte_unused struct cmdline *cl,
12663 __rte_unused void *data)
12665 struct cmd_set_fdir_input_set_result *res = parsed_result;
12666 struct rte_eth_fdir_filter_info info;
12668 memset(&info, 0, sizeof(info));
12669 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12670 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12671 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12672 info.info.input_set_conf.inset_size = 1;
12673 if (!strcmp(res->select, "select"))
12674 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12675 else if (!strcmp(res->select, "add"))
12676 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12677 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12678 RTE_ETH_FILTER_SET, &info);
12681 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12682 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12683 set_fdir_input_set, "set_fdir_input_set");
12684 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12685 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12687 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12688 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12690 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12691 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12692 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12693 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12695 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12696 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12697 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12698 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12699 "sctp-veri-tag#none");
12700 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12701 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12702 select, "select#add");
12704 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12705 .f = cmd_set_fdir_input_set_parsed,
12707 .help_str = "set_fdir_input_set <port_id> "
12708 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12709 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12710 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12711 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12712 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12713 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12714 "sctp-veri-tag|none select|add",
12716 (void *)&cmd_set_fdir_input_set_cmd,
12717 (void *)&cmd_set_fdir_input_set_port_id,
12718 (void *)&cmd_set_fdir_input_set_flow_type,
12719 (void *)&cmd_set_fdir_input_set_field,
12720 (void *)&cmd_set_fdir_input_set_select,
12725 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12726 struct cmd_mcast_addr_result {
12727 cmdline_fixed_string_t mcast_addr_cmd;
12728 cmdline_fixed_string_t what;
12730 struct rte_ether_addr mc_addr;
12733 static void cmd_mcast_addr_parsed(void *parsed_result,
12734 __rte_unused struct cmdline *cl,
12735 __rte_unused void *data)
12737 struct cmd_mcast_addr_result *res = parsed_result;
12739 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12740 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12741 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12742 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12743 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12746 if (strcmp(res->what, "add") == 0)
12747 mcast_addr_add(res->port_num, &res->mc_addr);
12749 mcast_addr_remove(res->port_num, &res->mc_addr);
12752 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12753 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12754 mcast_addr_cmd, "mcast_addr");
12755 cmdline_parse_token_string_t cmd_mcast_addr_what =
12756 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12758 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12759 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12760 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12761 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12763 cmdline_parse_inst_t cmd_mcast_addr = {
12764 .f = cmd_mcast_addr_parsed,
12766 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12767 "Add/Remove multicast MAC address on port_id",
12769 (void *)&cmd_mcast_addr_cmd,
12770 (void *)&cmd_mcast_addr_what,
12771 (void *)&cmd_mcast_addr_portnum,
12772 (void *)&cmd_mcast_addr_addr,
12777 /* l2 tunnel config
12778 * only support E-tag now.
12781 /* Ether type config */
12782 struct cmd_config_l2_tunnel_eth_type_result {
12783 cmdline_fixed_string_t port;
12784 cmdline_fixed_string_t config;
12785 cmdline_fixed_string_t all;
12787 cmdline_fixed_string_t l2_tunnel;
12788 cmdline_fixed_string_t l2_tunnel_type;
12789 cmdline_fixed_string_t eth_type;
12790 uint16_t eth_type_val;
12793 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12794 TOKEN_STRING_INITIALIZER
12795 (struct cmd_config_l2_tunnel_eth_type_result,
12797 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12798 TOKEN_STRING_INITIALIZER
12799 (struct cmd_config_l2_tunnel_eth_type_result,
12801 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12802 TOKEN_STRING_INITIALIZER
12803 (struct cmd_config_l2_tunnel_eth_type_result,
12805 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12806 TOKEN_NUM_INITIALIZER
12807 (struct cmd_config_l2_tunnel_eth_type_result,
12809 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12810 TOKEN_STRING_INITIALIZER
12811 (struct cmd_config_l2_tunnel_eth_type_result,
12812 l2_tunnel, "l2-tunnel");
12813 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12814 TOKEN_STRING_INITIALIZER
12815 (struct cmd_config_l2_tunnel_eth_type_result,
12816 l2_tunnel_type, "E-tag");
12817 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12818 TOKEN_STRING_INITIALIZER
12819 (struct cmd_config_l2_tunnel_eth_type_result,
12820 eth_type, "ether-type");
12821 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12822 TOKEN_NUM_INITIALIZER
12823 (struct cmd_config_l2_tunnel_eth_type_result,
12824 eth_type_val, UINT16);
12826 static enum rte_eth_tunnel_type
12827 str2fdir_l2_tunnel_type(char *string)
12831 static const struct {
12833 enum rte_eth_tunnel_type type;
12834 } l2_tunnel_type_str[] = {
12835 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12838 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12839 if (!strcmp(l2_tunnel_type_str[i].str, string))
12840 return l2_tunnel_type_str[i].type;
12842 return RTE_TUNNEL_TYPE_NONE;
12845 /* ether type config for all ports */
12847 cmd_config_l2_tunnel_eth_type_all_parsed
12848 (void *parsed_result,
12849 __rte_unused struct cmdline *cl,
12850 __rte_unused void *data)
12852 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12853 struct rte_eth_l2_tunnel_conf entry;
12856 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12857 entry.ether_type = res->eth_type_val;
12859 RTE_ETH_FOREACH_DEV(pid) {
12860 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12864 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12865 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12867 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12869 (void *)&cmd_config_l2_tunnel_eth_type_port,
12870 (void *)&cmd_config_l2_tunnel_eth_type_config,
12871 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12872 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12873 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12874 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12875 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12880 /* ether type config for a specific port */
12882 cmd_config_l2_tunnel_eth_type_specific_parsed(
12883 void *parsed_result,
12884 __rte_unused struct cmdline *cl,
12885 __rte_unused void *data)
12887 struct cmd_config_l2_tunnel_eth_type_result *res =
12889 struct rte_eth_l2_tunnel_conf entry;
12891 if (port_id_is_invalid(res->id, ENABLED_WARN))
12894 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12895 entry.ether_type = res->eth_type_val;
12897 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12900 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12901 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12903 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12905 (void *)&cmd_config_l2_tunnel_eth_type_port,
12906 (void *)&cmd_config_l2_tunnel_eth_type_config,
12907 (void *)&cmd_config_l2_tunnel_eth_type_id,
12908 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12909 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12910 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12911 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12916 /* Enable/disable l2 tunnel */
12917 struct cmd_config_l2_tunnel_en_dis_result {
12918 cmdline_fixed_string_t port;
12919 cmdline_fixed_string_t config;
12920 cmdline_fixed_string_t all;
12922 cmdline_fixed_string_t l2_tunnel;
12923 cmdline_fixed_string_t l2_tunnel_type;
12924 cmdline_fixed_string_t en_dis;
12927 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12928 TOKEN_STRING_INITIALIZER
12929 (struct cmd_config_l2_tunnel_en_dis_result,
12931 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12932 TOKEN_STRING_INITIALIZER
12933 (struct cmd_config_l2_tunnel_en_dis_result,
12935 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12936 TOKEN_STRING_INITIALIZER
12937 (struct cmd_config_l2_tunnel_en_dis_result,
12939 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12940 TOKEN_NUM_INITIALIZER
12941 (struct cmd_config_l2_tunnel_en_dis_result,
12943 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12944 TOKEN_STRING_INITIALIZER
12945 (struct cmd_config_l2_tunnel_en_dis_result,
12946 l2_tunnel, "l2-tunnel");
12947 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12948 TOKEN_STRING_INITIALIZER
12949 (struct cmd_config_l2_tunnel_en_dis_result,
12950 l2_tunnel_type, "E-tag");
12951 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12952 TOKEN_STRING_INITIALIZER
12953 (struct cmd_config_l2_tunnel_en_dis_result,
12954 en_dis, "enable#disable");
12956 /* enable/disable l2 tunnel for all ports */
12958 cmd_config_l2_tunnel_en_dis_all_parsed(
12959 void *parsed_result,
12960 __rte_unused struct cmdline *cl,
12961 __rte_unused void *data)
12963 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12964 struct rte_eth_l2_tunnel_conf entry;
12968 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12970 if (!strcmp("enable", res->en_dis))
12975 RTE_ETH_FOREACH_DEV(pid) {
12976 rte_eth_dev_l2_tunnel_offload_set(pid,
12978 ETH_L2_TUNNEL_ENABLE_MASK,
12983 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12984 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12986 .help_str = "port config all l2-tunnel E-tag enable|disable",
12988 (void *)&cmd_config_l2_tunnel_en_dis_port,
12989 (void *)&cmd_config_l2_tunnel_en_dis_config,
12990 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12991 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12992 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12993 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12998 /* enable/disable l2 tunnel for a port */
13000 cmd_config_l2_tunnel_en_dis_specific_parsed(
13001 void *parsed_result,
13002 __rte_unused struct cmdline *cl,
13003 __rte_unused void *data)
13005 struct cmd_config_l2_tunnel_en_dis_result *res =
13007 struct rte_eth_l2_tunnel_conf entry;
13009 if (port_id_is_invalid(res->id, ENABLED_WARN))
13012 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13014 if (!strcmp("enable", res->en_dis))
13015 rte_eth_dev_l2_tunnel_offload_set(res->id,
13017 ETH_L2_TUNNEL_ENABLE_MASK,
13020 rte_eth_dev_l2_tunnel_offload_set(res->id,
13022 ETH_L2_TUNNEL_ENABLE_MASK,
13026 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13027 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13029 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13031 (void *)&cmd_config_l2_tunnel_en_dis_port,
13032 (void *)&cmd_config_l2_tunnel_en_dis_config,
13033 (void *)&cmd_config_l2_tunnel_en_dis_id,
13034 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13035 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13036 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13041 /* E-tag configuration */
13043 /* Common result structure for all E-tag configuration */
13044 struct cmd_config_e_tag_result {
13045 cmdline_fixed_string_t e_tag;
13046 cmdline_fixed_string_t set;
13047 cmdline_fixed_string_t insertion;
13048 cmdline_fixed_string_t stripping;
13049 cmdline_fixed_string_t forwarding;
13050 cmdline_fixed_string_t filter;
13051 cmdline_fixed_string_t add;
13052 cmdline_fixed_string_t del;
13053 cmdline_fixed_string_t on;
13054 cmdline_fixed_string_t off;
13055 cmdline_fixed_string_t on_off;
13056 cmdline_fixed_string_t port_tag_id;
13057 uint32_t port_tag_id_val;
13058 cmdline_fixed_string_t e_tag_id;
13059 uint16_t e_tag_id_val;
13060 cmdline_fixed_string_t dst_pool;
13061 uint8_t dst_pool_val;
13062 cmdline_fixed_string_t port;
13064 cmdline_fixed_string_t vf;
13068 /* Common CLI fields for all E-tag configuration */
13069 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13070 TOKEN_STRING_INITIALIZER
13071 (struct cmd_config_e_tag_result,
13073 cmdline_parse_token_string_t cmd_config_e_tag_set =
13074 TOKEN_STRING_INITIALIZER
13075 (struct cmd_config_e_tag_result,
13077 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13078 TOKEN_STRING_INITIALIZER
13079 (struct cmd_config_e_tag_result,
13080 insertion, "insertion");
13081 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13082 TOKEN_STRING_INITIALIZER
13083 (struct cmd_config_e_tag_result,
13084 stripping, "stripping");
13085 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13086 TOKEN_STRING_INITIALIZER
13087 (struct cmd_config_e_tag_result,
13088 forwarding, "forwarding");
13089 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13090 TOKEN_STRING_INITIALIZER
13091 (struct cmd_config_e_tag_result,
13093 cmdline_parse_token_string_t cmd_config_e_tag_add =
13094 TOKEN_STRING_INITIALIZER
13095 (struct cmd_config_e_tag_result,
13097 cmdline_parse_token_string_t cmd_config_e_tag_del =
13098 TOKEN_STRING_INITIALIZER
13099 (struct cmd_config_e_tag_result,
13101 cmdline_parse_token_string_t cmd_config_e_tag_on =
13102 TOKEN_STRING_INITIALIZER
13103 (struct cmd_config_e_tag_result,
13105 cmdline_parse_token_string_t cmd_config_e_tag_off =
13106 TOKEN_STRING_INITIALIZER
13107 (struct cmd_config_e_tag_result,
13109 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13110 TOKEN_STRING_INITIALIZER
13111 (struct cmd_config_e_tag_result,
13113 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13114 TOKEN_STRING_INITIALIZER
13115 (struct cmd_config_e_tag_result,
13116 port_tag_id, "port-tag-id");
13117 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13118 TOKEN_NUM_INITIALIZER
13119 (struct cmd_config_e_tag_result,
13120 port_tag_id_val, UINT32);
13121 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13122 TOKEN_STRING_INITIALIZER
13123 (struct cmd_config_e_tag_result,
13124 e_tag_id, "e-tag-id");
13125 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13126 TOKEN_NUM_INITIALIZER
13127 (struct cmd_config_e_tag_result,
13128 e_tag_id_val, UINT16);
13129 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13130 TOKEN_STRING_INITIALIZER
13131 (struct cmd_config_e_tag_result,
13132 dst_pool, "dst-pool");
13133 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13134 TOKEN_NUM_INITIALIZER
13135 (struct cmd_config_e_tag_result,
13136 dst_pool_val, UINT8);
13137 cmdline_parse_token_string_t cmd_config_e_tag_port =
13138 TOKEN_STRING_INITIALIZER
13139 (struct cmd_config_e_tag_result,
13141 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13142 TOKEN_NUM_INITIALIZER
13143 (struct cmd_config_e_tag_result,
13145 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13146 TOKEN_STRING_INITIALIZER
13147 (struct cmd_config_e_tag_result,
13149 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13150 TOKEN_NUM_INITIALIZER
13151 (struct cmd_config_e_tag_result,
13154 /* E-tag insertion configuration */
13156 cmd_config_e_tag_insertion_en_parsed(
13157 void *parsed_result,
13158 __rte_unused struct cmdline *cl,
13159 __rte_unused void *data)
13161 struct cmd_config_e_tag_result *res =
13163 struct rte_eth_l2_tunnel_conf entry;
13165 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13168 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13169 entry.tunnel_id = res->port_tag_id_val;
13170 entry.vf_id = res->vf_id;
13171 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13173 ETH_L2_TUNNEL_INSERTION_MASK,
13178 cmd_config_e_tag_insertion_dis_parsed(
13179 void *parsed_result,
13180 __rte_unused struct cmdline *cl,
13181 __rte_unused void *data)
13183 struct cmd_config_e_tag_result *res =
13185 struct rte_eth_l2_tunnel_conf entry;
13187 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13190 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13191 entry.vf_id = res->vf_id;
13193 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13195 ETH_L2_TUNNEL_INSERTION_MASK,
13199 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13200 .f = cmd_config_e_tag_insertion_en_parsed,
13202 .help_str = "E-tag ... : E-tag insertion enable",
13204 (void *)&cmd_config_e_tag_e_tag,
13205 (void *)&cmd_config_e_tag_set,
13206 (void *)&cmd_config_e_tag_insertion,
13207 (void *)&cmd_config_e_tag_on,
13208 (void *)&cmd_config_e_tag_port_tag_id,
13209 (void *)&cmd_config_e_tag_port_tag_id_val,
13210 (void *)&cmd_config_e_tag_port,
13211 (void *)&cmd_config_e_tag_port_id,
13212 (void *)&cmd_config_e_tag_vf,
13213 (void *)&cmd_config_e_tag_vf_id,
13218 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13219 .f = cmd_config_e_tag_insertion_dis_parsed,
13221 .help_str = "E-tag ... : E-tag insertion disable",
13223 (void *)&cmd_config_e_tag_e_tag,
13224 (void *)&cmd_config_e_tag_set,
13225 (void *)&cmd_config_e_tag_insertion,
13226 (void *)&cmd_config_e_tag_off,
13227 (void *)&cmd_config_e_tag_port,
13228 (void *)&cmd_config_e_tag_port_id,
13229 (void *)&cmd_config_e_tag_vf,
13230 (void *)&cmd_config_e_tag_vf_id,
13235 /* E-tag stripping configuration */
13237 cmd_config_e_tag_stripping_parsed(
13238 void *parsed_result,
13239 __rte_unused struct cmdline *cl,
13240 __rte_unused void *data)
13242 struct cmd_config_e_tag_result *res =
13244 struct rte_eth_l2_tunnel_conf entry;
13246 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13249 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13251 if (!strcmp(res->on_off, "on"))
13252 rte_eth_dev_l2_tunnel_offload_set
13255 ETH_L2_TUNNEL_STRIPPING_MASK,
13258 rte_eth_dev_l2_tunnel_offload_set
13261 ETH_L2_TUNNEL_STRIPPING_MASK,
13265 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13266 .f = cmd_config_e_tag_stripping_parsed,
13268 .help_str = "E-tag ... : E-tag stripping enable/disable",
13270 (void *)&cmd_config_e_tag_e_tag,
13271 (void *)&cmd_config_e_tag_set,
13272 (void *)&cmd_config_e_tag_stripping,
13273 (void *)&cmd_config_e_tag_on_off,
13274 (void *)&cmd_config_e_tag_port,
13275 (void *)&cmd_config_e_tag_port_id,
13280 /* E-tag forwarding configuration */
13282 cmd_config_e_tag_forwarding_parsed(
13283 void *parsed_result,
13284 __rte_unused struct cmdline *cl,
13285 __rte_unused void *data)
13287 struct cmd_config_e_tag_result *res = parsed_result;
13288 struct rte_eth_l2_tunnel_conf entry;
13290 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13293 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13295 if (!strcmp(res->on_off, "on"))
13296 rte_eth_dev_l2_tunnel_offload_set
13299 ETH_L2_TUNNEL_FORWARDING_MASK,
13302 rte_eth_dev_l2_tunnel_offload_set
13305 ETH_L2_TUNNEL_FORWARDING_MASK,
13309 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13310 .f = cmd_config_e_tag_forwarding_parsed,
13312 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13314 (void *)&cmd_config_e_tag_e_tag,
13315 (void *)&cmd_config_e_tag_set,
13316 (void *)&cmd_config_e_tag_forwarding,
13317 (void *)&cmd_config_e_tag_on_off,
13318 (void *)&cmd_config_e_tag_port,
13319 (void *)&cmd_config_e_tag_port_id,
13324 /* E-tag filter configuration */
13326 cmd_config_e_tag_filter_add_parsed(
13327 void *parsed_result,
13328 __rte_unused struct cmdline *cl,
13329 __rte_unused void *data)
13331 struct cmd_config_e_tag_result *res = parsed_result;
13332 struct rte_eth_l2_tunnel_conf entry;
13335 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13338 if (res->e_tag_id_val > 0x3fff) {
13339 printf("e-tag-id must be equal or less than 0x3fff.\n");
13343 ret = rte_eth_dev_filter_supported(res->port_id,
13344 RTE_ETH_FILTER_L2_TUNNEL);
13346 printf("E-tag filter is not supported on port %u.\n",
13351 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13352 entry.tunnel_id = res->e_tag_id_val;
13353 entry.pool = res->dst_pool_val;
13355 ret = rte_eth_dev_filter_ctrl(res->port_id,
13356 RTE_ETH_FILTER_L2_TUNNEL,
13357 RTE_ETH_FILTER_ADD,
13360 printf("E-tag filter programming error: (%s)\n",
13364 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13365 .f = cmd_config_e_tag_filter_add_parsed,
13367 .help_str = "E-tag ... : E-tag filter add",
13369 (void *)&cmd_config_e_tag_e_tag,
13370 (void *)&cmd_config_e_tag_set,
13371 (void *)&cmd_config_e_tag_filter,
13372 (void *)&cmd_config_e_tag_add,
13373 (void *)&cmd_config_e_tag_e_tag_id,
13374 (void *)&cmd_config_e_tag_e_tag_id_val,
13375 (void *)&cmd_config_e_tag_dst_pool,
13376 (void *)&cmd_config_e_tag_dst_pool_val,
13377 (void *)&cmd_config_e_tag_port,
13378 (void *)&cmd_config_e_tag_port_id,
13384 cmd_config_e_tag_filter_del_parsed(
13385 void *parsed_result,
13386 __rte_unused struct cmdline *cl,
13387 __rte_unused void *data)
13389 struct cmd_config_e_tag_result *res = parsed_result;
13390 struct rte_eth_l2_tunnel_conf entry;
13393 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13396 if (res->e_tag_id_val > 0x3fff) {
13397 printf("e-tag-id must be less than 0x3fff.\n");
13401 ret = rte_eth_dev_filter_supported(res->port_id,
13402 RTE_ETH_FILTER_L2_TUNNEL);
13404 printf("E-tag filter is not supported on port %u.\n",
13409 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13410 entry.tunnel_id = res->e_tag_id_val;
13412 ret = rte_eth_dev_filter_ctrl(res->port_id,
13413 RTE_ETH_FILTER_L2_TUNNEL,
13414 RTE_ETH_FILTER_DELETE,
13417 printf("E-tag filter programming error: (%s)\n",
13421 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13422 .f = cmd_config_e_tag_filter_del_parsed,
13424 .help_str = "E-tag ... : E-tag filter delete",
13426 (void *)&cmd_config_e_tag_e_tag,
13427 (void *)&cmd_config_e_tag_set,
13428 (void *)&cmd_config_e_tag_filter,
13429 (void *)&cmd_config_e_tag_del,
13430 (void *)&cmd_config_e_tag_e_tag_id,
13431 (void *)&cmd_config_e_tag_e_tag_id_val,
13432 (void *)&cmd_config_e_tag_port,
13433 (void *)&cmd_config_e_tag_port_id,
13438 /* vf vlan anti spoof configuration */
13440 /* Common result structure for vf vlan anti spoof */
13441 struct cmd_vf_vlan_anti_spoof_result {
13442 cmdline_fixed_string_t set;
13443 cmdline_fixed_string_t vf;
13444 cmdline_fixed_string_t vlan;
13445 cmdline_fixed_string_t antispoof;
13448 cmdline_fixed_string_t on_off;
13451 /* Common CLI fields for vf vlan anti spoof enable disable */
13452 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13453 TOKEN_STRING_INITIALIZER
13454 (struct cmd_vf_vlan_anti_spoof_result,
13456 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13457 TOKEN_STRING_INITIALIZER
13458 (struct cmd_vf_vlan_anti_spoof_result,
13460 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13461 TOKEN_STRING_INITIALIZER
13462 (struct cmd_vf_vlan_anti_spoof_result,
13464 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13465 TOKEN_STRING_INITIALIZER
13466 (struct cmd_vf_vlan_anti_spoof_result,
13467 antispoof, "antispoof");
13468 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13469 TOKEN_NUM_INITIALIZER
13470 (struct cmd_vf_vlan_anti_spoof_result,
13472 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13473 TOKEN_NUM_INITIALIZER
13474 (struct cmd_vf_vlan_anti_spoof_result,
13476 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13477 TOKEN_STRING_INITIALIZER
13478 (struct cmd_vf_vlan_anti_spoof_result,
13482 cmd_set_vf_vlan_anti_spoof_parsed(
13483 void *parsed_result,
13484 __rte_unused struct cmdline *cl,
13485 __rte_unused void *data)
13487 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13488 int ret = -ENOTSUP;
13490 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13492 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13495 #ifdef RTE_LIBRTE_IXGBE_PMD
13496 if (ret == -ENOTSUP)
13497 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13498 res->vf_id, is_on);
13500 #ifdef RTE_LIBRTE_I40E_PMD
13501 if (ret == -ENOTSUP)
13502 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13503 res->vf_id, is_on);
13505 #ifdef RTE_LIBRTE_BNXT_PMD
13506 if (ret == -ENOTSUP)
13507 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13508 res->vf_id, is_on);
13515 printf("invalid vf_id %d\n", res->vf_id);
13518 printf("invalid port_id %d\n", res->port_id);
13521 printf("function not implemented\n");
13524 printf("programming error: (%s)\n", strerror(-ret));
13528 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13529 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13531 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13533 (void *)&cmd_vf_vlan_anti_spoof_set,
13534 (void *)&cmd_vf_vlan_anti_spoof_vf,
13535 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13536 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13537 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13538 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13539 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13544 /* vf mac anti spoof configuration */
13546 /* Common result structure for vf mac anti spoof */
13547 struct cmd_vf_mac_anti_spoof_result {
13548 cmdline_fixed_string_t set;
13549 cmdline_fixed_string_t vf;
13550 cmdline_fixed_string_t mac;
13551 cmdline_fixed_string_t antispoof;
13554 cmdline_fixed_string_t on_off;
13557 /* Common CLI fields for vf mac anti spoof enable disable */
13558 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13559 TOKEN_STRING_INITIALIZER
13560 (struct cmd_vf_mac_anti_spoof_result,
13562 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13563 TOKEN_STRING_INITIALIZER
13564 (struct cmd_vf_mac_anti_spoof_result,
13566 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13567 TOKEN_STRING_INITIALIZER
13568 (struct cmd_vf_mac_anti_spoof_result,
13570 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13571 TOKEN_STRING_INITIALIZER
13572 (struct cmd_vf_mac_anti_spoof_result,
13573 antispoof, "antispoof");
13574 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13575 TOKEN_NUM_INITIALIZER
13576 (struct cmd_vf_mac_anti_spoof_result,
13578 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13579 TOKEN_NUM_INITIALIZER
13580 (struct cmd_vf_mac_anti_spoof_result,
13582 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13583 TOKEN_STRING_INITIALIZER
13584 (struct cmd_vf_mac_anti_spoof_result,
13588 cmd_set_vf_mac_anti_spoof_parsed(
13589 void *parsed_result,
13590 __rte_unused struct cmdline *cl,
13591 __rte_unused void *data)
13593 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13594 int ret = -ENOTSUP;
13596 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13598 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13601 #ifdef RTE_LIBRTE_IXGBE_PMD
13602 if (ret == -ENOTSUP)
13603 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13604 res->vf_id, is_on);
13606 #ifdef RTE_LIBRTE_I40E_PMD
13607 if (ret == -ENOTSUP)
13608 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13609 res->vf_id, is_on);
13611 #ifdef RTE_LIBRTE_BNXT_PMD
13612 if (ret == -ENOTSUP)
13613 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13614 res->vf_id, is_on);
13621 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13624 printf("invalid port_id %d\n", res->port_id);
13627 printf("function not implemented\n");
13630 printf("programming error: (%s)\n", strerror(-ret));
13634 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13635 .f = cmd_set_vf_mac_anti_spoof_parsed,
13637 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13639 (void *)&cmd_vf_mac_anti_spoof_set,
13640 (void *)&cmd_vf_mac_anti_spoof_vf,
13641 (void *)&cmd_vf_mac_anti_spoof_mac,
13642 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13643 (void *)&cmd_vf_mac_anti_spoof_port_id,
13644 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13645 (void *)&cmd_vf_mac_anti_spoof_on_off,
13650 /* vf vlan strip queue configuration */
13652 /* Common result structure for vf mac anti spoof */
13653 struct cmd_vf_vlan_stripq_result {
13654 cmdline_fixed_string_t set;
13655 cmdline_fixed_string_t vf;
13656 cmdline_fixed_string_t vlan;
13657 cmdline_fixed_string_t stripq;
13660 cmdline_fixed_string_t on_off;
13663 /* Common CLI fields for vf vlan strip enable disable */
13664 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13665 TOKEN_STRING_INITIALIZER
13666 (struct cmd_vf_vlan_stripq_result,
13668 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13669 TOKEN_STRING_INITIALIZER
13670 (struct cmd_vf_vlan_stripq_result,
13672 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13673 TOKEN_STRING_INITIALIZER
13674 (struct cmd_vf_vlan_stripq_result,
13676 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13677 TOKEN_STRING_INITIALIZER
13678 (struct cmd_vf_vlan_stripq_result,
13680 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13681 TOKEN_NUM_INITIALIZER
13682 (struct cmd_vf_vlan_stripq_result,
13684 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13685 TOKEN_NUM_INITIALIZER
13686 (struct cmd_vf_vlan_stripq_result,
13688 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13689 TOKEN_STRING_INITIALIZER
13690 (struct cmd_vf_vlan_stripq_result,
13694 cmd_set_vf_vlan_stripq_parsed(
13695 void *parsed_result,
13696 __rte_unused struct cmdline *cl,
13697 __rte_unused void *data)
13699 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13700 int ret = -ENOTSUP;
13702 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13704 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13707 #ifdef RTE_LIBRTE_IXGBE_PMD
13708 if (ret == -ENOTSUP)
13709 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13710 res->vf_id, is_on);
13712 #ifdef RTE_LIBRTE_I40E_PMD
13713 if (ret == -ENOTSUP)
13714 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13715 res->vf_id, is_on);
13717 #ifdef RTE_LIBRTE_BNXT_PMD
13718 if (ret == -ENOTSUP)
13719 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13720 res->vf_id, is_on);
13727 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13730 printf("invalid port_id %d\n", res->port_id);
13733 printf("function not implemented\n");
13736 printf("programming error: (%s)\n", strerror(-ret));
13740 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13741 .f = cmd_set_vf_vlan_stripq_parsed,
13743 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13745 (void *)&cmd_vf_vlan_stripq_set,
13746 (void *)&cmd_vf_vlan_stripq_vf,
13747 (void *)&cmd_vf_vlan_stripq_vlan,
13748 (void *)&cmd_vf_vlan_stripq_stripq,
13749 (void *)&cmd_vf_vlan_stripq_port_id,
13750 (void *)&cmd_vf_vlan_stripq_vf_id,
13751 (void *)&cmd_vf_vlan_stripq_on_off,
13756 /* vf vlan insert configuration */
13758 /* Common result structure for vf vlan insert */
13759 struct cmd_vf_vlan_insert_result {
13760 cmdline_fixed_string_t set;
13761 cmdline_fixed_string_t vf;
13762 cmdline_fixed_string_t vlan;
13763 cmdline_fixed_string_t insert;
13769 /* Common CLI fields for vf vlan insert enable disable */
13770 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13771 TOKEN_STRING_INITIALIZER
13772 (struct cmd_vf_vlan_insert_result,
13774 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13775 TOKEN_STRING_INITIALIZER
13776 (struct cmd_vf_vlan_insert_result,
13778 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13779 TOKEN_STRING_INITIALIZER
13780 (struct cmd_vf_vlan_insert_result,
13782 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13783 TOKEN_STRING_INITIALIZER
13784 (struct cmd_vf_vlan_insert_result,
13786 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13787 TOKEN_NUM_INITIALIZER
13788 (struct cmd_vf_vlan_insert_result,
13790 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13791 TOKEN_NUM_INITIALIZER
13792 (struct cmd_vf_vlan_insert_result,
13794 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13795 TOKEN_NUM_INITIALIZER
13796 (struct cmd_vf_vlan_insert_result,
13800 cmd_set_vf_vlan_insert_parsed(
13801 void *parsed_result,
13802 __rte_unused struct cmdline *cl,
13803 __rte_unused void *data)
13805 struct cmd_vf_vlan_insert_result *res = parsed_result;
13806 int ret = -ENOTSUP;
13808 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13811 #ifdef RTE_LIBRTE_IXGBE_PMD
13812 if (ret == -ENOTSUP)
13813 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13816 #ifdef RTE_LIBRTE_I40E_PMD
13817 if (ret == -ENOTSUP)
13818 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13821 #ifdef RTE_LIBRTE_BNXT_PMD
13822 if (ret == -ENOTSUP)
13823 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13831 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13834 printf("invalid port_id %d\n", res->port_id);
13837 printf("function not implemented\n");
13840 printf("programming error: (%s)\n", strerror(-ret));
13844 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13845 .f = cmd_set_vf_vlan_insert_parsed,
13847 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13849 (void *)&cmd_vf_vlan_insert_set,
13850 (void *)&cmd_vf_vlan_insert_vf,
13851 (void *)&cmd_vf_vlan_insert_vlan,
13852 (void *)&cmd_vf_vlan_insert_insert,
13853 (void *)&cmd_vf_vlan_insert_port_id,
13854 (void *)&cmd_vf_vlan_insert_vf_id,
13855 (void *)&cmd_vf_vlan_insert_vlan_id,
13860 /* tx loopback configuration */
13862 /* Common result structure for tx loopback */
13863 struct cmd_tx_loopback_result {
13864 cmdline_fixed_string_t set;
13865 cmdline_fixed_string_t tx;
13866 cmdline_fixed_string_t loopback;
13868 cmdline_fixed_string_t on_off;
13871 /* Common CLI fields for tx loopback enable disable */
13872 cmdline_parse_token_string_t cmd_tx_loopback_set =
13873 TOKEN_STRING_INITIALIZER
13874 (struct cmd_tx_loopback_result,
13876 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13877 TOKEN_STRING_INITIALIZER
13878 (struct cmd_tx_loopback_result,
13880 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13881 TOKEN_STRING_INITIALIZER
13882 (struct cmd_tx_loopback_result,
13883 loopback, "loopback");
13884 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13885 TOKEN_NUM_INITIALIZER
13886 (struct cmd_tx_loopback_result,
13888 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13889 TOKEN_STRING_INITIALIZER
13890 (struct cmd_tx_loopback_result,
13894 cmd_set_tx_loopback_parsed(
13895 void *parsed_result,
13896 __rte_unused struct cmdline *cl,
13897 __rte_unused void *data)
13899 struct cmd_tx_loopback_result *res = parsed_result;
13900 int ret = -ENOTSUP;
13902 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13904 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13907 #ifdef RTE_LIBRTE_IXGBE_PMD
13908 if (ret == -ENOTSUP)
13909 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13911 #ifdef RTE_LIBRTE_I40E_PMD
13912 if (ret == -ENOTSUP)
13913 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13915 #ifdef RTE_LIBRTE_BNXT_PMD
13916 if (ret == -ENOTSUP)
13917 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13919 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13920 if (ret == -ENOTSUP)
13921 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13928 printf("invalid is_on %d\n", is_on);
13931 printf("invalid port_id %d\n", res->port_id);
13934 printf("function not implemented\n");
13937 printf("programming error: (%s)\n", strerror(-ret));
13941 cmdline_parse_inst_t cmd_set_tx_loopback = {
13942 .f = cmd_set_tx_loopback_parsed,
13944 .help_str = "set tx loopback <port_id> on|off",
13946 (void *)&cmd_tx_loopback_set,
13947 (void *)&cmd_tx_loopback_tx,
13948 (void *)&cmd_tx_loopback_loopback,
13949 (void *)&cmd_tx_loopback_port_id,
13950 (void *)&cmd_tx_loopback_on_off,
13955 /* all queues drop enable configuration */
13957 /* Common result structure for all queues drop enable */
13958 struct cmd_all_queues_drop_en_result {
13959 cmdline_fixed_string_t set;
13960 cmdline_fixed_string_t all;
13961 cmdline_fixed_string_t queues;
13962 cmdline_fixed_string_t drop;
13964 cmdline_fixed_string_t on_off;
13967 /* Common CLI fields for tx loopback enable disable */
13968 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13969 TOKEN_STRING_INITIALIZER
13970 (struct cmd_all_queues_drop_en_result,
13972 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13973 TOKEN_STRING_INITIALIZER
13974 (struct cmd_all_queues_drop_en_result,
13976 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13977 TOKEN_STRING_INITIALIZER
13978 (struct cmd_all_queues_drop_en_result,
13980 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13981 TOKEN_STRING_INITIALIZER
13982 (struct cmd_all_queues_drop_en_result,
13984 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13985 TOKEN_NUM_INITIALIZER
13986 (struct cmd_all_queues_drop_en_result,
13988 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13989 TOKEN_STRING_INITIALIZER
13990 (struct cmd_all_queues_drop_en_result,
13994 cmd_set_all_queues_drop_en_parsed(
13995 void *parsed_result,
13996 __rte_unused struct cmdline *cl,
13997 __rte_unused void *data)
13999 struct cmd_all_queues_drop_en_result *res = parsed_result;
14000 int ret = -ENOTSUP;
14001 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14003 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14006 #ifdef RTE_LIBRTE_IXGBE_PMD
14007 if (ret == -ENOTSUP)
14008 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14010 #ifdef RTE_LIBRTE_BNXT_PMD
14011 if (ret == -ENOTSUP)
14012 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14018 printf("invalid is_on %d\n", is_on);
14021 printf("invalid port_id %d\n", res->port_id);
14024 printf("function not implemented\n");
14027 printf("programming error: (%s)\n", strerror(-ret));
14031 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14032 .f = cmd_set_all_queues_drop_en_parsed,
14034 .help_str = "set all queues drop <port_id> on|off",
14036 (void *)&cmd_all_queues_drop_en_set,
14037 (void *)&cmd_all_queues_drop_en_all,
14038 (void *)&cmd_all_queues_drop_en_queues,
14039 (void *)&cmd_all_queues_drop_en_drop,
14040 (void *)&cmd_all_queues_drop_en_port_id,
14041 (void *)&cmd_all_queues_drop_en_on_off,
14046 /* vf split drop enable configuration */
14048 /* Common result structure for vf split drop enable */
14049 struct cmd_vf_split_drop_en_result {
14050 cmdline_fixed_string_t set;
14051 cmdline_fixed_string_t vf;
14052 cmdline_fixed_string_t split;
14053 cmdline_fixed_string_t drop;
14056 cmdline_fixed_string_t on_off;
14059 /* Common CLI fields for vf split drop enable disable */
14060 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14061 TOKEN_STRING_INITIALIZER
14062 (struct cmd_vf_split_drop_en_result,
14064 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14065 TOKEN_STRING_INITIALIZER
14066 (struct cmd_vf_split_drop_en_result,
14068 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14069 TOKEN_STRING_INITIALIZER
14070 (struct cmd_vf_split_drop_en_result,
14072 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14073 TOKEN_STRING_INITIALIZER
14074 (struct cmd_vf_split_drop_en_result,
14076 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14077 TOKEN_NUM_INITIALIZER
14078 (struct cmd_vf_split_drop_en_result,
14080 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14081 TOKEN_NUM_INITIALIZER
14082 (struct cmd_vf_split_drop_en_result,
14084 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14085 TOKEN_STRING_INITIALIZER
14086 (struct cmd_vf_split_drop_en_result,
14090 cmd_set_vf_split_drop_en_parsed(
14091 void *parsed_result,
14092 __rte_unused struct cmdline *cl,
14093 __rte_unused void *data)
14095 struct cmd_vf_split_drop_en_result *res = parsed_result;
14096 int ret = -ENOTSUP;
14097 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14099 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14102 #ifdef RTE_LIBRTE_IXGBE_PMD
14103 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14110 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14113 printf("invalid port_id %d\n", res->port_id);
14116 printf("not supported on port %d\n", res->port_id);
14119 printf("programming error: (%s)\n", strerror(-ret));
14123 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14124 .f = cmd_set_vf_split_drop_en_parsed,
14126 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14128 (void *)&cmd_vf_split_drop_en_set,
14129 (void *)&cmd_vf_split_drop_en_vf,
14130 (void *)&cmd_vf_split_drop_en_split,
14131 (void *)&cmd_vf_split_drop_en_drop,
14132 (void *)&cmd_vf_split_drop_en_port_id,
14133 (void *)&cmd_vf_split_drop_en_vf_id,
14134 (void *)&cmd_vf_split_drop_en_on_off,
14139 /* vf mac address configuration */
14141 /* Common result structure for vf mac address */
14142 struct cmd_set_vf_mac_addr_result {
14143 cmdline_fixed_string_t set;
14144 cmdline_fixed_string_t vf;
14145 cmdline_fixed_string_t mac;
14146 cmdline_fixed_string_t addr;
14149 struct rte_ether_addr mac_addr;
14153 /* Common CLI fields for vf split drop enable disable */
14154 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14155 TOKEN_STRING_INITIALIZER
14156 (struct cmd_set_vf_mac_addr_result,
14158 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14159 TOKEN_STRING_INITIALIZER
14160 (struct cmd_set_vf_mac_addr_result,
14162 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14163 TOKEN_STRING_INITIALIZER
14164 (struct cmd_set_vf_mac_addr_result,
14166 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14167 TOKEN_STRING_INITIALIZER
14168 (struct cmd_set_vf_mac_addr_result,
14170 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14171 TOKEN_NUM_INITIALIZER
14172 (struct cmd_set_vf_mac_addr_result,
14174 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14175 TOKEN_NUM_INITIALIZER
14176 (struct cmd_set_vf_mac_addr_result,
14178 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14179 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14183 cmd_set_vf_mac_addr_parsed(
14184 void *parsed_result,
14185 __rte_unused struct cmdline *cl,
14186 __rte_unused void *data)
14188 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14189 int ret = -ENOTSUP;
14191 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14194 #ifdef RTE_LIBRTE_IXGBE_PMD
14195 if (ret == -ENOTSUP)
14196 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14199 #ifdef RTE_LIBRTE_I40E_PMD
14200 if (ret == -ENOTSUP)
14201 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14204 #ifdef RTE_LIBRTE_BNXT_PMD
14205 if (ret == -ENOTSUP)
14206 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14214 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14217 printf("invalid port_id %d\n", res->port_id);
14220 printf("function not implemented\n");
14223 printf("programming error: (%s)\n", strerror(-ret));
14227 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14228 .f = cmd_set_vf_mac_addr_parsed,
14230 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14232 (void *)&cmd_set_vf_mac_addr_set,
14233 (void *)&cmd_set_vf_mac_addr_vf,
14234 (void *)&cmd_set_vf_mac_addr_mac,
14235 (void *)&cmd_set_vf_mac_addr_addr,
14236 (void *)&cmd_set_vf_mac_addr_port_id,
14237 (void *)&cmd_set_vf_mac_addr_vf_id,
14238 (void *)&cmd_set_vf_mac_addr_mac_addr,
14243 /* MACsec configuration */
14245 /* Common result structure for MACsec offload enable */
14246 struct cmd_macsec_offload_on_result {
14247 cmdline_fixed_string_t set;
14248 cmdline_fixed_string_t macsec;
14249 cmdline_fixed_string_t offload;
14251 cmdline_fixed_string_t on;
14252 cmdline_fixed_string_t encrypt;
14253 cmdline_fixed_string_t en_on_off;
14254 cmdline_fixed_string_t replay_protect;
14255 cmdline_fixed_string_t rp_on_off;
14258 /* Common CLI fields for MACsec offload disable */
14259 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14260 TOKEN_STRING_INITIALIZER
14261 (struct cmd_macsec_offload_on_result,
14263 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14264 TOKEN_STRING_INITIALIZER
14265 (struct cmd_macsec_offload_on_result,
14267 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14268 TOKEN_STRING_INITIALIZER
14269 (struct cmd_macsec_offload_on_result,
14270 offload, "offload");
14271 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14272 TOKEN_NUM_INITIALIZER
14273 (struct cmd_macsec_offload_on_result,
14275 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14276 TOKEN_STRING_INITIALIZER
14277 (struct cmd_macsec_offload_on_result,
14279 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14280 TOKEN_STRING_INITIALIZER
14281 (struct cmd_macsec_offload_on_result,
14282 encrypt, "encrypt");
14283 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14284 TOKEN_STRING_INITIALIZER
14285 (struct cmd_macsec_offload_on_result,
14286 en_on_off, "on#off");
14287 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14288 TOKEN_STRING_INITIALIZER
14289 (struct cmd_macsec_offload_on_result,
14290 replay_protect, "replay-protect");
14291 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14292 TOKEN_STRING_INITIALIZER
14293 (struct cmd_macsec_offload_on_result,
14294 rp_on_off, "on#off");
14297 cmd_set_macsec_offload_on_parsed(
14298 void *parsed_result,
14299 __rte_unused struct cmdline *cl,
14300 __rte_unused void *data)
14302 struct cmd_macsec_offload_on_result *res = parsed_result;
14303 int ret = -ENOTSUP;
14304 portid_t port_id = res->port_id;
14305 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14306 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14307 struct rte_eth_dev_info dev_info;
14309 if (port_id_is_invalid(port_id, ENABLED_WARN))
14311 if (!port_is_stopped(port_id)) {
14312 printf("Please stop port %d first\n", port_id);
14316 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14320 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14321 #ifdef RTE_LIBRTE_IXGBE_PMD
14322 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14330 ports[port_id].dev_conf.txmode.offloads |=
14331 DEV_TX_OFFLOAD_MACSEC_INSERT;
14332 cmd_reconfig_device_queue(port_id, 1, 1);
14335 printf("invalid port_id %d\n", port_id);
14338 printf("not supported on port %d\n", port_id);
14341 printf("programming error: (%s)\n", strerror(-ret));
14345 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14346 .f = cmd_set_macsec_offload_on_parsed,
14348 .help_str = "set macsec offload <port_id> on "
14349 "encrypt on|off replay-protect on|off",
14351 (void *)&cmd_macsec_offload_on_set,
14352 (void *)&cmd_macsec_offload_on_macsec,
14353 (void *)&cmd_macsec_offload_on_offload,
14354 (void *)&cmd_macsec_offload_on_port_id,
14355 (void *)&cmd_macsec_offload_on_on,
14356 (void *)&cmd_macsec_offload_on_encrypt,
14357 (void *)&cmd_macsec_offload_on_en_on_off,
14358 (void *)&cmd_macsec_offload_on_replay_protect,
14359 (void *)&cmd_macsec_offload_on_rp_on_off,
14364 /* Common result structure for MACsec offload disable */
14365 struct cmd_macsec_offload_off_result {
14366 cmdline_fixed_string_t set;
14367 cmdline_fixed_string_t macsec;
14368 cmdline_fixed_string_t offload;
14370 cmdline_fixed_string_t off;
14373 /* Common CLI fields for MACsec offload disable */
14374 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14375 TOKEN_STRING_INITIALIZER
14376 (struct cmd_macsec_offload_off_result,
14378 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14379 TOKEN_STRING_INITIALIZER
14380 (struct cmd_macsec_offload_off_result,
14382 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14383 TOKEN_STRING_INITIALIZER
14384 (struct cmd_macsec_offload_off_result,
14385 offload, "offload");
14386 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14387 TOKEN_NUM_INITIALIZER
14388 (struct cmd_macsec_offload_off_result,
14390 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14391 TOKEN_STRING_INITIALIZER
14392 (struct cmd_macsec_offload_off_result,
14396 cmd_set_macsec_offload_off_parsed(
14397 void *parsed_result,
14398 __rte_unused struct cmdline *cl,
14399 __rte_unused void *data)
14401 struct cmd_macsec_offload_off_result *res = parsed_result;
14402 int ret = -ENOTSUP;
14403 struct rte_eth_dev_info dev_info;
14404 portid_t port_id = res->port_id;
14406 if (port_id_is_invalid(port_id, ENABLED_WARN))
14408 if (!port_is_stopped(port_id)) {
14409 printf("Please stop port %d first\n", port_id);
14413 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14417 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14418 #ifdef RTE_LIBRTE_IXGBE_PMD
14419 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14424 ports[port_id].dev_conf.txmode.offloads &=
14425 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14426 cmd_reconfig_device_queue(port_id, 1, 1);
14429 printf("invalid port_id %d\n", port_id);
14432 printf("not supported on port %d\n", port_id);
14435 printf("programming error: (%s)\n", strerror(-ret));
14439 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14440 .f = cmd_set_macsec_offload_off_parsed,
14442 .help_str = "set macsec offload <port_id> off",
14444 (void *)&cmd_macsec_offload_off_set,
14445 (void *)&cmd_macsec_offload_off_macsec,
14446 (void *)&cmd_macsec_offload_off_offload,
14447 (void *)&cmd_macsec_offload_off_port_id,
14448 (void *)&cmd_macsec_offload_off_off,
14453 /* Common result structure for MACsec secure connection configure */
14454 struct cmd_macsec_sc_result {
14455 cmdline_fixed_string_t set;
14456 cmdline_fixed_string_t macsec;
14457 cmdline_fixed_string_t sc;
14458 cmdline_fixed_string_t tx_rx;
14460 struct rte_ether_addr mac;
14464 /* Common CLI fields for MACsec secure connection configure */
14465 cmdline_parse_token_string_t cmd_macsec_sc_set =
14466 TOKEN_STRING_INITIALIZER
14467 (struct cmd_macsec_sc_result,
14469 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14470 TOKEN_STRING_INITIALIZER
14471 (struct cmd_macsec_sc_result,
14473 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14474 TOKEN_STRING_INITIALIZER
14475 (struct cmd_macsec_sc_result,
14477 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14478 TOKEN_STRING_INITIALIZER
14479 (struct cmd_macsec_sc_result,
14481 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14482 TOKEN_NUM_INITIALIZER
14483 (struct cmd_macsec_sc_result,
14485 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14486 TOKEN_ETHERADDR_INITIALIZER
14487 (struct cmd_macsec_sc_result,
14489 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14490 TOKEN_NUM_INITIALIZER
14491 (struct cmd_macsec_sc_result,
14495 cmd_set_macsec_sc_parsed(
14496 void *parsed_result,
14497 __rte_unused struct cmdline *cl,
14498 __rte_unused void *data)
14500 struct cmd_macsec_sc_result *res = parsed_result;
14501 int ret = -ENOTSUP;
14502 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14504 #ifdef RTE_LIBRTE_IXGBE_PMD
14506 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14507 res->mac.addr_bytes) :
14508 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14509 res->mac.addr_bytes, res->pi);
14511 RTE_SET_USED(is_tx);
14517 printf("invalid port_id %d\n", res->port_id);
14520 printf("not supported on port %d\n", res->port_id);
14523 printf("programming error: (%s)\n", strerror(-ret));
14527 cmdline_parse_inst_t cmd_set_macsec_sc = {
14528 .f = cmd_set_macsec_sc_parsed,
14530 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14532 (void *)&cmd_macsec_sc_set,
14533 (void *)&cmd_macsec_sc_macsec,
14534 (void *)&cmd_macsec_sc_sc,
14535 (void *)&cmd_macsec_sc_tx_rx,
14536 (void *)&cmd_macsec_sc_port_id,
14537 (void *)&cmd_macsec_sc_mac,
14538 (void *)&cmd_macsec_sc_pi,
14543 /* Common result structure for MACsec secure connection configure */
14544 struct cmd_macsec_sa_result {
14545 cmdline_fixed_string_t set;
14546 cmdline_fixed_string_t macsec;
14547 cmdline_fixed_string_t sa;
14548 cmdline_fixed_string_t tx_rx;
14553 cmdline_fixed_string_t key;
14556 /* Common CLI fields for MACsec secure connection configure */
14557 cmdline_parse_token_string_t cmd_macsec_sa_set =
14558 TOKEN_STRING_INITIALIZER
14559 (struct cmd_macsec_sa_result,
14561 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14562 TOKEN_STRING_INITIALIZER
14563 (struct cmd_macsec_sa_result,
14565 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14566 TOKEN_STRING_INITIALIZER
14567 (struct cmd_macsec_sa_result,
14569 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14570 TOKEN_STRING_INITIALIZER
14571 (struct cmd_macsec_sa_result,
14573 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14574 TOKEN_NUM_INITIALIZER
14575 (struct cmd_macsec_sa_result,
14577 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14578 TOKEN_NUM_INITIALIZER
14579 (struct cmd_macsec_sa_result,
14581 cmdline_parse_token_num_t cmd_macsec_sa_an =
14582 TOKEN_NUM_INITIALIZER
14583 (struct cmd_macsec_sa_result,
14585 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14586 TOKEN_NUM_INITIALIZER
14587 (struct cmd_macsec_sa_result,
14589 cmdline_parse_token_string_t cmd_macsec_sa_key =
14590 TOKEN_STRING_INITIALIZER
14591 (struct cmd_macsec_sa_result,
14595 cmd_set_macsec_sa_parsed(
14596 void *parsed_result,
14597 __rte_unused struct cmdline *cl,
14598 __rte_unused void *data)
14600 struct cmd_macsec_sa_result *res = parsed_result;
14601 int ret = -ENOTSUP;
14602 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14603 uint8_t key[16] = { 0 };
14609 key_len = strlen(res->key) / 2;
14613 for (i = 0; i < key_len; i++) {
14614 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14617 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14620 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14623 #ifdef RTE_LIBRTE_IXGBE_PMD
14625 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14626 res->idx, res->an, res->pn, key) :
14627 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14628 res->idx, res->an, res->pn, key);
14630 RTE_SET_USED(is_tx);
14637 printf("invalid idx %d or an %d\n", res->idx, res->an);
14640 printf("invalid port_id %d\n", res->port_id);
14643 printf("not supported on port %d\n", res->port_id);
14646 printf("programming error: (%s)\n", strerror(-ret));
14650 cmdline_parse_inst_t cmd_set_macsec_sa = {
14651 .f = cmd_set_macsec_sa_parsed,
14653 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14655 (void *)&cmd_macsec_sa_set,
14656 (void *)&cmd_macsec_sa_macsec,
14657 (void *)&cmd_macsec_sa_sa,
14658 (void *)&cmd_macsec_sa_tx_rx,
14659 (void *)&cmd_macsec_sa_port_id,
14660 (void *)&cmd_macsec_sa_idx,
14661 (void *)&cmd_macsec_sa_an,
14662 (void *)&cmd_macsec_sa_pn,
14663 (void *)&cmd_macsec_sa_key,
14668 /* VF unicast promiscuous mode configuration */
14670 /* Common result structure for VF unicast promiscuous mode */
14671 struct cmd_vf_promisc_result {
14672 cmdline_fixed_string_t set;
14673 cmdline_fixed_string_t vf;
14674 cmdline_fixed_string_t promisc;
14677 cmdline_fixed_string_t on_off;
14680 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14681 cmdline_parse_token_string_t cmd_vf_promisc_set =
14682 TOKEN_STRING_INITIALIZER
14683 (struct cmd_vf_promisc_result,
14685 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14686 TOKEN_STRING_INITIALIZER
14687 (struct cmd_vf_promisc_result,
14689 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14690 TOKEN_STRING_INITIALIZER
14691 (struct cmd_vf_promisc_result,
14692 promisc, "promisc");
14693 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14694 TOKEN_NUM_INITIALIZER
14695 (struct cmd_vf_promisc_result,
14697 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14698 TOKEN_NUM_INITIALIZER
14699 (struct cmd_vf_promisc_result,
14701 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14702 TOKEN_STRING_INITIALIZER
14703 (struct cmd_vf_promisc_result,
14707 cmd_set_vf_promisc_parsed(
14708 void *parsed_result,
14709 __rte_unused struct cmdline *cl,
14710 __rte_unused void *data)
14712 struct cmd_vf_promisc_result *res = parsed_result;
14713 int ret = -ENOTSUP;
14715 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14717 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14720 #ifdef RTE_LIBRTE_I40E_PMD
14721 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14722 res->vf_id, is_on);
14729 printf("invalid vf_id %d\n", res->vf_id);
14732 printf("invalid port_id %d\n", res->port_id);
14735 printf("function not implemented\n");
14738 printf("programming error: (%s)\n", strerror(-ret));
14742 cmdline_parse_inst_t cmd_set_vf_promisc = {
14743 .f = cmd_set_vf_promisc_parsed,
14745 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14746 "Set unicast promiscuous mode for a VF from the PF",
14748 (void *)&cmd_vf_promisc_set,
14749 (void *)&cmd_vf_promisc_vf,
14750 (void *)&cmd_vf_promisc_promisc,
14751 (void *)&cmd_vf_promisc_port_id,
14752 (void *)&cmd_vf_promisc_vf_id,
14753 (void *)&cmd_vf_promisc_on_off,
14758 /* VF multicast promiscuous mode configuration */
14760 /* Common result structure for VF multicast promiscuous mode */
14761 struct cmd_vf_allmulti_result {
14762 cmdline_fixed_string_t set;
14763 cmdline_fixed_string_t vf;
14764 cmdline_fixed_string_t allmulti;
14767 cmdline_fixed_string_t on_off;
14770 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14771 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14772 TOKEN_STRING_INITIALIZER
14773 (struct cmd_vf_allmulti_result,
14775 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14776 TOKEN_STRING_INITIALIZER
14777 (struct cmd_vf_allmulti_result,
14779 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14780 TOKEN_STRING_INITIALIZER
14781 (struct cmd_vf_allmulti_result,
14782 allmulti, "allmulti");
14783 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14784 TOKEN_NUM_INITIALIZER
14785 (struct cmd_vf_allmulti_result,
14787 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14788 TOKEN_NUM_INITIALIZER
14789 (struct cmd_vf_allmulti_result,
14791 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14792 TOKEN_STRING_INITIALIZER
14793 (struct cmd_vf_allmulti_result,
14797 cmd_set_vf_allmulti_parsed(
14798 void *parsed_result,
14799 __rte_unused struct cmdline *cl,
14800 __rte_unused void *data)
14802 struct cmd_vf_allmulti_result *res = parsed_result;
14803 int ret = -ENOTSUP;
14805 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14807 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14810 #ifdef RTE_LIBRTE_I40E_PMD
14811 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14812 res->vf_id, is_on);
14819 printf("invalid vf_id %d\n", res->vf_id);
14822 printf("invalid port_id %d\n", res->port_id);
14825 printf("function not implemented\n");
14828 printf("programming error: (%s)\n", strerror(-ret));
14832 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14833 .f = cmd_set_vf_allmulti_parsed,
14835 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14836 "Set multicast promiscuous mode for a VF from the PF",
14838 (void *)&cmd_vf_allmulti_set,
14839 (void *)&cmd_vf_allmulti_vf,
14840 (void *)&cmd_vf_allmulti_allmulti,
14841 (void *)&cmd_vf_allmulti_port_id,
14842 (void *)&cmd_vf_allmulti_vf_id,
14843 (void *)&cmd_vf_allmulti_on_off,
14848 /* vf broadcast mode configuration */
14850 /* Common result structure for vf broadcast */
14851 struct cmd_set_vf_broadcast_result {
14852 cmdline_fixed_string_t set;
14853 cmdline_fixed_string_t vf;
14854 cmdline_fixed_string_t broadcast;
14857 cmdline_fixed_string_t on_off;
14860 /* Common CLI fields for vf broadcast enable disable */
14861 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14862 TOKEN_STRING_INITIALIZER
14863 (struct cmd_set_vf_broadcast_result,
14865 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14866 TOKEN_STRING_INITIALIZER
14867 (struct cmd_set_vf_broadcast_result,
14869 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14870 TOKEN_STRING_INITIALIZER
14871 (struct cmd_set_vf_broadcast_result,
14872 broadcast, "broadcast");
14873 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14874 TOKEN_NUM_INITIALIZER
14875 (struct cmd_set_vf_broadcast_result,
14877 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14878 TOKEN_NUM_INITIALIZER
14879 (struct cmd_set_vf_broadcast_result,
14881 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14882 TOKEN_STRING_INITIALIZER
14883 (struct cmd_set_vf_broadcast_result,
14887 cmd_set_vf_broadcast_parsed(
14888 void *parsed_result,
14889 __rte_unused struct cmdline *cl,
14890 __rte_unused void *data)
14892 struct cmd_set_vf_broadcast_result *res = parsed_result;
14893 int ret = -ENOTSUP;
14895 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14900 #ifdef RTE_LIBRTE_I40E_PMD
14901 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14902 res->vf_id, is_on);
14909 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14912 printf("invalid port_id %d\n", res->port_id);
14915 printf("function not implemented\n");
14918 printf("programming error: (%s)\n", strerror(-ret));
14922 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14923 .f = cmd_set_vf_broadcast_parsed,
14925 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14927 (void *)&cmd_set_vf_broadcast_set,
14928 (void *)&cmd_set_vf_broadcast_vf,
14929 (void *)&cmd_set_vf_broadcast_broadcast,
14930 (void *)&cmd_set_vf_broadcast_port_id,
14931 (void *)&cmd_set_vf_broadcast_vf_id,
14932 (void *)&cmd_set_vf_broadcast_on_off,
14937 /* vf vlan tag configuration */
14939 /* Common result structure for vf vlan tag */
14940 struct cmd_set_vf_vlan_tag_result {
14941 cmdline_fixed_string_t set;
14942 cmdline_fixed_string_t vf;
14943 cmdline_fixed_string_t vlan;
14944 cmdline_fixed_string_t tag;
14947 cmdline_fixed_string_t on_off;
14950 /* Common CLI fields for vf vlan tag enable disable */
14951 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14952 TOKEN_STRING_INITIALIZER
14953 (struct cmd_set_vf_vlan_tag_result,
14955 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14956 TOKEN_STRING_INITIALIZER
14957 (struct cmd_set_vf_vlan_tag_result,
14959 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14960 TOKEN_STRING_INITIALIZER
14961 (struct cmd_set_vf_vlan_tag_result,
14963 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14964 TOKEN_STRING_INITIALIZER
14965 (struct cmd_set_vf_vlan_tag_result,
14967 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14968 TOKEN_NUM_INITIALIZER
14969 (struct cmd_set_vf_vlan_tag_result,
14971 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14972 TOKEN_NUM_INITIALIZER
14973 (struct cmd_set_vf_vlan_tag_result,
14975 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14976 TOKEN_STRING_INITIALIZER
14977 (struct cmd_set_vf_vlan_tag_result,
14981 cmd_set_vf_vlan_tag_parsed(
14982 void *parsed_result,
14983 __rte_unused struct cmdline *cl,
14984 __rte_unused void *data)
14986 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14987 int ret = -ENOTSUP;
14989 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14991 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14994 #ifdef RTE_LIBRTE_I40E_PMD
14995 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14996 res->vf_id, is_on);
15003 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15006 printf("invalid port_id %d\n", res->port_id);
15009 printf("function not implemented\n");
15012 printf("programming error: (%s)\n", strerror(-ret));
15016 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15017 .f = cmd_set_vf_vlan_tag_parsed,
15019 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15021 (void *)&cmd_set_vf_vlan_tag_set,
15022 (void *)&cmd_set_vf_vlan_tag_vf,
15023 (void *)&cmd_set_vf_vlan_tag_vlan,
15024 (void *)&cmd_set_vf_vlan_tag_tag,
15025 (void *)&cmd_set_vf_vlan_tag_port_id,
15026 (void *)&cmd_set_vf_vlan_tag_vf_id,
15027 (void *)&cmd_set_vf_vlan_tag_on_off,
15032 /* Common definition of VF and TC TX bandwidth configuration */
15033 struct cmd_vf_tc_bw_result {
15034 cmdline_fixed_string_t set;
15035 cmdline_fixed_string_t vf;
15036 cmdline_fixed_string_t tc;
15037 cmdline_fixed_string_t tx;
15038 cmdline_fixed_string_t min_bw;
15039 cmdline_fixed_string_t max_bw;
15040 cmdline_fixed_string_t strict_link_prio;
15045 cmdline_fixed_string_t bw_list;
15049 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15050 TOKEN_STRING_INITIALIZER
15051 (struct cmd_vf_tc_bw_result,
15053 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15054 TOKEN_STRING_INITIALIZER
15055 (struct cmd_vf_tc_bw_result,
15057 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15058 TOKEN_STRING_INITIALIZER
15059 (struct cmd_vf_tc_bw_result,
15061 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15062 TOKEN_STRING_INITIALIZER
15063 (struct cmd_vf_tc_bw_result,
15065 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15066 TOKEN_STRING_INITIALIZER
15067 (struct cmd_vf_tc_bw_result,
15068 strict_link_prio, "strict-link-priority");
15069 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15070 TOKEN_STRING_INITIALIZER
15071 (struct cmd_vf_tc_bw_result,
15072 min_bw, "min-bandwidth");
15073 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15074 TOKEN_STRING_INITIALIZER
15075 (struct cmd_vf_tc_bw_result,
15076 max_bw, "max-bandwidth");
15077 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15078 TOKEN_NUM_INITIALIZER
15079 (struct cmd_vf_tc_bw_result,
15081 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15082 TOKEN_NUM_INITIALIZER
15083 (struct cmd_vf_tc_bw_result,
15085 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15086 TOKEN_NUM_INITIALIZER
15087 (struct cmd_vf_tc_bw_result,
15089 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15090 TOKEN_NUM_INITIALIZER
15091 (struct cmd_vf_tc_bw_result,
15093 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15094 TOKEN_STRING_INITIALIZER
15095 (struct cmd_vf_tc_bw_result,
15097 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15098 TOKEN_NUM_INITIALIZER
15099 (struct cmd_vf_tc_bw_result,
15102 /* VF max bandwidth setting */
15104 cmd_vf_max_bw_parsed(
15105 void *parsed_result,
15106 __rte_unused struct cmdline *cl,
15107 __rte_unused void *data)
15109 struct cmd_vf_tc_bw_result *res = parsed_result;
15110 int ret = -ENOTSUP;
15112 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15115 #ifdef RTE_LIBRTE_I40E_PMD
15116 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15117 res->vf_id, res->bw);
15124 printf("invalid vf_id %d or bandwidth %d\n",
15125 res->vf_id, res->bw);
15128 printf("invalid port_id %d\n", res->port_id);
15131 printf("function not implemented\n");
15134 printf("programming error: (%s)\n", strerror(-ret));
15138 cmdline_parse_inst_t cmd_vf_max_bw = {
15139 .f = cmd_vf_max_bw_parsed,
15141 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15143 (void *)&cmd_vf_tc_bw_set,
15144 (void *)&cmd_vf_tc_bw_vf,
15145 (void *)&cmd_vf_tc_bw_tx,
15146 (void *)&cmd_vf_tc_bw_max_bw,
15147 (void *)&cmd_vf_tc_bw_port_id,
15148 (void *)&cmd_vf_tc_bw_vf_id,
15149 (void *)&cmd_vf_tc_bw_bw,
15155 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15160 const char *p, *p0 = str;
15167 p = strchr(p0, '(');
15169 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15173 p0 = strchr(p, ')');
15175 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15179 if (size >= sizeof(s)) {
15180 printf("The string size exceeds the internal buffer size\n");
15183 snprintf(s, sizeof(s), "%.*s", size, p);
15184 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15186 printf("Failed to get the bandwidth list. ");
15190 for (i = 0; i < ret; i++)
15191 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15196 /* TC min bandwidth setting */
15198 cmd_vf_tc_min_bw_parsed(
15199 void *parsed_result,
15200 __rte_unused struct cmdline *cl,
15201 __rte_unused void *data)
15203 struct cmd_vf_tc_bw_result *res = parsed_result;
15206 int ret = -ENOTSUP;
15208 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15211 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15215 #ifdef RTE_LIBRTE_I40E_PMD
15216 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15224 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15227 printf("invalid port_id %d\n", res->port_id);
15230 printf("function not implemented\n");
15233 printf("programming error: (%s)\n", strerror(-ret));
15237 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15238 .f = cmd_vf_tc_min_bw_parsed,
15240 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15241 " <bw1, bw2, ...>",
15243 (void *)&cmd_vf_tc_bw_set,
15244 (void *)&cmd_vf_tc_bw_vf,
15245 (void *)&cmd_vf_tc_bw_tc,
15246 (void *)&cmd_vf_tc_bw_tx,
15247 (void *)&cmd_vf_tc_bw_min_bw,
15248 (void *)&cmd_vf_tc_bw_port_id,
15249 (void *)&cmd_vf_tc_bw_vf_id,
15250 (void *)&cmd_vf_tc_bw_bw_list,
15256 cmd_tc_min_bw_parsed(
15257 void *parsed_result,
15258 __rte_unused struct cmdline *cl,
15259 __rte_unused void *data)
15261 struct cmd_vf_tc_bw_result *res = parsed_result;
15262 struct rte_port *port;
15265 int ret = -ENOTSUP;
15267 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15270 port = &ports[res->port_id];
15271 /** Check if the port is not started **/
15272 if (port->port_status != RTE_PORT_STOPPED) {
15273 printf("Please stop port %d first\n", res->port_id);
15277 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15281 #ifdef RTE_LIBRTE_IXGBE_PMD
15282 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15289 printf("invalid bandwidth\n");
15292 printf("invalid port_id %d\n", res->port_id);
15295 printf("function not implemented\n");
15298 printf("programming error: (%s)\n", strerror(-ret));
15302 cmdline_parse_inst_t cmd_tc_min_bw = {
15303 .f = cmd_tc_min_bw_parsed,
15305 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15307 (void *)&cmd_vf_tc_bw_set,
15308 (void *)&cmd_vf_tc_bw_tc,
15309 (void *)&cmd_vf_tc_bw_tx,
15310 (void *)&cmd_vf_tc_bw_min_bw,
15311 (void *)&cmd_vf_tc_bw_port_id,
15312 (void *)&cmd_vf_tc_bw_bw_list,
15317 /* TC max bandwidth setting */
15319 cmd_vf_tc_max_bw_parsed(
15320 void *parsed_result,
15321 __rte_unused struct cmdline *cl,
15322 __rte_unused void *data)
15324 struct cmd_vf_tc_bw_result *res = parsed_result;
15325 int ret = -ENOTSUP;
15327 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15330 #ifdef RTE_LIBRTE_I40E_PMD
15331 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15332 res->tc_no, res->bw);
15339 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15340 res->vf_id, res->tc_no, res->bw);
15343 printf("invalid port_id %d\n", res->port_id);
15346 printf("function not implemented\n");
15349 printf("programming error: (%s)\n", strerror(-ret));
15353 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15354 .f = cmd_vf_tc_max_bw_parsed,
15356 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15359 (void *)&cmd_vf_tc_bw_set,
15360 (void *)&cmd_vf_tc_bw_vf,
15361 (void *)&cmd_vf_tc_bw_tc,
15362 (void *)&cmd_vf_tc_bw_tx,
15363 (void *)&cmd_vf_tc_bw_max_bw,
15364 (void *)&cmd_vf_tc_bw_port_id,
15365 (void *)&cmd_vf_tc_bw_vf_id,
15366 (void *)&cmd_vf_tc_bw_tc_no,
15367 (void *)&cmd_vf_tc_bw_bw,
15373 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15375 /* *** Set Port default Traffic Management Hierarchy *** */
15376 struct cmd_set_port_tm_hierarchy_default_result {
15377 cmdline_fixed_string_t set;
15378 cmdline_fixed_string_t port;
15379 cmdline_fixed_string_t tm;
15380 cmdline_fixed_string_t hierarchy;
15381 cmdline_fixed_string_t def;
15385 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15386 TOKEN_STRING_INITIALIZER(
15387 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15388 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15389 TOKEN_STRING_INITIALIZER(
15390 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15391 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15392 TOKEN_STRING_INITIALIZER(
15393 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15394 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15395 TOKEN_STRING_INITIALIZER(
15396 struct cmd_set_port_tm_hierarchy_default_result,
15397 hierarchy, "hierarchy");
15398 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15399 TOKEN_STRING_INITIALIZER(
15400 struct cmd_set_port_tm_hierarchy_default_result,
15402 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15403 TOKEN_NUM_INITIALIZER(
15404 struct cmd_set_port_tm_hierarchy_default_result,
15407 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15408 __rte_unused struct cmdline *cl,
15409 __rte_unused void *data)
15411 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15412 struct rte_port *p;
15413 portid_t port_id = res->port_id;
15415 if (port_id_is_invalid(port_id, ENABLED_WARN))
15418 p = &ports[port_id];
15420 /* Forward mode: tm */
15421 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15422 printf(" softnicfwd mode not enabled(error)\n");
15426 /* Set the default tm hierarchy */
15427 p->softport.default_tm_hierarchy_enable = 1;
15430 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15431 .f = cmd_set_port_tm_hierarchy_default_parsed,
15433 .help_str = "set port tm hierarchy default <port_id>",
15435 (void *)&cmd_set_port_tm_hierarchy_default_set,
15436 (void *)&cmd_set_port_tm_hierarchy_default_port,
15437 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15438 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15439 (void *)&cmd_set_port_tm_hierarchy_default_default,
15440 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15446 /** Set VXLAN encapsulation details */
15447 struct cmd_set_vxlan_result {
15448 cmdline_fixed_string_t set;
15449 cmdline_fixed_string_t vxlan;
15450 cmdline_fixed_string_t pos_token;
15451 cmdline_fixed_string_t ip_version;
15452 uint32_t vlan_present:1;
15456 cmdline_ipaddr_t ip_src;
15457 cmdline_ipaddr_t ip_dst;
15461 struct rte_ether_addr eth_src;
15462 struct rte_ether_addr eth_dst;
15465 cmdline_parse_token_string_t cmd_set_vxlan_set =
15466 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15467 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15468 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15469 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15470 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15472 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15473 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15474 "vxlan-with-vlan");
15475 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15476 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15478 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15479 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15481 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15482 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15484 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15485 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15486 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15487 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15489 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15490 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15491 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15492 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15494 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15495 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15496 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15497 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15499 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15500 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15501 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15502 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15504 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15505 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15506 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15507 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15509 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15510 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15511 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15512 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15514 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15515 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15516 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15517 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15519 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15520 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15521 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15522 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15524 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15525 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15526 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15527 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15529 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15530 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15532 static void cmd_set_vxlan_parsed(void *parsed_result,
15533 __rte_unused struct cmdline *cl,
15534 __rte_unused void *data)
15536 struct cmd_set_vxlan_result *res = parsed_result;
15541 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15544 vxlan_encap_conf.select_tos_ttl = 0;
15545 if (strcmp(res->vxlan, "vxlan") == 0)
15546 vxlan_encap_conf.select_vlan = 0;
15547 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15548 vxlan_encap_conf.select_vlan = 1;
15549 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15550 vxlan_encap_conf.select_vlan = 0;
15551 vxlan_encap_conf.select_tos_ttl = 1;
15553 if (strcmp(res->ip_version, "ipv4") == 0)
15554 vxlan_encap_conf.select_ipv4 = 1;
15555 else if (strcmp(res->ip_version, "ipv6") == 0)
15556 vxlan_encap_conf.select_ipv4 = 0;
15559 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15560 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15561 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15562 vxlan_encap_conf.ip_tos = res->tos;
15563 vxlan_encap_conf.ip_ttl = res->ttl;
15564 if (vxlan_encap_conf.select_ipv4) {
15565 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15566 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15568 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15569 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15571 if (vxlan_encap_conf.select_vlan)
15572 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15573 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15574 RTE_ETHER_ADDR_LEN);
15575 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15576 RTE_ETHER_ADDR_LEN);
15579 cmdline_parse_inst_t cmd_set_vxlan = {
15580 .f = cmd_set_vxlan_parsed,
15582 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15583 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15584 " eth-src <eth-src> eth-dst <eth-dst>",
15586 (void *)&cmd_set_vxlan_set,
15587 (void *)&cmd_set_vxlan_vxlan,
15588 (void *)&cmd_set_vxlan_ip_version,
15589 (void *)&cmd_set_vxlan_ip_version_value,
15590 (void *)&cmd_set_vxlan_vni,
15591 (void *)&cmd_set_vxlan_vni_value,
15592 (void *)&cmd_set_vxlan_udp_src,
15593 (void *)&cmd_set_vxlan_udp_src_value,
15594 (void *)&cmd_set_vxlan_udp_dst,
15595 (void *)&cmd_set_vxlan_udp_dst_value,
15596 (void *)&cmd_set_vxlan_ip_src,
15597 (void *)&cmd_set_vxlan_ip_src_value,
15598 (void *)&cmd_set_vxlan_ip_dst,
15599 (void *)&cmd_set_vxlan_ip_dst_value,
15600 (void *)&cmd_set_vxlan_eth_src,
15601 (void *)&cmd_set_vxlan_eth_src_value,
15602 (void *)&cmd_set_vxlan_eth_dst,
15603 (void *)&cmd_set_vxlan_eth_dst_value,
15608 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15609 .f = cmd_set_vxlan_parsed,
15611 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15612 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15613 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15614 " eth-dst <eth-dst>",
15616 (void *)&cmd_set_vxlan_set,
15617 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15618 (void *)&cmd_set_vxlan_ip_version,
15619 (void *)&cmd_set_vxlan_ip_version_value,
15620 (void *)&cmd_set_vxlan_vni,
15621 (void *)&cmd_set_vxlan_vni_value,
15622 (void *)&cmd_set_vxlan_udp_src,
15623 (void *)&cmd_set_vxlan_udp_src_value,
15624 (void *)&cmd_set_vxlan_udp_dst,
15625 (void *)&cmd_set_vxlan_udp_dst_value,
15626 (void *)&cmd_set_vxlan_ip_tos,
15627 (void *)&cmd_set_vxlan_ip_tos_value,
15628 (void *)&cmd_set_vxlan_ip_ttl,
15629 (void *)&cmd_set_vxlan_ip_ttl_value,
15630 (void *)&cmd_set_vxlan_ip_src,
15631 (void *)&cmd_set_vxlan_ip_src_value,
15632 (void *)&cmd_set_vxlan_ip_dst,
15633 (void *)&cmd_set_vxlan_ip_dst_value,
15634 (void *)&cmd_set_vxlan_eth_src,
15635 (void *)&cmd_set_vxlan_eth_src_value,
15636 (void *)&cmd_set_vxlan_eth_dst,
15637 (void *)&cmd_set_vxlan_eth_dst_value,
15642 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15643 .f = cmd_set_vxlan_parsed,
15645 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15646 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15647 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15650 (void *)&cmd_set_vxlan_set,
15651 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15652 (void *)&cmd_set_vxlan_ip_version,
15653 (void *)&cmd_set_vxlan_ip_version_value,
15654 (void *)&cmd_set_vxlan_vni,
15655 (void *)&cmd_set_vxlan_vni_value,
15656 (void *)&cmd_set_vxlan_udp_src,
15657 (void *)&cmd_set_vxlan_udp_src_value,
15658 (void *)&cmd_set_vxlan_udp_dst,
15659 (void *)&cmd_set_vxlan_udp_dst_value,
15660 (void *)&cmd_set_vxlan_ip_src,
15661 (void *)&cmd_set_vxlan_ip_src_value,
15662 (void *)&cmd_set_vxlan_ip_dst,
15663 (void *)&cmd_set_vxlan_ip_dst_value,
15664 (void *)&cmd_set_vxlan_vlan,
15665 (void *)&cmd_set_vxlan_vlan_value,
15666 (void *)&cmd_set_vxlan_eth_src,
15667 (void *)&cmd_set_vxlan_eth_src_value,
15668 (void *)&cmd_set_vxlan_eth_dst,
15669 (void *)&cmd_set_vxlan_eth_dst_value,
15674 /** Set NVGRE encapsulation details */
15675 struct cmd_set_nvgre_result {
15676 cmdline_fixed_string_t set;
15677 cmdline_fixed_string_t nvgre;
15678 cmdline_fixed_string_t pos_token;
15679 cmdline_fixed_string_t ip_version;
15681 cmdline_ipaddr_t ip_src;
15682 cmdline_ipaddr_t ip_dst;
15684 struct rte_ether_addr eth_src;
15685 struct rte_ether_addr eth_dst;
15688 cmdline_parse_token_string_t cmd_set_nvgre_set =
15689 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15690 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15691 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15692 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15693 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15694 "nvgre-with-vlan");
15695 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15696 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15698 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15699 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15701 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15702 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15704 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15705 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15706 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15707 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15709 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15710 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15711 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15712 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15714 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15715 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15716 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15717 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15719 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15720 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15721 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15722 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15724 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15725 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15726 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15727 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15729 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15730 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15732 static void cmd_set_nvgre_parsed(void *parsed_result,
15733 __rte_unused struct cmdline *cl,
15734 __rte_unused void *data)
15736 struct cmd_set_nvgre_result *res = parsed_result;
15738 uint32_t nvgre_tni;
15741 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15744 if (strcmp(res->nvgre, "nvgre") == 0)
15745 nvgre_encap_conf.select_vlan = 0;
15746 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15747 nvgre_encap_conf.select_vlan = 1;
15748 if (strcmp(res->ip_version, "ipv4") == 0)
15749 nvgre_encap_conf.select_ipv4 = 1;
15750 else if (strcmp(res->ip_version, "ipv6") == 0)
15751 nvgre_encap_conf.select_ipv4 = 0;
15754 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15755 if (nvgre_encap_conf.select_ipv4) {
15756 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15757 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15759 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15760 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15762 if (nvgre_encap_conf.select_vlan)
15763 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15764 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15765 RTE_ETHER_ADDR_LEN);
15766 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15767 RTE_ETHER_ADDR_LEN);
15770 cmdline_parse_inst_t cmd_set_nvgre = {
15771 .f = cmd_set_nvgre_parsed,
15773 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15774 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15775 " eth-dst <eth-dst>",
15777 (void *)&cmd_set_nvgre_set,
15778 (void *)&cmd_set_nvgre_nvgre,
15779 (void *)&cmd_set_nvgre_ip_version,
15780 (void *)&cmd_set_nvgre_ip_version_value,
15781 (void *)&cmd_set_nvgre_tni,
15782 (void *)&cmd_set_nvgre_tni_value,
15783 (void *)&cmd_set_nvgre_ip_src,
15784 (void *)&cmd_set_nvgre_ip_src_value,
15785 (void *)&cmd_set_nvgre_ip_dst,
15786 (void *)&cmd_set_nvgre_ip_dst_value,
15787 (void *)&cmd_set_nvgre_eth_src,
15788 (void *)&cmd_set_nvgre_eth_src_value,
15789 (void *)&cmd_set_nvgre_eth_dst,
15790 (void *)&cmd_set_nvgre_eth_dst_value,
15795 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15796 .f = cmd_set_nvgre_parsed,
15798 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15799 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15800 " eth-src <eth-src> eth-dst <eth-dst>",
15802 (void *)&cmd_set_nvgre_set,
15803 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15804 (void *)&cmd_set_nvgre_ip_version,
15805 (void *)&cmd_set_nvgre_ip_version_value,
15806 (void *)&cmd_set_nvgre_tni,
15807 (void *)&cmd_set_nvgre_tni_value,
15808 (void *)&cmd_set_nvgre_ip_src,
15809 (void *)&cmd_set_nvgre_ip_src_value,
15810 (void *)&cmd_set_nvgre_ip_dst,
15811 (void *)&cmd_set_nvgre_ip_dst_value,
15812 (void *)&cmd_set_nvgre_vlan,
15813 (void *)&cmd_set_nvgre_vlan_value,
15814 (void *)&cmd_set_nvgre_eth_src,
15815 (void *)&cmd_set_nvgre_eth_src_value,
15816 (void *)&cmd_set_nvgre_eth_dst,
15817 (void *)&cmd_set_nvgre_eth_dst_value,
15822 /** Set L2 encapsulation details */
15823 struct cmd_set_l2_encap_result {
15824 cmdline_fixed_string_t set;
15825 cmdline_fixed_string_t l2_encap;
15826 cmdline_fixed_string_t pos_token;
15827 cmdline_fixed_string_t ip_version;
15828 uint32_t vlan_present:1;
15830 struct rte_ether_addr eth_src;
15831 struct rte_ether_addr eth_dst;
15834 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15835 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15836 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15837 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15838 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15839 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15840 "l2_encap-with-vlan");
15841 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15842 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15844 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15845 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15847 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15848 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15850 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15851 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15852 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15853 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15855 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15856 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15857 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15858 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15860 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15861 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15863 static void cmd_set_l2_encap_parsed(void *parsed_result,
15864 __rte_unused struct cmdline *cl,
15865 __rte_unused void *data)
15867 struct cmd_set_l2_encap_result *res = parsed_result;
15869 if (strcmp(res->l2_encap, "l2_encap") == 0)
15870 l2_encap_conf.select_vlan = 0;
15871 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15872 l2_encap_conf.select_vlan = 1;
15873 if (strcmp(res->ip_version, "ipv4") == 0)
15874 l2_encap_conf.select_ipv4 = 1;
15875 else if (strcmp(res->ip_version, "ipv6") == 0)
15876 l2_encap_conf.select_ipv4 = 0;
15879 if (l2_encap_conf.select_vlan)
15880 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15881 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15882 RTE_ETHER_ADDR_LEN);
15883 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15884 RTE_ETHER_ADDR_LEN);
15887 cmdline_parse_inst_t cmd_set_l2_encap = {
15888 .f = cmd_set_l2_encap_parsed,
15890 .help_str = "set l2_encap ip-version ipv4|ipv6"
15891 " eth-src <eth-src> eth-dst <eth-dst>",
15893 (void *)&cmd_set_l2_encap_set,
15894 (void *)&cmd_set_l2_encap_l2_encap,
15895 (void *)&cmd_set_l2_encap_ip_version,
15896 (void *)&cmd_set_l2_encap_ip_version_value,
15897 (void *)&cmd_set_l2_encap_eth_src,
15898 (void *)&cmd_set_l2_encap_eth_src_value,
15899 (void *)&cmd_set_l2_encap_eth_dst,
15900 (void *)&cmd_set_l2_encap_eth_dst_value,
15905 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15906 .f = cmd_set_l2_encap_parsed,
15908 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15909 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15911 (void *)&cmd_set_l2_encap_set,
15912 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15913 (void *)&cmd_set_l2_encap_ip_version,
15914 (void *)&cmd_set_l2_encap_ip_version_value,
15915 (void *)&cmd_set_l2_encap_vlan,
15916 (void *)&cmd_set_l2_encap_vlan_value,
15917 (void *)&cmd_set_l2_encap_eth_src,
15918 (void *)&cmd_set_l2_encap_eth_src_value,
15919 (void *)&cmd_set_l2_encap_eth_dst,
15920 (void *)&cmd_set_l2_encap_eth_dst_value,
15925 /** Set L2 decapsulation details */
15926 struct cmd_set_l2_decap_result {
15927 cmdline_fixed_string_t set;
15928 cmdline_fixed_string_t l2_decap;
15929 cmdline_fixed_string_t pos_token;
15930 uint32_t vlan_present:1;
15933 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15934 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15935 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15936 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15938 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15939 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15940 "l2_decap-with-vlan");
15942 static void cmd_set_l2_decap_parsed(void *parsed_result,
15943 __rte_unused struct cmdline *cl,
15944 __rte_unused void *data)
15946 struct cmd_set_l2_decap_result *res = parsed_result;
15948 if (strcmp(res->l2_decap, "l2_decap") == 0)
15949 l2_decap_conf.select_vlan = 0;
15950 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15951 l2_decap_conf.select_vlan = 1;
15954 cmdline_parse_inst_t cmd_set_l2_decap = {
15955 .f = cmd_set_l2_decap_parsed,
15957 .help_str = "set l2_decap",
15959 (void *)&cmd_set_l2_decap_set,
15960 (void *)&cmd_set_l2_decap_l2_decap,
15965 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15966 .f = cmd_set_l2_decap_parsed,
15968 .help_str = "set l2_decap-with-vlan",
15970 (void *)&cmd_set_l2_decap_set,
15971 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15976 /** Set MPLSoGRE encapsulation details */
15977 struct cmd_set_mplsogre_encap_result {
15978 cmdline_fixed_string_t set;
15979 cmdline_fixed_string_t mplsogre;
15980 cmdline_fixed_string_t pos_token;
15981 cmdline_fixed_string_t ip_version;
15982 uint32_t vlan_present:1;
15984 cmdline_ipaddr_t ip_src;
15985 cmdline_ipaddr_t ip_dst;
15987 struct rte_ether_addr eth_src;
15988 struct rte_ether_addr eth_dst;
15991 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15992 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15994 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15995 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15997 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15998 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15999 mplsogre, "mplsogre_encap-with-vlan");
16000 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
16001 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16002 pos_token, "ip-version");
16003 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
16004 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16005 ip_version, "ipv4#ipv6");
16006 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
16007 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16008 pos_token, "label");
16009 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
16010 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
16012 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
16013 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16014 pos_token, "ip-src");
16015 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16016 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16017 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16018 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16019 pos_token, "ip-dst");
16020 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16021 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16022 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16023 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16024 pos_token, "vlan-tci");
16025 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16026 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16028 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16029 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16030 pos_token, "eth-src");
16031 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16032 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16034 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16035 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16036 pos_token, "eth-dst");
16037 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16038 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16041 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16042 __rte_unused struct cmdline *cl,
16043 __rte_unused void *data)
16045 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16047 uint32_t mplsogre_label;
16050 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16053 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16054 mplsogre_encap_conf.select_vlan = 0;
16055 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16056 mplsogre_encap_conf.select_vlan = 1;
16057 if (strcmp(res->ip_version, "ipv4") == 0)
16058 mplsogre_encap_conf.select_ipv4 = 1;
16059 else if (strcmp(res->ip_version, "ipv6") == 0)
16060 mplsogre_encap_conf.select_ipv4 = 0;
16063 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16064 if (mplsogre_encap_conf.select_ipv4) {
16065 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16066 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16068 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16069 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16071 if (mplsogre_encap_conf.select_vlan)
16072 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16073 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16074 RTE_ETHER_ADDR_LEN);
16075 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16076 RTE_ETHER_ADDR_LEN);
16079 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16080 .f = cmd_set_mplsogre_encap_parsed,
16082 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16083 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16084 " eth-dst <eth-dst>",
16086 (void *)&cmd_set_mplsogre_encap_set,
16087 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16088 (void *)&cmd_set_mplsogre_encap_ip_version,
16089 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16090 (void *)&cmd_set_mplsogre_encap_label,
16091 (void *)&cmd_set_mplsogre_encap_label_value,
16092 (void *)&cmd_set_mplsogre_encap_ip_src,
16093 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16094 (void *)&cmd_set_mplsogre_encap_ip_dst,
16095 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16096 (void *)&cmd_set_mplsogre_encap_eth_src,
16097 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16098 (void *)&cmd_set_mplsogre_encap_eth_dst,
16099 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16104 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16105 .f = cmd_set_mplsogre_encap_parsed,
16107 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16108 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16109 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16111 (void *)&cmd_set_mplsogre_encap_set,
16112 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16113 (void *)&cmd_set_mplsogre_encap_ip_version,
16114 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16115 (void *)&cmd_set_mplsogre_encap_label,
16116 (void *)&cmd_set_mplsogre_encap_label_value,
16117 (void *)&cmd_set_mplsogre_encap_ip_src,
16118 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16119 (void *)&cmd_set_mplsogre_encap_ip_dst,
16120 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16121 (void *)&cmd_set_mplsogre_encap_vlan,
16122 (void *)&cmd_set_mplsogre_encap_vlan_value,
16123 (void *)&cmd_set_mplsogre_encap_eth_src,
16124 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16125 (void *)&cmd_set_mplsogre_encap_eth_dst,
16126 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16131 /** Set MPLSoGRE decapsulation details */
16132 struct cmd_set_mplsogre_decap_result {
16133 cmdline_fixed_string_t set;
16134 cmdline_fixed_string_t mplsogre;
16135 cmdline_fixed_string_t pos_token;
16136 cmdline_fixed_string_t ip_version;
16137 uint32_t vlan_present:1;
16140 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16141 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16143 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16144 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16146 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16147 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16148 mplsogre, "mplsogre_decap-with-vlan");
16149 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16150 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16151 pos_token, "ip-version");
16152 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16153 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16154 ip_version, "ipv4#ipv6");
16156 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16157 __rte_unused struct cmdline *cl,
16158 __rte_unused void *data)
16160 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16162 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16163 mplsogre_decap_conf.select_vlan = 0;
16164 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16165 mplsogre_decap_conf.select_vlan = 1;
16166 if (strcmp(res->ip_version, "ipv4") == 0)
16167 mplsogre_decap_conf.select_ipv4 = 1;
16168 else if (strcmp(res->ip_version, "ipv6") == 0)
16169 mplsogre_decap_conf.select_ipv4 = 0;
16172 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16173 .f = cmd_set_mplsogre_decap_parsed,
16175 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16177 (void *)&cmd_set_mplsogre_decap_set,
16178 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16179 (void *)&cmd_set_mplsogre_decap_ip_version,
16180 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16185 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16186 .f = cmd_set_mplsogre_decap_parsed,
16188 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16190 (void *)&cmd_set_mplsogre_decap_set,
16191 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16192 (void *)&cmd_set_mplsogre_decap_ip_version,
16193 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16198 /** Set MPLSoUDP encapsulation details */
16199 struct cmd_set_mplsoudp_encap_result {
16200 cmdline_fixed_string_t set;
16201 cmdline_fixed_string_t mplsoudp;
16202 cmdline_fixed_string_t pos_token;
16203 cmdline_fixed_string_t ip_version;
16204 uint32_t vlan_present:1;
16208 cmdline_ipaddr_t ip_src;
16209 cmdline_ipaddr_t ip_dst;
16211 struct rte_ether_addr eth_src;
16212 struct rte_ether_addr eth_dst;
16215 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16216 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16218 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16219 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16221 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16222 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16223 mplsoudp, "mplsoudp_encap-with-vlan");
16224 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16225 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16226 pos_token, "ip-version");
16227 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16228 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16229 ip_version, "ipv4#ipv6");
16230 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16231 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16232 pos_token, "label");
16233 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16234 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16236 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16237 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16238 pos_token, "udp-src");
16239 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16240 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16242 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16243 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16244 pos_token, "udp-dst");
16245 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16246 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16248 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16249 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16250 pos_token, "ip-src");
16251 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16252 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16253 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16254 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16255 pos_token, "ip-dst");
16256 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16257 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16258 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16259 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16260 pos_token, "vlan-tci");
16261 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16262 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16264 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16265 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16266 pos_token, "eth-src");
16267 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16268 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16270 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16271 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16272 pos_token, "eth-dst");
16273 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16274 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16277 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16278 __rte_unused struct cmdline *cl,
16279 __rte_unused void *data)
16281 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16283 uint32_t mplsoudp_label;
16286 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16289 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16290 mplsoudp_encap_conf.select_vlan = 0;
16291 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16292 mplsoudp_encap_conf.select_vlan = 1;
16293 if (strcmp(res->ip_version, "ipv4") == 0)
16294 mplsoudp_encap_conf.select_ipv4 = 1;
16295 else if (strcmp(res->ip_version, "ipv6") == 0)
16296 mplsoudp_encap_conf.select_ipv4 = 0;
16299 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16300 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16301 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16302 if (mplsoudp_encap_conf.select_ipv4) {
16303 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16304 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16306 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16307 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16309 if (mplsoudp_encap_conf.select_vlan)
16310 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16311 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16312 RTE_ETHER_ADDR_LEN);
16313 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16314 RTE_ETHER_ADDR_LEN);
16317 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16318 .f = cmd_set_mplsoudp_encap_parsed,
16320 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16321 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16322 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16324 (void *)&cmd_set_mplsoudp_encap_set,
16325 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16326 (void *)&cmd_set_mplsoudp_encap_ip_version,
16327 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16328 (void *)&cmd_set_mplsoudp_encap_label,
16329 (void *)&cmd_set_mplsoudp_encap_label_value,
16330 (void *)&cmd_set_mplsoudp_encap_udp_src,
16331 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16332 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16333 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16334 (void *)&cmd_set_mplsoudp_encap_ip_src,
16335 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16336 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16337 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16338 (void *)&cmd_set_mplsoudp_encap_eth_src,
16339 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16340 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16341 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16346 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16347 .f = cmd_set_mplsoudp_encap_parsed,
16349 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16350 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16351 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16352 " eth-src <eth-src> eth-dst <eth-dst>",
16354 (void *)&cmd_set_mplsoudp_encap_set,
16355 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16356 (void *)&cmd_set_mplsoudp_encap_ip_version,
16357 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16358 (void *)&cmd_set_mplsoudp_encap_label,
16359 (void *)&cmd_set_mplsoudp_encap_label_value,
16360 (void *)&cmd_set_mplsoudp_encap_udp_src,
16361 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16362 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16363 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16364 (void *)&cmd_set_mplsoudp_encap_ip_src,
16365 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16366 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16367 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16368 (void *)&cmd_set_mplsoudp_encap_vlan,
16369 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16370 (void *)&cmd_set_mplsoudp_encap_eth_src,
16371 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16372 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16373 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16378 /** Set MPLSoUDP decapsulation details */
16379 struct cmd_set_mplsoudp_decap_result {
16380 cmdline_fixed_string_t set;
16381 cmdline_fixed_string_t mplsoudp;
16382 cmdline_fixed_string_t pos_token;
16383 cmdline_fixed_string_t ip_version;
16384 uint32_t vlan_present:1;
16387 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16388 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16390 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16391 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16393 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16394 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16395 mplsoudp, "mplsoudp_decap-with-vlan");
16396 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16397 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16398 pos_token, "ip-version");
16399 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16400 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16401 ip_version, "ipv4#ipv6");
16403 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16404 __rte_unused struct cmdline *cl,
16405 __rte_unused void *data)
16407 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16409 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16410 mplsoudp_decap_conf.select_vlan = 0;
16411 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16412 mplsoudp_decap_conf.select_vlan = 1;
16413 if (strcmp(res->ip_version, "ipv4") == 0)
16414 mplsoudp_decap_conf.select_ipv4 = 1;
16415 else if (strcmp(res->ip_version, "ipv6") == 0)
16416 mplsoudp_decap_conf.select_ipv4 = 0;
16419 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16420 .f = cmd_set_mplsoudp_decap_parsed,
16422 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16424 (void *)&cmd_set_mplsoudp_decap_set,
16425 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16426 (void *)&cmd_set_mplsoudp_decap_ip_version,
16427 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16432 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16433 .f = cmd_set_mplsoudp_decap_parsed,
16435 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16437 (void *)&cmd_set_mplsoudp_decap_set,
16438 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16439 (void *)&cmd_set_mplsoudp_decap_ip_version,
16440 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16445 /* Strict link priority scheduling mode setting */
16447 cmd_strict_link_prio_parsed(
16448 void *parsed_result,
16449 __rte_unused struct cmdline *cl,
16450 __rte_unused void *data)
16452 struct cmd_vf_tc_bw_result *res = parsed_result;
16453 int ret = -ENOTSUP;
16455 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16458 #ifdef RTE_LIBRTE_I40E_PMD
16459 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16466 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16469 printf("invalid port_id %d\n", res->port_id);
16472 printf("function not implemented\n");
16475 printf("programming error: (%s)\n", strerror(-ret));
16479 cmdline_parse_inst_t cmd_strict_link_prio = {
16480 .f = cmd_strict_link_prio_parsed,
16482 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16484 (void *)&cmd_vf_tc_bw_set,
16485 (void *)&cmd_vf_tc_bw_tx,
16486 (void *)&cmd_vf_tc_bw_strict_link_prio,
16487 (void *)&cmd_vf_tc_bw_port_id,
16488 (void *)&cmd_vf_tc_bw_tc_map,
16493 /* Load dynamic device personalization*/
16494 struct cmd_ddp_add_result {
16495 cmdline_fixed_string_t ddp;
16496 cmdline_fixed_string_t add;
16501 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16502 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16503 cmdline_parse_token_string_t cmd_ddp_add_add =
16504 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16505 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16506 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16507 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16508 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16511 cmd_ddp_add_parsed(
16512 void *parsed_result,
16513 __rte_unused struct cmdline *cl,
16514 __rte_unused void *data)
16516 struct cmd_ddp_add_result *res = parsed_result;
16522 int ret = -ENOTSUP;
16524 if (!all_ports_stopped()) {
16525 printf("Please stop all ports first\n");
16529 filepath = strdup(res->filepath);
16530 if (filepath == NULL) {
16531 printf("Failed to allocate memory\n");
16534 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16536 buff = open_file(file_fld[0], &size);
16538 free((void *)filepath);
16542 #ifdef RTE_LIBRTE_I40E_PMD
16543 if (ret == -ENOTSUP)
16544 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16546 RTE_PMD_I40E_PKG_OP_WR_ADD);
16549 if (ret == -EEXIST)
16550 printf("Profile has already existed.\n");
16552 printf("Failed to load profile.\n");
16553 else if (file_num == 2)
16554 save_file(file_fld[1], buff, size);
16557 free((void *)filepath);
16560 cmdline_parse_inst_t cmd_ddp_add = {
16561 .f = cmd_ddp_add_parsed,
16563 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16565 (void *)&cmd_ddp_add_ddp,
16566 (void *)&cmd_ddp_add_add,
16567 (void *)&cmd_ddp_add_port_id,
16568 (void *)&cmd_ddp_add_filepath,
16573 /* Delete dynamic device personalization*/
16574 struct cmd_ddp_del_result {
16575 cmdline_fixed_string_t ddp;
16576 cmdline_fixed_string_t del;
16581 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16582 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16583 cmdline_parse_token_string_t cmd_ddp_del_del =
16584 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16585 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16586 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16587 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16588 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16591 cmd_ddp_del_parsed(
16592 void *parsed_result,
16593 __rte_unused struct cmdline *cl,
16594 __rte_unused void *data)
16596 struct cmd_ddp_del_result *res = parsed_result;
16599 int ret = -ENOTSUP;
16601 if (!all_ports_stopped()) {
16602 printf("Please stop all ports first\n");
16606 buff = open_file(res->filepath, &size);
16610 #ifdef RTE_LIBRTE_I40E_PMD
16611 if (ret == -ENOTSUP)
16612 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16614 RTE_PMD_I40E_PKG_OP_WR_DEL);
16617 if (ret == -EACCES)
16618 printf("Profile does not exist.\n");
16620 printf("Failed to delete profile.\n");
16625 cmdline_parse_inst_t cmd_ddp_del = {
16626 .f = cmd_ddp_del_parsed,
16628 .help_str = "ddp del <port_id> <backup_profile_path>",
16630 (void *)&cmd_ddp_del_ddp,
16631 (void *)&cmd_ddp_del_del,
16632 (void *)&cmd_ddp_del_port_id,
16633 (void *)&cmd_ddp_del_filepath,
16638 /* Get dynamic device personalization profile info */
16639 struct cmd_ddp_info_result {
16640 cmdline_fixed_string_t ddp;
16641 cmdline_fixed_string_t get;
16642 cmdline_fixed_string_t info;
16646 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16647 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16648 cmdline_parse_token_string_t cmd_ddp_info_get =
16649 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16650 cmdline_parse_token_string_t cmd_ddp_info_info =
16651 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16652 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16653 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16656 cmd_ddp_info_parsed(
16657 void *parsed_result,
16658 __rte_unused struct cmdline *cl,
16659 __rte_unused void *data)
16661 struct cmd_ddp_info_result *res = parsed_result;
16664 int ret = -ENOTSUP;
16665 #ifdef RTE_LIBRTE_I40E_PMD
16668 uint32_t buff_size = 0;
16669 struct rte_pmd_i40e_profile_info info;
16670 uint32_t dev_num = 0;
16671 struct rte_pmd_i40e_ddp_device_id *devs;
16672 uint32_t proto_num = 0;
16673 struct rte_pmd_i40e_proto_info *proto = NULL;
16674 uint32_t pctype_num = 0;
16675 struct rte_pmd_i40e_ptype_info *pctype;
16676 uint32_t ptype_num = 0;
16677 struct rte_pmd_i40e_ptype_info *ptype;
16682 pkg = open_file(res->filepath, &pkg_size);
16686 #ifdef RTE_LIBRTE_I40E_PMD
16687 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16688 (uint8_t *)&info, sizeof(info),
16689 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16691 printf("Global Track id: 0x%x\n", info.track_id);
16692 printf("Global Version: %d.%d.%d.%d\n",
16693 info.version.major,
16694 info.version.minor,
16695 info.version.update,
16696 info.version.draft);
16697 printf("Global Package name: %s\n\n", info.name);
16700 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16701 (uint8_t *)&info, sizeof(info),
16702 RTE_PMD_I40E_PKG_INFO_HEADER);
16704 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16705 printf("i40e Profile Version: %d.%d.%d.%d\n",
16706 info.version.major,
16707 info.version.minor,
16708 info.version.update,
16709 info.version.draft);
16710 printf("i40e Profile name: %s\n\n", info.name);
16713 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16714 (uint8_t *)&buff_size, sizeof(buff_size),
16715 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16716 if (!ret && buff_size) {
16717 buff = (uint8_t *)malloc(buff_size);
16719 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16721 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16723 printf("Package Notes:\n%s\n\n", buff);
16728 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16729 (uint8_t *)&dev_num, sizeof(dev_num),
16730 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16731 if (!ret && dev_num) {
16732 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16733 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16735 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16736 (uint8_t *)devs, buff_size,
16737 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16739 printf("List of supported devices:\n");
16740 for (i = 0; i < dev_num; i++) {
16741 printf(" %04X:%04X %04X:%04X\n",
16742 devs[i].vendor_dev_id >> 16,
16743 devs[i].vendor_dev_id & 0xFFFF,
16744 devs[i].sub_vendor_dev_id >> 16,
16745 devs[i].sub_vendor_dev_id & 0xFFFF);
16753 /* get information about protocols and packet types */
16754 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16755 (uint8_t *)&proto_num, sizeof(proto_num),
16756 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16757 if (ret || !proto_num)
16758 goto no_print_return;
16760 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16761 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16763 goto no_print_return;
16765 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16767 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16769 printf("List of used protocols:\n");
16770 for (i = 0; i < proto_num; i++)
16771 printf(" %2u: %s\n", proto[i].proto_id,
16775 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16776 (uint8_t *)&pctype_num, sizeof(pctype_num),
16777 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16778 if (ret || !pctype_num)
16779 goto no_print_pctypes;
16781 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16782 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16784 goto no_print_pctypes;
16786 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16788 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16791 goto no_print_pctypes;
16794 printf("List of defined packet classification types:\n");
16795 for (i = 0; i < pctype_num; i++) {
16796 printf(" %2u:", pctype[i].ptype_id);
16797 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16798 proto_id = pctype[i].protocols[j];
16799 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16800 for (n = 0; n < proto_num; n++) {
16801 if (proto[n].proto_id == proto_id) {
16802 printf(" %s", proto[n].name);
16815 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16817 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16818 if (ret || !ptype_num)
16819 goto no_print_return;
16821 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16822 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16824 goto no_print_return;
16826 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16828 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16831 goto no_print_return;
16833 printf("List of defined packet types:\n");
16834 for (i = 0; i < ptype_num; i++) {
16835 printf(" %2u:", ptype[i].ptype_id);
16836 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16837 proto_id = ptype[i].protocols[j];
16838 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16839 for (n = 0; n < proto_num; n++) {
16840 if (proto[n].proto_id == proto_id) {
16841 printf(" %s", proto[n].name);
16857 if (ret == -ENOTSUP)
16858 printf("Function not supported in PMD driver\n");
16862 cmdline_parse_inst_t cmd_ddp_get_info = {
16863 .f = cmd_ddp_info_parsed,
16865 .help_str = "ddp get info <profile_path>",
16867 (void *)&cmd_ddp_info_ddp,
16868 (void *)&cmd_ddp_info_get,
16869 (void *)&cmd_ddp_info_info,
16870 (void *)&cmd_ddp_info_filepath,
16875 /* Get dynamic device personalization profile info list*/
16876 #define PROFILE_INFO_SIZE 48
16877 #define MAX_PROFILE_NUM 16
16879 struct cmd_ddp_get_list_result {
16880 cmdline_fixed_string_t ddp;
16881 cmdline_fixed_string_t get;
16882 cmdline_fixed_string_t list;
16886 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16887 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16888 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16889 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16890 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16891 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16892 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16893 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16896 cmd_ddp_get_list_parsed(
16897 __rte_unused void *parsed_result,
16898 __rte_unused struct cmdline *cl,
16899 __rte_unused void *data)
16901 #ifdef RTE_LIBRTE_I40E_PMD
16902 struct cmd_ddp_get_list_result *res = parsed_result;
16903 struct rte_pmd_i40e_profile_list *p_list;
16904 struct rte_pmd_i40e_profile_info *p_info;
16909 int ret = -ENOTSUP;
16911 #ifdef RTE_LIBRTE_I40E_PMD
16912 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16913 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16915 printf("%s: Failed to malloc buffer\n", __func__);
16919 if (ret == -ENOTSUP)
16920 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16921 (uint8_t *)p_list, size);
16924 p_num = p_list->p_count;
16925 printf("Profile number is: %d\n\n", p_num);
16927 for (i = 0; i < p_num; i++) {
16928 p_info = &p_list->p_info[i];
16929 printf("Profile %d:\n", i);
16930 printf("Track id: 0x%x\n", p_info->track_id);
16931 printf("Version: %d.%d.%d.%d\n",
16932 p_info->version.major,
16933 p_info->version.minor,
16934 p_info->version.update,
16935 p_info->version.draft);
16936 printf("Profile name: %s\n\n", p_info->name);
16944 printf("Failed to get ddp list\n");
16947 cmdline_parse_inst_t cmd_ddp_get_list = {
16948 .f = cmd_ddp_get_list_parsed,
16950 .help_str = "ddp get list <port_id>",
16952 (void *)&cmd_ddp_get_list_ddp,
16953 (void *)&cmd_ddp_get_list_get,
16954 (void *)&cmd_ddp_get_list_list,
16955 (void *)&cmd_ddp_get_list_port_id,
16960 /* Configure input set */
16961 struct cmd_cfg_input_set_result {
16962 cmdline_fixed_string_t port;
16963 cmdline_fixed_string_t cfg;
16965 cmdline_fixed_string_t pctype;
16967 cmdline_fixed_string_t inset_type;
16968 cmdline_fixed_string_t opt;
16969 cmdline_fixed_string_t field;
16974 cmd_cfg_input_set_parsed(
16975 __rte_unused void *parsed_result,
16976 __rte_unused struct cmdline *cl,
16977 __rte_unused void *data)
16979 #ifdef RTE_LIBRTE_I40E_PMD
16980 struct cmd_cfg_input_set_result *res = parsed_result;
16981 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16982 struct rte_pmd_i40e_inset inset;
16984 int ret = -ENOTSUP;
16986 if (!all_ports_stopped()) {
16987 printf("Please stop all ports first\n");
16991 #ifdef RTE_LIBRTE_I40E_PMD
16992 if (!strcmp(res->inset_type, "hash_inset"))
16993 inset_type = INSET_HASH;
16994 else if (!strcmp(res->inset_type, "fdir_inset"))
16995 inset_type = INSET_FDIR;
16996 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16997 inset_type = INSET_FDIR_FLX;
16998 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16999 &inset, inset_type);
17001 printf("Failed to get input set.\n");
17005 if (!strcmp(res->opt, "get")) {
17006 ret = rte_pmd_i40e_inset_field_get(inset.inset,
17009 printf("Field index %d is enabled.\n", res->field_idx);
17011 printf("Field index %d is disabled.\n", res->field_idx);
17013 } else if (!strcmp(res->opt, "set"))
17014 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17016 else if (!strcmp(res->opt, "clear"))
17017 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17020 printf("Failed to configure input set field.\n");
17024 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17025 &inset, inset_type);
17027 printf("Failed to set input set.\n");
17032 if (ret == -ENOTSUP)
17033 printf("Function not supported\n");
17036 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17037 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17039 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17040 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17042 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17043 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17045 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17046 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17048 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17049 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17051 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17052 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17054 "hash_inset#fdir_inset#fdir_flx_inset");
17055 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17056 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17057 opt, "get#set#clear");
17058 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17059 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17061 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17062 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17065 cmdline_parse_inst_t cmd_cfg_input_set = {
17066 .f = cmd_cfg_input_set_parsed,
17068 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17069 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17071 (void *)&cmd_cfg_input_set_port,
17072 (void *)&cmd_cfg_input_set_cfg,
17073 (void *)&cmd_cfg_input_set_port_id,
17074 (void *)&cmd_cfg_input_set_pctype,
17075 (void *)&cmd_cfg_input_set_pctype_id,
17076 (void *)&cmd_cfg_input_set_inset_type,
17077 (void *)&cmd_cfg_input_set_opt,
17078 (void *)&cmd_cfg_input_set_field,
17079 (void *)&cmd_cfg_input_set_field_idx,
17084 /* Clear input set */
17085 struct cmd_clear_input_set_result {
17086 cmdline_fixed_string_t port;
17087 cmdline_fixed_string_t cfg;
17089 cmdline_fixed_string_t pctype;
17091 cmdline_fixed_string_t inset_type;
17092 cmdline_fixed_string_t clear;
17093 cmdline_fixed_string_t all;
17097 cmd_clear_input_set_parsed(
17098 __rte_unused void *parsed_result,
17099 __rte_unused struct cmdline *cl,
17100 __rte_unused void *data)
17102 #ifdef RTE_LIBRTE_I40E_PMD
17103 struct cmd_clear_input_set_result *res = parsed_result;
17104 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17105 struct rte_pmd_i40e_inset inset;
17107 int ret = -ENOTSUP;
17109 if (!all_ports_stopped()) {
17110 printf("Please stop all ports first\n");
17114 #ifdef RTE_LIBRTE_I40E_PMD
17115 if (!strcmp(res->inset_type, "hash_inset"))
17116 inset_type = INSET_HASH;
17117 else if (!strcmp(res->inset_type, "fdir_inset"))
17118 inset_type = INSET_FDIR;
17119 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17120 inset_type = INSET_FDIR_FLX;
17122 memset(&inset, 0, sizeof(inset));
17124 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17125 &inset, inset_type);
17127 printf("Failed to clear input set.\n");
17133 if (ret == -ENOTSUP)
17134 printf("Function not supported\n");
17137 cmdline_parse_token_string_t cmd_clear_input_set_port =
17138 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17140 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17141 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17143 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17144 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17146 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17147 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17149 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17150 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17152 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17153 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17155 "hash_inset#fdir_inset#fdir_flx_inset");
17156 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17157 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17159 cmdline_parse_token_string_t cmd_clear_input_set_all =
17160 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17163 cmdline_parse_inst_t cmd_clear_input_set = {
17164 .f = cmd_clear_input_set_parsed,
17166 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17167 "fdir_inset|fdir_flx_inset clear all",
17169 (void *)&cmd_clear_input_set_port,
17170 (void *)&cmd_clear_input_set_cfg,
17171 (void *)&cmd_clear_input_set_port_id,
17172 (void *)&cmd_clear_input_set_pctype,
17173 (void *)&cmd_clear_input_set_pctype_id,
17174 (void *)&cmd_clear_input_set_inset_type,
17175 (void *)&cmd_clear_input_set_clear,
17176 (void *)&cmd_clear_input_set_all,
17181 /* show vf stats */
17183 /* Common result structure for show vf stats */
17184 struct cmd_show_vf_stats_result {
17185 cmdline_fixed_string_t show;
17186 cmdline_fixed_string_t vf;
17187 cmdline_fixed_string_t stats;
17192 /* Common CLI fields show vf stats*/
17193 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17194 TOKEN_STRING_INITIALIZER
17195 (struct cmd_show_vf_stats_result,
17197 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17198 TOKEN_STRING_INITIALIZER
17199 (struct cmd_show_vf_stats_result,
17201 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17202 TOKEN_STRING_INITIALIZER
17203 (struct cmd_show_vf_stats_result,
17205 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17206 TOKEN_NUM_INITIALIZER
17207 (struct cmd_show_vf_stats_result,
17209 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17210 TOKEN_NUM_INITIALIZER
17211 (struct cmd_show_vf_stats_result,
17215 cmd_show_vf_stats_parsed(
17216 void *parsed_result,
17217 __rte_unused struct cmdline *cl,
17218 __rte_unused void *data)
17220 struct cmd_show_vf_stats_result *res = parsed_result;
17221 struct rte_eth_stats stats;
17222 int ret = -ENOTSUP;
17223 static const char *nic_stats_border = "########################";
17225 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17228 memset(&stats, 0, sizeof(stats));
17230 #ifdef RTE_LIBRTE_I40E_PMD
17231 if (ret == -ENOTSUP)
17232 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17236 #ifdef RTE_LIBRTE_BNXT_PMD
17237 if (ret == -ENOTSUP)
17238 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17247 printf("invalid vf_id %d\n", res->vf_id);
17250 printf("invalid port_id %d\n", res->port_id);
17253 printf("function not implemented\n");
17256 printf("programming error: (%s)\n", strerror(-ret));
17259 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17260 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17262 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17264 stats.ipackets, stats.imissed, stats.ibytes);
17265 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17266 printf(" RX-nombuf: %-10"PRIu64"\n",
17268 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17270 stats.opackets, stats.oerrors, stats.obytes);
17272 printf(" %s############################%s\n",
17273 nic_stats_border, nic_stats_border);
17276 cmdline_parse_inst_t cmd_show_vf_stats = {
17277 .f = cmd_show_vf_stats_parsed,
17279 .help_str = "show vf stats <port_id> <vf_id>",
17281 (void *)&cmd_show_vf_stats_show,
17282 (void *)&cmd_show_vf_stats_vf,
17283 (void *)&cmd_show_vf_stats_stats,
17284 (void *)&cmd_show_vf_stats_port_id,
17285 (void *)&cmd_show_vf_stats_vf_id,
17290 /* clear vf stats */
17292 /* Common result structure for clear vf stats */
17293 struct cmd_clear_vf_stats_result {
17294 cmdline_fixed_string_t clear;
17295 cmdline_fixed_string_t vf;
17296 cmdline_fixed_string_t stats;
17301 /* Common CLI fields clear vf stats*/
17302 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17303 TOKEN_STRING_INITIALIZER
17304 (struct cmd_clear_vf_stats_result,
17306 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17307 TOKEN_STRING_INITIALIZER
17308 (struct cmd_clear_vf_stats_result,
17310 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17311 TOKEN_STRING_INITIALIZER
17312 (struct cmd_clear_vf_stats_result,
17314 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17315 TOKEN_NUM_INITIALIZER
17316 (struct cmd_clear_vf_stats_result,
17318 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17319 TOKEN_NUM_INITIALIZER
17320 (struct cmd_clear_vf_stats_result,
17324 cmd_clear_vf_stats_parsed(
17325 void *parsed_result,
17326 __rte_unused struct cmdline *cl,
17327 __rte_unused void *data)
17329 struct cmd_clear_vf_stats_result *res = parsed_result;
17330 int ret = -ENOTSUP;
17332 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17335 #ifdef RTE_LIBRTE_I40E_PMD
17336 if (ret == -ENOTSUP)
17337 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17340 #ifdef RTE_LIBRTE_BNXT_PMD
17341 if (ret == -ENOTSUP)
17342 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17350 printf("invalid vf_id %d\n", res->vf_id);
17353 printf("invalid port_id %d\n", res->port_id);
17356 printf("function not implemented\n");
17359 printf("programming error: (%s)\n", strerror(-ret));
17363 cmdline_parse_inst_t cmd_clear_vf_stats = {
17364 .f = cmd_clear_vf_stats_parsed,
17366 .help_str = "clear vf stats <port_id> <vf_id>",
17368 (void *)&cmd_clear_vf_stats_clear,
17369 (void *)&cmd_clear_vf_stats_vf,
17370 (void *)&cmd_clear_vf_stats_stats,
17371 (void *)&cmd_clear_vf_stats_port_id,
17372 (void *)&cmd_clear_vf_stats_vf_id,
17377 /* port config pctype mapping reset */
17379 /* Common result structure for port config pctype mapping reset */
17380 struct cmd_pctype_mapping_reset_result {
17381 cmdline_fixed_string_t port;
17382 cmdline_fixed_string_t config;
17384 cmdline_fixed_string_t pctype;
17385 cmdline_fixed_string_t mapping;
17386 cmdline_fixed_string_t reset;
17389 /* Common CLI fields for port config pctype mapping reset*/
17390 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17391 TOKEN_STRING_INITIALIZER
17392 (struct cmd_pctype_mapping_reset_result,
17394 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17395 TOKEN_STRING_INITIALIZER
17396 (struct cmd_pctype_mapping_reset_result,
17398 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17399 TOKEN_NUM_INITIALIZER
17400 (struct cmd_pctype_mapping_reset_result,
17402 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17403 TOKEN_STRING_INITIALIZER
17404 (struct cmd_pctype_mapping_reset_result,
17406 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17407 TOKEN_STRING_INITIALIZER
17408 (struct cmd_pctype_mapping_reset_result,
17409 mapping, "mapping");
17410 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17411 TOKEN_STRING_INITIALIZER
17412 (struct cmd_pctype_mapping_reset_result,
17416 cmd_pctype_mapping_reset_parsed(
17417 void *parsed_result,
17418 __rte_unused struct cmdline *cl,
17419 __rte_unused void *data)
17421 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17422 int ret = -ENOTSUP;
17424 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17427 #ifdef RTE_LIBRTE_I40E_PMD
17428 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17435 printf("invalid port_id %d\n", res->port_id);
17438 printf("function not implemented\n");
17441 printf("programming error: (%s)\n", strerror(-ret));
17445 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17446 .f = cmd_pctype_mapping_reset_parsed,
17448 .help_str = "port config <port_id> pctype mapping reset",
17450 (void *)&cmd_pctype_mapping_reset_port,
17451 (void *)&cmd_pctype_mapping_reset_config,
17452 (void *)&cmd_pctype_mapping_reset_port_id,
17453 (void *)&cmd_pctype_mapping_reset_pctype,
17454 (void *)&cmd_pctype_mapping_reset_mapping,
17455 (void *)&cmd_pctype_mapping_reset_reset,
17460 /* show port pctype mapping */
17462 /* Common result structure for show port pctype mapping */
17463 struct cmd_pctype_mapping_get_result {
17464 cmdline_fixed_string_t show;
17465 cmdline_fixed_string_t port;
17467 cmdline_fixed_string_t pctype;
17468 cmdline_fixed_string_t mapping;
17471 /* Common CLI fields for pctype mapping get */
17472 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17473 TOKEN_STRING_INITIALIZER
17474 (struct cmd_pctype_mapping_get_result,
17476 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17477 TOKEN_STRING_INITIALIZER
17478 (struct cmd_pctype_mapping_get_result,
17480 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17481 TOKEN_NUM_INITIALIZER
17482 (struct cmd_pctype_mapping_get_result,
17484 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17485 TOKEN_STRING_INITIALIZER
17486 (struct cmd_pctype_mapping_get_result,
17488 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17489 TOKEN_STRING_INITIALIZER
17490 (struct cmd_pctype_mapping_get_result,
17491 mapping, "mapping");
17494 cmd_pctype_mapping_get_parsed(
17495 void *parsed_result,
17496 __rte_unused struct cmdline *cl,
17497 __rte_unused void *data)
17499 struct cmd_pctype_mapping_get_result *res = parsed_result;
17500 int ret = -ENOTSUP;
17501 #ifdef RTE_LIBRTE_I40E_PMD
17502 struct rte_pmd_i40e_flow_type_mapping
17503 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17504 int i, j, first_pctype;
17507 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17510 #ifdef RTE_LIBRTE_I40E_PMD
17511 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17518 printf("invalid port_id %d\n", res->port_id);
17521 printf("function not implemented\n");
17524 printf("programming error: (%s)\n", strerror(-ret));
17528 #ifdef RTE_LIBRTE_I40E_PMD
17529 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17530 if (mapping[i].pctype != 0ULL) {
17533 printf("pctype: ");
17534 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17535 if (mapping[i].pctype & (1ULL << j)) {
17536 printf(first_pctype ?
17537 "%02d" : ",%02d", j);
17541 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17547 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17548 .f = cmd_pctype_mapping_get_parsed,
17550 .help_str = "show port <port_id> pctype mapping",
17552 (void *)&cmd_pctype_mapping_get_show,
17553 (void *)&cmd_pctype_mapping_get_port,
17554 (void *)&cmd_pctype_mapping_get_port_id,
17555 (void *)&cmd_pctype_mapping_get_pctype,
17556 (void *)&cmd_pctype_mapping_get_mapping,
17561 /* port config pctype mapping update */
17563 /* Common result structure for port config pctype mapping update */
17564 struct cmd_pctype_mapping_update_result {
17565 cmdline_fixed_string_t port;
17566 cmdline_fixed_string_t config;
17568 cmdline_fixed_string_t pctype;
17569 cmdline_fixed_string_t mapping;
17570 cmdline_fixed_string_t update;
17571 cmdline_fixed_string_t pctype_list;
17572 uint16_t flow_type;
17575 /* Common CLI fields for pctype mapping update*/
17576 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17577 TOKEN_STRING_INITIALIZER
17578 (struct cmd_pctype_mapping_update_result,
17580 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17581 TOKEN_STRING_INITIALIZER
17582 (struct cmd_pctype_mapping_update_result,
17584 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17585 TOKEN_NUM_INITIALIZER
17586 (struct cmd_pctype_mapping_update_result,
17588 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17589 TOKEN_STRING_INITIALIZER
17590 (struct cmd_pctype_mapping_update_result,
17592 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17593 TOKEN_STRING_INITIALIZER
17594 (struct cmd_pctype_mapping_update_result,
17595 mapping, "mapping");
17596 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17597 TOKEN_STRING_INITIALIZER
17598 (struct cmd_pctype_mapping_update_result,
17600 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17601 TOKEN_STRING_INITIALIZER
17602 (struct cmd_pctype_mapping_update_result,
17603 pctype_list, NULL);
17604 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17605 TOKEN_NUM_INITIALIZER
17606 (struct cmd_pctype_mapping_update_result,
17607 flow_type, UINT16);
17610 cmd_pctype_mapping_update_parsed(
17611 void *parsed_result,
17612 __rte_unused struct cmdline *cl,
17613 __rte_unused void *data)
17615 struct cmd_pctype_mapping_update_result *res = parsed_result;
17616 int ret = -ENOTSUP;
17617 #ifdef RTE_LIBRTE_I40E_PMD
17618 struct rte_pmd_i40e_flow_type_mapping mapping;
17620 unsigned int nb_item;
17621 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17624 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17627 #ifdef RTE_LIBRTE_I40E_PMD
17628 nb_item = parse_item_list(res->pctype_list, "pctypes",
17629 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17630 mapping.flow_type = res->flow_type;
17631 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17632 mapping.pctype |= (1ULL << pctype_list[i]);
17633 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17643 printf("invalid pctype or flow type\n");
17646 printf("invalid port_id %d\n", res->port_id);
17649 printf("function not implemented\n");
17652 printf("programming error: (%s)\n", strerror(-ret));
17656 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17657 .f = cmd_pctype_mapping_update_parsed,
17659 .help_str = "port config <port_id> pctype mapping update"
17660 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17662 (void *)&cmd_pctype_mapping_update_port,
17663 (void *)&cmd_pctype_mapping_update_config,
17664 (void *)&cmd_pctype_mapping_update_port_id,
17665 (void *)&cmd_pctype_mapping_update_pctype,
17666 (void *)&cmd_pctype_mapping_update_mapping,
17667 (void *)&cmd_pctype_mapping_update_update,
17668 (void *)&cmd_pctype_mapping_update_pc_type,
17669 (void *)&cmd_pctype_mapping_update_flow_type,
17674 /* ptype mapping get */
17676 /* Common result structure for ptype mapping get */
17677 struct cmd_ptype_mapping_get_result {
17678 cmdline_fixed_string_t ptype;
17679 cmdline_fixed_string_t mapping;
17680 cmdline_fixed_string_t get;
17682 uint8_t valid_only;
17685 /* Common CLI fields for ptype mapping get */
17686 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17687 TOKEN_STRING_INITIALIZER
17688 (struct cmd_ptype_mapping_get_result,
17690 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17691 TOKEN_STRING_INITIALIZER
17692 (struct cmd_ptype_mapping_get_result,
17693 mapping, "mapping");
17694 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17695 TOKEN_STRING_INITIALIZER
17696 (struct cmd_ptype_mapping_get_result,
17698 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17699 TOKEN_NUM_INITIALIZER
17700 (struct cmd_ptype_mapping_get_result,
17702 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17703 TOKEN_NUM_INITIALIZER
17704 (struct cmd_ptype_mapping_get_result,
17705 valid_only, UINT8);
17708 cmd_ptype_mapping_get_parsed(
17709 void *parsed_result,
17710 __rte_unused struct cmdline *cl,
17711 __rte_unused void *data)
17713 struct cmd_ptype_mapping_get_result *res = parsed_result;
17714 int ret = -ENOTSUP;
17715 #ifdef RTE_LIBRTE_I40E_PMD
17716 int max_ptype_num = 256;
17717 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17722 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17725 #ifdef RTE_LIBRTE_I40E_PMD
17726 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17737 printf("invalid port_id %d\n", res->port_id);
17740 printf("function not implemented\n");
17743 printf("programming error: (%s)\n", strerror(-ret));
17746 #ifdef RTE_LIBRTE_I40E_PMD
17748 for (i = 0; i < count; i++)
17749 printf("%3d\t0x%08x\n",
17750 mapping[i].hw_ptype, mapping[i].sw_ptype);
17755 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17756 .f = cmd_ptype_mapping_get_parsed,
17758 .help_str = "ptype mapping get <port_id> <valid_only>",
17760 (void *)&cmd_ptype_mapping_get_ptype,
17761 (void *)&cmd_ptype_mapping_get_mapping,
17762 (void *)&cmd_ptype_mapping_get_get,
17763 (void *)&cmd_ptype_mapping_get_port_id,
17764 (void *)&cmd_ptype_mapping_get_valid_only,
17769 /* ptype mapping replace */
17771 /* Common result structure for ptype mapping replace */
17772 struct cmd_ptype_mapping_replace_result {
17773 cmdline_fixed_string_t ptype;
17774 cmdline_fixed_string_t mapping;
17775 cmdline_fixed_string_t replace;
17782 /* Common CLI fields for ptype mapping replace */
17783 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17784 TOKEN_STRING_INITIALIZER
17785 (struct cmd_ptype_mapping_replace_result,
17787 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17788 TOKEN_STRING_INITIALIZER
17789 (struct cmd_ptype_mapping_replace_result,
17790 mapping, "mapping");
17791 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17792 TOKEN_STRING_INITIALIZER
17793 (struct cmd_ptype_mapping_replace_result,
17794 replace, "replace");
17795 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17796 TOKEN_NUM_INITIALIZER
17797 (struct cmd_ptype_mapping_replace_result,
17799 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17800 TOKEN_NUM_INITIALIZER
17801 (struct cmd_ptype_mapping_replace_result,
17803 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17804 TOKEN_NUM_INITIALIZER
17805 (struct cmd_ptype_mapping_replace_result,
17807 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17808 TOKEN_NUM_INITIALIZER
17809 (struct cmd_ptype_mapping_replace_result,
17813 cmd_ptype_mapping_replace_parsed(
17814 void *parsed_result,
17815 __rte_unused struct cmdline *cl,
17816 __rte_unused void *data)
17818 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17819 int ret = -ENOTSUP;
17821 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17824 #ifdef RTE_LIBRTE_I40E_PMD
17825 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17835 printf("invalid ptype 0x%8x or 0x%8x\n",
17836 res->target, res->pkt_type);
17839 printf("invalid port_id %d\n", res->port_id);
17842 printf("function not implemented\n");
17845 printf("programming error: (%s)\n", strerror(-ret));
17849 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17850 .f = cmd_ptype_mapping_replace_parsed,
17853 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17855 (void *)&cmd_ptype_mapping_replace_ptype,
17856 (void *)&cmd_ptype_mapping_replace_mapping,
17857 (void *)&cmd_ptype_mapping_replace_replace,
17858 (void *)&cmd_ptype_mapping_replace_port_id,
17859 (void *)&cmd_ptype_mapping_replace_target,
17860 (void *)&cmd_ptype_mapping_replace_mask,
17861 (void *)&cmd_ptype_mapping_replace_pkt_type,
17866 /* ptype mapping reset */
17868 /* Common result structure for ptype mapping reset */
17869 struct cmd_ptype_mapping_reset_result {
17870 cmdline_fixed_string_t ptype;
17871 cmdline_fixed_string_t mapping;
17872 cmdline_fixed_string_t reset;
17876 /* Common CLI fields for ptype mapping reset*/
17877 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17878 TOKEN_STRING_INITIALIZER
17879 (struct cmd_ptype_mapping_reset_result,
17881 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17882 TOKEN_STRING_INITIALIZER
17883 (struct cmd_ptype_mapping_reset_result,
17884 mapping, "mapping");
17885 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17886 TOKEN_STRING_INITIALIZER
17887 (struct cmd_ptype_mapping_reset_result,
17889 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17890 TOKEN_NUM_INITIALIZER
17891 (struct cmd_ptype_mapping_reset_result,
17895 cmd_ptype_mapping_reset_parsed(
17896 void *parsed_result,
17897 __rte_unused struct cmdline *cl,
17898 __rte_unused void *data)
17900 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17901 int ret = -ENOTSUP;
17903 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17906 #ifdef RTE_LIBRTE_I40E_PMD
17907 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17914 printf("invalid port_id %d\n", res->port_id);
17917 printf("function not implemented\n");
17920 printf("programming error: (%s)\n", strerror(-ret));
17924 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17925 .f = cmd_ptype_mapping_reset_parsed,
17927 .help_str = "ptype mapping reset <port_id>",
17929 (void *)&cmd_ptype_mapping_reset_ptype,
17930 (void *)&cmd_ptype_mapping_reset_mapping,
17931 (void *)&cmd_ptype_mapping_reset_reset,
17932 (void *)&cmd_ptype_mapping_reset_port_id,
17937 /* ptype mapping update */
17939 /* Common result structure for ptype mapping update */
17940 struct cmd_ptype_mapping_update_result {
17941 cmdline_fixed_string_t ptype;
17942 cmdline_fixed_string_t mapping;
17943 cmdline_fixed_string_t reset;
17949 /* Common CLI fields for ptype mapping update*/
17950 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17951 TOKEN_STRING_INITIALIZER
17952 (struct cmd_ptype_mapping_update_result,
17954 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17955 TOKEN_STRING_INITIALIZER
17956 (struct cmd_ptype_mapping_update_result,
17957 mapping, "mapping");
17958 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17959 TOKEN_STRING_INITIALIZER
17960 (struct cmd_ptype_mapping_update_result,
17962 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17963 TOKEN_NUM_INITIALIZER
17964 (struct cmd_ptype_mapping_update_result,
17966 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17967 TOKEN_NUM_INITIALIZER
17968 (struct cmd_ptype_mapping_update_result,
17970 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17971 TOKEN_NUM_INITIALIZER
17972 (struct cmd_ptype_mapping_update_result,
17976 cmd_ptype_mapping_update_parsed(
17977 void *parsed_result,
17978 __rte_unused struct cmdline *cl,
17979 __rte_unused void *data)
17981 struct cmd_ptype_mapping_update_result *res = parsed_result;
17982 int ret = -ENOTSUP;
17983 #ifdef RTE_LIBRTE_I40E_PMD
17984 struct rte_pmd_i40e_ptype_mapping mapping;
17986 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17989 #ifdef RTE_LIBRTE_I40E_PMD
17990 mapping.hw_ptype = res->hw_ptype;
17991 mapping.sw_ptype = res->sw_ptype;
17992 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
18002 printf("invalid ptype 0x%8x\n", res->sw_ptype);
18005 printf("invalid port_id %d\n", res->port_id);
18008 printf("function not implemented\n");
18011 printf("programming error: (%s)\n", strerror(-ret));
18015 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18016 .f = cmd_ptype_mapping_update_parsed,
18018 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18020 (void *)&cmd_ptype_mapping_update_ptype,
18021 (void *)&cmd_ptype_mapping_update_mapping,
18022 (void *)&cmd_ptype_mapping_update_update,
18023 (void *)&cmd_ptype_mapping_update_port_id,
18024 (void *)&cmd_ptype_mapping_update_hw_ptype,
18025 (void *)&cmd_ptype_mapping_update_sw_ptype,
18030 /* Common result structure for file commands */
18031 struct cmd_cmdfile_result {
18032 cmdline_fixed_string_t load;
18033 cmdline_fixed_string_t filename;
18036 /* Common CLI fields for file commands */
18037 cmdline_parse_token_string_t cmd_load_cmdfile =
18038 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18039 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18040 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18043 cmd_load_from_file_parsed(
18044 void *parsed_result,
18045 __rte_unused struct cmdline *cl,
18046 __rte_unused void *data)
18048 struct cmd_cmdfile_result *res = parsed_result;
18050 cmdline_read_from_file(res->filename);
18053 cmdline_parse_inst_t cmd_load_from_file = {
18054 .f = cmd_load_from_file_parsed,
18056 .help_str = "load <filename>",
18058 (void *)&cmd_load_cmdfile,
18059 (void *)&cmd_load_cmdfile_filename,
18064 /* Get Rx offloads capabilities */
18065 struct cmd_rx_offload_get_capa_result {
18066 cmdline_fixed_string_t show;
18067 cmdline_fixed_string_t port;
18069 cmdline_fixed_string_t rx_offload;
18070 cmdline_fixed_string_t capabilities;
18073 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18074 TOKEN_STRING_INITIALIZER
18075 (struct cmd_rx_offload_get_capa_result,
18077 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18078 TOKEN_STRING_INITIALIZER
18079 (struct cmd_rx_offload_get_capa_result,
18081 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18082 TOKEN_NUM_INITIALIZER
18083 (struct cmd_rx_offload_get_capa_result,
18085 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18086 TOKEN_STRING_INITIALIZER
18087 (struct cmd_rx_offload_get_capa_result,
18088 rx_offload, "rx_offload");
18089 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18090 TOKEN_STRING_INITIALIZER
18091 (struct cmd_rx_offload_get_capa_result,
18092 capabilities, "capabilities");
18095 print_rx_offloads(uint64_t offloads)
18097 uint64_t single_offload;
18105 begin = __builtin_ctzll(offloads);
18106 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18108 single_offload = 1ULL << begin;
18109 for (bit = begin; bit < end; bit++) {
18110 if (offloads & single_offload)
18112 rte_eth_dev_rx_offload_name(single_offload));
18113 single_offload <<= 1;
18118 cmd_rx_offload_get_capa_parsed(
18119 void *parsed_result,
18120 __rte_unused struct cmdline *cl,
18121 __rte_unused void *data)
18123 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18124 struct rte_eth_dev_info dev_info;
18125 portid_t port_id = res->port_id;
18126 uint64_t queue_offloads;
18127 uint64_t port_offloads;
18130 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18134 queue_offloads = dev_info.rx_queue_offload_capa;
18135 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18137 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18138 printf(" Per Queue :");
18139 print_rx_offloads(queue_offloads);
18142 printf(" Per Port :");
18143 print_rx_offloads(port_offloads);
18147 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18148 .f = cmd_rx_offload_get_capa_parsed,
18150 .help_str = "show port <port_id> rx_offload capabilities",
18152 (void *)&cmd_rx_offload_get_capa_show,
18153 (void *)&cmd_rx_offload_get_capa_port,
18154 (void *)&cmd_rx_offload_get_capa_port_id,
18155 (void *)&cmd_rx_offload_get_capa_rx_offload,
18156 (void *)&cmd_rx_offload_get_capa_capabilities,
18161 /* Get Rx offloads configuration */
18162 struct cmd_rx_offload_get_configuration_result {
18163 cmdline_fixed_string_t show;
18164 cmdline_fixed_string_t port;
18166 cmdline_fixed_string_t rx_offload;
18167 cmdline_fixed_string_t configuration;
18170 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18171 TOKEN_STRING_INITIALIZER
18172 (struct cmd_rx_offload_get_configuration_result,
18174 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18175 TOKEN_STRING_INITIALIZER
18176 (struct cmd_rx_offload_get_configuration_result,
18178 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18179 TOKEN_NUM_INITIALIZER
18180 (struct cmd_rx_offload_get_configuration_result,
18182 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18183 TOKEN_STRING_INITIALIZER
18184 (struct cmd_rx_offload_get_configuration_result,
18185 rx_offload, "rx_offload");
18186 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18187 TOKEN_STRING_INITIALIZER
18188 (struct cmd_rx_offload_get_configuration_result,
18189 configuration, "configuration");
18192 cmd_rx_offload_get_configuration_parsed(
18193 void *parsed_result,
18194 __rte_unused struct cmdline *cl,
18195 __rte_unused void *data)
18197 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18198 struct rte_eth_dev_info dev_info;
18199 portid_t port_id = res->port_id;
18200 struct rte_port *port = &ports[port_id];
18201 uint64_t port_offloads;
18202 uint64_t queue_offloads;
18203 uint16_t nb_rx_queues;
18207 printf("Rx Offloading Configuration of port %d :\n", port_id);
18209 port_offloads = port->dev_conf.rxmode.offloads;
18211 print_rx_offloads(port_offloads);
18214 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18218 nb_rx_queues = dev_info.nb_rx_queues;
18219 for (q = 0; q < nb_rx_queues; q++) {
18220 queue_offloads = port->rx_conf[q].offloads;
18221 printf(" Queue[%2d] :", q);
18222 print_rx_offloads(queue_offloads);
18228 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18229 .f = cmd_rx_offload_get_configuration_parsed,
18231 .help_str = "show port <port_id> rx_offload configuration",
18233 (void *)&cmd_rx_offload_get_configuration_show,
18234 (void *)&cmd_rx_offload_get_configuration_port,
18235 (void *)&cmd_rx_offload_get_configuration_port_id,
18236 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18237 (void *)&cmd_rx_offload_get_configuration_configuration,
18242 /* Enable/Disable a per port offloading */
18243 struct cmd_config_per_port_rx_offload_result {
18244 cmdline_fixed_string_t port;
18245 cmdline_fixed_string_t config;
18247 cmdline_fixed_string_t rx_offload;
18248 cmdline_fixed_string_t offload;
18249 cmdline_fixed_string_t on_off;
18252 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18253 TOKEN_STRING_INITIALIZER
18254 (struct cmd_config_per_port_rx_offload_result,
18256 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18257 TOKEN_STRING_INITIALIZER
18258 (struct cmd_config_per_port_rx_offload_result,
18260 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18261 TOKEN_NUM_INITIALIZER
18262 (struct cmd_config_per_port_rx_offload_result,
18264 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18265 TOKEN_STRING_INITIALIZER
18266 (struct cmd_config_per_port_rx_offload_result,
18267 rx_offload, "rx_offload");
18268 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18269 TOKEN_STRING_INITIALIZER
18270 (struct cmd_config_per_port_rx_offload_result,
18271 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18272 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18273 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18274 "scatter#timestamp#security#keep_crc#rss_hash");
18275 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18276 TOKEN_STRING_INITIALIZER
18277 (struct cmd_config_per_port_rx_offload_result,
18281 search_rx_offload(const char *name)
18283 uint64_t single_offload;
18284 const char *single_name;
18288 single_offload = 1;
18289 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18290 single_name = rte_eth_dev_rx_offload_name(single_offload);
18291 if (!strcasecmp(single_name, name)) {
18295 single_offload <<= 1;
18299 return single_offload;
18305 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18306 __rte_unused struct cmdline *cl,
18307 __rte_unused void *data)
18309 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18310 portid_t port_id = res->port_id;
18311 struct rte_eth_dev_info dev_info;
18312 struct rte_port *port = &ports[port_id];
18313 uint64_t single_offload;
18314 uint16_t nb_rx_queues;
18318 if (port->port_status != RTE_PORT_STOPPED) {
18319 printf("Error: Can't config offload when Port %d "
18320 "is not stopped\n", port_id);
18324 single_offload = search_rx_offload(res->offload);
18325 if (single_offload == 0) {
18326 printf("Unknown offload name: %s\n", res->offload);
18330 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18334 nb_rx_queues = dev_info.nb_rx_queues;
18335 if (!strcmp(res->on_off, "on")) {
18336 port->dev_conf.rxmode.offloads |= single_offload;
18337 for (q = 0; q < nb_rx_queues; q++)
18338 port->rx_conf[q].offloads |= single_offload;
18340 port->dev_conf.rxmode.offloads &= ~single_offload;
18341 for (q = 0; q < nb_rx_queues; q++)
18342 port->rx_conf[q].offloads &= ~single_offload;
18345 cmd_reconfig_device_queue(port_id, 1, 1);
18348 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18349 .f = cmd_config_per_port_rx_offload_parsed,
18351 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18352 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18353 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18354 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18357 (void *)&cmd_config_per_port_rx_offload_result_port,
18358 (void *)&cmd_config_per_port_rx_offload_result_config,
18359 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18360 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18361 (void *)&cmd_config_per_port_rx_offload_result_offload,
18362 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18367 /* Enable/Disable a per queue offloading */
18368 struct cmd_config_per_queue_rx_offload_result {
18369 cmdline_fixed_string_t port;
18371 cmdline_fixed_string_t rxq;
18373 cmdline_fixed_string_t rx_offload;
18374 cmdline_fixed_string_t offload;
18375 cmdline_fixed_string_t on_off;
18378 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18379 TOKEN_STRING_INITIALIZER
18380 (struct cmd_config_per_queue_rx_offload_result,
18382 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18383 TOKEN_NUM_INITIALIZER
18384 (struct cmd_config_per_queue_rx_offload_result,
18386 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18387 TOKEN_STRING_INITIALIZER
18388 (struct cmd_config_per_queue_rx_offload_result,
18390 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18391 TOKEN_NUM_INITIALIZER
18392 (struct cmd_config_per_queue_rx_offload_result,
18394 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18395 TOKEN_STRING_INITIALIZER
18396 (struct cmd_config_per_queue_rx_offload_result,
18397 rx_offload, "rx_offload");
18398 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18399 TOKEN_STRING_INITIALIZER
18400 (struct cmd_config_per_queue_rx_offload_result,
18401 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18402 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18403 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18404 "scatter#timestamp#security#keep_crc");
18405 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18406 TOKEN_STRING_INITIALIZER
18407 (struct cmd_config_per_queue_rx_offload_result,
18411 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18412 __rte_unused struct cmdline *cl,
18413 __rte_unused void *data)
18415 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18416 struct rte_eth_dev_info dev_info;
18417 portid_t port_id = res->port_id;
18418 uint16_t queue_id = res->queue_id;
18419 struct rte_port *port = &ports[port_id];
18420 uint64_t single_offload;
18423 if (port->port_status != RTE_PORT_STOPPED) {
18424 printf("Error: Can't config offload when Port %d "
18425 "is not stopped\n", port_id);
18429 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18433 if (queue_id >= dev_info.nb_rx_queues) {
18434 printf("Error: input queue_id should be 0 ... "
18435 "%d\n", dev_info.nb_rx_queues - 1);
18439 single_offload = search_rx_offload(res->offload);
18440 if (single_offload == 0) {
18441 printf("Unknown offload name: %s\n", res->offload);
18445 if (!strcmp(res->on_off, "on"))
18446 port->rx_conf[queue_id].offloads |= single_offload;
18448 port->rx_conf[queue_id].offloads &= ~single_offload;
18450 cmd_reconfig_device_queue(port_id, 1, 1);
18453 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18454 .f = cmd_config_per_queue_rx_offload_parsed,
18456 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18457 "vlan_strip|ipv4_cksum|"
18458 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18459 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18460 "jumbo_frame|scatter|timestamp|security|keep_crc "
18463 (void *)&cmd_config_per_queue_rx_offload_result_port,
18464 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18465 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18466 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18467 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18468 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18469 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18474 /* Get Tx offloads capabilities */
18475 struct cmd_tx_offload_get_capa_result {
18476 cmdline_fixed_string_t show;
18477 cmdline_fixed_string_t port;
18479 cmdline_fixed_string_t tx_offload;
18480 cmdline_fixed_string_t capabilities;
18483 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18484 TOKEN_STRING_INITIALIZER
18485 (struct cmd_tx_offload_get_capa_result,
18487 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18488 TOKEN_STRING_INITIALIZER
18489 (struct cmd_tx_offload_get_capa_result,
18491 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18492 TOKEN_NUM_INITIALIZER
18493 (struct cmd_tx_offload_get_capa_result,
18495 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18496 TOKEN_STRING_INITIALIZER
18497 (struct cmd_tx_offload_get_capa_result,
18498 tx_offload, "tx_offload");
18499 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18500 TOKEN_STRING_INITIALIZER
18501 (struct cmd_tx_offload_get_capa_result,
18502 capabilities, "capabilities");
18505 print_tx_offloads(uint64_t offloads)
18507 uint64_t single_offload;
18515 begin = __builtin_ctzll(offloads);
18516 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18518 single_offload = 1ULL << begin;
18519 for (bit = begin; bit < end; bit++) {
18520 if (offloads & single_offload)
18522 rte_eth_dev_tx_offload_name(single_offload));
18523 single_offload <<= 1;
18528 cmd_tx_offload_get_capa_parsed(
18529 void *parsed_result,
18530 __rte_unused struct cmdline *cl,
18531 __rte_unused void *data)
18533 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18534 struct rte_eth_dev_info dev_info;
18535 portid_t port_id = res->port_id;
18536 uint64_t queue_offloads;
18537 uint64_t port_offloads;
18540 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18544 queue_offloads = dev_info.tx_queue_offload_capa;
18545 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18547 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18548 printf(" Per Queue :");
18549 print_tx_offloads(queue_offloads);
18552 printf(" Per Port :");
18553 print_tx_offloads(port_offloads);
18557 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18558 .f = cmd_tx_offload_get_capa_parsed,
18560 .help_str = "show port <port_id> tx_offload capabilities",
18562 (void *)&cmd_tx_offload_get_capa_show,
18563 (void *)&cmd_tx_offload_get_capa_port,
18564 (void *)&cmd_tx_offload_get_capa_port_id,
18565 (void *)&cmd_tx_offload_get_capa_tx_offload,
18566 (void *)&cmd_tx_offload_get_capa_capabilities,
18571 /* Get Tx offloads configuration */
18572 struct cmd_tx_offload_get_configuration_result {
18573 cmdline_fixed_string_t show;
18574 cmdline_fixed_string_t port;
18576 cmdline_fixed_string_t tx_offload;
18577 cmdline_fixed_string_t configuration;
18580 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18581 TOKEN_STRING_INITIALIZER
18582 (struct cmd_tx_offload_get_configuration_result,
18584 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18585 TOKEN_STRING_INITIALIZER
18586 (struct cmd_tx_offload_get_configuration_result,
18588 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18589 TOKEN_NUM_INITIALIZER
18590 (struct cmd_tx_offload_get_configuration_result,
18592 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18593 TOKEN_STRING_INITIALIZER
18594 (struct cmd_tx_offload_get_configuration_result,
18595 tx_offload, "tx_offload");
18596 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18597 TOKEN_STRING_INITIALIZER
18598 (struct cmd_tx_offload_get_configuration_result,
18599 configuration, "configuration");
18602 cmd_tx_offload_get_configuration_parsed(
18603 void *parsed_result,
18604 __rte_unused struct cmdline *cl,
18605 __rte_unused void *data)
18607 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18608 struct rte_eth_dev_info dev_info;
18609 portid_t port_id = res->port_id;
18610 struct rte_port *port = &ports[port_id];
18611 uint64_t port_offloads;
18612 uint64_t queue_offloads;
18613 uint16_t nb_tx_queues;
18617 printf("Tx Offloading Configuration of port %d :\n", port_id);
18619 port_offloads = port->dev_conf.txmode.offloads;
18621 print_tx_offloads(port_offloads);
18624 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18628 nb_tx_queues = dev_info.nb_tx_queues;
18629 for (q = 0; q < nb_tx_queues; q++) {
18630 queue_offloads = port->tx_conf[q].offloads;
18631 printf(" Queue[%2d] :", q);
18632 print_tx_offloads(queue_offloads);
18638 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18639 .f = cmd_tx_offload_get_configuration_parsed,
18641 .help_str = "show port <port_id> tx_offload configuration",
18643 (void *)&cmd_tx_offload_get_configuration_show,
18644 (void *)&cmd_tx_offload_get_configuration_port,
18645 (void *)&cmd_tx_offload_get_configuration_port_id,
18646 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18647 (void *)&cmd_tx_offload_get_configuration_configuration,
18652 /* Enable/Disable a per port offloading */
18653 struct cmd_config_per_port_tx_offload_result {
18654 cmdline_fixed_string_t port;
18655 cmdline_fixed_string_t config;
18657 cmdline_fixed_string_t tx_offload;
18658 cmdline_fixed_string_t offload;
18659 cmdline_fixed_string_t on_off;
18662 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18663 TOKEN_STRING_INITIALIZER
18664 (struct cmd_config_per_port_tx_offload_result,
18666 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18667 TOKEN_STRING_INITIALIZER
18668 (struct cmd_config_per_port_tx_offload_result,
18670 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18671 TOKEN_NUM_INITIALIZER
18672 (struct cmd_config_per_port_tx_offload_result,
18674 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18675 TOKEN_STRING_INITIALIZER
18676 (struct cmd_config_per_port_tx_offload_result,
18677 tx_offload, "tx_offload");
18678 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18679 TOKEN_STRING_INITIALIZER
18680 (struct cmd_config_per_port_tx_offload_result,
18681 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18682 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18683 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18684 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18685 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18686 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18687 TOKEN_STRING_INITIALIZER
18688 (struct cmd_config_per_port_tx_offload_result,
18692 search_tx_offload(const char *name)
18694 uint64_t single_offload;
18695 const char *single_name;
18699 single_offload = 1;
18700 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18701 single_name = rte_eth_dev_tx_offload_name(single_offload);
18702 if (single_name == NULL)
18704 if (!strcasecmp(single_name, name)) {
18707 } else if (!strcasecmp(single_name, "UNKNOWN"))
18709 single_offload <<= 1;
18713 return single_offload;
18719 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18720 __rte_unused struct cmdline *cl,
18721 __rte_unused void *data)
18723 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18724 portid_t port_id = res->port_id;
18725 struct rte_eth_dev_info dev_info;
18726 struct rte_port *port = &ports[port_id];
18727 uint64_t single_offload;
18728 uint16_t nb_tx_queues;
18732 if (port->port_status != RTE_PORT_STOPPED) {
18733 printf("Error: Can't config offload when Port %d "
18734 "is not stopped\n", port_id);
18738 single_offload = search_tx_offload(res->offload);
18739 if (single_offload == 0) {
18740 printf("Unknown offload name: %s\n", res->offload);
18744 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18748 nb_tx_queues = dev_info.nb_tx_queues;
18749 if (!strcmp(res->on_off, "on")) {
18750 port->dev_conf.txmode.offloads |= single_offload;
18751 for (q = 0; q < nb_tx_queues; q++)
18752 port->tx_conf[q].offloads |= single_offload;
18754 port->dev_conf.txmode.offloads &= ~single_offload;
18755 for (q = 0; q < nb_tx_queues; q++)
18756 port->tx_conf[q].offloads &= ~single_offload;
18759 cmd_reconfig_device_queue(port_id, 1, 1);
18762 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18763 .f = cmd_config_per_port_tx_offload_parsed,
18765 .help_str = "port config <port_id> tx_offload "
18766 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18767 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18768 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18769 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18770 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18772 (void *)&cmd_config_per_port_tx_offload_result_port,
18773 (void *)&cmd_config_per_port_tx_offload_result_config,
18774 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18775 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18776 (void *)&cmd_config_per_port_tx_offload_result_offload,
18777 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18782 /* Enable/Disable a per queue offloading */
18783 struct cmd_config_per_queue_tx_offload_result {
18784 cmdline_fixed_string_t port;
18786 cmdline_fixed_string_t txq;
18788 cmdline_fixed_string_t tx_offload;
18789 cmdline_fixed_string_t offload;
18790 cmdline_fixed_string_t on_off;
18793 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18794 TOKEN_STRING_INITIALIZER
18795 (struct cmd_config_per_queue_tx_offload_result,
18797 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18798 TOKEN_NUM_INITIALIZER
18799 (struct cmd_config_per_queue_tx_offload_result,
18801 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18802 TOKEN_STRING_INITIALIZER
18803 (struct cmd_config_per_queue_tx_offload_result,
18805 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18806 TOKEN_NUM_INITIALIZER
18807 (struct cmd_config_per_queue_tx_offload_result,
18809 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18810 TOKEN_STRING_INITIALIZER
18811 (struct cmd_config_per_queue_tx_offload_result,
18812 tx_offload, "tx_offload");
18813 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18814 TOKEN_STRING_INITIALIZER
18815 (struct cmd_config_per_queue_tx_offload_result,
18816 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18817 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18818 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18819 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18820 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18821 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18822 TOKEN_STRING_INITIALIZER
18823 (struct cmd_config_per_queue_tx_offload_result,
18827 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18828 __rte_unused struct cmdline *cl,
18829 __rte_unused void *data)
18831 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18832 struct rte_eth_dev_info dev_info;
18833 portid_t port_id = res->port_id;
18834 uint16_t queue_id = res->queue_id;
18835 struct rte_port *port = &ports[port_id];
18836 uint64_t single_offload;
18839 if (port->port_status != RTE_PORT_STOPPED) {
18840 printf("Error: Can't config offload when Port %d "
18841 "is not stopped\n", port_id);
18845 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18849 if (queue_id >= dev_info.nb_tx_queues) {
18850 printf("Error: input queue_id should be 0 ... "
18851 "%d\n", dev_info.nb_tx_queues - 1);
18855 single_offload = search_tx_offload(res->offload);
18856 if (single_offload == 0) {
18857 printf("Unknown offload name: %s\n", res->offload);
18861 if (!strcmp(res->on_off, "on"))
18862 port->tx_conf[queue_id].offloads |= single_offload;
18864 port->tx_conf[queue_id].offloads &= ~single_offload;
18866 cmd_reconfig_device_queue(port_id, 1, 1);
18869 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18870 .f = cmd_config_per_queue_tx_offload_parsed,
18872 .help_str = "port <port_id> txq <queue_id> tx_offload "
18873 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18874 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18875 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18876 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18877 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18880 (void *)&cmd_config_per_queue_tx_offload_result_port,
18881 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18882 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18883 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18884 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18885 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18886 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18891 /* *** configure tx_metadata for specific port *** */
18892 struct cmd_config_tx_metadata_specific_result {
18893 cmdline_fixed_string_t port;
18894 cmdline_fixed_string_t keyword;
18896 cmdline_fixed_string_t item;
18901 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18902 __rte_unused struct cmdline *cl,
18903 __rte_unused void *data)
18905 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18907 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18909 ports[res->port_id].tx_metadata = res->value;
18910 /* Add/remove callback to insert valid metadata in every Tx packet. */
18911 if (ports[res->port_id].tx_metadata)
18912 add_tx_md_callback(res->port_id);
18914 remove_tx_md_callback(res->port_id);
18915 rte_flow_dynf_metadata_register();
18918 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18919 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18921 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18922 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18923 keyword, "config");
18924 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18925 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18927 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18928 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18929 item, "tx_metadata");
18930 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18931 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18934 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18935 .f = cmd_config_tx_metadata_specific_parsed,
18937 .help_str = "port config <port_id> tx_metadata <value>",
18939 (void *)&cmd_config_tx_metadata_specific_port,
18940 (void *)&cmd_config_tx_metadata_specific_keyword,
18941 (void *)&cmd_config_tx_metadata_specific_id,
18942 (void *)&cmd_config_tx_metadata_specific_item,
18943 (void *)&cmd_config_tx_metadata_specific_value,
18948 /* *** set dynf *** */
18949 struct cmd_config_tx_dynf_specific_result {
18950 cmdline_fixed_string_t port;
18951 cmdline_fixed_string_t keyword;
18953 cmdline_fixed_string_t item;
18954 cmdline_fixed_string_t name;
18955 cmdline_fixed_string_t value;
18959 cmd_config_dynf_specific_parsed(void *parsed_result,
18960 __rte_unused struct cmdline *cl,
18961 __rte_unused void *data)
18963 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18964 struct rte_mbuf_dynflag desc_flag;
18966 uint64_t old_port_flags;
18968 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18970 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18972 if (strlcpy(desc_flag.name, res->name,
18973 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18974 printf("Flag name too long\n");
18977 desc_flag.flags = 0;
18978 flag = rte_mbuf_dynflag_register(&desc_flag);
18980 printf("Can't register flag\n");
18983 strcpy(dynf_names[flag], desc_flag.name);
18985 old_port_flags = ports[res->port_id].mbuf_dynf;
18986 if (!strcmp(res->value, "set")) {
18987 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18988 if (old_port_flags == 0)
18989 add_tx_dynf_callback(res->port_id);
18991 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18992 if (ports[res->port_id].mbuf_dynf == 0)
18993 remove_tx_dynf_callback(res->port_id);
18997 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18998 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19000 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
19001 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19002 keyword, "config");
19003 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
19004 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19006 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
19007 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19009 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
19010 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19012 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
19013 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19014 value, "set#clear");
19016 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19017 .f = cmd_config_dynf_specific_parsed,
19019 .help_str = "port config <port id> dynf <name> set|clear",
19021 (void *)&cmd_config_tx_dynf_specific_port,
19022 (void *)&cmd_config_tx_dynf_specific_keyword,
19023 (void *)&cmd_config_tx_dynf_specific_port_id,
19024 (void *)&cmd_config_tx_dynf_specific_item,
19025 (void *)&cmd_config_tx_dynf_specific_name,
19026 (void *)&cmd_config_tx_dynf_specific_value,
19031 /* *** display tx_metadata per port configuration *** */
19032 struct cmd_show_tx_metadata_result {
19033 cmdline_fixed_string_t cmd_show;
19034 cmdline_fixed_string_t cmd_port;
19035 cmdline_fixed_string_t cmd_keyword;
19040 cmd_show_tx_metadata_parsed(void *parsed_result,
19041 __rte_unused struct cmdline *cl,
19042 __rte_unused void *data)
19044 struct cmd_show_tx_metadata_result *res = parsed_result;
19046 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19047 printf("invalid port id %u\n", res->cmd_pid);
19050 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19051 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19052 ports[res->cmd_pid].tx_metadata);
19056 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19057 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19059 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19060 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19062 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19063 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19065 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19066 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19067 cmd_keyword, "tx_metadata");
19069 cmdline_parse_inst_t cmd_show_tx_metadata = {
19070 .f = cmd_show_tx_metadata_parsed,
19072 .help_str = "show port <port_id> tx_metadata",
19074 (void *)&cmd_show_tx_metadata_show,
19075 (void *)&cmd_show_tx_metadata_port,
19076 (void *)&cmd_show_tx_metadata_pid,
19077 (void *)&cmd_show_tx_metadata_keyword,
19082 /* show port supported ptypes */
19084 /* Common result structure for show port ptypes */
19085 struct cmd_show_port_supported_ptypes_result {
19086 cmdline_fixed_string_t show;
19087 cmdline_fixed_string_t port;
19089 cmdline_fixed_string_t ptypes;
19092 /* Common CLI fields for show port ptypes */
19093 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19094 TOKEN_STRING_INITIALIZER
19095 (struct cmd_show_port_supported_ptypes_result,
19097 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19098 TOKEN_STRING_INITIALIZER
19099 (struct cmd_show_port_supported_ptypes_result,
19101 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19102 TOKEN_NUM_INITIALIZER
19103 (struct cmd_show_port_supported_ptypes_result,
19105 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19106 TOKEN_STRING_INITIALIZER
19107 (struct cmd_show_port_supported_ptypes_result,
19111 cmd_show_port_supported_ptypes_parsed(
19112 void *parsed_result,
19113 __rte_unused struct cmdline *cl,
19114 __rte_unused void *data)
19116 #define RSVD_PTYPE_MASK 0xf0000000
19117 #define MAX_PTYPES_PER_LAYER 16
19118 #define LTYPE_NAMESIZE 32
19119 #define PTYPE_NAMESIZE 256
19120 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19121 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19122 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19123 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19124 uint16_t port_id = res->port_id;
19127 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19131 while (ptype_mask != RSVD_PTYPE_MASK) {
19133 switch (ptype_mask) {
19134 case RTE_PTYPE_L2_MASK:
19135 strlcpy(ltype, "L2", sizeof(ltype));
19137 case RTE_PTYPE_L3_MASK:
19138 strlcpy(ltype, "L3", sizeof(ltype));
19140 case RTE_PTYPE_L4_MASK:
19141 strlcpy(ltype, "L4", sizeof(ltype));
19143 case RTE_PTYPE_TUNNEL_MASK:
19144 strlcpy(ltype, "Tunnel", sizeof(ltype));
19146 case RTE_PTYPE_INNER_L2_MASK:
19147 strlcpy(ltype, "Inner L2", sizeof(ltype));
19149 case RTE_PTYPE_INNER_L3_MASK:
19150 strlcpy(ltype, "Inner L3", sizeof(ltype));
19152 case RTE_PTYPE_INNER_L4_MASK:
19153 strlcpy(ltype, "Inner L4", sizeof(ltype));
19159 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19160 ptype_mask, ptypes,
19161 MAX_PTYPES_PER_LAYER);
19164 printf("Supported %s ptypes:\n", ltype);
19166 printf("%s ptypes unsupported\n", ltype);
19168 for (i = 0; i < ret; ++i) {
19169 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19170 printf("%s\n", buf);
19177 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19178 .f = cmd_show_port_supported_ptypes_parsed,
19180 .help_str = "show port <port_id> ptypes",
19182 (void *)&cmd_show_port_supported_ptypes_show,
19183 (void *)&cmd_show_port_supported_ptypes_port,
19184 (void *)&cmd_show_port_supported_ptypes_port_id,
19185 (void *)&cmd_show_port_supported_ptypes_ptypes,
19190 /* *** display rx/tx descriptor status *** */
19191 struct cmd_show_rx_tx_desc_status_result {
19192 cmdline_fixed_string_t cmd_show;
19193 cmdline_fixed_string_t cmd_port;
19194 cmdline_fixed_string_t cmd_keyword;
19195 cmdline_fixed_string_t cmd_desc;
19196 cmdline_fixed_string_t cmd_status;
19203 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19204 __rte_unused struct cmdline *cl,
19205 __rte_unused void *data)
19207 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19210 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19211 printf("invalid port id %u\n", res->cmd_pid);
19215 if (!strcmp(res->cmd_keyword, "rxq")) {
19216 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19219 printf("Invalid queueid = %d\n", res->cmd_qid);
19222 if (rc == RTE_ETH_RX_DESC_AVAIL)
19223 printf("Desc status = AVAILABLE\n");
19224 else if (rc == RTE_ETH_RX_DESC_DONE)
19225 printf("Desc status = DONE\n");
19227 printf("Desc status = UNAVAILABLE\n");
19228 } else if (!strcmp(res->cmd_keyword, "txq")) {
19229 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19232 printf("Invalid queueid = %d\n", res->cmd_qid);
19235 if (rc == RTE_ETH_TX_DESC_FULL)
19236 printf("Desc status = FULL\n");
19237 else if (rc == RTE_ETH_TX_DESC_DONE)
19238 printf("Desc status = DONE\n");
19240 printf("Desc status = UNAVAILABLE\n");
19244 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19245 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19247 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19248 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19250 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19251 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19253 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19254 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19255 cmd_keyword, "rxq#txq");
19256 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19257 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19259 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19260 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19262 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19263 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19265 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19266 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19267 cmd_status, "status");
19268 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19269 .f = cmd_show_rx_tx_desc_status_parsed,
19271 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19274 (void *)&cmd_show_rx_tx_desc_status_show,
19275 (void *)&cmd_show_rx_tx_desc_status_port,
19276 (void *)&cmd_show_rx_tx_desc_status_pid,
19277 (void *)&cmd_show_rx_tx_desc_status_keyword,
19278 (void *)&cmd_show_rx_tx_desc_status_qid,
19279 (void *)&cmd_show_rx_tx_desc_status_desc,
19280 (void *)&cmd_show_rx_tx_desc_status_did,
19281 (void *)&cmd_show_rx_tx_desc_status_status,
19286 /* Common result structure for set port ptypes */
19287 struct cmd_set_port_ptypes_result {
19288 cmdline_fixed_string_t set;
19289 cmdline_fixed_string_t port;
19291 cmdline_fixed_string_t ptype_mask;
19295 /* Common CLI fields for set port ptypes */
19296 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19297 TOKEN_STRING_INITIALIZER
19298 (struct cmd_set_port_ptypes_result,
19300 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19301 TOKEN_STRING_INITIALIZER
19302 (struct cmd_set_port_ptypes_result,
19304 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19305 TOKEN_NUM_INITIALIZER
19306 (struct cmd_set_port_ptypes_result,
19308 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19309 TOKEN_STRING_INITIALIZER
19310 (struct cmd_set_port_ptypes_result,
19311 ptype_mask, "ptype_mask");
19312 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19313 TOKEN_NUM_INITIALIZER
19314 (struct cmd_set_port_ptypes_result,
19318 cmd_set_port_ptypes_parsed(
19319 void *parsed_result,
19320 __rte_unused struct cmdline *cl,
19321 __rte_unused void *data)
19323 struct cmd_set_port_ptypes_result *res = parsed_result;
19324 #define PTYPE_NAMESIZE 256
19325 char ptype_name[PTYPE_NAMESIZE];
19326 uint16_t port_id = res->port_id;
19327 uint32_t ptype_mask = res->mask;
19330 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19333 printf("Port %d doesn't support any ptypes.\n", port_id);
19337 uint32_t ptypes[ret];
19339 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19341 printf("Unable to set requested ptypes for Port %d\n", port_id);
19345 printf("Successfully set following ptypes for Port %d\n", port_id);
19346 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19347 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19348 printf("%s\n", ptype_name);
19351 clear_ptypes = false;
19354 cmdline_parse_inst_t cmd_set_port_ptypes = {
19355 .f = cmd_set_port_ptypes_parsed,
19357 .help_str = "set port <port_id> ptype_mask <mask>",
19359 (void *)&cmd_set_port_ptypes_set,
19360 (void *)&cmd_set_port_ptypes_port,
19361 (void *)&cmd_set_port_ptypes_port_id,
19362 (void *)&cmd_set_port_ptypes_mask_str,
19363 (void *)&cmd_set_port_ptypes_mask_u32,
19368 /* *** display mac addresses added to a port *** */
19369 struct cmd_showport_macs_result {
19370 cmdline_fixed_string_t cmd_show;
19371 cmdline_fixed_string_t cmd_port;
19372 cmdline_fixed_string_t cmd_keyword;
19377 cmd_showport_macs_parsed(void *parsed_result,
19378 __rte_unused struct cmdline *cl,
19379 __rte_unused void *data)
19381 struct cmd_showport_macs_result *res = parsed_result;
19383 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19386 if (!strcmp(res->cmd_keyword, "macs"))
19387 show_macs(res->cmd_pid);
19388 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19389 show_mcast_macs(res->cmd_pid);
19392 cmdline_parse_token_string_t cmd_showport_macs_show =
19393 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19395 cmdline_parse_token_string_t cmd_showport_macs_port =
19396 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19398 cmdline_parse_token_num_t cmd_showport_macs_pid =
19399 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19401 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19402 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19403 cmd_keyword, "macs#mcast_macs");
19405 cmdline_parse_inst_t cmd_showport_macs = {
19406 .f = cmd_showport_macs_parsed,
19408 .help_str = "show port <port_id> macs|mcast_macs",
19410 (void *)&cmd_showport_macs_show,
19411 (void *)&cmd_showport_macs_port,
19412 (void *)&cmd_showport_macs_pid,
19413 (void *)&cmd_showport_macs_keyword,
19418 /* ******************************************************************************** */
19420 /* list of instructions */
19421 cmdline_parse_ctx_t main_ctx[] = {
19422 (cmdline_parse_inst_t *)&cmd_help_brief,
19423 (cmdline_parse_inst_t *)&cmd_help_long,
19424 (cmdline_parse_inst_t *)&cmd_quit,
19425 (cmdline_parse_inst_t *)&cmd_load_from_file,
19426 (cmdline_parse_inst_t *)&cmd_showport,
19427 (cmdline_parse_inst_t *)&cmd_showqueue,
19428 (cmdline_parse_inst_t *)&cmd_showportall,
19429 (cmdline_parse_inst_t *)&cmd_showdevice,
19430 (cmdline_parse_inst_t *)&cmd_showcfg,
19431 (cmdline_parse_inst_t *)&cmd_showfwdall,
19432 (cmdline_parse_inst_t *)&cmd_start,
19433 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19434 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19435 (cmdline_parse_inst_t *)&cmd_set_link_up,
19436 (cmdline_parse_inst_t *)&cmd_set_link_down,
19437 (cmdline_parse_inst_t *)&cmd_reset,
19438 (cmdline_parse_inst_t *)&cmd_set_numbers,
19439 (cmdline_parse_inst_t *)&cmd_set_log,
19440 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19441 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19442 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19443 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19444 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19445 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19446 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19447 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19448 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19449 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19450 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19451 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19452 (cmdline_parse_inst_t *)&cmd_set_link_check,
19453 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19454 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19455 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19456 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19457 #ifdef RTE_LIBRTE_PMD_BOND
19458 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19459 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19460 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19461 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19462 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19463 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19464 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19465 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19466 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19467 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19468 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19470 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19471 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19472 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19473 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19474 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19475 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19476 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19477 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19478 (cmdline_parse_inst_t *)&cmd_csum_set,
19479 (cmdline_parse_inst_t *)&cmd_csum_show,
19480 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19481 (cmdline_parse_inst_t *)&cmd_tso_set,
19482 (cmdline_parse_inst_t *)&cmd_tso_show,
19483 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19484 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19485 (cmdline_parse_inst_t *)&cmd_gro_enable,
19486 (cmdline_parse_inst_t *)&cmd_gro_flush,
19487 (cmdline_parse_inst_t *)&cmd_gro_show,
19488 (cmdline_parse_inst_t *)&cmd_gso_enable,
19489 (cmdline_parse_inst_t *)&cmd_gso_size,
19490 (cmdline_parse_inst_t *)&cmd_gso_show,
19491 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19492 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19493 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19494 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19495 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19496 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19497 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19498 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19499 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19500 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19501 (cmdline_parse_inst_t *)&cmd_config_dcb,
19502 (cmdline_parse_inst_t *)&cmd_read_reg,
19503 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19504 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19505 (cmdline_parse_inst_t *)&cmd_write_reg,
19506 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19507 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19508 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19509 (cmdline_parse_inst_t *)&cmd_stop,
19510 (cmdline_parse_inst_t *)&cmd_mac_addr,
19511 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19512 (cmdline_parse_inst_t *)&cmd_set_qmap,
19513 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19514 (cmdline_parse_inst_t *)&cmd_operate_port,
19515 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19516 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19517 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19518 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19519 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19520 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19521 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19522 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19523 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19524 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19525 (cmdline_parse_inst_t *)&cmd_config_mtu,
19526 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19527 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19528 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19529 (cmdline_parse_inst_t *)&cmd_config_rss,
19530 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19531 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19532 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19533 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19534 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19535 (cmdline_parse_inst_t *)&cmd_showport_reta,
19536 (cmdline_parse_inst_t *)&cmd_showport_macs,
19537 (cmdline_parse_inst_t *)&cmd_config_burst,
19538 (cmdline_parse_inst_t *)&cmd_config_thresh,
19539 (cmdline_parse_inst_t *)&cmd_config_threshold,
19540 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19541 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19542 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19543 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19544 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19545 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19546 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19547 (cmdline_parse_inst_t *)&cmd_global_config,
19548 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19549 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19550 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19551 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19552 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19553 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19554 (cmdline_parse_inst_t *)&cmd_dump,
19555 (cmdline_parse_inst_t *)&cmd_dump_one,
19556 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19557 (cmdline_parse_inst_t *)&cmd_syn_filter,
19558 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19559 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19560 (cmdline_parse_inst_t *)&cmd_flex_filter,
19561 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19562 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19563 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19564 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19565 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19566 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19567 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19568 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19569 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19570 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19571 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19572 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19573 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19574 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19575 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19576 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19577 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19578 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19579 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19580 (cmdline_parse_inst_t *)&cmd_flow,
19581 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19582 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19583 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19584 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19585 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19586 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19587 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19588 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19589 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19590 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19591 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19592 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19593 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19594 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19595 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19596 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19597 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19598 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19599 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19600 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19601 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19602 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19603 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19604 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19605 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19606 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19607 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19608 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19609 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19610 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19611 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19612 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19613 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19614 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19615 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19616 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19617 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19618 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19619 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19620 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19621 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19622 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19623 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19624 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19625 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19626 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19627 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19628 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19629 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19630 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19631 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19633 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19634 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19635 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19636 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19637 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19638 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19639 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19640 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19641 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19642 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19643 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19644 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19645 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19646 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19647 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19648 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19649 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19650 (cmdline_parse_inst_t *)&cmd_ddp_add,
19651 (cmdline_parse_inst_t *)&cmd_ddp_del,
19652 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19653 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19654 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19655 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19656 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19657 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19658 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19659 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19660 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19661 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19662 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19663 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19665 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19666 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19667 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19668 (cmdline_parse_inst_t *)&cmd_queue_region,
19669 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19670 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19671 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19672 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19673 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19674 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19675 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19676 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19677 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19678 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19679 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19680 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19681 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19682 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19683 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19684 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19685 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19686 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19687 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19688 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19689 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19690 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19691 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19692 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19693 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19694 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19695 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19696 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19697 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19698 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19699 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19700 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19701 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19702 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19703 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19704 #ifdef RTE_LIBRTE_BPF
19705 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19706 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19708 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19709 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19710 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19711 (cmdline_parse_inst_t *)&cmd_set_raw,
19712 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19713 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19714 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19718 /* read cmdline commands from file */
19720 cmdline_read_from_file(const char *filename)
19722 struct cmdline *cl;
19724 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19726 printf("Failed to create file based cmdline context: %s\n",
19731 cmdline_interact(cl);
19736 printf("Read CLI commands from %s\n", filename);
19739 /* prompt function, called from main on MASTER lcore */
19743 /* initialize non-constant commands */
19744 cmd_set_fwd_mode_init();
19745 cmd_set_fwd_retry_mode_init();
19747 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19748 if (testpmd_cl == NULL)
19750 cmdline_interact(testpmd_cl);
19751 cmdline_stdin_exit(testpmd_cl);
19757 if (testpmd_cl != NULL)
19758 cmdline_quit(testpmd_cl);
19762 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19764 if (id == (portid_t)RTE_PORT_ALL) {
19767 RTE_ETH_FOREACH_DEV(pid) {
19768 /* check if need_reconfig has been set to 1 */
19769 if (ports[pid].need_reconfig == 0)
19770 ports[pid].need_reconfig = dev;
19771 /* check if need_reconfig_queues has been set to 1 */
19772 if (ports[pid].need_reconfig_queues == 0)
19773 ports[pid].need_reconfig_queues = queue;
19775 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19776 /* check if need_reconfig has been set to 1 */
19777 if (ports[id].need_reconfig == 0)
19778 ports[id].need_reconfig = dev;
19779 /* check if need_reconfig_queues has been set to 1 */
19780 if (ports[id].need_reconfig_queues == 0)
19781 ports[id].need_reconfig_queues = queue;