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 port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|rxpkts|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) macs|mcast_macs"
250 " Display list of mac addresses added to port.\n\n"
252 "show port (port_id) fec capabilities"
253 " Show fec capabilities of a port.\n\n"
255 "show port (port_id) fec_mode"
256 " Show fec mode of a port.\n\n"
260 if (show_all || !strcmp(res->section, "config")) {
266 "Configuration changes only become active when"
267 " forwarding is started/restarted.\n\n"
270 " Reset forwarding to the default configuration.\n\n"
272 "set verbose (level)\n"
273 " Set the debug verbosity level X.\n\n"
275 "set log global|(type) (level)\n"
276 " Set the log level.\n\n"
279 " Set number of ports.\n\n"
282 " Set number of cores.\n\n"
284 "set coremask (mask)\n"
285 " Set the forwarding cores hexadecimal mask.\n\n"
287 "set portmask (mask)\n"
288 " Set the forwarding ports hexadecimal mask.\n\n"
291 " Set number of packets per burst.\n\n"
293 "set burst tx delay (microseconds) retry (num)\n"
294 " Set the transmit delay time and number of retries,"
295 " effective when retry is enabled.\n\n"
297 "set rxpkts (x[,y]*)\n"
298 " Set the length of each segment to scatter"
299 " packets on receiving if split feature is engaged."
300 " Affects only the queues configured with split"
303 "set txpkts (x[,y]*)\n"
304 " Set the length of each segment of TXONLY"
305 " and optionally CSUM packets.\n\n"
307 "set txsplit (off|on|rand)\n"
308 " Set the split policy for the TX packets."
309 " Right now only applicable for CSUM and TXONLY"
312 "set txtimes (x, y)\n"
313 " Set the scheduling on timestamps"
314 " timings for the TXONLY mode\n\n"
316 "set corelist (x[,y]*)\n"
317 " Set the list of forwarding cores.\n\n"
319 "set portlist (x[,y]*)\n"
320 " Set the list of forwarding ports.\n\n"
322 "set port setup on (iterator|event)\n"
323 " Select how attached port is retrieved for setup.\n\n"
325 "set tx loopback (port_id) (on|off)\n"
326 " Enable or disable tx loopback.\n\n"
328 "set all queues drop (port_id) (on|off)\n"
329 " Set drop enable bit for all queues.\n\n"
331 "set vf split drop (port_id) (vf_id) (on|off)\n"
332 " Set split drop enable bit for a VF from the PF.\n\n"
334 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
335 " Set MAC antispoof for a VF from the PF.\n\n"
337 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
338 " Enable MACsec offload.\n\n"
340 "set macsec offload (port_id) off\n"
341 " Disable MACsec offload.\n\n"
343 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
344 " Configure MACsec secure connection (SC).\n\n"
346 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
347 " Configure MACsec secure association (SA).\n\n"
349 "set vf broadcast (port_id) (vf_id) (on|off)\n"
350 " Set VF broadcast for a VF from the PF.\n\n"
352 "vlan set stripq (on|off) (port_id,queue_id)\n"
353 " Set the VLAN strip for a queue on a port.\n\n"
355 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
356 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
358 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
359 " Set VLAN insert for a VF from the PF.\n\n"
361 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
362 " Set VLAN antispoof for a VF from the PF.\n\n"
364 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
365 " Set VLAN tag for a VF from the PF.\n\n"
367 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
368 " Set a VF's max bandwidth(Mbps).\n\n"
370 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
371 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
373 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
374 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
376 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
377 " Set some TCs' strict link priority mode on a physical port.\n\n"
379 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
380 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
382 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
383 " Set the VLAN strip or filter or qinq strip or extend\n\n"
385 "vlan set (inner|outer) tpid (value) (port_id)\n"
386 " Set the VLAN TPID for Packet Filtering on"
389 "rx_vlan add (vlan_id|all) (port_id)\n"
390 " Add a vlan_id, or all identifiers, to the set"
391 " of VLAN identifiers filtered by port_id.\n\n"
393 "rx_vlan rm (vlan_id|all) (port_id)\n"
394 " Remove a vlan_id, or all identifiers, from the set"
395 " of VLAN identifiers filtered by port_id.\n\n"
397 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
398 " Add a vlan_id, to the set of VLAN identifiers"
399 "filtered for VF(s) from port_id.\n\n"
401 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
402 " Remove a vlan_id, to the set of VLAN identifiers"
403 "filtered for VF(s) from port_id.\n\n"
405 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
406 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
407 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
408 " add a tunnel filter of a port.\n\n"
410 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
411 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
412 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
413 " remove a tunnel filter of a port.\n\n"
415 "rx_vxlan_port add (udp_port) (port_id)\n"
416 " Add an UDP port for VXLAN packet filter on a port\n\n"
418 "rx_vxlan_port rm (udp_port) (port_id)\n"
419 " Remove an UDP port for VXLAN packet filter on a port\n\n"
421 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
422 " Set hardware insertion of VLAN IDs (single or double VLAN "
423 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
425 "tx_vlan set pvid port_id vlan_id (on|off)\n"
426 " Set port based TX VLAN insertion.\n\n"
428 "tx_vlan reset (port_id)\n"
429 " Disable hardware insertion of a VLAN header in"
430 " packets sent on a port.\n\n"
432 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
433 " Select hardware or software calculation of the"
434 " checksum when transmitting a packet using the"
435 " csum forward engine.\n"
436 " ip|udp|tcp|sctp always concern the inner layer.\n"
437 " outer-ip concerns the outer IP layer in"
438 " outer-udp concerns the outer UDP layer in"
439 " case the packet is recognized as a tunnel packet by"
440 " the forward engine (vxlan, gre and ipip are supported)\n"
441 " Please check the NIC datasheet for HW limits.\n\n"
443 "csum parse-tunnel (on|off) (tx_port_id)\n"
444 " If disabled, treat tunnel packets as non-tunneled"
445 " packets (treat inner headers as payload). The port\n"
446 " argument is the port used for TX in csum forward"
449 "csum show (port_id)\n"
450 " Display tx checksum offload configuration\n\n"
452 "tso set (segsize) (portid)\n"
453 " Enable TCP Segmentation Offload in csum forward"
455 " Please check the NIC datasheet for HW limits.\n\n"
458 " Display the status of TCP Segmentation Offload.\n\n"
460 "set port (port_id) gro on|off\n"
461 " Enable or disable Generic Receive Offload in"
462 " csum forwarding engine.\n\n"
464 "show port (port_id) gro\n"
465 " Display GRO configuration.\n\n"
467 "set gro flush (cycles)\n"
468 " Set the cycle to flush GROed packets from"
469 " reassembly tables.\n\n"
471 "set port (port_id) gso (on|off)"
472 " Enable or disable Generic Segmentation Offload in"
473 " csum forwarding engine.\n\n"
475 "set gso segsz (length)\n"
476 " Set max packet length for output GSO segments,"
477 " including packet header and payload.\n\n"
479 "show port (port_id) gso\n"
480 " Show GSO configuration.\n\n"
483 " Set packet forwarding mode.\n\n"
485 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
486 " Add a MAC address on port_id.\n\n"
488 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
489 " Remove a MAC address from port_id.\n\n"
491 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
492 " Set the default MAC address for port_id.\n\n"
494 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
495 " Add a MAC address for a VF on the port.\n\n"
497 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
498 " Set the MAC address for a VF from the PF.\n\n"
500 "set eth-peer (port_id) (peer_addr)\n"
501 " set the peer address for certain port.\n\n"
503 "set port (port_id) uta (mac_address|all) (on|off)\n"
504 " Add/Remove a or all unicast hash filter(s)"
507 "set promisc (port_id|all) (on|off)\n"
508 " Set the promiscuous mode on port_id, or all.\n\n"
510 "set allmulti (port_id|all) (on|off)\n"
511 " Set the allmulti mode on port_id, or all.\n\n"
513 "set vf promisc (port_id) (vf_id) (on|off)\n"
514 " Set unicast promiscuous mode for a VF from the PF.\n\n"
516 "set vf allmulti (port_id) (vf_id) (on|off)\n"
517 " Set multicast promiscuous mode for a VF from the PF.\n\n"
519 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
520 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
521 " (on|off) autoneg (on|off) (port_id)\n"
522 "set flow_ctrl rx (on|off) (portid)\n"
523 "set flow_ctrl tx (on|off) (portid)\n"
524 "set flow_ctrl high_water (high_water) (portid)\n"
525 "set flow_ctrl low_water (low_water) (portid)\n"
526 "set flow_ctrl pause_time (pause_time) (portid)\n"
527 "set flow_ctrl send_xon (send_xon) (portid)\n"
528 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
529 "set flow_ctrl autoneg (on|off) (port_id)\n"
530 " Set the link flow control parameter on a port.\n\n"
532 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
533 " (low_water) (pause_time) (priority) (port_id)\n"
534 " Set the priority flow control parameter on a"
537 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
538 " Set statistics mapping (qmapping 0..15) for RX/TX"
540 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
541 " on port 0 to mapping 5.\n\n"
543 "set xstats-hide-zero on|off\n"
544 " Set the option to hide the zero values"
545 " for xstats display.\n"
547 "set record-core-cycles on|off\n"
548 " Set the option to enable measurement of CPU cycles.\n"
550 "set record-burst-stats on|off\n"
551 " Set the option to enable display of RX and TX bursts.\n"
553 "set port (port_id) vf (vf_id) rx|tx on|off\n"
554 " Enable/Disable a VF receive/tranmit from a port\n\n"
556 "set port (port_id) vf (vf_id) (mac_addr)"
557 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
558 " Add/Remove unicast or multicast MAC addr filter"
561 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
563 " AUPE:accepts untagged VLAN;"
564 "ROPE:accept unicast hash\n\n"
565 " BAM:accepts broadcast packets;"
566 "MPE:accepts all multicast packets\n\n"
567 " Enable/Disable a VF receive mode of a port\n\n"
569 "set port (port_id) queue (queue_id) rate (rate_num)\n"
570 " Set rate limit for a queue of a port\n\n"
572 "set port (port_id) vf (vf_id) rate (rate_num) "
573 "queue_mask (queue_mask_value)\n"
574 " Set rate limit for queues in VF of a port\n\n"
576 "set port (port_id) mirror-rule (rule_id)"
577 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
578 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
579 " Set pool or vlan type mirror rule on a port.\n"
580 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
581 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
584 "set port (port_id) mirror-rule (rule_id)"
585 " (uplink-mirror|downlink-mirror) dst-pool"
586 " (pool_id) (on|off)\n"
587 " Set uplink or downlink type mirror rule on a port.\n"
588 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
589 " 0 on' enable mirror income traffic to pool 0.\n\n"
591 "reset port (port_id) mirror-rule (rule_id)\n"
592 " Reset a mirror rule.\n\n"
594 "set flush_rx (on|off)\n"
595 " Flush (default) or don't flush RX streams before"
596 " forwarding. Mainly used with PCAP drivers.\n\n"
598 "set bypass mode (normal|bypass|isolate) (port_id)\n"
599 " Set the bypass mode for the lowest port on bypass enabled"
602 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
603 "mode (normal|bypass|isolate) (port_id)\n"
604 " Set the event required to initiate specified bypass mode for"
605 " the lowest port on a bypass enabled NIC where:\n"
606 " timeout = enable bypass after watchdog timeout.\n"
607 " os_on = enable bypass when OS/board is powered on.\n"
608 " os_off = enable bypass when OS/board is powered off.\n"
609 " power_on = enable bypass when power supply is turned on.\n"
610 " power_off = enable bypass when power supply is turned off."
613 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
614 " Set the bypass watchdog timeout to 'n' seconds"
615 " where 0 = instant.\n\n"
617 "show bypass config (port_id)\n"
618 " Show the bypass configuration for a bypass enabled NIC"
619 " using the lowest port on the NIC.\n\n"
621 #ifdef RTE_LIBRTE_PMD_BOND
622 "create bonded device (mode) (socket)\n"
623 " Create a new bonded device with specific bonding mode and socket.\n\n"
625 "add bonding slave (slave_id) (port_id)\n"
626 " Add a slave device to a bonded device.\n\n"
628 "remove bonding slave (slave_id) (port_id)\n"
629 " Remove a slave device from a bonded device.\n\n"
631 "set bonding mode (value) (port_id)\n"
632 " Set the bonding mode on a bonded device.\n\n"
634 "set bonding primary (slave_id) (port_id)\n"
635 " Set the primary slave for a bonded device.\n\n"
637 "show bonding config (port_id)\n"
638 " Show the bonding config for port_id.\n\n"
640 "set bonding mac_addr (port_id) (address)\n"
641 " Set the MAC address of a bonded device.\n\n"
643 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
644 " Set Aggregation mode for IEEE802.3AD (mode 4)"
646 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
647 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
649 "set bonding mon_period (port_id) (value)\n"
650 " Set the bonding link status monitoring polling period in ms.\n\n"
652 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
653 " Enable/disable dedicated queues for LACP control traffic.\n\n"
656 "set link-up port (port_id)\n"
657 " Set link up for a port.\n\n"
659 "set link-down port (port_id)\n"
660 " Set link down for a port.\n\n"
662 "E-tag set insertion on port-tag-id (value)"
663 " port (port_id) vf (vf_id)\n"
664 " Enable E-tag insertion for a VF on a port\n\n"
666 "E-tag set insertion off port (port_id) vf (vf_id)\n"
667 " Disable E-tag insertion for a VF on a port\n\n"
669 "E-tag set stripping (on|off) port (port_id)\n"
670 " Enable/disable E-tag stripping on a port\n\n"
672 "E-tag set forwarding (on|off) port (port_id)\n"
673 " Enable/disable E-tag based forwarding"
676 "E-tag set filter add e-tag-id (value) dst-pool"
677 " (pool_id) port (port_id)\n"
678 " Add an E-tag forwarding filter on a port\n\n"
680 "E-tag set filter del e-tag-id (value) port (port_id)\n"
681 " Delete an E-tag forwarding filter on a port\n\n"
683 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
684 " Load a profile package on a port\n\n"
686 "ddp del (port_id) (backup_profile_path)\n"
687 " Delete a profile package from a port\n\n"
689 "ptype mapping get (port_id) (valid_only)\n"
690 " Get ptype mapping on a port\n\n"
692 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
693 " Replace target with the pkt_type in ptype mapping\n\n"
695 "ptype mapping reset (port_id)\n"
696 " Reset ptype mapping on a port\n\n"
698 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
699 " Update a ptype mapping item on a port\n\n"
701 "set port (port_id) ptype_mask (ptype_mask)\n"
702 " set packet types classification for a specific port\n\n"
704 "set port (port_id) queue-region region_id (value) "
705 "queue_start_index (value) queue_num (value)\n"
706 " Set a queue region on a port\n\n"
708 "set port (port_id) queue-region region_id (value) "
710 " Set a flowtype region index on a port\n\n"
712 "set port (port_id) queue-region UP (value) region_id (value)\n"
713 " Set the mapping of User Priority to "
714 "queue region on a port\n\n"
716 "set port (port_id) queue-region flush (on|off)\n"
717 " flush all queue region related configuration\n\n"
719 "show port meter cap (port_id)\n"
720 " Show port meter capability information\n\n"
722 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
723 " meter profile add - srtcm rfc 2697\n\n"
725 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
726 " meter profile add - trtcm rfc 2698\n\n"
728 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
729 " meter profile add - trtcm rfc 4115\n\n"
731 "del port meter profile (port_id) (profile_id)\n"
732 " meter profile delete\n\n"
734 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
735 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
736 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
737 "(dscp_tbl_entry63)]\n"
740 "enable port meter (port_id) (mtr_id)\n"
743 "disable port meter (port_id) (mtr_id)\n"
746 "del port meter (port_id) (mtr_id)\n"
749 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
750 " meter update meter profile\n\n"
752 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
753 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
754 " update meter dscp table entries\n\n"
756 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
757 "(action0) [(action1) (action2)]\n"
758 " meter update policer action\n\n"
760 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
761 " meter update stats\n\n"
763 "show port (port_id) queue-region\n"
764 " show all queue region related configuration info\n\n"
766 "set port (port_id) fec_mode auto|off|rs|baser\n"
767 " set fec mode for a specific port\n\n"
769 , list_pkt_forwarding_modes()
773 if (show_all || !strcmp(res->section, "ports")) {
779 "----------------\n\n"
781 "port start (port_id|all)\n"
782 " Start all ports or port_id.\n\n"
784 "port stop (port_id|all)\n"
785 " Stop all ports or port_id.\n\n"
787 "port close (port_id|all)\n"
788 " Close all ports or port_id.\n\n"
790 "port reset (port_id|all)\n"
791 " Reset all ports or port_id.\n\n"
793 "port attach (ident)\n"
794 " Attach physical or virtual dev by pci address or virtual device name\n\n"
796 "port detach (port_id)\n"
797 " Detach physical or virtual dev by port_id\n\n"
799 "port config (port_id|all)"
800 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
801 " duplex (half|full|auto)\n"
802 " Set speed and duplex for all ports or port_id\n\n"
804 "port config (port_id|all) loopback (mode)\n"
805 " Set loopback mode for all ports or port_id\n\n"
807 "port config all (rxq|txq|rxd|txd) (value)\n"
808 " Set number for rxq/txq/rxd/txd.\n\n"
810 "port config all max-pkt-len (value)\n"
811 " Set the max packet length.\n\n"
813 "port config all max-lro-pkt-size (value)\n"
814 " Set the max LRO aggregated packet size.\n\n"
816 "port config all drop-en (on|off)\n"
817 " Enable or disable packet drop on all RX queues of all ports when no "
818 "receive buffers available.\n\n"
820 "port config all rss (all|default|ip|tcp|udp|sctp|"
821 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|"
822 "level-outer|level-inner|<flowtype_id>)\n"
823 " Set the RSS mode.\n\n"
825 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
826 " Set the RSS redirection table.\n\n"
828 "port config (port_id) dcb vt (on|off) (traffic_class)"
830 " Set the DCB mode.\n\n"
832 "port config all burst (value)\n"
833 " Set the number of packets per burst.\n\n"
835 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
837 " Set the ring prefetch/host/writeback threshold"
838 " for tx/rx queue.\n\n"
840 "port config all (txfreet|txrst|rxfreet) (value)\n"
841 " Set free threshold for rx/tx, or set"
842 " tx rs bit threshold.\n\n"
843 "port config mtu X value\n"
844 " Set the MTU of port X to a given value\n\n"
846 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
847 " Set a rx/tx queue's ring size configuration, the new"
848 " value will take effect after command that (re-)start the port"
849 " or command that setup the specific queue\n\n"
851 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
852 " Start/stop a rx/tx queue of port X. Only take effect"
853 " when port X is started\n\n"
855 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
856 " Switch on/off a deferred start of port X rx/tx queue. Only"
857 " take effect when port X is stopped.\n\n"
859 "port (port_id) (rxq|txq) (queue_id) setup\n"
860 " Setup a rx/tx queue of port X.\n\n"
862 "port config (port_id|all) l2-tunnel E-tag ether-type"
864 " Set the value of E-tag ether-type.\n\n"
866 "port config (port_id|all) l2-tunnel E-tag"
867 " (enable|disable)\n"
868 " Enable/disable the E-tag support.\n\n"
870 "port config (port_id) pctype mapping reset\n"
871 " Reset flow type to pctype mapping on a port\n\n"
873 "port config (port_id) pctype mapping update"
874 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
875 " Update a flow type to pctype mapping item on a port\n\n"
877 "port config (port_id) pctype (pctype_id) hash_inset|"
878 "fdir_inset|fdir_flx_inset get|set|clear field\n"
880 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
882 "port config (port_id) pctype (pctype_id) hash_inset|"
883 "fdir_inset|fdir_flx_inset clear all"
884 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
886 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
887 " Add/remove UDP tunnel port for tunneling offload\n\n"
889 "port config <port_id> rx_offload vlan_strip|"
890 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
891 "outer_ipv4_cksum|macsec_strip|header_split|"
892 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
893 "buffer_split|timestamp|security|keep_crc on|off\n"
894 " Enable or disable a per port Rx offloading"
895 " on all Rx queues of a port\n\n"
897 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
898 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
899 "outer_ipv4_cksum|macsec_strip|header_split|"
900 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
901 "buffer_split|timestamp|security|keep_crc on|off\n"
902 " Enable or disable a per queue Rx offloading"
903 " only on a specific Rx queue\n\n"
905 "port config (port_id) tx_offload vlan_insert|"
906 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
907 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
908 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
909 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
911 " Enable or disable a per port Tx offloading"
912 " on all Tx queues of a port\n\n"
914 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
915 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
916 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
917 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
918 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
920 " Enable or disable a per queue Tx offloading"
921 " only on a specific Tx queue\n\n"
923 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
924 " Load an eBPF program as a callback"
925 " for particular RX/TX queue\n\n"
927 "bpf-unload rx|tx (port) (queue)\n"
928 " Unload previously loaded eBPF program"
929 " for particular RX/TX queue\n\n"
931 "port config (port_id) tx_metadata (value)\n"
932 " Set Tx metadata value per port. Testpmd will add this value"
933 " to any Tx packet sent from this port\n\n"
935 "port config (port_id) dynf (name) set|clear\n"
936 " Register a dynf and Set/clear this flag on Tx. "
937 "Testpmd will set this value to any Tx packet "
938 "sent from this port\n\n"
942 if (show_all || !strcmp(res->section, "registers")) {
950 "read reg (port_id) (address)\n"
951 " Display value of a port register.\n\n"
953 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
954 " Display a port register bit field.\n\n"
956 "read regbit (port_id) (address) (bit_x)\n"
957 " Display a single port register bit.\n\n"
959 "write reg (port_id) (address) (value)\n"
960 " Set value of a port register.\n\n"
962 "write regfield (port_id) (address) (bit_x) (bit_y)"
964 " Set bit field of a port register.\n\n"
966 "write regbit (port_id) (address) (bit_x) (value)\n"
967 " Set single bit value of a port register.\n\n"
970 if (show_all || !strcmp(res->section, "filters")) {
978 "ethertype_filter (port_id) (add|del)"
979 " (mac_addr|mac_ignr) (mac_address) ethertype"
980 " (ether_type) (drop|fwd) queue (queue_id)\n"
981 " Add/Del an ethertype filter.\n\n"
983 "2tuple_filter (port_id) (add|del)"
984 " dst_port (dst_port_value) protocol (protocol_value)"
985 " mask (mask_value) tcp_flags (tcp_flags_value)"
986 " priority (prio_value) queue (queue_id)\n"
987 " Add/Del a 2tuple filter.\n\n"
989 "5tuple_filter (port_id) (add|del)"
990 " dst_ip (dst_address) src_ip (src_address)"
991 " dst_port (dst_port_value) src_port (src_port_value)"
992 " protocol (protocol_value)"
993 " mask (mask_value) tcp_flags (tcp_flags_value)"
994 " priority (prio_value) queue (queue_id)\n"
995 " Add/Del a 5tuple filter.\n\n"
997 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
998 " Add/Del syn filter.\n\n"
1000 "flex_filter (port_id) (add|del) len (len_value)"
1001 " bytes (bytes_value) mask (mask_value)"
1002 " priority (prio_value) queue (queue_id)\n"
1003 " Add/Del a flex filter.\n\n"
1005 "flow_director_filter (port_id) mode IP (add|del|update)"
1006 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
1007 " src (src_ip_address) dst (dst_ip_address)"
1008 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
1009 " vlan (vlan_value) flexbytes (flexbytes_value)"
1010 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1011 " fd_id (fd_id_value)\n"
1012 " Add/Del an IP type flow director filter.\n\n"
1014 "flow_director_filter (port_id) mode IP (add|del|update)"
1015 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1016 " src (src_ip_address) (src_port)"
1017 " dst (dst_ip_address) (dst_port)"
1018 " tos (tos_value) ttl (ttl_value)"
1019 " vlan (vlan_value) flexbytes (flexbytes_value)"
1020 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1021 " fd_id (fd_id_value)\n"
1022 " Add/Del an UDP/TCP type flow director filter.\n\n"
1024 "flow_director_filter (port_id) mode IP (add|del|update)"
1025 " flow (ipv4-sctp|ipv6-sctp)"
1026 " src (src_ip_address) (src_port)"
1027 " dst (dst_ip_address) (dst_port)"
1028 " tag (verification_tag) "
1029 " tos (tos_value) ttl (ttl_value)"
1030 " vlan (vlan_value)"
1031 " flexbytes (flexbytes_value) (drop|fwd)"
1032 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1033 " Add/Del a SCTP type flow director filter.\n\n"
1035 "flow_director_filter (port_id) mode IP (add|del|update)"
1036 " flow l2_payload ether (ethertype)"
1037 " flexbytes (flexbytes_value) (drop|fwd)"
1038 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1039 " Add/Del a l2 payload type flow director filter.\n\n"
1041 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1042 " mac (mac_address) vlan (vlan_value)"
1043 " flexbytes (flexbytes_value) (drop|fwd)"
1044 " queue (queue_id) fd_id (fd_id_value)\n"
1045 " Add/Del a MAC-VLAN flow director filter.\n\n"
1047 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1048 " mac (mac_address) vlan (vlan_value)"
1049 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1050 " flexbytes (flexbytes_value) (drop|fwd)"
1051 " queue (queue_id) fd_id (fd_id_value)\n"
1052 " Add/Del a Tunnel flow director filter.\n\n"
1054 "flow_director_filter (port_id) mode raw (add|del|update)"
1055 " flow (flow_id) (drop|fwd) queue (queue_id)"
1056 " fd_id (fd_id_value) packet (packet file name)\n"
1057 " Add/Del a raw type flow director filter.\n\n"
1059 "flush_flow_director (port_id)\n"
1060 " Flush all flow director entries of a device.\n\n"
1062 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1063 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1064 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1065 " Set flow director IP mask.\n\n"
1067 "flow_director_mask (port_id) mode MAC-VLAN"
1068 " vlan (vlan_value)\n"
1069 " Set flow director MAC-VLAN mask.\n\n"
1071 "flow_director_mask (port_id) mode Tunnel"
1072 " vlan (vlan_value) mac (mac_value)"
1073 " tunnel-type (tunnel_type_value)"
1074 " tunnel-id (tunnel_id_value)\n"
1075 " Set flow director Tunnel mask.\n\n"
1077 "flow_director_flex_mask (port_id)"
1078 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1079 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1081 " Configure mask of flex payload.\n\n"
1083 "flow_director_flex_payload (port_id)"
1084 " (raw|l2|l3|l4) (config)\n"
1085 " Configure flex payload selection.\n\n"
1087 "get_sym_hash_ena_per_port (port_id)\n"
1088 " get symmetric hash enable configuration per port.\n\n"
1090 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1091 " set symmetric hash enable configuration per port"
1092 " to enable or disable.\n\n"
1094 "get_hash_global_config (port_id)\n"
1095 " Get the global configurations of hash filters.\n\n"
1097 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1098 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1099 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1100 " (enable|disable)\n"
1101 " Set the global configurations of hash filters.\n\n"
1103 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1104 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1105 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1106 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1107 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1108 "ipv6-next-header|udp-src-port|udp-dst-port|"
1109 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1110 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1111 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1112 "fld-8th|none) (select|add)\n"
1113 " Set the input set for hash.\n\n"
1115 "set_fdir_input_set (port_id) "
1116 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1117 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1118 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1119 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1120 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1121 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1122 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1124 " Set the input set for FDir.\n\n"
1126 "flow validate {port_id}"
1127 " [group {group_id}] [priority {level}]"
1128 " [ingress] [egress]"
1129 " pattern {item} [/ {item} [...]] / end"
1130 " actions {action} [/ {action} [...]] / end\n"
1131 " Check whether a flow rule can be created.\n\n"
1133 "flow create {port_id}"
1134 " [group {group_id}] [priority {level}]"
1135 " [ingress] [egress]"
1136 " pattern {item} [/ {item} [...]] / end"
1137 " actions {action} [/ {action} [...]] / end\n"
1138 " Create a flow rule.\n\n"
1140 "flow destroy {port_id} rule {rule_id} [...]\n"
1141 " Destroy specific flow rules.\n\n"
1143 "flow flush {port_id}\n"
1144 " Destroy all flow rules.\n\n"
1146 "flow query {port_id} {rule_id} {action}\n"
1147 " Query an existing flow rule.\n\n"
1149 "flow list {port_id} [group {group_id}] [...]\n"
1150 " List existing flow rules sorted by priority,"
1151 " filtered by group identifiers.\n\n"
1153 "flow isolate {port_id} {boolean}\n"
1154 " Restrict ingress traffic to the defined"
1157 "flow aged {port_id} [destroy]\n"
1158 " List and destroy aged flows"
1161 "flow shared_action {port_id} create"
1162 " [action_id {shared_action_id}]"
1163 " [ingress] [egress]"
1164 " action {action} / end\n"
1165 " Create shared action.\n\n"
1167 "flow shared_action {port_id} update"
1168 " {shared_action_id} action {action} / end\n"
1169 " Update shared action.\n\n"
1171 "flow shared_action {port_id} destroy"
1172 " action_id {shared_action_id} [...]\n"
1173 " Destroy specific shared actions.\n\n"
1175 "flow shared_action {port_id} query"
1176 " {shared_action_id}\n"
1177 " Query an existing shared action.\n\n"
1179 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1180 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1181 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1182 " Configure the VXLAN encapsulation for flows.\n\n"
1184 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1185 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1186 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1187 " eth-dst (eth-dst)\n"
1188 " Configure the VXLAN encapsulation for flows.\n\n"
1190 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1191 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1192 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1193 " eth-dst (eth-dst)\n"
1194 " Configure the VXLAN encapsulation for flows.\n\n"
1196 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1197 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1199 " Configure the NVGRE encapsulation for flows.\n\n"
1201 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1202 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1203 " eth-src (eth-src) eth-dst (eth-dst)\n"
1204 " Configure the NVGRE encapsulation for flows.\n\n"
1206 "set raw_encap {flow items}\n"
1207 " Configure the encapsulation with raw data.\n\n"
1209 "set raw_decap {flow items}\n"
1210 " Configure the decapsulation with raw data.\n\n"
1215 if (show_all || !strcmp(res->section, "traffic_management")) {
1219 "Traffic Management:\n"
1221 "show port tm cap (port_id)\n"
1222 " Display the port TM capability.\n\n"
1224 "show port tm level cap (port_id) (level_id)\n"
1225 " Display the port TM hierarchical level capability.\n\n"
1227 "show port tm node cap (port_id) (node_id)\n"
1228 " Display the port TM node capability.\n\n"
1230 "show port tm node type (port_id) (node_id)\n"
1231 " Display the port TM node type.\n\n"
1233 "show port tm node stats (port_id) (node_id) (clear)\n"
1234 " Display the port TM node stats.\n\n"
1236 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1237 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1238 " (packet_length_adjust) (packet_mode)\n"
1239 " Add port tm node private shaper profile.\n\n"
1241 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1242 " Delete port tm node private shaper profile.\n\n"
1244 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1245 " (shaper_profile_id)\n"
1246 " Add/update port tm node shared shaper.\n\n"
1248 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1249 " Delete port tm node shared shaper.\n\n"
1251 "set port tm node shaper profile (port_id) (node_id)"
1252 " (shaper_profile_id)\n"
1253 " Set port tm node shaper profile.\n\n"
1255 "add port tm node wred profile (port_id) (wred_profile_id)"
1256 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1257 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1258 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1259 " Add port tm node wred profile.\n\n"
1261 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1262 " Delete port tm node wred profile.\n\n"
1264 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1265 " (priority) (weight) (level_id) (shaper_profile_id)"
1266 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1267 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1268 " Add port tm nonleaf node.\n\n"
1270 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1271 " (priority) (weight) (level_id) (shaper_profile_id)"
1272 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1273 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1274 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1276 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1277 " (priority) (weight) (level_id) (shaper_profile_id)"
1278 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1279 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1280 " Add port tm leaf node.\n\n"
1282 "del port tm node (port_id) (node_id)\n"
1283 " Delete port tm node.\n\n"
1285 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1286 " (priority) (weight)\n"
1287 " Set port tm node parent.\n\n"
1289 "suspend port tm node (port_id) (node_id)"
1290 " Suspend tm node.\n\n"
1292 "resume port tm node (port_id) (node_id)"
1293 " Resume tm node.\n\n"
1295 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1296 " Commit tm hierarchy.\n\n"
1298 "set port tm mark ip_ecn (port) (green) (yellow)"
1300 " Enables/Disables the traffic management marking"
1301 " for IP ECN (Explicit Congestion Notification)"
1302 " packets on a given port\n\n"
1304 "set port tm mark ip_dscp (port) (green) (yellow)"
1306 " Enables/Disables the traffic management marking"
1307 " on the port for IP dscp packets\n\n"
1309 "set port tm mark vlan_dei (port) (green) (yellow)"
1311 " Enables/Disables the traffic management marking"
1312 " on the port for VLAN packets with DEI enabled\n\n"
1316 if (show_all || !strcmp(res->section, "devices")) {
1320 "Device Operations:\n"
1322 "device detach (identifier)\n"
1323 " Detach device by identifier.\n\n"
1329 cmdline_parse_token_string_t cmd_help_long_help =
1330 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1332 cmdline_parse_token_string_t cmd_help_long_section =
1333 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1334 "all#control#display#config#"
1335 "ports#registers#filters#traffic_management#devices");
1337 cmdline_parse_inst_t cmd_help_long = {
1338 .f = cmd_help_long_parsed,
1340 .help_str = "help all|control|display|config|ports|register|"
1341 "filters|traffic_management|devices: "
1344 (void *)&cmd_help_long_help,
1345 (void *)&cmd_help_long_section,
1351 /* *** start/stop/close all ports *** */
1352 struct cmd_operate_port_result {
1353 cmdline_fixed_string_t keyword;
1354 cmdline_fixed_string_t name;
1355 cmdline_fixed_string_t value;
1358 static void cmd_operate_port_parsed(void *parsed_result,
1359 __rte_unused struct cmdline *cl,
1360 __rte_unused void *data)
1362 struct cmd_operate_port_result *res = parsed_result;
1364 if (!strcmp(res->name, "start"))
1365 start_port(RTE_PORT_ALL);
1366 else if (!strcmp(res->name, "stop"))
1367 stop_port(RTE_PORT_ALL);
1368 else if (!strcmp(res->name, "close"))
1369 close_port(RTE_PORT_ALL);
1370 else if (!strcmp(res->name, "reset"))
1371 reset_port(RTE_PORT_ALL);
1373 printf("Unknown parameter\n");
1376 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1377 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1379 cmdline_parse_token_string_t cmd_operate_port_all_port =
1380 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1381 "start#stop#close#reset");
1382 cmdline_parse_token_string_t cmd_operate_port_all_all =
1383 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1385 cmdline_parse_inst_t cmd_operate_port = {
1386 .f = cmd_operate_port_parsed,
1388 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1390 (void *)&cmd_operate_port_all_cmd,
1391 (void *)&cmd_operate_port_all_port,
1392 (void *)&cmd_operate_port_all_all,
1397 /* *** start/stop/close specific port *** */
1398 struct cmd_operate_specific_port_result {
1399 cmdline_fixed_string_t keyword;
1400 cmdline_fixed_string_t name;
1404 static void cmd_operate_specific_port_parsed(void *parsed_result,
1405 __rte_unused struct cmdline *cl,
1406 __rte_unused void *data)
1408 struct cmd_operate_specific_port_result *res = parsed_result;
1410 if (!strcmp(res->name, "start"))
1411 start_port(res->value);
1412 else if (!strcmp(res->name, "stop"))
1413 stop_port(res->value);
1414 else if (!strcmp(res->name, "close"))
1415 close_port(res->value);
1416 else if (!strcmp(res->name, "reset"))
1417 reset_port(res->value);
1419 printf("Unknown parameter\n");
1422 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1423 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1425 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1426 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1427 name, "start#stop#close#reset");
1428 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1429 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1432 cmdline_parse_inst_t cmd_operate_specific_port = {
1433 .f = cmd_operate_specific_port_parsed,
1435 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1437 (void *)&cmd_operate_specific_port_cmd,
1438 (void *)&cmd_operate_specific_port_port,
1439 (void *)&cmd_operate_specific_port_id,
1444 /* *** enable port setup (after attach) via iterator or event *** */
1445 struct cmd_set_port_setup_on_result {
1446 cmdline_fixed_string_t set;
1447 cmdline_fixed_string_t port;
1448 cmdline_fixed_string_t setup;
1449 cmdline_fixed_string_t on;
1450 cmdline_fixed_string_t mode;
1453 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1454 __rte_unused struct cmdline *cl,
1455 __rte_unused void *data)
1457 struct cmd_set_port_setup_on_result *res = parsed_result;
1459 if (strcmp(res->mode, "event") == 0)
1460 setup_on_probe_event = true;
1461 else if (strcmp(res->mode, "iterator") == 0)
1462 setup_on_probe_event = false;
1464 printf("Unknown mode\n");
1467 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1468 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1470 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1471 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1473 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1474 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1476 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1477 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1479 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1480 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1481 mode, "iterator#event");
1483 cmdline_parse_inst_t cmd_set_port_setup_on = {
1484 .f = cmd_set_port_setup_on_parsed,
1486 .help_str = "set port setup on iterator|event",
1488 (void *)&cmd_set_port_setup_on_set,
1489 (void *)&cmd_set_port_setup_on_port,
1490 (void *)&cmd_set_port_setup_on_setup,
1491 (void *)&cmd_set_port_setup_on_on,
1492 (void *)&cmd_set_port_setup_on_mode,
1497 /* *** attach a specified port *** */
1498 struct cmd_operate_attach_port_result {
1499 cmdline_fixed_string_t port;
1500 cmdline_fixed_string_t keyword;
1501 cmdline_multi_string_t identifier;
1504 static void cmd_operate_attach_port_parsed(void *parsed_result,
1505 __rte_unused struct cmdline *cl,
1506 __rte_unused void *data)
1508 struct cmd_operate_attach_port_result *res = parsed_result;
1510 if (!strcmp(res->keyword, "attach"))
1511 attach_port(res->identifier);
1513 printf("Unknown parameter\n");
1516 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1517 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1519 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1520 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1522 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1523 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1524 identifier, TOKEN_STRING_MULTI);
1526 cmdline_parse_inst_t cmd_operate_attach_port = {
1527 .f = cmd_operate_attach_port_parsed,
1529 .help_str = "port attach <identifier>: "
1530 "(identifier: pci address or virtual dev name)",
1532 (void *)&cmd_operate_attach_port_port,
1533 (void *)&cmd_operate_attach_port_keyword,
1534 (void *)&cmd_operate_attach_port_identifier,
1539 /* *** detach a specified port *** */
1540 struct cmd_operate_detach_port_result {
1541 cmdline_fixed_string_t port;
1542 cmdline_fixed_string_t keyword;
1546 static void cmd_operate_detach_port_parsed(void *parsed_result,
1547 __rte_unused struct cmdline *cl,
1548 __rte_unused void *data)
1550 struct cmd_operate_detach_port_result *res = parsed_result;
1552 if (!strcmp(res->keyword, "detach")) {
1553 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1554 detach_port_device(res->port_id);
1556 printf("Unknown parameter\n");
1560 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1561 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1563 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1564 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1566 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1567 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1570 cmdline_parse_inst_t cmd_operate_detach_port = {
1571 .f = cmd_operate_detach_port_parsed,
1573 .help_str = "port detach <port_id>",
1575 (void *)&cmd_operate_detach_port_port,
1576 (void *)&cmd_operate_detach_port_keyword,
1577 (void *)&cmd_operate_detach_port_port_id,
1582 /* *** detach device by identifier *** */
1583 struct cmd_operate_detach_device_result {
1584 cmdline_fixed_string_t device;
1585 cmdline_fixed_string_t keyword;
1586 cmdline_fixed_string_t identifier;
1589 static void cmd_operate_detach_device_parsed(void *parsed_result,
1590 __rte_unused struct cmdline *cl,
1591 __rte_unused void *data)
1593 struct cmd_operate_detach_device_result *res = parsed_result;
1595 if (!strcmp(res->keyword, "detach"))
1596 detach_devargs(res->identifier);
1598 printf("Unknown parameter\n");
1601 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1602 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1604 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1605 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1607 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1608 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1611 cmdline_parse_inst_t cmd_operate_detach_device = {
1612 .f = cmd_operate_detach_device_parsed,
1614 .help_str = "device detach <identifier>:"
1615 "(identifier: pci address or virtual dev name)",
1617 (void *)&cmd_operate_detach_device_device,
1618 (void *)&cmd_operate_detach_device_keyword,
1619 (void *)&cmd_operate_detach_device_identifier,
1623 /* *** configure speed for all ports *** */
1624 struct cmd_config_speed_all {
1625 cmdline_fixed_string_t port;
1626 cmdline_fixed_string_t keyword;
1627 cmdline_fixed_string_t all;
1628 cmdline_fixed_string_t item1;
1629 cmdline_fixed_string_t item2;
1630 cmdline_fixed_string_t value1;
1631 cmdline_fixed_string_t value2;
1635 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1640 if (!strcmp(duplexstr, "half")) {
1641 duplex = ETH_LINK_HALF_DUPLEX;
1642 } else if (!strcmp(duplexstr, "full")) {
1643 duplex = ETH_LINK_FULL_DUPLEX;
1644 } else if (!strcmp(duplexstr, "auto")) {
1645 duplex = ETH_LINK_FULL_DUPLEX;
1647 printf("Unknown duplex parameter\n");
1651 if (!strcmp(speedstr, "10")) {
1652 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1653 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1654 } else if (!strcmp(speedstr, "100")) {
1655 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1656 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1658 if (duplex != ETH_LINK_FULL_DUPLEX) {
1659 printf("Invalid speed/duplex parameters\n");
1662 if (!strcmp(speedstr, "1000")) {
1663 *speed = ETH_LINK_SPEED_1G;
1664 } else if (!strcmp(speedstr, "10000")) {
1665 *speed = ETH_LINK_SPEED_10G;
1666 } else if (!strcmp(speedstr, "25000")) {
1667 *speed = ETH_LINK_SPEED_25G;
1668 } else if (!strcmp(speedstr, "40000")) {
1669 *speed = ETH_LINK_SPEED_40G;
1670 } else if (!strcmp(speedstr, "50000")) {
1671 *speed = ETH_LINK_SPEED_50G;
1672 } else if (!strcmp(speedstr, "100000")) {
1673 *speed = ETH_LINK_SPEED_100G;
1674 } else if (!strcmp(speedstr, "200000")) {
1675 *speed = ETH_LINK_SPEED_200G;
1676 } else if (!strcmp(speedstr, "auto")) {
1677 *speed = ETH_LINK_SPEED_AUTONEG;
1679 printf("Unknown speed parameter\n");
1688 cmd_config_speed_all_parsed(void *parsed_result,
1689 __rte_unused struct cmdline *cl,
1690 __rte_unused void *data)
1692 struct cmd_config_speed_all *res = parsed_result;
1693 uint32_t link_speed;
1696 if (!all_ports_stopped()) {
1697 printf("Please stop all ports first\n");
1701 if (parse_and_check_speed_duplex(res->value1, res->value2,
1705 RTE_ETH_FOREACH_DEV(pid) {
1706 ports[pid].dev_conf.link_speeds = link_speed;
1709 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1712 cmdline_parse_token_string_t cmd_config_speed_all_port =
1713 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1714 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1717 cmdline_parse_token_string_t cmd_config_speed_all_all =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1719 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1721 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1723 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1724 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1725 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1726 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1727 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1730 cmdline_parse_inst_t cmd_config_speed_all = {
1731 .f = cmd_config_speed_all_parsed,
1733 .help_str = "port config all speed "
1734 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1737 (void *)&cmd_config_speed_all_port,
1738 (void *)&cmd_config_speed_all_keyword,
1739 (void *)&cmd_config_speed_all_all,
1740 (void *)&cmd_config_speed_all_item1,
1741 (void *)&cmd_config_speed_all_value1,
1742 (void *)&cmd_config_speed_all_item2,
1743 (void *)&cmd_config_speed_all_value2,
1748 /* *** configure speed for specific port *** */
1749 struct cmd_config_speed_specific {
1750 cmdline_fixed_string_t port;
1751 cmdline_fixed_string_t keyword;
1753 cmdline_fixed_string_t item1;
1754 cmdline_fixed_string_t item2;
1755 cmdline_fixed_string_t value1;
1756 cmdline_fixed_string_t value2;
1760 cmd_config_speed_specific_parsed(void *parsed_result,
1761 __rte_unused struct cmdline *cl,
1762 __rte_unused void *data)
1764 struct cmd_config_speed_specific *res = parsed_result;
1765 uint32_t link_speed;
1767 if (!all_ports_stopped()) {
1768 printf("Please stop all ports first\n");
1772 if (port_id_is_invalid(res->id, ENABLED_WARN))
1775 if (parse_and_check_speed_duplex(res->value1, res->value2,
1779 ports[res->id].dev_conf.link_speeds = link_speed;
1781 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1785 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1786 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1788 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1789 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1791 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1792 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1793 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1796 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1798 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1799 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1802 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1803 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1806 cmdline_parse_inst_t cmd_config_speed_specific = {
1807 .f = cmd_config_speed_specific_parsed,
1809 .help_str = "port config <port_id> speed "
1810 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1813 (void *)&cmd_config_speed_specific_port,
1814 (void *)&cmd_config_speed_specific_keyword,
1815 (void *)&cmd_config_speed_specific_id,
1816 (void *)&cmd_config_speed_specific_item1,
1817 (void *)&cmd_config_speed_specific_value1,
1818 (void *)&cmd_config_speed_specific_item2,
1819 (void *)&cmd_config_speed_specific_value2,
1824 /* *** configure loopback for all ports *** */
1825 struct cmd_config_loopback_all {
1826 cmdline_fixed_string_t port;
1827 cmdline_fixed_string_t keyword;
1828 cmdline_fixed_string_t all;
1829 cmdline_fixed_string_t item;
1834 cmd_config_loopback_all_parsed(void *parsed_result,
1835 __rte_unused struct cmdline *cl,
1836 __rte_unused void *data)
1838 struct cmd_config_loopback_all *res = parsed_result;
1841 if (!all_ports_stopped()) {
1842 printf("Please stop all ports first\n");
1846 RTE_ETH_FOREACH_DEV(pid) {
1847 ports[pid].dev_conf.lpbk_mode = res->mode;
1850 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1853 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1854 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1855 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1856 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1858 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1859 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1860 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1863 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1864 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1866 cmdline_parse_inst_t cmd_config_loopback_all = {
1867 .f = cmd_config_loopback_all_parsed,
1869 .help_str = "port config all loopback <mode>",
1871 (void *)&cmd_config_loopback_all_port,
1872 (void *)&cmd_config_loopback_all_keyword,
1873 (void *)&cmd_config_loopback_all_all,
1874 (void *)&cmd_config_loopback_all_item,
1875 (void *)&cmd_config_loopback_all_mode,
1880 /* *** configure loopback for specific port *** */
1881 struct cmd_config_loopback_specific {
1882 cmdline_fixed_string_t port;
1883 cmdline_fixed_string_t keyword;
1885 cmdline_fixed_string_t item;
1890 cmd_config_loopback_specific_parsed(void *parsed_result,
1891 __rte_unused struct cmdline *cl,
1892 __rte_unused void *data)
1894 struct cmd_config_loopback_specific *res = parsed_result;
1896 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1899 if (!port_is_stopped(res->port_id)) {
1900 printf("Please stop port %u first\n", res->port_id);
1904 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1906 cmd_reconfig_device_queue(res->port_id, 1, 1);
1910 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1911 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1913 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1914 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1916 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1917 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1919 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1920 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1922 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1923 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1926 cmdline_parse_inst_t cmd_config_loopback_specific = {
1927 .f = cmd_config_loopback_specific_parsed,
1929 .help_str = "port config <port_id> loopback <mode>",
1931 (void *)&cmd_config_loopback_specific_port,
1932 (void *)&cmd_config_loopback_specific_keyword,
1933 (void *)&cmd_config_loopback_specific_id,
1934 (void *)&cmd_config_loopback_specific_item,
1935 (void *)&cmd_config_loopback_specific_mode,
1940 /* *** configure txq/rxq, txd/rxd *** */
1941 struct cmd_config_rx_tx {
1942 cmdline_fixed_string_t port;
1943 cmdline_fixed_string_t keyword;
1944 cmdline_fixed_string_t all;
1945 cmdline_fixed_string_t name;
1950 cmd_config_rx_tx_parsed(void *parsed_result,
1951 __rte_unused struct cmdline *cl,
1952 __rte_unused void *data)
1954 struct cmd_config_rx_tx *res = parsed_result;
1956 if (!all_ports_stopped()) {
1957 printf("Please stop all ports first\n");
1960 if (!strcmp(res->name, "rxq")) {
1961 if (!res->value && !nb_txq) {
1962 printf("Warning: Either rx or tx queues should be non zero\n");
1965 if (check_nb_rxq(res->value) != 0)
1967 nb_rxq = res->value;
1969 else if (!strcmp(res->name, "txq")) {
1970 if (!res->value && !nb_rxq) {
1971 printf("Warning: Either rx or tx queues should be non zero\n");
1974 if (check_nb_txq(res->value) != 0)
1976 nb_txq = res->value;
1978 else if (!strcmp(res->name, "rxd")) {
1979 if (check_nb_rxd(res->value) != 0)
1981 nb_rxd = res->value;
1982 } else if (!strcmp(res->name, "txd")) {
1983 if (check_nb_txd(res->value) != 0)
1986 nb_txd = res->value;
1988 printf("Unknown parameter\n");
1996 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1999 cmdline_parse_token_string_t cmd_config_rx_tx_port =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
2001 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2003 cmdline_parse_token_string_t cmd_config_rx_tx_all =
2004 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2005 cmdline_parse_token_string_t cmd_config_rx_tx_name =
2006 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2008 cmdline_parse_token_num_t cmd_config_rx_tx_value =
2009 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
2011 cmdline_parse_inst_t cmd_config_rx_tx = {
2012 .f = cmd_config_rx_tx_parsed,
2014 .help_str = "port config all rxq|txq|rxd|txd <value>",
2016 (void *)&cmd_config_rx_tx_port,
2017 (void *)&cmd_config_rx_tx_keyword,
2018 (void *)&cmd_config_rx_tx_all,
2019 (void *)&cmd_config_rx_tx_name,
2020 (void *)&cmd_config_rx_tx_value,
2025 /* *** config max packet length *** */
2026 struct cmd_config_max_pkt_len_result {
2027 cmdline_fixed_string_t port;
2028 cmdline_fixed_string_t keyword;
2029 cmdline_fixed_string_t all;
2030 cmdline_fixed_string_t name;
2035 cmd_config_max_pkt_len_parsed(void *parsed_result,
2036 __rte_unused struct cmdline *cl,
2037 __rte_unused void *data)
2039 struct cmd_config_max_pkt_len_result *res = parsed_result;
2042 if (!all_ports_stopped()) {
2043 printf("Please stop all ports first\n");
2047 RTE_ETH_FOREACH_DEV(pid) {
2048 struct rte_port *port = &ports[pid];
2049 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2051 if (!strcmp(res->name, "max-pkt-len")) {
2052 if (res->value < RTE_ETHER_MIN_LEN) {
2053 printf("max-pkt-len can not be less than %d\n",
2057 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2060 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2061 if (res->value > RTE_ETHER_MAX_LEN)
2062 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2064 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2065 port->dev_conf.rxmode.offloads = rx_offloads;
2067 printf("Unknown parameter\n");
2074 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2077 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2078 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2080 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2081 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2083 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2084 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2086 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2087 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2089 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2090 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2093 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2094 .f = cmd_config_max_pkt_len_parsed,
2096 .help_str = "port config all max-pkt-len <value>",
2098 (void *)&cmd_config_max_pkt_len_port,
2099 (void *)&cmd_config_max_pkt_len_keyword,
2100 (void *)&cmd_config_max_pkt_len_all,
2101 (void *)&cmd_config_max_pkt_len_name,
2102 (void *)&cmd_config_max_pkt_len_value,
2107 /* *** config max LRO aggregated packet size *** */
2108 struct cmd_config_max_lro_pkt_size_result {
2109 cmdline_fixed_string_t port;
2110 cmdline_fixed_string_t keyword;
2111 cmdline_fixed_string_t all;
2112 cmdline_fixed_string_t name;
2117 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2118 __rte_unused struct cmdline *cl,
2119 __rte_unused void *data)
2121 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2124 if (!all_ports_stopped()) {
2125 printf("Please stop all ports first\n");
2129 RTE_ETH_FOREACH_DEV(pid) {
2130 struct rte_port *port = &ports[pid];
2132 if (!strcmp(res->name, "max-lro-pkt-size")) {
2134 port->dev_conf.rxmode.max_lro_pkt_size)
2137 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2139 printf("Unknown parameter\n");
2146 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2149 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2150 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2152 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2153 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2155 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2156 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2158 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2159 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2160 name, "max-lro-pkt-size");
2161 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2162 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2165 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2166 .f = cmd_config_max_lro_pkt_size_parsed,
2168 .help_str = "port config all max-lro-pkt-size <value>",
2170 (void *)&cmd_config_max_lro_pkt_size_port,
2171 (void *)&cmd_config_max_lro_pkt_size_keyword,
2172 (void *)&cmd_config_max_lro_pkt_size_all,
2173 (void *)&cmd_config_max_lro_pkt_size_name,
2174 (void *)&cmd_config_max_lro_pkt_size_value,
2179 /* *** configure port MTU *** */
2180 struct cmd_config_mtu_result {
2181 cmdline_fixed_string_t port;
2182 cmdline_fixed_string_t keyword;
2183 cmdline_fixed_string_t mtu;
2189 cmd_config_mtu_parsed(void *parsed_result,
2190 __rte_unused struct cmdline *cl,
2191 __rte_unused void *data)
2193 struct cmd_config_mtu_result *res = parsed_result;
2195 if (res->value < RTE_ETHER_MIN_LEN) {
2196 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2199 port_mtu_set(res->port_id, res->value);
2202 cmdline_parse_token_string_t cmd_config_mtu_port =
2203 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2205 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2206 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2208 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2209 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2211 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2212 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2213 cmdline_parse_token_num_t cmd_config_mtu_value =
2214 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2216 cmdline_parse_inst_t cmd_config_mtu = {
2217 .f = cmd_config_mtu_parsed,
2219 .help_str = "port config mtu <port_id> <value>",
2221 (void *)&cmd_config_mtu_port,
2222 (void *)&cmd_config_mtu_keyword,
2223 (void *)&cmd_config_mtu_mtu,
2224 (void *)&cmd_config_mtu_port_id,
2225 (void *)&cmd_config_mtu_value,
2230 /* *** configure rx mode *** */
2231 struct cmd_config_rx_mode_flag {
2232 cmdline_fixed_string_t port;
2233 cmdline_fixed_string_t keyword;
2234 cmdline_fixed_string_t all;
2235 cmdline_fixed_string_t name;
2236 cmdline_fixed_string_t value;
2240 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2241 __rte_unused struct cmdline *cl,
2242 __rte_unused void *data)
2244 struct cmd_config_rx_mode_flag *res = parsed_result;
2246 if (!all_ports_stopped()) {
2247 printf("Please stop all ports first\n");
2251 if (!strcmp(res->name, "drop-en")) {
2252 if (!strcmp(res->value, "on"))
2254 else if (!strcmp(res->value, "off"))
2257 printf("Unknown parameter\n");
2261 printf("Unknown parameter\n");
2267 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2270 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2271 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2272 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2273 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2275 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2276 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2277 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2278 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2280 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2281 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2284 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2285 .f = cmd_config_rx_mode_flag_parsed,
2287 .help_str = "port config all drop-en on|off",
2289 (void *)&cmd_config_rx_mode_flag_port,
2290 (void *)&cmd_config_rx_mode_flag_keyword,
2291 (void *)&cmd_config_rx_mode_flag_all,
2292 (void *)&cmd_config_rx_mode_flag_name,
2293 (void *)&cmd_config_rx_mode_flag_value,
2298 /* *** configure rss *** */
2299 struct cmd_config_rss {
2300 cmdline_fixed_string_t port;
2301 cmdline_fixed_string_t keyword;
2302 cmdline_fixed_string_t all;
2303 cmdline_fixed_string_t name;
2304 cmdline_fixed_string_t value;
2308 cmd_config_rss_parsed(void *parsed_result,
2309 __rte_unused struct cmdline *cl,
2310 __rte_unused void *data)
2312 struct cmd_config_rss *res = parsed_result;
2313 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2314 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2315 int use_default = 0;
2316 int all_updated = 1;
2321 if (!strcmp(res->value, "all"))
2322 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2323 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2324 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2325 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2326 else if (!strcmp(res->value, "eth"))
2327 rss_conf.rss_hf = ETH_RSS_ETH;
2328 else if (!strcmp(res->value, "vlan"))
2329 rss_conf.rss_hf = ETH_RSS_VLAN;
2330 else if (!strcmp(res->value, "ip"))
2331 rss_conf.rss_hf = ETH_RSS_IP;
2332 else if (!strcmp(res->value, "udp"))
2333 rss_conf.rss_hf = ETH_RSS_UDP;
2334 else if (!strcmp(res->value, "tcp"))
2335 rss_conf.rss_hf = ETH_RSS_TCP;
2336 else if (!strcmp(res->value, "sctp"))
2337 rss_conf.rss_hf = ETH_RSS_SCTP;
2338 else if (!strcmp(res->value, "ether"))
2339 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2340 else if (!strcmp(res->value, "port"))
2341 rss_conf.rss_hf = ETH_RSS_PORT;
2342 else if (!strcmp(res->value, "vxlan"))
2343 rss_conf.rss_hf = ETH_RSS_VXLAN;
2344 else if (!strcmp(res->value, "geneve"))
2345 rss_conf.rss_hf = ETH_RSS_GENEVE;
2346 else if (!strcmp(res->value, "nvgre"))
2347 rss_conf.rss_hf = ETH_RSS_NVGRE;
2348 else if (!strcmp(res->value, "l3-pre32"))
2349 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2350 else if (!strcmp(res->value, "l3-pre40"))
2351 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2352 else if (!strcmp(res->value, "l3-pre48"))
2353 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2354 else if (!strcmp(res->value, "l3-pre56"))
2355 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2356 else if (!strcmp(res->value, "l3-pre64"))
2357 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2358 else if (!strcmp(res->value, "l3-pre96"))
2359 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2360 else if (!strcmp(res->value, "l3-src-only"))
2361 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2362 else if (!strcmp(res->value, "l3-dst-only"))
2363 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2364 else if (!strcmp(res->value, "l4-src-only"))
2365 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2366 else if (!strcmp(res->value, "l4-dst-only"))
2367 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2368 else if (!strcmp(res->value, "l2-src-only"))
2369 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2370 else if (!strcmp(res->value, "l2-dst-only"))
2371 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2372 else if (!strcmp(res->value, "l2tpv3"))
2373 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2374 else if (!strcmp(res->value, "esp"))
2375 rss_conf.rss_hf = ETH_RSS_ESP;
2376 else if (!strcmp(res->value, "ah"))
2377 rss_conf.rss_hf = ETH_RSS_AH;
2378 else if (!strcmp(res->value, "pfcp"))
2379 rss_conf.rss_hf = ETH_RSS_PFCP;
2380 else if (!strcmp(res->value, "pppoe"))
2381 rss_conf.rss_hf = ETH_RSS_PPPOE;
2382 else if (!strcmp(res->value, "gtpu"))
2383 rss_conf.rss_hf = ETH_RSS_GTPU;
2384 else if (!strcmp(res->value, "none"))
2385 rss_conf.rss_hf = 0;
2386 else if (!strcmp(res->value, "level-default")) {
2387 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2388 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2389 } else if (!strcmp(res->value, "level-outer")) {
2390 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2391 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2392 } else if (!strcmp(res->value, "level-inner")) {
2393 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2394 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2395 } else if (!strcmp(res->value, "default"))
2397 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2398 atoi(res->value) < 64)
2399 rss_conf.rss_hf = 1ULL << atoi(res->value);
2401 printf("Unknown parameter\n");
2404 rss_conf.rss_key = NULL;
2405 /* Update global configuration for RSS types. */
2406 RTE_ETH_FOREACH_DEV(i) {
2407 struct rte_eth_rss_conf local_rss_conf;
2409 ret = eth_dev_info_get_print_err(i, &dev_info);
2414 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2416 local_rss_conf = rss_conf;
2417 local_rss_conf.rss_hf = rss_conf.rss_hf &
2418 dev_info.flow_type_rss_offloads;
2419 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2420 printf("Port %u modified RSS hash function based on hardware support,"
2421 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2422 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2424 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2427 printf("Configuration of RSS hash at ethernet port %d "
2428 "failed with error (%d): %s.\n",
2429 i, -diag, strerror(-diag));
2432 if (all_updated && !use_default) {
2433 rss_hf = rss_conf.rss_hf;
2434 printf("rss_hf %#"PRIx64"\n", rss_hf);
2438 cmdline_parse_token_string_t cmd_config_rss_port =
2439 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2440 cmdline_parse_token_string_t cmd_config_rss_keyword =
2441 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2442 cmdline_parse_token_string_t cmd_config_rss_all =
2443 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2444 cmdline_parse_token_string_t cmd_config_rss_name =
2445 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2446 cmdline_parse_token_string_t cmd_config_rss_value =
2447 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2449 cmdline_parse_inst_t cmd_config_rss = {
2450 .f = cmd_config_rss_parsed,
2452 .help_str = "port config all rss "
2453 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2454 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2455 "level-outer|level-inner|<flowtype_id>",
2457 (void *)&cmd_config_rss_port,
2458 (void *)&cmd_config_rss_keyword,
2459 (void *)&cmd_config_rss_all,
2460 (void *)&cmd_config_rss_name,
2461 (void *)&cmd_config_rss_value,
2466 /* *** configure rss hash key *** */
2467 struct cmd_config_rss_hash_key {
2468 cmdline_fixed_string_t port;
2469 cmdline_fixed_string_t config;
2471 cmdline_fixed_string_t rss_hash_key;
2472 cmdline_fixed_string_t rss_type;
2473 cmdline_fixed_string_t key;
2477 hexa_digit_to_value(char hexa_digit)
2479 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2480 return (uint8_t) (hexa_digit - '0');
2481 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2482 return (uint8_t) ((hexa_digit - 'a') + 10);
2483 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2484 return (uint8_t) ((hexa_digit - 'A') + 10);
2485 /* Invalid hexa digit */
2490 parse_and_check_key_hexa_digit(char *key, int idx)
2494 hexa_v = hexa_digit_to_value(key[idx]);
2496 printf("invalid key: character %c at position %d is not a "
2497 "valid hexa digit\n", key[idx], idx);
2502 cmd_config_rss_hash_key_parsed(void *parsed_result,
2503 __rte_unused struct cmdline *cl,
2504 __rte_unused void *data)
2506 struct cmd_config_rss_hash_key *res = parsed_result;
2507 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2511 struct rte_eth_dev_info dev_info;
2512 uint8_t hash_key_size;
2516 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2520 if (dev_info.hash_key_size > 0 &&
2521 dev_info.hash_key_size <= sizeof(hash_key))
2522 hash_key_size = dev_info.hash_key_size;
2524 printf("dev_info did not provide a valid hash key size\n");
2527 /* Check the length of the RSS hash key */
2528 key_len = strlen(res->key);
2529 if (key_len != (hash_key_size * 2)) {
2530 printf("key length: %d invalid - key must be a string of %d"
2531 " hexa-decimal numbers\n",
2532 (int) key_len, hash_key_size * 2);
2535 /* Translate RSS hash key into binary representation */
2536 for (i = 0; i < hash_key_size; i++) {
2537 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2540 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2543 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2545 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2549 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2550 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2551 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2552 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2554 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2555 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2556 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2557 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2558 rss_hash_key, "rss-hash-key");
2559 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2561 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2562 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2563 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2564 "ipv6-tcp-ex#ipv6-udp-ex#"
2565 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2566 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2567 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2568 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2569 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2571 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2572 .f = cmd_config_rss_hash_key_parsed,
2574 .help_str = "port config <port_id> rss-hash-key "
2575 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2576 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2577 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2578 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2579 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2580 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2581 "<string of hex digits (variable length, NIC dependent)>",
2583 (void *)&cmd_config_rss_hash_key_port,
2584 (void *)&cmd_config_rss_hash_key_config,
2585 (void *)&cmd_config_rss_hash_key_port_id,
2586 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2587 (void *)&cmd_config_rss_hash_key_rss_type,
2588 (void *)&cmd_config_rss_hash_key_value,
2593 /* *** configure port rxq/txq ring size *** */
2594 struct cmd_config_rxtx_ring_size {
2595 cmdline_fixed_string_t port;
2596 cmdline_fixed_string_t config;
2598 cmdline_fixed_string_t rxtxq;
2600 cmdline_fixed_string_t rsize;
2605 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2606 __rte_unused struct cmdline *cl,
2607 __rte_unused void *data)
2609 struct cmd_config_rxtx_ring_size *res = parsed_result;
2610 struct rte_port *port;
2613 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2616 if (res->portid == (portid_t)RTE_PORT_ALL) {
2617 printf("Invalid port id\n");
2621 port = &ports[res->portid];
2623 if (!strcmp(res->rxtxq, "rxq"))
2625 else if (!strcmp(res->rxtxq, "txq"))
2628 printf("Unknown parameter\n");
2632 if (isrx && rx_queue_id_is_invalid(res->qid))
2634 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2637 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2638 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2644 port->nb_rx_desc[res->qid] = res->size;
2646 port->nb_tx_desc[res->qid] = res->size;
2648 cmd_reconfig_device_queue(res->portid, 0, 1);
2651 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2652 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2654 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2655 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2657 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2658 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2660 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2661 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2663 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2664 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2666 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2667 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2668 rsize, "ring_size");
2669 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2670 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2673 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2674 .f = cmd_config_rxtx_ring_size_parsed,
2676 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2678 (void *)&cmd_config_rxtx_ring_size_port,
2679 (void *)&cmd_config_rxtx_ring_size_config,
2680 (void *)&cmd_config_rxtx_ring_size_portid,
2681 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2682 (void *)&cmd_config_rxtx_ring_size_qid,
2683 (void *)&cmd_config_rxtx_ring_size_rsize,
2684 (void *)&cmd_config_rxtx_ring_size_size,
2689 /* *** configure port rxq/txq start/stop *** */
2690 struct cmd_config_rxtx_queue {
2691 cmdline_fixed_string_t port;
2693 cmdline_fixed_string_t rxtxq;
2695 cmdline_fixed_string_t opname;
2699 cmd_config_rxtx_queue_parsed(void *parsed_result,
2700 __rte_unused struct cmdline *cl,
2701 __rte_unused void *data)
2703 struct cmd_config_rxtx_queue *res = parsed_result;
2708 if (test_done == 0) {
2709 printf("Please stop forwarding first\n");
2713 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2716 if (port_is_started(res->portid) != 1) {
2717 printf("Please start port %u first\n", res->portid);
2721 if (!strcmp(res->rxtxq, "rxq"))
2723 else if (!strcmp(res->rxtxq, "txq"))
2726 printf("Unknown parameter\n");
2730 if (isrx && rx_queue_id_is_invalid(res->qid))
2732 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2735 if (!strcmp(res->opname, "start"))
2737 else if (!strcmp(res->opname, "stop"))
2740 printf("Unknown parameter\n");
2744 if (isstart && isrx)
2745 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2746 else if (!isstart && isrx)
2747 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2748 else if (isstart && !isrx)
2749 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2751 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2753 if (ret == -ENOTSUP)
2754 printf("Function not supported in PMD driver\n");
2757 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2758 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2759 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2760 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2761 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2762 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2763 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2764 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2765 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2766 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2769 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2770 .f = cmd_config_rxtx_queue_parsed,
2772 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2774 (void *)&cmd_config_rxtx_queue_port,
2775 (void *)&cmd_config_rxtx_queue_portid,
2776 (void *)&cmd_config_rxtx_queue_rxtxq,
2777 (void *)&cmd_config_rxtx_queue_qid,
2778 (void *)&cmd_config_rxtx_queue_opname,
2783 /* *** configure port rxq/txq deferred start on/off *** */
2784 struct cmd_config_deferred_start_rxtx_queue {
2785 cmdline_fixed_string_t port;
2787 cmdline_fixed_string_t rxtxq;
2789 cmdline_fixed_string_t opname;
2790 cmdline_fixed_string_t state;
2794 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2795 __rte_unused struct cmdline *cl,
2796 __rte_unused void *data)
2798 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2799 struct rte_port *port;
2802 uint8_t needreconfig = 0;
2804 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2807 if (port_is_started(res->port_id) != 0) {
2808 printf("Please stop port %u first\n", res->port_id);
2812 port = &ports[res->port_id];
2814 isrx = !strcmp(res->rxtxq, "rxq");
2816 if (isrx && rx_queue_id_is_invalid(res->qid))
2818 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2821 ison = !strcmp(res->state, "on");
2823 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2824 port->rx_conf[res->qid].rx_deferred_start = ison;
2826 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2827 port->tx_conf[res->qid].tx_deferred_start = ison;
2832 cmd_reconfig_device_queue(res->port_id, 0, 1);
2835 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2836 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2838 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2839 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2841 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2842 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2844 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2845 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2847 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2848 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2849 opname, "deferred_start");
2850 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2851 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2854 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2855 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2857 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2859 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2860 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2861 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2862 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2863 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2864 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2869 /* *** configure port rxq/txq setup *** */
2870 struct cmd_setup_rxtx_queue {
2871 cmdline_fixed_string_t port;
2873 cmdline_fixed_string_t rxtxq;
2875 cmdline_fixed_string_t setup;
2878 /* Common CLI fields for queue setup */
2879 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2880 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2881 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2882 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2883 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2884 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2885 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2886 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2887 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2888 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2891 cmd_setup_rxtx_queue_parsed(
2892 void *parsed_result,
2893 __rte_unused struct cmdline *cl,
2894 __rte_unused void *data)
2896 struct cmd_setup_rxtx_queue *res = parsed_result;
2897 struct rte_port *port;
2898 struct rte_mempool *mp;
2899 unsigned int socket_id;
2903 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2906 if (res->portid == (portid_t)RTE_PORT_ALL) {
2907 printf("Invalid port id\n");
2911 if (!strcmp(res->rxtxq, "rxq"))
2913 else if (!strcmp(res->rxtxq, "txq"))
2916 printf("Unknown parameter\n");
2920 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2921 printf("Invalid rx queue\n");
2923 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2924 printf("Invalid tx queue\n");
2928 port = &ports[res->portid];
2930 socket_id = rxring_numa[res->portid];
2931 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2932 socket_id = port->socket_id;
2934 mp = mbuf_pool_find(socket_id, 0);
2936 printf("Failed to setup RX queue: "
2937 "No mempool allocation"
2938 " on the socket %d\n",
2939 rxring_numa[res->portid]);
2942 ret = rte_eth_rx_queue_setup(res->portid,
2944 port->nb_rx_desc[res->qid],
2946 &port->rx_conf[res->qid],
2949 printf("Failed to setup RX queue\n");
2951 socket_id = txring_numa[res->portid];
2952 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2953 socket_id = port->socket_id;
2955 ret = rte_eth_tx_queue_setup(res->portid,
2957 port->nb_tx_desc[res->qid],
2959 &port->tx_conf[res->qid]);
2961 printf("Failed to setup TX queue\n");
2965 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2966 .f = cmd_setup_rxtx_queue_parsed,
2968 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2970 (void *)&cmd_setup_rxtx_queue_port,
2971 (void *)&cmd_setup_rxtx_queue_portid,
2972 (void *)&cmd_setup_rxtx_queue_rxtxq,
2973 (void *)&cmd_setup_rxtx_queue_qid,
2974 (void *)&cmd_setup_rxtx_queue_setup,
2980 /* *** Configure RSS RETA *** */
2981 struct cmd_config_rss_reta {
2982 cmdline_fixed_string_t port;
2983 cmdline_fixed_string_t keyword;
2985 cmdline_fixed_string_t name;
2986 cmdline_fixed_string_t list_name;
2987 cmdline_fixed_string_t list_of_items;
2991 parse_reta_config(const char *str,
2992 struct rte_eth_rss_reta_entry64 *reta_conf,
2993 uint16_t nb_entries)
2997 uint16_t hash_index, idx, shift;
3000 const char *p, *p0 = str;
3007 unsigned long int_fld[_NUM_FLD];
3008 char *str_fld[_NUM_FLD];
3010 while ((p = strchr(p0,'(')) != NULL) {
3012 if((p0 = strchr(p,')')) == NULL)
3016 if(size >= sizeof(s))
3019 snprintf(s, sizeof(s), "%.*s", size, p);
3020 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3022 for (i = 0; i < _NUM_FLD; i++) {
3024 int_fld[i] = strtoul(str_fld[i], &end, 0);
3025 if (errno != 0 || end == str_fld[i] ||
3030 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3031 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3033 if (hash_index >= nb_entries) {
3034 printf("Invalid RETA hash index=%d\n", hash_index);
3038 idx = hash_index / RTE_RETA_GROUP_SIZE;
3039 shift = hash_index % RTE_RETA_GROUP_SIZE;
3040 reta_conf[idx].mask |= (1ULL << shift);
3041 reta_conf[idx].reta[shift] = nb_queue;
3048 cmd_set_rss_reta_parsed(void *parsed_result,
3049 __rte_unused struct cmdline *cl,
3050 __rte_unused void *data)
3053 struct rte_eth_dev_info dev_info;
3054 struct rte_eth_rss_reta_entry64 reta_conf[8];
3055 struct cmd_config_rss_reta *res = parsed_result;
3057 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3061 if (dev_info.reta_size == 0) {
3062 printf("Redirection table size is 0 which is "
3063 "invalid for RSS\n");
3066 printf("The reta size of port %d is %u\n",
3067 res->port_id, dev_info.reta_size);
3068 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3069 printf("Currently do not support more than %u entries of "
3070 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3074 memset(reta_conf, 0, sizeof(reta_conf));
3075 if (!strcmp(res->list_name, "reta")) {
3076 if (parse_reta_config(res->list_of_items, reta_conf,
3077 dev_info.reta_size)) {
3078 printf("Invalid RSS Redirection Table "
3079 "config entered\n");
3082 ret = rte_eth_dev_rss_reta_update(res->port_id,
3083 reta_conf, dev_info.reta_size);
3085 printf("Bad redirection table parameter, "
3086 "return code = %d \n", ret);
3090 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3091 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3092 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3093 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3094 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3095 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3096 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3097 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3098 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3099 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3100 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3101 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3103 cmdline_parse_inst_t cmd_config_rss_reta = {
3104 .f = cmd_set_rss_reta_parsed,
3106 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3108 (void *)&cmd_config_rss_reta_port,
3109 (void *)&cmd_config_rss_reta_keyword,
3110 (void *)&cmd_config_rss_reta_port_id,
3111 (void *)&cmd_config_rss_reta_name,
3112 (void *)&cmd_config_rss_reta_list_name,
3113 (void *)&cmd_config_rss_reta_list_of_items,
3118 /* *** SHOW PORT RETA INFO *** */
3119 struct cmd_showport_reta {
3120 cmdline_fixed_string_t show;
3121 cmdline_fixed_string_t port;
3123 cmdline_fixed_string_t rss;
3124 cmdline_fixed_string_t reta;
3126 cmdline_fixed_string_t list_of_items;
3130 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3131 uint16_t nb_entries,
3135 const char *p, *p0 = str;
3140 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3141 RTE_RETA_GROUP_SIZE;
3144 p = strchr(p0, '(');
3148 p0 = strchr(p, ')');
3152 if (size >= sizeof(s)) {
3153 printf("The string size exceeds the internal buffer size\n");
3156 snprintf(s, sizeof(s), "%.*s", size, p);
3157 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3158 if (ret <= 0 || ret != num) {
3159 printf("The bits of masks do not match the number of "
3160 "reta entries: %u\n", num);
3163 for (i = 0; i < ret; i++)
3164 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3170 cmd_showport_reta_parsed(void *parsed_result,
3171 __rte_unused struct cmdline *cl,
3172 __rte_unused void *data)
3174 struct cmd_showport_reta *res = parsed_result;
3175 struct rte_eth_rss_reta_entry64 reta_conf[8];
3176 struct rte_eth_dev_info dev_info;
3177 uint16_t max_reta_size;
3180 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3184 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3185 if (res->size == 0 || res->size > max_reta_size) {
3186 printf("Invalid redirection table size: %u (1-%u)\n",
3187 res->size, max_reta_size);
3191 memset(reta_conf, 0, sizeof(reta_conf));
3192 if (showport_parse_reta_config(reta_conf, res->size,
3193 res->list_of_items) < 0) {
3194 printf("Invalid string: %s for reta masks\n",
3195 res->list_of_items);
3198 port_rss_reta_info(res->port_id, reta_conf, res->size);
3201 cmdline_parse_token_string_t cmd_showport_reta_show =
3202 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3203 cmdline_parse_token_string_t cmd_showport_reta_port =
3204 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3205 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3206 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3207 cmdline_parse_token_string_t cmd_showport_reta_rss =
3208 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3209 cmdline_parse_token_string_t cmd_showport_reta_reta =
3210 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3211 cmdline_parse_token_num_t cmd_showport_reta_size =
3212 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3213 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3214 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3215 list_of_items, NULL);
3217 cmdline_parse_inst_t cmd_showport_reta = {
3218 .f = cmd_showport_reta_parsed,
3220 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3222 (void *)&cmd_showport_reta_show,
3223 (void *)&cmd_showport_reta_port,
3224 (void *)&cmd_showport_reta_port_id,
3225 (void *)&cmd_showport_reta_rss,
3226 (void *)&cmd_showport_reta_reta,
3227 (void *)&cmd_showport_reta_size,
3228 (void *)&cmd_showport_reta_list_of_items,
3233 /* *** Show RSS hash configuration *** */
3234 struct cmd_showport_rss_hash {
3235 cmdline_fixed_string_t show;
3236 cmdline_fixed_string_t port;
3238 cmdline_fixed_string_t rss_hash;
3239 cmdline_fixed_string_t rss_type;
3240 cmdline_fixed_string_t key; /* optional argument */
3243 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3244 __rte_unused struct cmdline *cl,
3247 struct cmd_showport_rss_hash *res = parsed_result;
3249 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3252 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3253 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3254 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3255 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3256 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3257 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3258 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3259 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3261 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3262 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3264 cmdline_parse_inst_t cmd_showport_rss_hash = {
3265 .f = cmd_showport_rss_hash_parsed,
3267 .help_str = "show port <port_id> rss-hash",
3269 (void *)&cmd_showport_rss_hash_show,
3270 (void *)&cmd_showport_rss_hash_port,
3271 (void *)&cmd_showport_rss_hash_port_id,
3272 (void *)&cmd_showport_rss_hash_rss_hash,
3277 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3278 .f = cmd_showport_rss_hash_parsed,
3280 .help_str = "show port <port_id> rss-hash key",
3282 (void *)&cmd_showport_rss_hash_show,
3283 (void *)&cmd_showport_rss_hash_port,
3284 (void *)&cmd_showport_rss_hash_port_id,
3285 (void *)&cmd_showport_rss_hash_rss_hash,
3286 (void *)&cmd_showport_rss_hash_rss_key,
3291 /* *** Configure DCB *** */
3292 struct cmd_config_dcb {
3293 cmdline_fixed_string_t port;
3294 cmdline_fixed_string_t config;
3296 cmdline_fixed_string_t dcb;
3297 cmdline_fixed_string_t vt;
3298 cmdline_fixed_string_t vt_en;
3300 cmdline_fixed_string_t pfc;
3301 cmdline_fixed_string_t pfc_en;
3305 cmd_config_dcb_parsed(void *parsed_result,
3306 __rte_unused struct cmdline *cl,
3307 __rte_unused void *data)
3309 struct cmd_config_dcb *res = parsed_result;
3310 portid_t port_id = res->port_id;
3311 struct rte_port *port;
3315 port = &ports[port_id];
3316 /** Check if the port is not started **/
3317 if (port->port_status != RTE_PORT_STOPPED) {
3318 printf("Please stop port %d first\n", port_id);
3322 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3323 printf("The invalid number of traffic class,"
3324 " only 4 or 8 allowed.\n");
3328 if (nb_fwd_lcores < res->num_tcs) {
3329 printf("nb_cores shouldn't be less than number of TCs.\n");
3332 if (!strncmp(res->pfc_en, "on", 2))
3337 /* DCB in VT mode */
3338 if (!strncmp(res->vt_en, "on", 2))
3339 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3340 (enum rte_eth_nb_tcs)res->num_tcs,
3343 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3344 (enum rte_eth_nb_tcs)res->num_tcs,
3349 printf("Cannot initialize network ports.\n");
3353 cmd_reconfig_device_queue(port_id, 1, 1);
3356 cmdline_parse_token_string_t cmd_config_dcb_port =
3357 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3358 cmdline_parse_token_string_t cmd_config_dcb_config =
3359 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3360 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3361 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3362 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3363 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3364 cmdline_parse_token_string_t cmd_config_dcb_vt =
3365 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3366 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3367 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3368 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3369 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3370 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3371 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3372 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3373 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3375 cmdline_parse_inst_t cmd_config_dcb = {
3376 .f = cmd_config_dcb_parsed,
3378 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3380 (void *)&cmd_config_dcb_port,
3381 (void *)&cmd_config_dcb_config,
3382 (void *)&cmd_config_dcb_port_id,
3383 (void *)&cmd_config_dcb_dcb,
3384 (void *)&cmd_config_dcb_vt,
3385 (void *)&cmd_config_dcb_vt_en,
3386 (void *)&cmd_config_dcb_num_tcs,
3387 (void *)&cmd_config_dcb_pfc,
3388 (void *)&cmd_config_dcb_pfc_en,
3393 /* *** configure number of packets per burst *** */
3394 struct cmd_config_burst {
3395 cmdline_fixed_string_t port;
3396 cmdline_fixed_string_t keyword;
3397 cmdline_fixed_string_t all;
3398 cmdline_fixed_string_t name;
3403 cmd_config_burst_parsed(void *parsed_result,
3404 __rte_unused struct cmdline *cl,
3405 __rte_unused void *data)
3407 struct cmd_config_burst *res = parsed_result;
3408 struct rte_eth_dev_info dev_info;
3409 uint16_t rec_nb_pkts;
3412 if (!all_ports_stopped()) {
3413 printf("Please stop all ports first\n");
3417 if (!strcmp(res->name, "burst")) {
3418 if (res->value == 0) {
3419 /* If user gives a value of zero, query the PMD for
3420 * its recommended Rx burst size. Testpmd uses a single
3421 * size for all ports, so assume all ports are the same
3422 * NIC model and use the values from Port 0.
3424 ret = eth_dev_info_get_print_err(0, &dev_info);
3428 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3430 if (rec_nb_pkts == 0) {
3431 printf("PMD does not recommend a burst size.\n"
3432 "User provided value must be between"
3433 " 1 and %d\n", MAX_PKT_BURST);
3435 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3436 printf("PMD recommended burst size of %d"
3437 " exceeds maximum value of %d\n",
3438 rec_nb_pkts, MAX_PKT_BURST);
3441 printf("Using PMD-provided burst value of %d\n",
3443 nb_pkt_per_burst = rec_nb_pkts;
3444 } else if (res->value > MAX_PKT_BURST) {
3445 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3448 nb_pkt_per_burst = res->value;
3450 printf("Unknown parameter\n");
3456 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3459 cmdline_parse_token_string_t cmd_config_burst_port =
3460 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3461 cmdline_parse_token_string_t cmd_config_burst_keyword =
3462 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3463 cmdline_parse_token_string_t cmd_config_burst_all =
3464 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3465 cmdline_parse_token_string_t cmd_config_burst_name =
3466 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3467 cmdline_parse_token_num_t cmd_config_burst_value =
3468 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3470 cmdline_parse_inst_t cmd_config_burst = {
3471 .f = cmd_config_burst_parsed,
3473 .help_str = "port config all burst <value>",
3475 (void *)&cmd_config_burst_port,
3476 (void *)&cmd_config_burst_keyword,
3477 (void *)&cmd_config_burst_all,
3478 (void *)&cmd_config_burst_name,
3479 (void *)&cmd_config_burst_value,
3484 /* *** configure rx/tx queues *** */
3485 struct cmd_config_thresh {
3486 cmdline_fixed_string_t port;
3487 cmdline_fixed_string_t keyword;
3488 cmdline_fixed_string_t all;
3489 cmdline_fixed_string_t name;
3494 cmd_config_thresh_parsed(void *parsed_result,
3495 __rte_unused struct cmdline *cl,
3496 __rte_unused void *data)
3498 struct cmd_config_thresh *res = parsed_result;
3500 if (!all_ports_stopped()) {
3501 printf("Please stop all ports first\n");
3505 if (!strcmp(res->name, "txpt"))
3506 tx_pthresh = res->value;
3507 else if(!strcmp(res->name, "txht"))
3508 tx_hthresh = res->value;
3509 else if(!strcmp(res->name, "txwt"))
3510 tx_wthresh = res->value;
3511 else if(!strcmp(res->name, "rxpt"))
3512 rx_pthresh = res->value;
3513 else if(!strcmp(res->name, "rxht"))
3514 rx_hthresh = res->value;
3515 else if(!strcmp(res->name, "rxwt"))
3516 rx_wthresh = res->value;
3518 printf("Unknown parameter\n");
3524 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3527 cmdline_parse_token_string_t cmd_config_thresh_port =
3528 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3529 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3530 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3531 cmdline_parse_token_string_t cmd_config_thresh_all =
3532 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3533 cmdline_parse_token_string_t cmd_config_thresh_name =
3534 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3535 "txpt#txht#txwt#rxpt#rxht#rxwt");
3536 cmdline_parse_token_num_t cmd_config_thresh_value =
3537 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3539 cmdline_parse_inst_t cmd_config_thresh = {
3540 .f = cmd_config_thresh_parsed,
3542 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3544 (void *)&cmd_config_thresh_port,
3545 (void *)&cmd_config_thresh_keyword,
3546 (void *)&cmd_config_thresh_all,
3547 (void *)&cmd_config_thresh_name,
3548 (void *)&cmd_config_thresh_value,
3553 /* *** configure free/rs threshold *** */
3554 struct cmd_config_threshold {
3555 cmdline_fixed_string_t port;
3556 cmdline_fixed_string_t keyword;
3557 cmdline_fixed_string_t all;
3558 cmdline_fixed_string_t name;
3563 cmd_config_threshold_parsed(void *parsed_result,
3564 __rte_unused struct cmdline *cl,
3565 __rte_unused void *data)
3567 struct cmd_config_threshold *res = parsed_result;
3569 if (!all_ports_stopped()) {
3570 printf("Please stop all ports first\n");
3574 if (!strcmp(res->name, "txfreet"))
3575 tx_free_thresh = res->value;
3576 else if (!strcmp(res->name, "txrst"))
3577 tx_rs_thresh = res->value;
3578 else if (!strcmp(res->name, "rxfreet"))
3579 rx_free_thresh = res->value;
3581 printf("Unknown parameter\n");
3587 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3590 cmdline_parse_token_string_t cmd_config_threshold_port =
3591 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3592 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3593 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3595 cmdline_parse_token_string_t cmd_config_threshold_all =
3596 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3597 cmdline_parse_token_string_t cmd_config_threshold_name =
3598 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3599 "txfreet#txrst#rxfreet");
3600 cmdline_parse_token_num_t cmd_config_threshold_value =
3601 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3603 cmdline_parse_inst_t cmd_config_threshold = {
3604 .f = cmd_config_threshold_parsed,
3606 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3608 (void *)&cmd_config_threshold_port,
3609 (void *)&cmd_config_threshold_keyword,
3610 (void *)&cmd_config_threshold_all,
3611 (void *)&cmd_config_threshold_name,
3612 (void *)&cmd_config_threshold_value,
3618 struct cmd_stop_result {
3619 cmdline_fixed_string_t stop;
3622 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3623 __rte_unused struct cmdline *cl,
3624 __rte_unused void *data)
3626 stop_packet_forwarding();
3629 cmdline_parse_token_string_t cmd_stop_stop =
3630 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3632 cmdline_parse_inst_t cmd_stop = {
3633 .f = cmd_stop_parsed,
3635 .help_str = "stop: Stop packet forwarding",
3637 (void *)&cmd_stop_stop,
3642 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3645 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3646 unsigned int *parsed_items, int check_unique_values)
3648 unsigned int nb_item;
3656 * First parse all items in the list and store their value.
3661 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3663 if ((c >= '0') && (c <= '9')) {
3664 value = (unsigned int) (value * 10 + (c - '0'));
3669 printf("character %c is not a decimal digit\n", c);
3673 printf("No valid value before comma\n");
3676 if (nb_item < max_items) {
3677 parsed_items[nb_item] = value;
3683 if (nb_item >= max_items) {
3684 printf("Number of %s = %u > %u (maximum items)\n",
3685 item_name, nb_item + 1, max_items);
3688 parsed_items[nb_item++] = value;
3689 if (! check_unique_values)
3693 * Then, check that all values in the list are differents.
3694 * No optimization here...
3696 for (i = 0; i < nb_item; i++) {
3697 for (j = i + 1; j < nb_item; j++) {
3698 if (parsed_items[j] == parsed_items[i]) {
3699 printf("duplicated %s %u at index %u and %u\n",
3700 item_name, parsed_items[i], i, j);
3708 struct cmd_set_list_result {
3709 cmdline_fixed_string_t cmd_keyword;
3710 cmdline_fixed_string_t list_name;
3711 cmdline_fixed_string_t list_of_items;
3714 static void cmd_set_list_parsed(void *parsed_result,
3715 __rte_unused struct cmdline *cl,
3716 __rte_unused void *data)
3718 struct cmd_set_list_result *res;
3720 unsigned int lcorelist[RTE_MAX_LCORE];
3721 unsigned int portlist[RTE_MAX_ETHPORTS];
3723 unsigned int nb_item;
3725 if (test_done == 0) {
3726 printf("Please stop forwarding first\n");
3730 res = parsed_result;
3731 if (!strcmp(res->list_name, "corelist")) {
3732 nb_item = parse_item_list(res->list_of_items, "core",
3734 parsed_items.lcorelist, 1);
3736 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3741 if (!strcmp(res->list_name, "portlist")) {
3742 nb_item = parse_item_list(res->list_of_items, "port",
3744 parsed_items.portlist, 1);
3746 set_fwd_ports_list(parsed_items.portlist, nb_item);
3752 cmdline_parse_token_string_t cmd_set_list_keyword =
3753 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3755 cmdline_parse_token_string_t cmd_set_list_name =
3756 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3757 "corelist#portlist");
3758 cmdline_parse_token_string_t cmd_set_list_of_items =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3762 cmdline_parse_inst_t cmd_set_fwd_list = {
3763 .f = cmd_set_list_parsed,
3765 .help_str = "set corelist|portlist <list0[,list1]*>",
3767 (void *)&cmd_set_list_keyword,
3768 (void *)&cmd_set_list_name,
3769 (void *)&cmd_set_list_of_items,
3774 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3776 struct cmd_setmask_result {
3777 cmdline_fixed_string_t set;
3778 cmdline_fixed_string_t mask;
3782 static void cmd_set_mask_parsed(void *parsed_result,
3783 __rte_unused struct cmdline *cl,
3784 __rte_unused void *data)
3786 struct cmd_setmask_result *res = parsed_result;
3788 if (test_done == 0) {
3789 printf("Please stop forwarding first\n");
3792 if (!strcmp(res->mask, "coremask")) {
3793 set_fwd_lcores_mask(res->hexavalue);
3795 } else if (!strcmp(res->mask, "portmask")) {
3796 set_fwd_ports_mask(res->hexavalue);
3801 cmdline_parse_token_string_t cmd_setmask_set =
3802 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3803 cmdline_parse_token_string_t cmd_setmask_mask =
3804 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3805 "coremask#portmask");
3806 cmdline_parse_token_num_t cmd_setmask_value =
3807 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3809 cmdline_parse_inst_t cmd_set_fwd_mask = {
3810 .f = cmd_set_mask_parsed,
3812 .help_str = "set coremask|portmask <hexadecimal value>",
3814 (void *)&cmd_setmask_set,
3815 (void *)&cmd_setmask_mask,
3816 (void *)&cmd_setmask_value,
3822 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3824 struct cmd_set_result {
3825 cmdline_fixed_string_t set;
3826 cmdline_fixed_string_t what;
3830 static void cmd_set_parsed(void *parsed_result,
3831 __rte_unused struct cmdline *cl,
3832 __rte_unused void *data)
3834 struct cmd_set_result *res = parsed_result;
3835 if (!strcmp(res->what, "nbport")) {
3836 set_fwd_ports_number(res->value);
3838 } else if (!strcmp(res->what, "nbcore")) {
3839 set_fwd_lcores_number(res->value);
3841 } else if (!strcmp(res->what, "burst"))
3842 set_nb_pkt_per_burst(res->value);
3843 else if (!strcmp(res->what, "verbose"))
3844 set_verbose_level(res->value);
3847 cmdline_parse_token_string_t cmd_set_set =
3848 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3849 cmdline_parse_token_string_t cmd_set_what =
3850 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3851 "nbport#nbcore#burst#verbose");
3852 cmdline_parse_token_num_t cmd_set_value =
3853 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3855 cmdline_parse_inst_t cmd_set_numbers = {
3856 .f = cmd_set_parsed,
3858 .help_str = "set nbport|nbcore|burst|verbose <value>",
3860 (void *)&cmd_set_set,
3861 (void *)&cmd_set_what,
3862 (void *)&cmd_set_value,
3867 /* *** SET LOG LEVEL CONFIGURATION *** */
3869 struct cmd_set_log_result {
3870 cmdline_fixed_string_t set;
3871 cmdline_fixed_string_t log;
3872 cmdline_fixed_string_t type;
3877 cmd_set_log_parsed(void *parsed_result,
3878 __rte_unused struct cmdline *cl,
3879 __rte_unused void *data)
3881 struct cmd_set_log_result *res;
3884 res = parsed_result;
3885 if (!strcmp(res->type, "global"))
3886 rte_log_set_global_level(res->level);
3888 ret = rte_log_set_level_regexp(res->type, res->level);
3890 printf("Unable to set log level\n");
3894 cmdline_parse_token_string_t cmd_set_log_set =
3895 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3896 cmdline_parse_token_string_t cmd_set_log_log =
3897 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3898 cmdline_parse_token_string_t cmd_set_log_type =
3899 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3900 cmdline_parse_token_num_t cmd_set_log_level =
3901 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3903 cmdline_parse_inst_t cmd_set_log = {
3904 .f = cmd_set_log_parsed,
3906 .help_str = "set log global|<type> <level>",
3908 (void *)&cmd_set_log_set,
3909 (void *)&cmd_set_log_log,
3910 (void *)&cmd_set_log_type,
3911 (void *)&cmd_set_log_level,
3916 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3918 struct cmd_set_rxpkts_result {
3919 cmdline_fixed_string_t cmd_keyword;
3920 cmdline_fixed_string_t rxpkts;
3921 cmdline_fixed_string_t seg_lengths;
3925 cmd_set_rxpkts_parsed(void *parsed_result,
3926 __rte_unused struct cmdline *cl,
3927 __rte_unused void *data)
3929 struct cmd_set_rxpkts_result *res;
3930 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3931 unsigned int nb_segs;
3933 res = parsed_result;
3934 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3935 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3937 set_rx_pkt_segments(seg_lengths, nb_segs);
3940 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3941 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3942 cmd_keyword, "set");
3943 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3944 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3946 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3947 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3950 cmdline_parse_inst_t cmd_set_rxpkts = {
3951 .f = cmd_set_rxpkts_parsed,
3953 .help_str = "set rxpkts <len0[,len1]*>",
3955 (void *)&cmd_set_rxpkts_keyword,
3956 (void *)&cmd_set_rxpkts_name,
3957 (void *)&cmd_set_rxpkts_lengths,
3962 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3964 struct cmd_set_txpkts_result {
3965 cmdline_fixed_string_t cmd_keyword;
3966 cmdline_fixed_string_t txpkts;
3967 cmdline_fixed_string_t seg_lengths;
3971 cmd_set_txpkts_parsed(void *parsed_result,
3972 __rte_unused struct cmdline *cl,
3973 __rte_unused void *data)
3975 struct cmd_set_txpkts_result *res;
3976 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3977 unsigned int nb_segs;
3979 res = parsed_result;
3980 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3981 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3983 set_tx_pkt_segments(seg_lengths, nb_segs);
3986 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3987 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3988 cmd_keyword, "set");
3989 cmdline_parse_token_string_t cmd_set_txpkts_name =
3990 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3992 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3996 cmdline_parse_inst_t cmd_set_txpkts = {
3997 .f = cmd_set_txpkts_parsed,
3999 .help_str = "set txpkts <len0[,len1]*>",
4001 (void *)&cmd_set_txpkts_keyword,
4002 (void *)&cmd_set_txpkts_name,
4003 (void *)&cmd_set_txpkts_lengths,
4008 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4010 struct cmd_set_txsplit_result {
4011 cmdline_fixed_string_t cmd_keyword;
4012 cmdline_fixed_string_t txsplit;
4013 cmdline_fixed_string_t mode;
4017 cmd_set_txsplit_parsed(void *parsed_result,
4018 __rte_unused struct cmdline *cl,
4019 __rte_unused void *data)
4021 struct cmd_set_txsplit_result *res;
4023 res = parsed_result;
4024 set_tx_pkt_split(res->mode);
4027 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4028 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4029 cmd_keyword, "set");
4030 cmdline_parse_token_string_t cmd_set_txsplit_name =
4031 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4032 txsplit, "txsplit");
4033 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4034 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4037 cmdline_parse_inst_t cmd_set_txsplit = {
4038 .f = cmd_set_txsplit_parsed,
4040 .help_str = "set txsplit on|off|rand",
4042 (void *)&cmd_set_txsplit_keyword,
4043 (void *)&cmd_set_txsplit_name,
4044 (void *)&cmd_set_txsplit_mode,
4049 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4051 struct cmd_set_txtimes_result {
4052 cmdline_fixed_string_t cmd_keyword;
4053 cmdline_fixed_string_t txtimes;
4054 cmdline_fixed_string_t tx_times;
4058 cmd_set_txtimes_parsed(void *parsed_result,
4059 __rte_unused struct cmdline *cl,
4060 __rte_unused void *data)
4062 struct cmd_set_txtimes_result *res;
4063 unsigned int tx_times[2] = {0, 0};
4064 unsigned int n_times;
4066 res = parsed_result;
4067 n_times = parse_item_list(res->tx_times, "tx times",
4070 set_tx_pkt_times(tx_times);
4073 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4074 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4075 cmd_keyword, "set");
4076 cmdline_parse_token_string_t cmd_set_txtimes_name =
4077 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4078 txtimes, "txtimes");
4079 cmdline_parse_token_string_t cmd_set_txtimes_value =
4080 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4083 cmdline_parse_inst_t cmd_set_txtimes = {
4084 .f = cmd_set_txtimes_parsed,
4086 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4088 (void *)&cmd_set_txtimes_keyword,
4089 (void *)&cmd_set_txtimes_name,
4090 (void *)&cmd_set_txtimes_value,
4095 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4096 struct cmd_rx_vlan_filter_all_result {
4097 cmdline_fixed_string_t rx_vlan;
4098 cmdline_fixed_string_t what;
4099 cmdline_fixed_string_t all;
4104 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4105 __rte_unused struct cmdline *cl,
4106 __rte_unused void *data)
4108 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4110 if (!strcmp(res->what, "add"))
4111 rx_vlan_all_filter_set(res->port_id, 1);
4113 rx_vlan_all_filter_set(res->port_id, 0);
4116 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4117 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4118 rx_vlan, "rx_vlan");
4119 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4120 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4122 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4123 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4125 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4126 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4129 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4130 .f = cmd_rx_vlan_filter_all_parsed,
4132 .help_str = "rx_vlan add|rm all <port_id>: "
4133 "Add/Remove all identifiers to/from the set of VLAN "
4134 "identifiers filtered by a port",
4136 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4137 (void *)&cmd_rx_vlan_filter_all_what,
4138 (void *)&cmd_rx_vlan_filter_all_all,
4139 (void *)&cmd_rx_vlan_filter_all_portid,
4144 /* *** VLAN OFFLOAD SET ON A PORT *** */
4145 struct cmd_vlan_offload_result {
4146 cmdline_fixed_string_t vlan;
4147 cmdline_fixed_string_t set;
4148 cmdline_fixed_string_t vlan_type;
4149 cmdline_fixed_string_t what;
4150 cmdline_fixed_string_t on;
4151 cmdline_fixed_string_t port_id;
4155 cmd_vlan_offload_parsed(void *parsed_result,
4156 __rte_unused struct cmdline *cl,
4157 __rte_unused void *data)
4160 struct cmd_vlan_offload_result *res = parsed_result;
4163 portid_t port_id = 0;
4167 len = strnlen(str, STR_TOKEN_SIZE);
4169 /* Get port_id first */
4177 tmp = strtoul(str, NULL, 0);
4178 /* If port_id greater that what portid_t can represent, return */
4179 if(tmp >= RTE_MAX_ETHPORTS)
4181 port_id = (portid_t)tmp;
4183 if (!strcmp(res->on, "on"))
4188 if (!strcmp(res->what, "strip"))
4189 rx_vlan_strip_set(port_id, on);
4190 else if(!strcmp(res->what, "stripq")){
4191 uint16_t queue_id = 0;
4193 /* No queue_id, return */
4195 printf("must specify (port,queue_id)\n");
4198 tmp = strtoul(str + i + 1, NULL, 0);
4199 /* If queue_id greater that what 16-bits can represent, return */
4203 queue_id = (uint16_t)tmp;
4204 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4206 else if (!strcmp(res->what, "filter"))
4207 rx_vlan_filter_set(port_id, on);
4208 else if (!strcmp(res->what, "qinq_strip"))
4209 rx_vlan_qinq_strip_set(port_id, on);
4211 vlan_extend_set(port_id, on);
4216 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4217 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4219 cmdline_parse_token_string_t cmd_vlan_offload_set =
4220 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4222 cmdline_parse_token_string_t cmd_vlan_offload_what =
4223 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4224 what, "strip#filter#qinq_strip#extend#stripq");
4225 cmdline_parse_token_string_t cmd_vlan_offload_on =
4226 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4228 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4229 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4232 cmdline_parse_inst_t cmd_vlan_offload = {
4233 .f = cmd_vlan_offload_parsed,
4235 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4236 "<port_id[,queue_id]>: "
4237 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4239 (void *)&cmd_vlan_offload_vlan,
4240 (void *)&cmd_vlan_offload_set,
4241 (void *)&cmd_vlan_offload_what,
4242 (void *)&cmd_vlan_offload_on,
4243 (void *)&cmd_vlan_offload_portid,
4248 /* *** VLAN TPID SET ON A PORT *** */
4249 struct cmd_vlan_tpid_result {
4250 cmdline_fixed_string_t vlan;
4251 cmdline_fixed_string_t set;
4252 cmdline_fixed_string_t vlan_type;
4253 cmdline_fixed_string_t what;
4259 cmd_vlan_tpid_parsed(void *parsed_result,
4260 __rte_unused struct cmdline *cl,
4261 __rte_unused void *data)
4263 struct cmd_vlan_tpid_result *res = parsed_result;
4264 enum rte_vlan_type vlan_type;
4266 if (!strcmp(res->vlan_type, "inner"))
4267 vlan_type = ETH_VLAN_TYPE_INNER;
4268 else if (!strcmp(res->vlan_type, "outer"))
4269 vlan_type = ETH_VLAN_TYPE_OUTER;
4271 printf("Unknown vlan type\n");
4274 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4277 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4278 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4280 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4281 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4283 cmdline_parse_token_string_t cmd_vlan_type =
4284 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4285 vlan_type, "inner#outer");
4286 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4287 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4289 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4290 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4292 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4293 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4296 cmdline_parse_inst_t cmd_vlan_tpid = {
4297 .f = cmd_vlan_tpid_parsed,
4299 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4300 "Set the VLAN Ether type",
4302 (void *)&cmd_vlan_tpid_vlan,
4303 (void *)&cmd_vlan_tpid_set,
4304 (void *)&cmd_vlan_type,
4305 (void *)&cmd_vlan_tpid_what,
4306 (void *)&cmd_vlan_tpid_tpid,
4307 (void *)&cmd_vlan_tpid_portid,
4312 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4313 struct cmd_rx_vlan_filter_result {
4314 cmdline_fixed_string_t rx_vlan;
4315 cmdline_fixed_string_t what;
4321 cmd_rx_vlan_filter_parsed(void *parsed_result,
4322 __rte_unused struct cmdline *cl,
4323 __rte_unused void *data)
4325 struct cmd_rx_vlan_filter_result *res = parsed_result;
4327 if (!strcmp(res->what, "add"))
4328 rx_vft_set(res->port_id, res->vlan_id, 1);
4330 rx_vft_set(res->port_id, res->vlan_id, 0);
4333 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4334 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4335 rx_vlan, "rx_vlan");
4336 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4337 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4339 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4340 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4342 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4343 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4346 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4347 .f = cmd_rx_vlan_filter_parsed,
4349 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4350 "Add/Remove a VLAN identifier to/from the set of VLAN "
4351 "identifiers filtered by a port",
4353 (void *)&cmd_rx_vlan_filter_rx_vlan,
4354 (void *)&cmd_rx_vlan_filter_what,
4355 (void *)&cmd_rx_vlan_filter_vlanid,
4356 (void *)&cmd_rx_vlan_filter_portid,
4361 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4362 struct cmd_tx_vlan_set_result {
4363 cmdline_fixed_string_t tx_vlan;
4364 cmdline_fixed_string_t set;
4370 cmd_tx_vlan_set_parsed(void *parsed_result,
4371 __rte_unused struct cmdline *cl,
4372 __rte_unused void *data)
4374 struct cmd_tx_vlan_set_result *res = parsed_result;
4376 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4379 if (!port_is_stopped(res->port_id)) {
4380 printf("Please stop port %d first\n", res->port_id);
4384 tx_vlan_set(res->port_id, res->vlan_id);
4386 cmd_reconfig_device_queue(res->port_id, 1, 1);
4389 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4390 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4391 tx_vlan, "tx_vlan");
4392 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4393 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4395 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4396 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4398 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4399 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4402 cmdline_parse_inst_t cmd_tx_vlan_set = {
4403 .f = cmd_tx_vlan_set_parsed,
4405 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4406 "Enable hardware insertion of a single VLAN header "
4407 "with a given TAG Identifier in packets sent on a port",
4409 (void *)&cmd_tx_vlan_set_tx_vlan,
4410 (void *)&cmd_tx_vlan_set_set,
4411 (void *)&cmd_tx_vlan_set_portid,
4412 (void *)&cmd_tx_vlan_set_vlanid,
4417 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4418 struct cmd_tx_vlan_set_qinq_result {
4419 cmdline_fixed_string_t tx_vlan;
4420 cmdline_fixed_string_t set;
4423 uint16_t vlan_id_outer;
4427 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4428 __rte_unused struct cmdline *cl,
4429 __rte_unused void *data)
4431 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4433 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4436 if (!port_is_stopped(res->port_id)) {
4437 printf("Please stop port %d first\n", res->port_id);
4441 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4443 cmd_reconfig_device_queue(res->port_id, 1, 1);
4446 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4447 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4448 tx_vlan, "tx_vlan");
4449 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4450 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4452 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4453 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4455 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4456 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4458 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4459 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4460 vlan_id_outer, UINT16);
4462 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4463 .f = cmd_tx_vlan_set_qinq_parsed,
4465 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4466 "Enable hardware insertion of double VLAN header "
4467 "with given TAG Identifiers in packets sent on a port",
4469 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4470 (void *)&cmd_tx_vlan_set_qinq_set,
4471 (void *)&cmd_tx_vlan_set_qinq_portid,
4472 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4473 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4478 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4479 struct cmd_tx_vlan_set_pvid_result {
4480 cmdline_fixed_string_t tx_vlan;
4481 cmdline_fixed_string_t set;
4482 cmdline_fixed_string_t pvid;
4485 cmdline_fixed_string_t mode;
4489 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4490 __rte_unused struct cmdline *cl,
4491 __rte_unused void *data)
4493 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4495 if (strcmp(res->mode, "on") == 0)
4496 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4498 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4501 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4502 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4503 tx_vlan, "tx_vlan");
4504 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4505 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4507 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4508 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4510 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4511 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4513 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4514 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4516 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4517 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4520 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4521 .f = cmd_tx_vlan_set_pvid_parsed,
4523 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4525 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4526 (void *)&cmd_tx_vlan_set_pvid_set,
4527 (void *)&cmd_tx_vlan_set_pvid_pvid,
4528 (void *)&cmd_tx_vlan_set_pvid_port_id,
4529 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4530 (void *)&cmd_tx_vlan_set_pvid_mode,
4535 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4536 struct cmd_tx_vlan_reset_result {
4537 cmdline_fixed_string_t tx_vlan;
4538 cmdline_fixed_string_t reset;
4543 cmd_tx_vlan_reset_parsed(void *parsed_result,
4544 __rte_unused struct cmdline *cl,
4545 __rte_unused void *data)
4547 struct cmd_tx_vlan_reset_result *res = parsed_result;
4549 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4552 if (!port_is_stopped(res->port_id)) {
4553 printf("Please stop port %d first\n", res->port_id);
4557 tx_vlan_reset(res->port_id);
4559 cmd_reconfig_device_queue(res->port_id, 1, 1);
4562 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4563 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4564 tx_vlan, "tx_vlan");
4565 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4566 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4568 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4569 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4572 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4573 .f = cmd_tx_vlan_reset_parsed,
4575 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4576 "VLAN header in packets sent on a port",
4578 (void *)&cmd_tx_vlan_reset_tx_vlan,
4579 (void *)&cmd_tx_vlan_reset_reset,
4580 (void *)&cmd_tx_vlan_reset_portid,
4586 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4587 struct cmd_csum_result {
4588 cmdline_fixed_string_t csum;
4589 cmdline_fixed_string_t mode;
4590 cmdline_fixed_string_t proto;
4591 cmdline_fixed_string_t hwsw;
4596 csum_show(int port_id)
4598 struct rte_eth_dev_info dev_info;
4599 uint64_t tx_offloads;
4602 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4603 printf("Parse tunnel is %s\n",
4604 (ports[port_id].parse_tunnel) ? "on" : "off");
4605 printf("IP checksum offload is %s\n",
4606 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4607 printf("UDP checksum offload is %s\n",
4608 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4609 printf("TCP checksum offload is %s\n",
4610 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4611 printf("SCTP checksum offload is %s\n",
4612 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4613 printf("Outer-Ip checksum offload is %s\n",
4614 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4615 printf("Outer-Udp checksum offload is %s\n",
4616 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4618 /* display warnings if configuration is not supported by the NIC */
4619 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4623 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4624 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4625 printf("Warning: hardware IP checksum enabled but not "
4626 "supported by port %d\n", port_id);
4628 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4629 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4630 printf("Warning: hardware UDP checksum enabled but not "
4631 "supported by port %d\n", port_id);
4633 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4634 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4635 printf("Warning: hardware TCP checksum enabled but not "
4636 "supported by port %d\n", port_id);
4638 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4639 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4640 printf("Warning: hardware SCTP checksum enabled but not "
4641 "supported by port %d\n", port_id);
4643 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4644 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4645 printf("Warning: hardware outer IP checksum enabled but not "
4646 "supported by port %d\n", port_id);
4648 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4649 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4651 printf("Warning: hardware outer UDP checksum enabled but not "
4652 "supported by port %d\n", port_id);
4657 cmd_config_queue_tx_offloads(struct rte_port *port)
4661 /* Apply queue tx offloads configuration */
4662 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4663 port->tx_conf[k].offloads =
4664 port->dev_conf.txmode.offloads;
4668 cmd_csum_parsed(void *parsed_result,
4669 __rte_unused struct cmdline *cl,
4670 __rte_unused void *data)
4672 struct cmd_csum_result *res = parsed_result;
4674 uint64_t csum_offloads = 0;
4675 struct rte_eth_dev_info dev_info;
4678 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4679 printf("invalid port %d\n", res->port_id);
4682 if (!port_is_stopped(res->port_id)) {
4683 printf("Please stop port %d first\n", res->port_id);
4687 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4691 if (!strcmp(res->mode, "set")) {
4693 if (!strcmp(res->hwsw, "hw"))
4696 if (!strcmp(res->proto, "ip")) {
4697 if (hw == 0 || (dev_info.tx_offload_capa &
4698 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4699 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4701 printf("IP checksum offload is not supported "
4702 "by port %u\n", res->port_id);
4704 } else if (!strcmp(res->proto, "udp")) {
4705 if (hw == 0 || (dev_info.tx_offload_capa &
4706 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4707 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4709 printf("UDP checksum offload is not supported "
4710 "by port %u\n", res->port_id);
4712 } else if (!strcmp(res->proto, "tcp")) {
4713 if (hw == 0 || (dev_info.tx_offload_capa &
4714 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4715 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4717 printf("TCP checksum offload is not supported "
4718 "by port %u\n", res->port_id);
4720 } else if (!strcmp(res->proto, "sctp")) {
4721 if (hw == 0 || (dev_info.tx_offload_capa &
4722 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4723 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4725 printf("SCTP checksum offload is not supported "
4726 "by port %u\n", res->port_id);
4728 } else if (!strcmp(res->proto, "outer-ip")) {
4729 if (hw == 0 || (dev_info.tx_offload_capa &
4730 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4732 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4734 printf("Outer IP checksum offload is not "
4735 "supported by port %u\n", res->port_id);
4737 } else if (!strcmp(res->proto, "outer-udp")) {
4738 if (hw == 0 || (dev_info.tx_offload_capa &
4739 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4741 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4743 printf("Outer UDP checksum offload is not "
4744 "supported by port %u\n", res->port_id);
4749 ports[res->port_id].dev_conf.txmode.offloads |=
4752 ports[res->port_id].dev_conf.txmode.offloads &=
4755 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4757 csum_show(res->port_id);
4759 cmd_reconfig_device_queue(res->port_id, 1, 1);
4762 cmdline_parse_token_string_t cmd_csum_csum =
4763 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4765 cmdline_parse_token_string_t cmd_csum_mode =
4766 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4768 cmdline_parse_token_string_t cmd_csum_proto =
4769 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4770 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4771 cmdline_parse_token_string_t cmd_csum_hwsw =
4772 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4774 cmdline_parse_token_num_t cmd_csum_portid =
4775 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4778 cmdline_parse_inst_t cmd_csum_set = {
4779 .f = cmd_csum_parsed,
4781 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4782 "Enable/Disable hardware calculation of L3/L4 checksum when "
4783 "using csum forward engine",
4785 (void *)&cmd_csum_csum,
4786 (void *)&cmd_csum_mode,
4787 (void *)&cmd_csum_proto,
4788 (void *)&cmd_csum_hwsw,
4789 (void *)&cmd_csum_portid,
4794 cmdline_parse_token_string_t cmd_csum_mode_show =
4795 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4798 cmdline_parse_inst_t cmd_csum_show = {
4799 .f = cmd_csum_parsed,
4801 .help_str = "csum show <port_id>: Show checksum offload configuration",
4803 (void *)&cmd_csum_csum,
4804 (void *)&cmd_csum_mode_show,
4805 (void *)&cmd_csum_portid,
4810 /* Enable/disable tunnel parsing */
4811 struct cmd_csum_tunnel_result {
4812 cmdline_fixed_string_t csum;
4813 cmdline_fixed_string_t parse;
4814 cmdline_fixed_string_t onoff;
4819 cmd_csum_tunnel_parsed(void *parsed_result,
4820 __rte_unused struct cmdline *cl,
4821 __rte_unused void *data)
4823 struct cmd_csum_tunnel_result *res = parsed_result;
4825 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4828 if (!strcmp(res->onoff, "on"))
4829 ports[res->port_id].parse_tunnel = 1;
4831 ports[res->port_id].parse_tunnel = 0;
4833 csum_show(res->port_id);
4836 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4837 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4839 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4840 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4841 parse, "parse-tunnel");
4842 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4843 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4845 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4846 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4849 cmdline_parse_inst_t cmd_csum_tunnel = {
4850 .f = cmd_csum_tunnel_parsed,
4852 .help_str = "csum parse-tunnel on|off <port_id>: "
4853 "Enable/Disable parsing of tunnels for csum engine",
4855 (void *)&cmd_csum_tunnel_csum,
4856 (void *)&cmd_csum_tunnel_parse,
4857 (void *)&cmd_csum_tunnel_onoff,
4858 (void *)&cmd_csum_tunnel_portid,
4863 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4864 struct cmd_tso_set_result {
4865 cmdline_fixed_string_t tso;
4866 cmdline_fixed_string_t mode;
4872 cmd_tso_set_parsed(void *parsed_result,
4873 __rte_unused struct cmdline *cl,
4874 __rte_unused void *data)
4876 struct cmd_tso_set_result *res = parsed_result;
4877 struct rte_eth_dev_info dev_info;
4880 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4882 if (!port_is_stopped(res->port_id)) {
4883 printf("Please stop port %d first\n", res->port_id);
4887 if (!strcmp(res->mode, "set"))
4888 ports[res->port_id].tso_segsz = res->tso_segsz;
4890 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4894 if ((ports[res->port_id].tso_segsz != 0) &&
4895 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4896 printf("Error: TSO is not supported by port %d\n",
4901 if (ports[res->port_id].tso_segsz == 0) {
4902 ports[res->port_id].dev_conf.txmode.offloads &=
4903 ~DEV_TX_OFFLOAD_TCP_TSO;
4904 printf("TSO for non-tunneled packets is disabled\n");
4906 ports[res->port_id].dev_conf.txmode.offloads |=
4907 DEV_TX_OFFLOAD_TCP_TSO;
4908 printf("TSO segment size for non-tunneled packets is %d\n",
4909 ports[res->port_id].tso_segsz);
4911 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4913 /* display warnings if configuration is not supported by the NIC */
4914 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4918 if ((ports[res->port_id].tso_segsz != 0) &&
4919 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4920 printf("Warning: TSO enabled but not "
4921 "supported by port %d\n", res->port_id);
4924 cmd_reconfig_device_queue(res->port_id, 1, 1);
4927 cmdline_parse_token_string_t cmd_tso_set_tso =
4928 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4930 cmdline_parse_token_string_t cmd_tso_set_mode =
4931 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4933 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4934 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4936 cmdline_parse_token_num_t cmd_tso_set_portid =
4937 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4940 cmdline_parse_inst_t cmd_tso_set = {
4941 .f = cmd_tso_set_parsed,
4943 .help_str = "tso set <tso_segsz> <port_id>: "
4944 "Set TSO segment size of non-tunneled packets for csum engine "
4947 (void *)&cmd_tso_set_tso,
4948 (void *)&cmd_tso_set_mode,
4949 (void *)&cmd_tso_set_tso_segsz,
4950 (void *)&cmd_tso_set_portid,
4955 cmdline_parse_token_string_t cmd_tso_show_mode =
4956 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4960 cmdline_parse_inst_t cmd_tso_show = {
4961 .f = cmd_tso_set_parsed,
4963 .help_str = "tso show <port_id>: "
4964 "Show TSO segment size of non-tunneled packets for csum engine",
4966 (void *)&cmd_tso_set_tso,
4967 (void *)&cmd_tso_show_mode,
4968 (void *)&cmd_tso_set_portid,
4973 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4974 struct cmd_tunnel_tso_set_result {
4975 cmdline_fixed_string_t tso;
4976 cmdline_fixed_string_t mode;
4981 static struct rte_eth_dev_info
4982 check_tunnel_tso_nic_support(portid_t port_id)
4984 struct rte_eth_dev_info dev_info;
4986 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4989 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4990 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4991 "not enabled for port %d\n", port_id);
4992 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4993 printf("Warning: GRE TUNNEL TSO not supported therefore "
4994 "not enabled for port %d\n", port_id);
4995 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4996 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4997 "not enabled for port %d\n", port_id);
4998 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4999 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5000 "not enabled for port %d\n", port_id);
5001 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5002 printf("Warning: IP TUNNEL TSO not supported therefore "
5003 "not enabled for port %d\n", port_id);
5004 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5005 printf("Warning: UDP TUNNEL TSO not supported therefore "
5006 "not enabled for port %d\n", port_id);
5011 cmd_tunnel_tso_set_parsed(void *parsed_result,
5012 __rte_unused struct cmdline *cl,
5013 __rte_unused void *data)
5015 struct cmd_tunnel_tso_set_result *res = parsed_result;
5016 struct rte_eth_dev_info dev_info;
5018 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5020 if (!port_is_stopped(res->port_id)) {
5021 printf("Please stop port %d first\n", res->port_id);
5025 if (!strcmp(res->mode, "set"))
5026 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5028 dev_info = check_tunnel_tso_nic_support(res->port_id);
5029 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5030 ports[res->port_id].dev_conf.txmode.offloads &=
5031 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5032 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5033 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5034 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5035 DEV_TX_OFFLOAD_IP_TNL_TSO |
5036 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5037 printf("TSO for tunneled packets is disabled\n");
5039 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5040 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5041 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5042 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5043 DEV_TX_OFFLOAD_IP_TNL_TSO |
5044 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5046 ports[res->port_id].dev_conf.txmode.offloads |=
5047 (tso_offloads & dev_info.tx_offload_capa);
5048 printf("TSO segment size for tunneled packets is %d\n",
5049 ports[res->port_id].tunnel_tso_segsz);
5051 /* Below conditions are needed to make it work:
5052 * (1) tunnel TSO is supported by the NIC;
5053 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5055 * (3) for tunneled pkts with outer L3 of IPv4,
5056 * "csum set outer-ip" must be set to hw, because after tso,
5057 * total_len of outer IP header is changed, and the checksum
5058 * of outer IP header calculated by sw should be wrong; that
5059 * is not necessary for IPv6 tunneled pkts because there's no
5060 * checksum in IP header anymore.
5063 if (!ports[res->port_id].parse_tunnel)
5064 printf("Warning: csum parse_tunnel must be set "
5065 "so that tunneled packets are recognized\n");
5066 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5067 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5068 printf("Warning: csum set outer-ip must be set to hw "
5069 "if outer L3 is IPv4; not necessary for IPv6\n");
5072 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5073 cmd_reconfig_device_queue(res->port_id, 1, 1);
5076 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5077 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5079 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5080 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5082 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5083 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5085 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5086 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5089 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5090 .f = cmd_tunnel_tso_set_parsed,
5092 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5093 "Set TSO segment size of tunneled packets for csum engine "
5096 (void *)&cmd_tunnel_tso_set_tso,
5097 (void *)&cmd_tunnel_tso_set_mode,
5098 (void *)&cmd_tunnel_tso_set_tso_segsz,
5099 (void *)&cmd_tunnel_tso_set_portid,
5104 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5105 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5109 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5110 .f = cmd_tunnel_tso_set_parsed,
5112 .help_str = "tunnel_tso show <port_id> "
5113 "Show TSO segment size of tunneled packets for csum engine",
5115 (void *)&cmd_tunnel_tso_set_tso,
5116 (void *)&cmd_tunnel_tso_show_mode,
5117 (void *)&cmd_tunnel_tso_set_portid,
5122 /* *** SET GRO FOR A PORT *** */
5123 struct cmd_gro_enable_result {
5124 cmdline_fixed_string_t cmd_set;
5125 cmdline_fixed_string_t cmd_port;
5126 cmdline_fixed_string_t cmd_keyword;
5127 cmdline_fixed_string_t cmd_onoff;
5132 cmd_gro_enable_parsed(void *parsed_result,
5133 __rte_unused struct cmdline *cl,
5134 __rte_unused void *data)
5136 struct cmd_gro_enable_result *res;
5138 res = parsed_result;
5139 if (!strcmp(res->cmd_keyword, "gro"))
5140 setup_gro(res->cmd_onoff, res->cmd_pid);
5143 cmdline_parse_token_string_t cmd_gro_enable_set =
5144 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5146 cmdline_parse_token_string_t cmd_gro_enable_port =
5147 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5148 cmd_keyword, "port");
5149 cmdline_parse_token_num_t cmd_gro_enable_pid =
5150 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5152 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5153 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5154 cmd_keyword, "gro");
5155 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5156 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5157 cmd_onoff, "on#off");
5159 cmdline_parse_inst_t cmd_gro_enable = {
5160 .f = cmd_gro_enable_parsed,
5162 .help_str = "set port <port_id> gro on|off",
5164 (void *)&cmd_gro_enable_set,
5165 (void *)&cmd_gro_enable_port,
5166 (void *)&cmd_gro_enable_pid,
5167 (void *)&cmd_gro_enable_keyword,
5168 (void *)&cmd_gro_enable_onoff,
5173 /* *** DISPLAY GRO CONFIGURATION *** */
5174 struct cmd_gro_show_result {
5175 cmdline_fixed_string_t cmd_show;
5176 cmdline_fixed_string_t cmd_port;
5177 cmdline_fixed_string_t cmd_keyword;
5182 cmd_gro_show_parsed(void *parsed_result,
5183 __rte_unused struct cmdline *cl,
5184 __rte_unused void *data)
5186 struct cmd_gro_show_result *res;
5188 res = parsed_result;
5189 if (!strcmp(res->cmd_keyword, "gro"))
5190 show_gro(res->cmd_pid);
5193 cmdline_parse_token_string_t cmd_gro_show_show =
5194 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5196 cmdline_parse_token_string_t cmd_gro_show_port =
5197 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5199 cmdline_parse_token_num_t cmd_gro_show_pid =
5200 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5202 cmdline_parse_token_string_t cmd_gro_show_keyword =
5203 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5204 cmd_keyword, "gro");
5206 cmdline_parse_inst_t cmd_gro_show = {
5207 .f = cmd_gro_show_parsed,
5209 .help_str = "show port <port_id> gro",
5211 (void *)&cmd_gro_show_show,
5212 (void *)&cmd_gro_show_port,
5213 (void *)&cmd_gro_show_pid,
5214 (void *)&cmd_gro_show_keyword,
5219 /* *** SET FLUSH CYCLES FOR GRO *** */
5220 struct cmd_gro_flush_result {
5221 cmdline_fixed_string_t cmd_set;
5222 cmdline_fixed_string_t cmd_keyword;
5223 cmdline_fixed_string_t cmd_flush;
5228 cmd_gro_flush_parsed(void *parsed_result,
5229 __rte_unused struct cmdline *cl,
5230 __rte_unused void *data)
5232 struct cmd_gro_flush_result *res;
5234 res = parsed_result;
5235 if ((!strcmp(res->cmd_keyword, "gro")) &&
5236 (!strcmp(res->cmd_flush, "flush")))
5237 setup_gro_flush_cycles(res->cmd_cycles);
5240 cmdline_parse_token_string_t cmd_gro_flush_set =
5241 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5243 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5244 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5245 cmd_keyword, "gro");
5246 cmdline_parse_token_string_t cmd_gro_flush_flush =
5247 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5248 cmd_flush, "flush");
5249 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5250 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5253 cmdline_parse_inst_t cmd_gro_flush = {
5254 .f = cmd_gro_flush_parsed,
5256 .help_str = "set gro flush <cycles>",
5258 (void *)&cmd_gro_flush_set,
5259 (void *)&cmd_gro_flush_keyword,
5260 (void *)&cmd_gro_flush_flush,
5261 (void *)&cmd_gro_flush_cycles,
5266 /* *** ENABLE/DISABLE GSO *** */
5267 struct cmd_gso_enable_result {
5268 cmdline_fixed_string_t cmd_set;
5269 cmdline_fixed_string_t cmd_port;
5270 cmdline_fixed_string_t cmd_keyword;
5271 cmdline_fixed_string_t cmd_mode;
5276 cmd_gso_enable_parsed(void *parsed_result,
5277 __rte_unused struct cmdline *cl,
5278 __rte_unused void *data)
5280 struct cmd_gso_enable_result *res;
5282 res = parsed_result;
5283 if (!strcmp(res->cmd_keyword, "gso"))
5284 setup_gso(res->cmd_mode, res->cmd_pid);
5287 cmdline_parse_token_string_t cmd_gso_enable_set =
5288 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5290 cmdline_parse_token_string_t cmd_gso_enable_port =
5291 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5293 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5294 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5295 cmd_keyword, "gso");
5296 cmdline_parse_token_string_t cmd_gso_enable_mode =
5297 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5298 cmd_mode, "on#off");
5299 cmdline_parse_token_num_t cmd_gso_enable_pid =
5300 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5303 cmdline_parse_inst_t cmd_gso_enable = {
5304 .f = cmd_gso_enable_parsed,
5306 .help_str = "set port <port_id> gso on|off",
5308 (void *)&cmd_gso_enable_set,
5309 (void *)&cmd_gso_enable_port,
5310 (void *)&cmd_gso_enable_pid,
5311 (void *)&cmd_gso_enable_keyword,
5312 (void *)&cmd_gso_enable_mode,
5317 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5318 struct cmd_gso_size_result {
5319 cmdline_fixed_string_t cmd_set;
5320 cmdline_fixed_string_t cmd_keyword;
5321 cmdline_fixed_string_t cmd_segsz;
5326 cmd_gso_size_parsed(void *parsed_result,
5327 __rte_unused struct cmdline *cl,
5328 __rte_unused void *data)
5330 struct cmd_gso_size_result *res = parsed_result;
5332 if (test_done == 0) {
5333 printf("Before setting GSO segsz, please first"
5334 " stop forwarding\n");
5338 if (!strcmp(res->cmd_keyword, "gso") &&
5339 !strcmp(res->cmd_segsz, "segsz")) {
5340 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5341 printf("gso_size should be larger than %zu."
5342 " Please input a legal value\n",
5343 RTE_GSO_SEG_SIZE_MIN);
5345 gso_max_segment_size = res->cmd_size;
5349 cmdline_parse_token_string_t cmd_gso_size_set =
5350 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5352 cmdline_parse_token_string_t cmd_gso_size_keyword =
5353 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5354 cmd_keyword, "gso");
5355 cmdline_parse_token_string_t cmd_gso_size_segsz =
5356 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5357 cmd_segsz, "segsz");
5358 cmdline_parse_token_num_t cmd_gso_size_size =
5359 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5362 cmdline_parse_inst_t cmd_gso_size = {
5363 .f = cmd_gso_size_parsed,
5365 .help_str = "set gso segsz <length>",
5367 (void *)&cmd_gso_size_set,
5368 (void *)&cmd_gso_size_keyword,
5369 (void *)&cmd_gso_size_segsz,
5370 (void *)&cmd_gso_size_size,
5375 /* *** SHOW GSO CONFIGURATION *** */
5376 struct cmd_gso_show_result {
5377 cmdline_fixed_string_t cmd_show;
5378 cmdline_fixed_string_t cmd_port;
5379 cmdline_fixed_string_t cmd_keyword;
5384 cmd_gso_show_parsed(void *parsed_result,
5385 __rte_unused struct cmdline *cl,
5386 __rte_unused void *data)
5388 struct cmd_gso_show_result *res = parsed_result;
5390 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5391 printf("invalid port id %u\n", res->cmd_pid);
5394 if (!strcmp(res->cmd_keyword, "gso")) {
5395 if (gso_ports[res->cmd_pid].enable) {
5396 printf("Max GSO'd packet size: %uB\n"
5397 "Supported GSO types: TCP/IPv4, "
5398 "UDP/IPv4, VxLAN with inner "
5399 "TCP/IPv4 packet, GRE with inner "
5400 "TCP/IPv4 packet\n",
5401 gso_max_segment_size);
5403 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5407 cmdline_parse_token_string_t cmd_gso_show_show =
5408 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5410 cmdline_parse_token_string_t cmd_gso_show_port =
5411 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5413 cmdline_parse_token_string_t cmd_gso_show_keyword =
5414 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5415 cmd_keyword, "gso");
5416 cmdline_parse_token_num_t cmd_gso_show_pid =
5417 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5420 cmdline_parse_inst_t cmd_gso_show = {
5421 .f = cmd_gso_show_parsed,
5423 .help_str = "show port <port_id> gso",
5425 (void *)&cmd_gso_show_show,
5426 (void *)&cmd_gso_show_port,
5427 (void *)&cmd_gso_show_pid,
5428 (void *)&cmd_gso_show_keyword,
5433 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5434 struct cmd_set_flush_rx {
5435 cmdline_fixed_string_t set;
5436 cmdline_fixed_string_t flush_rx;
5437 cmdline_fixed_string_t mode;
5441 cmd_set_flush_rx_parsed(void *parsed_result,
5442 __rte_unused struct cmdline *cl,
5443 __rte_unused void *data)
5445 struct cmd_set_flush_rx *res = parsed_result;
5446 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5449 cmdline_parse_token_string_t cmd_setflushrx_set =
5450 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5452 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5453 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5454 flush_rx, "flush_rx");
5455 cmdline_parse_token_string_t cmd_setflushrx_mode =
5456 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5460 cmdline_parse_inst_t cmd_set_flush_rx = {
5461 .f = cmd_set_flush_rx_parsed,
5462 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5465 (void *)&cmd_setflushrx_set,
5466 (void *)&cmd_setflushrx_flush_rx,
5467 (void *)&cmd_setflushrx_mode,
5472 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5473 struct cmd_set_link_check {
5474 cmdline_fixed_string_t set;
5475 cmdline_fixed_string_t link_check;
5476 cmdline_fixed_string_t mode;
5480 cmd_set_link_check_parsed(void *parsed_result,
5481 __rte_unused struct cmdline *cl,
5482 __rte_unused void *data)
5484 struct cmd_set_link_check *res = parsed_result;
5485 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5488 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5489 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5491 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5492 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5493 link_check, "link_check");
5494 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5495 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5499 cmdline_parse_inst_t cmd_set_link_check = {
5500 .f = cmd_set_link_check_parsed,
5501 .help_str = "set link_check on|off: Enable/Disable link status check "
5502 "when starting/stopping a port",
5505 (void *)&cmd_setlinkcheck_set,
5506 (void *)&cmd_setlinkcheck_link_check,
5507 (void *)&cmd_setlinkcheck_mode,
5512 /* *** SET NIC BYPASS MODE *** */
5513 struct cmd_set_bypass_mode_result {
5514 cmdline_fixed_string_t set;
5515 cmdline_fixed_string_t bypass;
5516 cmdline_fixed_string_t mode;
5517 cmdline_fixed_string_t value;
5522 cmd_set_bypass_mode_parsed(void *parsed_result,
5523 __rte_unused struct cmdline *cl,
5524 __rte_unused void *data)
5526 struct cmd_set_bypass_mode_result *res = parsed_result;
5527 portid_t port_id = res->port_id;
5528 int32_t rc = -EINVAL;
5530 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5531 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5533 if (!strcmp(res->value, "bypass"))
5534 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5535 else if (!strcmp(res->value, "isolate"))
5536 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5538 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5540 /* Set the bypass mode for the relevant port. */
5541 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5544 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5547 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5548 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5550 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5551 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5553 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5554 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5556 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5557 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5558 value, "normal#bypass#isolate");
5559 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5560 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5563 cmdline_parse_inst_t cmd_set_bypass_mode = {
5564 .f = cmd_set_bypass_mode_parsed,
5565 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5566 "Set the NIC bypass mode for port_id",
5569 (void *)&cmd_setbypass_mode_set,
5570 (void *)&cmd_setbypass_mode_bypass,
5571 (void *)&cmd_setbypass_mode_mode,
5572 (void *)&cmd_setbypass_mode_value,
5573 (void *)&cmd_setbypass_mode_port,
5578 /* *** SET NIC BYPASS EVENT *** */
5579 struct cmd_set_bypass_event_result {
5580 cmdline_fixed_string_t set;
5581 cmdline_fixed_string_t bypass;
5582 cmdline_fixed_string_t event;
5583 cmdline_fixed_string_t event_value;
5584 cmdline_fixed_string_t mode;
5585 cmdline_fixed_string_t mode_value;
5590 cmd_set_bypass_event_parsed(void *parsed_result,
5591 __rte_unused struct cmdline *cl,
5592 __rte_unused void *data)
5594 int32_t rc = -EINVAL;
5595 struct cmd_set_bypass_event_result *res = parsed_result;
5596 portid_t port_id = res->port_id;
5598 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5599 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5600 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5602 if (!strcmp(res->event_value, "timeout"))
5603 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5604 else if (!strcmp(res->event_value, "os_on"))
5605 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5606 else if (!strcmp(res->event_value, "os_off"))
5607 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5608 else if (!strcmp(res->event_value, "power_on"))
5609 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5610 else if (!strcmp(res->event_value, "power_off"))
5611 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5613 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5615 if (!strcmp(res->mode_value, "bypass"))
5616 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5617 else if (!strcmp(res->mode_value, "isolate"))
5618 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5620 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5622 /* Set the watchdog timeout. */
5623 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5626 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5627 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5631 printf("Failed to set timeout value %u "
5632 "for port %d, errto code: %d.\n",
5633 bypass_timeout, port_id, rc);
5637 /* Set the bypass event to transition to bypass mode. */
5638 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5643 printf("\t Failed to set bypass event for port = %d.\n",
5647 cmdline_parse_token_string_t cmd_setbypass_event_set =
5648 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5650 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5651 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5653 cmdline_parse_token_string_t cmd_setbypass_event_event =
5654 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5656 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5657 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5658 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5659 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5660 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5662 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5663 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5664 mode_value, "normal#bypass#isolate");
5665 cmdline_parse_token_num_t cmd_setbypass_event_port =
5666 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5669 cmdline_parse_inst_t cmd_set_bypass_event = {
5670 .f = cmd_set_bypass_event_parsed,
5671 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5672 "power_off mode normal|bypass|isolate <port_id>: "
5673 "Set the NIC bypass event mode for port_id",
5676 (void *)&cmd_setbypass_event_set,
5677 (void *)&cmd_setbypass_event_bypass,
5678 (void *)&cmd_setbypass_event_event,
5679 (void *)&cmd_setbypass_event_event_value,
5680 (void *)&cmd_setbypass_event_mode,
5681 (void *)&cmd_setbypass_event_mode_value,
5682 (void *)&cmd_setbypass_event_port,
5688 /* *** SET NIC BYPASS TIMEOUT *** */
5689 struct cmd_set_bypass_timeout_result {
5690 cmdline_fixed_string_t set;
5691 cmdline_fixed_string_t bypass;
5692 cmdline_fixed_string_t timeout;
5693 cmdline_fixed_string_t value;
5697 cmd_set_bypass_timeout_parsed(void *parsed_result,
5698 __rte_unused struct cmdline *cl,
5699 __rte_unused void *data)
5701 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5703 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5704 if (!strcmp(res->value, "1.5"))
5705 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5706 else if (!strcmp(res->value, "2"))
5707 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5708 else if (!strcmp(res->value, "3"))
5709 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5710 else if (!strcmp(res->value, "4"))
5711 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5712 else if (!strcmp(res->value, "8"))
5713 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5714 else if (!strcmp(res->value, "16"))
5715 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5716 else if (!strcmp(res->value, "32"))
5717 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5719 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5723 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5724 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5726 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5727 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5729 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5730 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5731 timeout, "timeout");
5732 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5733 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5734 value, "0#1.5#2#3#4#8#16#32");
5736 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5737 .f = cmd_set_bypass_timeout_parsed,
5738 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5739 "Set the NIC bypass watchdog timeout in seconds",
5742 (void *)&cmd_setbypass_timeout_set,
5743 (void *)&cmd_setbypass_timeout_bypass,
5744 (void *)&cmd_setbypass_timeout_timeout,
5745 (void *)&cmd_setbypass_timeout_value,
5750 /* *** SHOW NIC BYPASS MODE *** */
5751 struct cmd_show_bypass_config_result {
5752 cmdline_fixed_string_t show;
5753 cmdline_fixed_string_t bypass;
5754 cmdline_fixed_string_t config;
5759 cmd_show_bypass_config_parsed(void *parsed_result,
5760 __rte_unused struct cmdline *cl,
5761 __rte_unused void *data)
5763 struct cmd_show_bypass_config_result *res = parsed_result;
5764 portid_t port_id = res->port_id;
5766 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5767 uint32_t event_mode;
5768 uint32_t bypass_mode;
5769 uint32_t timeout = bypass_timeout;
5772 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5773 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5774 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5775 {"UNKNOWN", "normal", "bypass", "isolate"};
5776 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5784 /* Display the bypass mode.*/
5785 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5786 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5790 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5791 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5793 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5796 /* Display the bypass timeout.*/
5797 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5798 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5800 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5802 /* Display the bypass events and associated modes. */
5803 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5805 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5806 printf("\tFailed to get bypass mode for event = %s\n",
5809 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5810 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5812 printf("\tbypass event: %-16s = %s\n", events[i],
5818 printf("\tFailed to get bypass configuration for port = %d\n",
5822 cmdline_parse_token_string_t cmd_showbypass_config_show =
5823 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5825 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5826 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5828 cmdline_parse_token_string_t cmd_showbypass_config_config =
5829 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5831 cmdline_parse_token_num_t cmd_showbypass_config_port =
5832 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5835 cmdline_parse_inst_t cmd_show_bypass_config = {
5836 .f = cmd_show_bypass_config_parsed,
5837 .help_str = "show bypass config <port_id>: "
5838 "Show the NIC bypass config for port_id",
5841 (void *)&cmd_showbypass_config_show,
5842 (void *)&cmd_showbypass_config_bypass,
5843 (void *)&cmd_showbypass_config_config,
5844 (void *)&cmd_showbypass_config_port,
5849 #ifdef RTE_LIBRTE_PMD_BOND
5850 /* *** SET BONDING MODE *** */
5851 struct cmd_set_bonding_mode_result {
5852 cmdline_fixed_string_t set;
5853 cmdline_fixed_string_t bonding;
5854 cmdline_fixed_string_t mode;
5859 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5860 __rte_unused struct cmdline *cl,
5861 __rte_unused void *data)
5863 struct cmd_set_bonding_mode_result *res = parsed_result;
5864 portid_t port_id = res->port_id;
5866 /* Set the bonding mode for the relevant port. */
5867 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5868 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5871 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5872 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5874 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5875 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5876 bonding, "bonding");
5877 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5878 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5880 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5881 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5883 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5884 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5887 cmdline_parse_inst_t cmd_set_bonding_mode = {
5888 .f = cmd_set_bonding_mode_parsed,
5889 .help_str = "set bonding mode <mode_value> <port_id>: "
5890 "Set the bonding mode for port_id",
5893 (void *) &cmd_setbonding_mode_set,
5894 (void *) &cmd_setbonding_mode_bonding,
5895 (void *) &cmd_setbonding_mode_mode,
5896 (void *) &cmd_setbonding_mode_value,
5897 (void *) &cmd_setbonding_mode_port,
5902 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5903 struct cmd_set_bonding_lacp_dedicated_queues_result {
5904 cmdline_fixed_string_t set;
5905 cmdline_fixed_string_t bonding;
5906 cmdline_fixed_string_t lacp;
5907 cmdline_fixed_string_t dedicated_queues;
5909 cmdline_fixed_string_t mode;
5912 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5913 __rte_unused struct cmdline *cl,
5914 __rte_unused void *data)
5916 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5917 portid_t port_id = res->port_id;
5918 struct rte_port *port;
5920 port = &ports[port_id];
5922 /** Check if the port is not started **/
5923 if (port->port_status != RTE_PORT_STOPPED) {
5924 printf("Please stop port %d first\n", port_id);
5928 if (!strcmp(res->mode, "enable")) {
5929 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5930 printf("Dedicate queues for LACP control packets"
5933 printf("Enabling dedicate queues for LACP control "
5934 "packets on port %d failed\n", port_id);
5935 } else if (!strcmp(res->mode, "disable")) {
5936 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5937 printf("Dedicated queues for LACP control packets "
5940 printf("Disabling dedicated queues for LACP control "
5941 "traffic on port %d failed\n", port_id);
5945 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5946 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5948 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5949 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5950 bonding, "bonding");
5951 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5952 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5954 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5955 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5956 dedicated_queues, "dedicated_queues");
5957 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5958 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5960 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5961 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5962 mode, "enable#disable");
5964 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5965 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5966 .help_str = "set bonding lacp dedicated_queues <port_id> "
5968 "Enable/disable dedicated queues for LACP control traffic for port_id",
5971 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5972 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5973 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5974 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5975 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5976 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5981 /* *** SET BALANCE XMIT POLICY *** */
5982 struct cmd_set_bonding_balance_xmit_policy_result {
5983 cmdline_fixed_string_t set;
5984 cmdline_fixed_string_t bonding;
5985 cmdline_fixed_string_t balance_xmit_policy;
5987 cmdline_fixed_string_t policy;
5990 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5991 __rte_unused struct cmdline *cl,
5992 __rte_unused void *data)
5994 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5995 portid_t port_id = res->port_id;
5998 if (!strcmp(res->policy, "l2")) {
5999 policy = BALANCE_XMIT_POLICY_LAYER2;
6000 } else if (!strcmp(res->policy, "l23")) {
6001 policy = BALANCE_XMIT_POLICY_LAYER23;
6002 } else if (!strcmp(res->policy, "l34")) {
6003 policy = BALANCE_XMIT_POLICY_LAYER34;
6005 printf("\t Invalid xmit policy selection");
6009 /* Set the bonding mode for the relevant port. */
6010 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6011 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6016 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6017 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6019 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6020 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6021 bonding, "bonding");
6022 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6023 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6024 balance_xmit_policy, "balance_xmit_policy");
6025 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6026 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6028 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6029 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6030 policy, "l2#l23#l34");
6032 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6033 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6034 .help_str = "set bonding balance_xmit_policy <port_id> "
6036 "Set the bonding balance_xmit_policy for port_id",
6039 (void *)&cmd_setbonding_balance_xmit_policy_set,
6040 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6041 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6042 (void *)&cmd_setbonding_balance_xmit_policy_port,
6043 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6048 /* *** SHOW NIC BONDING CONFIGURATION *** */
6049 struct cmd_show_bonding_config_result {
6050 cmdline_fixed_string_t show;
6051 cmdline_fixed_string_t bonding;
6052 cmdline_fixed_string_t config;
6056 static void cmd_show_bonding_config_parsed(void *parsed_result,
6057 __rte_unused struct cmdline *cl,
6058 __rte_unused void *data)
6060 struct cmd_show_bonding_config_result *res = parsed_result;
6061 int bonding_mode, agg_mode;
6062 portid_t slaves[RTE_MAX_ETHPORTS];
6063 int num_slaves, num_active_slaves;
6066 portid_t port_id = res->port_id;
6068 /* Display the bonding mode.*/
6069 bonding_mode = rte_eth_bond_mode_get(port_id);
6070 if (bonding_mode < 0) {
6071 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6074 printf("\tBonding mode: %d\n", bonding_mode);
6076 if (bonding_mode == BONDING_MODE_BALANCE) {
6077 int balance_xmit_policy;
6079 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6080 if (balance_xmit_policy < 0) {
6081 printf("\tFailed to get balance xmit policy for port = %d\n",
6085 printf("\tBalance Xmit Policy: ");
6087 switch (balance_xmit_policy) {
6088 case BALANCE_XMIT_POLICY_LAYER2:
6089 printf("BALANCE_XMIT_POLICY_LAYER2");
6091 case BALANCE_XMIT_POLICY_LAYER23:
6092 printf("BALANCE_XMIT_POLICY_LAYER23");
6094 case BALANCE_XMIT_POLICY_LAYER34:
6095 printf("BALANCE_XMIT_POLICY_LAYER34");
6102 if (bonding_mode == BONDING_MODE_8023AD) {
6103 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6104 printf("\tIEEE802.3AD Aggregator Mode: ");
6107 printf("bandwidth");
6119 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6121 if (num_slaves < 0) {
6122 printf("\tFailed to get slave list for port = %d\n", port_id);
6125 if (num_slaves > 0) {
6126 printf("\tSlaves (%d): [", num_slaves);
6127 for (i = 0; i < num_slaves - 1; i++)
6128 printf("%d ", slaves[i]);
6130 printf("%d]\n", slaves[num_slaves - 1]);
6132 printf("\tSlaves: []\n");
6136 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6139 if (num_active_slaves < 0) {
6140 printf("\tFailed to get active slave list for port = %d\n", port_id);
6143 if (num_active_slaves > 0) {
6144 printf("\tActive Slaves (%d): [", num_active_slaves);
6145 for (i = 0; i < num_active_slaves - 1; i++)
6146 printf("%d ", slaves[i]);
6148 printf("%d]\n", slaves[num_active_slaves - 1]);
6151 printf("\tActive Slaves: []\n");
6155 primary_id = rte_eth_bond_primary_get(port_id);
6156 if (primary_id < 0) {
6157 printf("\tFailed to get primary slave for port = %d\n", port_id);
6160 printf("\tPrimary: [%d]\n", primary_id);
6164 cmdline_parse_token_string_t cmd_showbonding_config_show =
6165 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6167 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6168 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6169 bonding, "bonding");
6170 cmdline_parse_token_string_t cmd_showbonding_config_config =
6171 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6173 cmdline_parse_token_num_t cmd_showbonding_config_port =
6174 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6177 cmdline_parse_inst_t cmd_show_bonding_config = {
6178 .f = cmd_show_bonding_config_parsed,
6179 .help_str = "show bonding config <port_id>: "
6180 "Show the bonding config for port_id",
6183 (void *)&cmd_showbonding_config_show,
6184 (void *)&cmd_showbonding_config_bonding,
6185 (void *)&cmd_showbonding_config_config,
6186 (void *)&cmd_showbonding_config_port,
6191 /* *** SET BONDING PRIMARY *** */
6192 struct cmd_set_bonding_primary_result {
6193 cmdline_fixed_string_t set;
6194 cmdline_fixed_string_t bonding;
6195 cmdline_fixed_string_t primary;
6200 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6201 __rte_unused struct cmdline *cl,
6202 __rte_unused void *data)
6204 struct cmd_set_bonding_primary_result *res = parsed_result;
6205 portid_t master_port_id = res->port_id;
6206 portid_t slave_port_id = res->slave_id;
6208 /* Set the primary slave for a bonded device. */
6209 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6210 printf("\t Failed to set primary slave for port = %d.\n",
6217 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6218 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6220 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6221 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6222 bonding, "bonding");
6223 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6224 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6225 primary, "primary");
6226 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6227 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6229 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6230 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6233 cmdline_parse_inst_t cmd_set_bonding_primary = {
6234 .f = cmd_set_bonding_primary_parsed,
6235 .help_str = "set bonding primary <slave_id> <port_id>: "
6236 "Set the primary slave for port_id",
6239 (void *)&cmd_setbonding_primary_set,
6240 (void *)&cmd_setbonding_primary_bonding,
6241 (void *)&cmd_setbonding_primary_primary,
6242 (void *)&cmd_setbonding_primary_slave,
6243 (void *)&cmd_setbonding_primary_port,
6248 /* *** ADD SLAVE *** */
6249 struct cmd_add_bonding_slave_result {
6250 cmdline_fixed_string_t add;
6251 cmdline_fixed_string_t bonding;
6252 cmdline_fixed_string_t slave;
6257 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6258 __rte_unused struct cmdline *cl,
6259 __rte_unused void *data)
6261 struct cmd_add_bonding_slave_result *res = parsed_result;
6262 portid_t master_port_id = res->port_id;
6263 portid_t slave_port_id = res->slave_id;
6265 /* add the slave for a bonded device. */
6266 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6267 printf("\t Failed to add slave %d to master port = %d.\n",
6268 slave_port_id, master_port_id);
6272 set_port_slave_flag(slave_port_id);
6275 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6276 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6278 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6279 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6280 bonding, "bonding");
6281 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6282 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6284 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6285 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6287 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6288 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6291 cmdline_parse_inst_t cmd_add_bonding_slave = {
6292 .f = cmd_add_bonding_slave_parsed,
6293 .help_str = "add bonding slave <slave_id> <port_id>: "
6294 "Add a slave device to a bonded device",
6297 (void *)&cmd_addbonding_slave_add,
6298 (void *)&cmd_addbonding_slave_bonding,
6299 (void *)&cmd_addbonding_slave_slave,
6300 (void *)&cmd_addbonding_slave_slaveid,
6301 (void *)&cmd_addbonding_slave_port,
6306 /* *** REMOVE SLAVE *** */
6307 struct cmd_remove_bonding_slave_result {
6308 cmdline_fixed_string_t remove;
6309 cmdline_fixed_string_t bonding;
6310 cmdline_fixed_string_t slave;
6315 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6316 __rte_unused struct cmdline *cl,
6317 __rte_unused void *data)
6319 struct cmd_remove_bonding_slave_result *res = parsed_result;
6320 portid_t master_port_id = res->port_id;
6321 portid_t slave_port_id = res->slave_id;
6323 /* remove the slave from a bonded device. */
6324 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6325 printf("\t Failed to remove slave %d from master port = %d.\n",
6326 slave_port_id, master_port_id);
6330 clear_port_slave_flag(slave_port_id);
6333 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6334 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6336 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6337 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6338 bonding, "bonding");
6339 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6340 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6342 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6343 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6345 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6346 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6349 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6350 .f = cmd_remove_bonding_slave_parsed,
6351 .help_str = "remove bonding slave <slave_id> <port_id>: "
6352 "Remove a slave device from a bonded device",
6355 (void *)&cmd_removebonding_slave_remove,
6356 (void *)&cmd_removebonding_slave_bonding,
6357 (void *)&cmd_removebonding_slave_slave,
6358 (void *)&cmd_removebonding_slave_slaveid,
6359 (void *)&cmd_removebonding_slave_port,
6364 /* *** CREATE BONDED DEVICE *** */
6365 struct cmd_create_bonded_device_result {
6366 cmdline_fixed_string_t create;
6367 cmdline_fixed_string_t bonded;
6368 cmdline_fixed_string_t device;
6373 static int bond_dev_num = 0;
6375 static void cmd_create_bonded_device_parsed(void *parsed_result,
6376 __rte_unused struct cmdline *cl,
6377 __rte_unused void *data)
6379 struct cmd_create_bonded_device_result *res = parsed_result;
6380 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6384 if (test_done == 0) {
6385 printf("Please stop forwarding first\n");
6389 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6392 /* Create a new bonded device. */
6393 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6395 printf("\t Failed to create bonded device.\n");
6398 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6401 /* Update number of ports */
6402 nb_ports = rte_eth_dev_count_avail();
6403 reconfig(port_id, res->socket);
6404 ret = rte_eth_promiscuous_enable(port_id);
6406 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6407 port_id, rte_strerror(-ret));
6409 ports[port_id].need_setup = 0;
6410 ports[port_id].port_status = RTE_PORT_STOPPED;
6415 cmdline_parse_token_string_t cmd_createbonded_device_create =
6416 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6418 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6419 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6421 cmdline_parse_token_string_t cmd_createbonded_device_device =
6422 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6424 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6425 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6427 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6428 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6431 cmdline_parse_inst_t cmd_create_bonded_device = {
6432 .f = cmd_create_bonded_device_parsed,
6433 .help_str = "create bonded device <mode> <socket>: "
6434 "Create a new bonded device with specific bonding mode and socket",
6437 (void *)&cmd_createbonded_device_create,
6438 (void *)&cmd_createbonded_device_bonded,
6439 (void *)&cmd_createbonded_device_device,
6440 (void *)&cmd_createbonded_device_mode,
6441 (void *)&cmd_createbonded_device_socket,
6446 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6447 struct cmd_set_bond_mac_addr_result {
6448 cmdline_fixed_string_t set;
6449 cmdline_fixed_string_t bonding;
6450 cmdline_fixed_string_t mac_addr;
6452 struct rte_ether_addr address;
6455 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6456 __rte_unused struct cmdline *cl,
6457 __rte_unused void *data)
6459 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6462 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6465 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6467 /* check the return value and print it if is < 0 */
6469 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6472 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6473 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6474 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6475 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6477 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6478 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6480 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6481 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6483 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6484 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6486 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6487 .f = cmd_set_bond_mac_addr_parsed,
6489 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6491 (void *)&cmd_set_bond_mac_addr_set,
6492 (void *)&cmd_set_bond_mac_addr_bonding,
6493 (void *)&cmd_set_bond_mac_addr_mac,
6494 (void *)&cmd_set_bond_mac_addr_portnum,
6495 (void *)&cmd_set_bond_mac_addr_addr,
6501 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6502 struct cmd_set_bond_mon_period_result {
6503 cmdline_fixed_string_t set;
6504 cmdline_fixed_string_t bonding;
6505 cmdline_fixed_string_t mon_period;
6510 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6511 __rte_unused struct cmdline *cl,
6512 __rte_unused void *data)
6514 struct cmd_set_bond_mon_period_result *res = parsed_result;
6517 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6519 /* check the return value and print it if is < 0 */
6521 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6524 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6525 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6527 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6528 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6529 bonding, "bonding");
6530 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6531 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6532 mon_period, "mon_period");
6533 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6534 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6536 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6537 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6540 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6541 .f = cmd_set_bond_mon_period_parsed,
6543 .help_str = "set bonding mon_period <port_id> <period_ms>",
6545 (void *)&cmd_set_bond_mon_period_set,
6546 (void *)&cmd_set_bond_mon_period_bonding,
6547 (void *)&cmd_set_bond_mon_period_mon_period,
6548 (void *)&cmd_set_bond_mon_period_portnum,
6549 (void *)&cmd_set_bond_mon_period_period_ms,
6556 struct cmd_set_bonding_agg_mode_policy_result {
6557 cmdline_fixed_string_t set;
6558 cmdline_fixed_string_t bonding;
6559 cmdline_fixed_string_t agg_mode;
6561 cmdline_fixed_string_t policy;
6566 cmd_set_bonding_agg_mode(void *parsed_result,
6567 __rte_unused struct cmdline *cl,
6568 __rte_unused void *data)
6570 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6571 uint8_t policy = AGG_BANDWIDTH;
6573 if (!strcmp(res->policy, "bandwidth"))
6574 policy = AGG_BANDWIDTH;
6575 else if (!strcmp(res->policy, "stable"))
6576 policy = AGG_STABLE;
6577 else if (!strcmp(res->policy, "count"))
6580 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6584 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6585 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6587 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6588 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6589 bonding, "bonding");
6591 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6592 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6593 agg_mode, "agg_mode");
6595 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6596 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6599 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6600 TOKEN_STRING_INITIALIZER(
6601 struct cmd_set_bonding_balance_xmit_policy_result,
6602 policy, "stable#bandwidth#count");
6604 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6605 .f = cmd_set_bonding_agg_mode,
6607 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6609 (void *)&cmd_set_bonding_agg_mode_set,
6610 (void *)&cmd_set_bonding_agg_mode_bonding,
6611 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6612 (void *)&cmd_set_bonding_agg_mode_portnum,
6613 (void *)&cmd_set_bonding_agg_mode_policy_string,
6619 #endif /* RTE_LIBRTE_PMD_BOND */
6621 /* *** SET FORWARDING MODE *** */
6622 struct cmd_set_fwd_mode_result {
6623 cmdline_fixed_string_t set;
6624 cmdline_fixed_string_t fwd;
6625 cmdline_fixed_string_t mode;
6628 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6629 __rte_unused struct cmdline *cl,
6630 __rte_unused void *data)
6632 struct cmd_set_fwd_mode_result *res = parsed_result;
6635 set_pkt_forwarding_mode(res->mode);
6638 cmdline_parse_token_string_t cmd_setfwd_set =
6639 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6640 cmdline_parse_token_string_t cmd_setfwd_fwd =
6641 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6642 cmdline_parse_token_string_t cmd_setfwd_mode =
6643 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6644 "" /* defined at init */);
6646 cmdline_parse_inst_t cmd_set_fwd_mode = {
6647 .f = cmd_set_fwd_mode_parsed,
6649 .help_str = NULL, /* defined at init */
6651 (void *)&cmd_setfwd_set,
6652 (void *)&cmd_setfwd_fwd,
6653 (void *)&cmd_setfwd_mode,
6658 static void cmd_set_fwd_mode_init(void)
6661 static char token[128];
6662 static char help[256];
6663 cmdline_parse_token_string_t *token_struct;
6665 modes = list_pkt_forwarding_modes();
6666 snprintf(help, sizeof(help), "set fwd %s: "
6667 "Set packet forwarding mode", modes);
6668 cmd_set_fwd_mode.help_str = help;
6670 /* string token separator is # */
6671 for (c = token; *modes != '\0'; modes++)
6676 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6677 token_struct->string_data.str = token;
6680 /* *** SET RETRY FORWARDING MODE *** */
6681 struct cmd_set_fwd_retry_mode_result {
6682 cmdline_fixed_string_t set;
6683 cmdline_fixed_string_t fwd;
6684 cmdline_fixed_string_t mode;
6685 cmdline_fixed_string_t retry;
6688 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6689 __rte_unused struct cmdline *cl,
6690 __rte_unused void *data)
6692 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6695 set_pkt_forwarding_mode(res->mode);
6698 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6699 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6701 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6702 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6704 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6705 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6707 "" /* defined at init */);
6708 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6709 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6712 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6713 .f = cmd_set_fwd_retry_mode_parsed,
6715 .help_str = NULL, /* defined at init */
6717 (void *)&cmd_setfwd_retry_set,
6718 (void *)&cmd_setfwd_retry_fwd,
6719 (void *)&cmd_setfwd_retry_mode,
6720 (void *)&cmd_setfwd_retry_retry,
6725 static void cmd_set_fwd_retry_mode_init(void)
6728 static char token[128];
6729 static char help[256];
6730 cmdline_parse_token_string_t *token_struct;
6732 modes = list_pkt_forwarding_retry_modes();
6733 snprintf(help, sizeof(help), "set fwd %s retry: "
6734 "Set packet forwarding mode with retry", modes);
6735 cmd_set_fwd_retry_mode.help_str = help;
6737 /* string token separator is # */
6738 for (c = token; *modes != '\0'; modes++)
6743 token_struct = (cmdline_parse_token_string_t *)
6744 cmd_set_fwd_retry_mode.tokens[2];
6745 token_struct->string_data.str = token;
6748 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6749 struct cmd_set_burst_tx_retry_result {
6750 cmdline_fixed_string_t set;
6751 cmdline_fixed_string_t burst;
6752 cmdline_fixed_string_t tx;
6753 cmdline_fixed_string_t delay;
6755 cmdline_fixed_string_t retry;
6759 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6760 __rte_unused struct cmdline *cl,
6761 __rte_unused void *data)
6763 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6765 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6766 && !strcmp(res->tx, "tx")) {
6767 if (!strcmp(res->delay, "delay"))
6768 burst_tx_delay_time = res->time;
6769 if (!strcmp(res->retry, "retry"))
6770 burst_tx_retry_num = res->retry_num;
6775 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6776 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6777 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6778 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6780 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6781 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6782 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6783 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6784 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6785 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6786 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6787 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6788 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6789 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6791 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6792 .f = cmd_set_burst_tx_retry_parsed,
6793 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6795 (void *)&cmd_set_burst_tx_retry_set,
6796 (void *)&cmd_set_burst_tx_retry_burst,
6797 (void *)&cmd_set_burst_tx_retry_tx,
6798 (void *)&cmd_set_burst_tx_retry_delay,
6799 (void *)&cmd_set_burst_tx_retry_time,
6800 (void *)&cmd_set_burst_tx_retry_retry,
6801 (void *)&cmd_set_burst_tx_retry_retry_num,
6806 /* *** SET PROMISC MODE *** */
6807 struct cmd_set_promisc_mode_result {
6808 cmdline_fixed_string_t set;
6809 cmdline_fixed_string_t promisc;
6810 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6811 uint16_t port_num; /* valid if "allports" argument == 0 */
6812 cmdline_fixed_string_t mode;
6815 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6816 __rte_unused struct cmdline *cl,
6819 struct cmd_set_promisc_mode_result *res = parsed_result;
6823 if (!strcmp(res->mode, "on"))
6830 RTE_ETH_FOREACH_DEV(i)
6831 eth_set_promisc_mode(i, enable);
6833 eth_set_promisc_mode(res->port_num, enable);
6837 cmdline_parse_token_string_t cmd_setpromisc_set =
6838 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6839 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6840 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6842 cmdline_parse_token_string_t cmd_setpromisc_portall =
6843 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6845 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6846 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6848 cmdline_parse_token_string_t cmd_setpromisc_mode =
6849 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6852 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6853 .f = cmd_set_promisc_mode_parsed,
6855 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6857 (void *)&cmd_setpromisc_set,
6858 (void *)&cmd_setpromisc_promisc,
6859 (void *)&cmd_setpromisc_portall,
6860 (void *)&cmd_setpromisc_mode,
6865 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6866 .f = cmd_set_promisc_mode_parsed,
6868 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6870 (void *)&cmd_setpromisc_set,
6871 (void *)&cmd_setpromisc_promisc,
6872 (void *)&cmd_setpromisc_portnum,
6873 (void *)&cmd_setpromisc_mode,
6878 /* *** SET ALLMULTI MODE *** */
6879 struct cmd_set_allmulti_mode_result {
6880 cmdline_fixed_string_t set;
6881 cmdline_fixed_string_t allmulti;
6882 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6883 uint16_t port_num; /* valid if "allports" argument == 0 */
6884 cmdline_fixed_string_t mode;
6887 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6888 __rte_unused struct cmdline *cl,
6891 struct cmd_set_allmulti_mode_result *res = parsed_result;
6895 if (!strcmp(res->mode, "on"))
6902 RTE_ETH_FOREACH_DEV(i) {
6903 eth_set_allmulticast_mode(i, enable);
6907 eth_set_allmulticast_mode(res->port_num, enable);
6911 cmdline_parse_token_string_t cmd_setallmulti_set =
6912 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6913 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6914 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6916 cmdline_parse_token_string_t cmd_setallmulti_portall =
6917 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6919 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6920 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6922 cmdline_parse_token_string_t cmd_setallmulti_mode =
6923 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6926 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6927 .f = cmd_set_allmulti_mode_parsed,
6929 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6931 (void *)&cmd_setallmulti_set,
6932 (void *)&cmd_setallmulti_allmulti,
6933 (void *)&cmd_setallmulti_portall,
6934 (void *)&cmd_setallmulti_mode,
6939 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6940 .f = cmd_set_allmulti_mode_parsed,
6942 .help_str = "set allmulti <port_id> on|off: "
6943 "Set allmulti mode on port_id",
6945 (void *)&cmd_setallmulti_set,
6946 (void *)&cmd_setallmulti_allmulti,
6947 (void *)&cmd_setallmulti_portnum,
6948 (void *)&cmd_setallmulti_mode,
6953 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6954 struct cmd_link_flow_ctrl_set_result {
6955 cmdline_fixed_string_t set;
6956 cmdline_fixed_string_t flow_ctrl;
6957 cmdline_fixed_string_t rx;
6958 cmdline_fixed_string_t rx_lfc_mode;
6959 cmdline_fixed_string_t tx;
6960 cmdline_fixed_string_t tx_lfc_mode;
6961 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6962 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6963 cmdline_fixed_string_t autoneg_str;
6964 cmdline_fixed_string_t autoneg;
6965 cmdline_fixed_string_t hw_str;
6966 uint32_t high_water;
6967 cmdline_fixed_string_t lw_str;
6969 cmdline_fixed_string_t pt_str;
6970 uint16_t pause_time;
6971 cmdline_fixed_string_t xon_str;
6976 cmdline_parse_token_string_t cmd_lfc_set_set =
6977 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6979 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6980 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6981 flow_ctrl, "flow_ctrl");
6982 cmdline_parse_token_string_t cmd_lfc_set_rx =
6983 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6985 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6986 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6987 rx_lfc_mode, "on#off");
6988 cmdline_parse_token_string_t cmd_lfc_set_tx =
6989 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6991 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6992 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6993 tx_lfc_mode, "on#off");
6994 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6995 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6996 hw_str, "high_water");
6997 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6998 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6999 high_water, UINT32);
7000 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7001 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7002 lw_str, "low_water");
7003 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7004 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7006 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7007 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7008 pt_str, "pause_time");
7009 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7010 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7011 pause_time, UINT16);
7012 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7013 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7014 xon_str, "send_xon");
7015 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7016 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7018 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7019 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7020 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7021 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7022 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7023 mac_ctrl_frame_fwd_mode, "on#off");
7024 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7025 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7026 autoneg_str, "autoneg");
7027 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7028 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7030 cmdline_parse_token_num_t cmd_lfc_set_portid =
7031 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7034 /* forward declaration */
7036 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7039 cmdline_parse_inst_t cmd_link_flow_control_set = {
7040 .f = cmd_link_flow_ctrl_set_parsed,
7042 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7043 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7044 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7046 (void *)&cmd_lfc_set_set,
7047 (void *)&cmd_lfc_set_flow_ctrl,
7048 (void *)&cmd_lfc_set_rx,
7049 (void *)&cmd_lfc_set_rx_mode,
7050 (void *)&cmd_lfc_set_tx,
7051 (void *)&cmd_lfc_set_tx_mode,
7052 (void *)&cmd_lfc_set_high_water,
7053 (void *)&cmd_lfc_set_low_water,
7054 (void *)&cmd_lfc_set_pause_time,
7055 (void *)&cmd_lfc_set_send_xon,
7056 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7057 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7058 (void *)&cmd_lfc_set_autoneg_str,
7059 (void *)&cmd_lfc_set_autoneg,
7060 (void *)&cmd_lfc_set_portid,
7065 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7066 .f = cmd_link_flow_ctrl_set_parsed,
7067 .data = (void *)&cmd_link_flow_control_set_rx,
7068 .help_str = "set flow_ctrl rx on|off <port_id>: "
7069 "Change rx flow control parameter",
7071 (void *)&cmd_lfc_set_set,
7072 (void *)&cmd_lfc_set_flow_ctrl,
7073 (void *)&cmd_lfc_set_rx,
7074 (void *)&cmd_lfc_set_rx_mode,
7075 (void *)&cmd_lfc_set_portid,
7080 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7081 .f = cmd_link_flow_ctrl_set_parsed,
7082 .data = (void *)&cmd_link_flow_control_set_tx,
7083 .help_str = "set flow_ctrl tx on|off <port_id>: "
7084 "Change tx flow control parameter",
7086 (void *)&cmd_lfc_set_set,
7087 (void *)&cmd_lfc_set_flow_ctrl,
7088 (void *)&cmd_lfc_set_tx,
7089 (void *)&cmd_lfc_set_tx_mode,
7090 (void *)&cmd_lfc_set_portid,
7095 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7096 .f = cmd_link_flow_ctrl_set_parsed,
7097 .data = (void *)&cmd_link_flow_control_set_hw,
7098 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7099 "Change high water flow control parameter",
7101 (void *)&cmd_lfc_set_set,
7102 (void *)&cmd_lfc_set_flow_ctrl,
7103 (void *)&cmd_lfc_set_high_water_str,
7104 (void *)&cmd_lfc_set_high_water,
7105 (void *)&cmd_lfc_set_portid,
7110 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7111 .f = cmd_link_flow_ctrl_set_parsed,
7112 .data = (void *)&cmd_link_flow_control_set_lw,
7113 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7114 "Change low water flow control parameter",
7116 (void *)&cmd_lfc_set_set,
7117 (void *)&cmd_lfc_set_flow_ctrl,
7118 (void *)&cmd_lfc_set_low_water_str,
7119 (void *)&cmd_lfc_set_low_water,
7120 (void *)&cmd_lfc_set_portid,
7125 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7126 .f = cmd_link_flow_ctrl_set_parsed,
7127 .data = (void *)&cmd_link_flow_control_set_pt,
7128 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7129 "Change pause time flow control parameter",
7131 (void *)&cmd_lfc_set_set,
7132 (void *)&cmd_lfc_set_flow_ctrl,
7133 (void *)&cmd_lfc_set_pause_time_str,
7134 (void *)&cmd_lfc_set_pause_time,
7135 (void *)&cmd_lfc_set_portid,
7140 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7141 .f = cmd_link_flow_ctrl_set_parsed,
7142 .data = (void *)&cmd_link_flow_control_set_xon,
7143 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7144 "Change send_xon flow control parameter",
7146 (void *)&cmd_lfc_set_set,
7147 (void *)&cmd_lfc_set_flow_ctrl,
7148 (void *)&cmd_lfc_set_send_xon_str,
7149 (void *)&cmd_lfc_set_send_xon,
7150 (void *)&cmd_lfc_set_portid,
7155 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7156 .f = cmd_link_flow_ctrl_set_parsed,
7157 .data = (void *)&cmd_link_flow_control_set_macfwd,
7158 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7159 "Change mac ctrl fwd flow control parameter",
7161 (void *)&cmd_lfc_set_set,
7162 (void *)&cmd_lfc_set_flow_ctrl,
7163 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7164 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7165 (void *)&cmd_lfc_set_portid,
7170 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7171 .f = cmd_link_flow_ctrl_set_parsed,
7172 .data = (void *)&cmd_link_flow_control_set_autoneg,
7173 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7174 "Change autoneg flow control parameter",
7176 (void *)&cmd_lfc_set_set,
7177 (void *)&cmd_lfc_set_flow_ctrl,
7178 (void *)&cmd_lfc_set_autoneg_str,
7179 (void *)&cmd_lfc_set_autoneg,
7180 (void *)&cmd_lfc_set_portid,
7186 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7187 __rte_unused struct cmdline *cl,
7190 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7191 cmdline_parse_inst_t *cmd = data;
7192 struct rte_eth_fc_conf fc_conf;
7198 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7199 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7200 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7201 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7203 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7204 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7207 /* Partial command line, retrieve current configuration */
7209 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7211 printf("cannot get current flow ctrl parameters, return"
7212 "code = %d\n", ret);
7216 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7217 (fc_conf.mode == RTE_FC_FULL))
7219 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7220 (fc_conf.mode == RTE_FC_FULL))
7224 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7225 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7227 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7228 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7230 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7232 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7233 fc_conf.high_water = res->high_water;
7235 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7236 fc_conf.low_water = res->low_water;
7238 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7239 fc_conf.pause_time = res->pause_time;
7241 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7242 fc_conf.send_xon = res->send_xon;
7244 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7245 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7246 fc_conf.mac_ctrl_frame_fwd = 1;
7248 fc_conf.mac_ctrl_frame_fwd = 0;
7251 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7252 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7254 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7256 printf("bad flow contrl parameter, return code = %d \n", ret);
7259 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7260 struct cmd_priority_flow_ctrl_set_result {
7261 cmdline_fixed_string_t set;
7262 cmdline_fixed_string_t pfc_ctrl;
7263 cmdline_fixed_string_t rx;
7264 cmdline_fixed_string_t rx_pfc_mode;
7265 cmdline_fixed_string_t tx;
7266 cmdline_fixed_string_t tx_pfc_mode;
7267 uint32_t high_water;
7269 uint16_t pause_time;
7275 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7276 __rte_unused struct cmdline *cl,
7277 __rte_unused void *data)
7279 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7280 struct rte_eth_pfc_conf pfc_conf;
7281 int rx_fc_enable, tx_fc_enable;
7285 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7286 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7287 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7288 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7290 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7291 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7294 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7295 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7296 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7297 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7298 pfc_conf.fc.high_water = res->high_water;
7299 pfc_conf.fc.low_water = res->low_water;
7300 pfc_conf.fc.pause_time = res->pause_time;
7301 pfc_conf.priority = res->priority;
7303 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7305 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7308 cmdline_parse_token_string_t cmd_pfc_set_set =
7309 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7311 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7312 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7313 pfc_ctrl, "pfc_ctrl");
7314 cmdline_parse_token_string_t cmd_pfc_set_rx =
7315 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7317 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7318 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7319 rx_pfc_mode, "on#off");
7320 cmdline_parse_token_string_t cmd_pfc_set_tx =
7321 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7323 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7324 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7325 tx_pfc_mode, "on#off");
7326 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7327 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7328 high_water, UINT32);
7329 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7330 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7332 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7333 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7334 pause_time, UINT16);
7335 cmdline_parse_token_num_t cmd_pfc_set_priority =
7336 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7338 cmdline_parse_token_num_t cmd_pfc_set_portid =
7339 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7342 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7343 .f = cmd_priority_flow_ctrl_set_parsed,
7345 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7346 "<pause_time> <priority> <port_id>: "
7347 "Configure the Ethernet priority flow control",
7349 (void *)&cmd_pfc_set_set,
7350 (void *)&cmd_pfc_set_flow_ctrl,
7351 (void *)&cmd_pfc_set_rx,
7352 (void *)&cmd_pfc_set_rx_mode,
7353 (void *)&cmd_pfc_set_tx,
7354 (void *)&cmd_pfc_set_tx_mode,
7355 (void *)&cmd_pfc_set_high_water,
7356 (void *)&cmd_pfc_set_low_water,
7357 (void *)&cmd_pfc_set_pause_time,
7358 (void *)&cmd_pfc_set_priority,
7359 (void *)&cmd_pfc_set_portid,
7364 /* *** RESET CONFIGURATION *** */
7365 struct cmd_reset_result {
7366 cmdline_fixed_string_t reset;
7367 cmdline_fixed_string_t def;
7370 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7372 __rte_unused void *data)
7374 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7375 set_def_fwd_config();
7378 cmdline_parse_token_string_t cmd_reset_set =
7379 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7380 cmdline_parse_token_string_t cmd_reset_def =
7381 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7384 cmdline_parse_inst_t cmd_reset = {
7385 .f = cmd_reset_parsed,
7387 .help_str = "set default: Reset default forwarding configuration",
7389 (void *)&cmd_reset_set,
7390 (void *)&cmd_reset_def,
7395 /* *** START FORWARDING *** */
7396 struct cmd_start_result {
7397 cmdline_fixed_string_t start;
7400 cmdline_parse_token_string_t cmd_start_start =
7401 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7403 static void cmd_start_parsed(__rte_unused void *parsed_result,
7404 __rte_unused struct cmdline *cl,
7405 __rte_unused void *data)
7407 start_packet_forwarding(0);
7410 cmdline_parse_inst_t cmd_start = {
7411 .f = cmd_start_parsed,
7413 .help_str = "start: Start packet forwarding",
7415 (void *)&cmd_start_start,
7420 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7421 struct cmd_start_tx_first_result {
7422 cmdline_fixed_string_t start;
7423 cmdline_fixed_string_t tx_first;
7427 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7428 __rte_unused struct cmdline *cl,
7429 __rte_unused void *data)
7431 start_packet_forwarding(1);
7434 cmdline_parse_token_string_t cmd_start_tx_first_start =
7435 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7437 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7438 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7439 tx_first, "tx_first");
7441 cmdline_parse_inst_t cmd_start_tx_first = {
7442 .f = cmd_start_tx_first_parsed,
7444 .help_str = "start tx_first: Start packet forwarding, "
7445 "after sending 1 burst of packets",
7447 (void *)&cmd_start_tx_first_start,
7448 (void *)&cmd_start_tx_first_tx_first,
7453 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7454 struct cmd_start_tx_first_n_result {
7455 cmdline_fixed_string_t start;
7456 cmdline_fixed_string_t tx_first;
7461 cmd_start_tx_first_n_parsed(void *parsed_result,
7462 __rte_unused struct cmdline *cl,
7463 __rte_unused void *data)
7465 struct cmd_start_tx_first_n_result *res = parsed_result;
7467 start_packet_forwarding(res->tx_num);
7470 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7471 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7473 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7474 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7475 tx_first, "tx_first");
7476 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7477 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7480 cmdline_parse_inst_t cmd_start_tx_first_n = {
7481 .f = cmd_start_tx_first_n_parsed,
7483 .help_str = "start tx_first <num>: "
7484 "packet forwarding, after sending <num> bursts of packets",
7486 (void *)&cmd_start_tx_first_n_start,
7487 (void *)&cmd_start_tx_first_n_tx_first,
7488 (void *)&cmd_start_tx_first_n_tx_num,
7493 /* *** SET LINK UP *** */
7494 struct cmd_set_link_up_result {
7495 cmdline_fixed_string_t set;
7496 cmdline_fixed_string_t link_up;
7497 cmdline_fixed_string_t port;
7501 cmdline_parse_token_string_t cmd_set_link_up_set =
7502 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7503 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7504 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7506 cmdline_parse_token_string_t cmd_set_link_up_port =
7507 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7508 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7509 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7511 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7512 __rte_unused struct cmdline *cl,
7513 __rte_unused void *data)
7515 struct cmd_set_link_up_result *res = parsed_result;
7516 dev_set_link_up(res->port_id);
7519 cmdline_parse_inst_t cmd_set_link_up = {
7520 .f = cmd_set_link_up_parsed,
7522 .help_str = "set link-up port <port id>",
7524 (void *)&cmd_set_link_up_set,
7525 (void *)&cmd_set_link_up_link_up,
7526 (void *)&cmd_set_link_up_port,
7527 (void *)&cmd_set_link_up_port_id,
7532 /* *** SET LINK DOWN *** */
7533 struct cmd_set_link_down_result {
7534 cmdline_fixed_string_t set;
7535 cmdline_fixed_string_t link_down;
7536 cmdline_fixed_string_t port;
7540 cmdline_parse_token_string_t cmd_set_link_down_set =
7541 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7542 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7543 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7545 cmdline_parse_token_string_t cmd_set_link_down_port =
7546 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7547 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7548 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7550 static void cmd_set_link_down_parsed(
7551 __rte_unused void *parsed_result,
7552 __rte_unused struct cmdline *cl,
7553 __rte_unused void *data)
7555 struct cmd_set_link_down_result *res = parsed_result;
7556 dev_set_link_down(res->port_id);
7559 cmdline_parse_inst_t cmd_set_link_down = {
7560 .f = cmd_set_link_down_parsed,
7562 .help_str = "set link-down port <port id>",
7564 (void *)&cmd_set_link_down_set,
7565 (void *)&cmd_set_link_down_link_down,
7566 (void *)&cmd_set_link_down_port,
7567 (void *)&cmd_set_link_down_port_id,
7572 /* *** SHOW CFG *** */
7573 struct cmd_showcfg_result {
7574 cmdline_fixed_string_t show;
7575 cmdline_fixed_string_t cfg;
7576 cmdline_fixed_string_t what;
7579 static void cmd_showcfg_parsed(void *parsed_result,
7580 __rte_unused struct cmdline *cl,
7581 __rte_unused void *data)
7583 struct cmd_showcfg_result *res = parsed_result;
7584 if (!strcmp(res->what, "rxtx"))
7585 rxtx_config_display();
7586 else if (!strcmp(res->what, "cores"))
7587 fwd_lcores_config_display();
7588 else if (!strcmp(res->what, "fwd"))
7589 pkt_fwd_config_display(&cur_fwd_config);
7590 else if (!strcmp(res->what, "rxpkts"))
7591 show_rx_pkt_segments();
7592 else if (!strcmp(res->what, "txpkts"))
7593 show_tx_pkt_segments();
7594 else if (!strcmp(res->what, "txtimes"))
7595 show_tx_pkt_times();
7598 cmdline_parse_token_string_t cmd_showcfg_show =
7599 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7600 cmdline_parse_token_string_t cmd_showcfg_port =
7601 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7602 cmdline_parse_token_string_t cmd_showcfg_what =
7603 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7604 "rxtx#cores#fwd#rxpkts#txpkts#txtimes");
7606 cmdline_parse_inst_t cmd_showcfg = {
7607 .f = cmd_showcfg_parsed,
7609 .help_str = "show config rxtx|cores|fwd|rxpkts|txpkts|txtimes",
7611 (void *)&cmd_showcfg_show,
7612 (void *)&cmd_showcfg_port,
7613 (void *)&cmd_showcfg_what,
7618 /* *** SHOW ALL PORT INFO *** */
7619 struct cmd_showportall_result {
7620 cmdline_fixed_string_t show;
7621 cmdline_fixed_string_t port;
7622 cmdline_fixed_string_t what;
7623 cmdline_fixed_string_t all;
7626 static void cmd_showportall_parsed(void *parsed_result,
7627 __rte_unused struct cmdline *cl,
7628 __rte_unused void *data)
7632 struct cmd_showportall_result *res = parsed_result;
7633 if (!strcmp(res->show, "clear")) {
7634 if (!strcmp(res->what, "stats"))
7635 RTE_ETH_FOREACH_DEV(i)
7637 else if (!strcmp(res->what, "xstats"))
7638 RTE_ETH_FOREACH_DEV(i)
7639 nic_xstats_clear(i);
7640 } else if (!strcmp(res->what, "info"))
7641 RTE_ETH_FOREACH_DEV(i)
7642 port_infos_display(i);
7643 else if (!strcmp(res->what, "summary")) {
7644 port_summary_header_display();
7645 RTE_ETH_FOREACH_DEV(i)
7646 port_summary_display(i);
7648 else if (!strcmp(res->what, "stats"))
7649 RTE_ETH_FOREACH_DEV(i)
7650 nic_stats_display(i);
7651 else if (!strcmp(res->what, "xstats"))
7652 RTE_ETH_FOREACH_DEV(i)
7653 nic_xstats_display(i);
7654 else if (!strcmp(res->what, "fdir"))
7655 RTE_ETH_FOREACH_DEV(i)
7657 else if (!strcmp(res->what, "stat_qmap"))
7658 RTE_ETH_FOREACH_DEV(i)
7659 nic_stats_mapping_display(i);
7660 else if (!strcmp(res->what, "dcb_tc"))
7661 RTE_ETH_FOREACH_DEV(i)
7662 port_dcb_info_display(i);
7663 else if (!strcmp(res->what, "cap"))
7664 RTE_ETH_FOREACH_DEV(i)
7665 port_offload_cap_display(i);
7668 cmdline_parse_token_string_t cmd_showportall_show =
7669 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7671 cmdline_parse_token_string_t cmd_showportall_port =
7672 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7673 cmdline_parse_token_string_t cmd_showportall_what =
7674 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7675 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7676 cmdline_parse_token_string_t cmd_showportall_all =
7677 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7678 cmdline_parse_inst_t cmd_showportall = {
7679 .f = cmd_showportall_parsed,
7681 .help_str = "show|clear port "
7682 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7684 (void *)&cmd_showportall_show,
7685 (void *)&cmd_showportall_port,
7686 (void *)&cmd_showportall_what,
7687 (void *)&cmd_showportall_all,
7692 /* *** SHOW PORT INFO *** */
7693 struct cmd_showport_result {
7694 cmdline_fixed_string_t show;
7695 cmdline_fixed_string_t port;
7696 cmdline_fixed_string_t what;
7700 static void cmd_showport_parsed(void *parsed_result,
7701 __rte_unused struct cmdline *cl,
7702 __rte_unused void *data)
7704 struct cmd_showport_result *res = parsed_result;
7705 if (!strcmp(res->show, "clear")) {
7706 if (!strcmp(res->what, "stats"))
7707 nic_stats_clear(res->portnum);
7708 else if (!strcmp(res->what, "xstats"))
7709 nic_xstats_clear(res->portnum);
7710 } else if (!strcmp(res->what, "info"))
7711 port_infos_display(res->portnum);
7712 else if (!strcmp(res->what, "summary")) {
7713 port_summary_header_display();
7714 port_summary_display(res->portnum);
7716 else if (!strcmp(res->what, "stats"))
7717 nic_stats_display(res->portnum);
7718 else if (!strcmp(res->what, "xstats"))
7719 nic_xstats_display(res->portnum);
7720 else if (!strcmp(res->what, "fdir"))
7721 fdir_get_infos(res->portnum);
7722 else if (!strcmp(res->what, "stat_qmap"))
7723 nic_stats_mapping_display(res->portnum);
7724 else if (!strcmp(res->what, "dcb_tc"))
7725 port_dcb_info_display(res->portnum);
7726 else if (!strcmp(res->what, "cap"))
7727 port_offload_cap_display(res->portnum);
7730 cmdline_parse_token_string_t cmd_showport_show =
7731 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7733 cmdline_parse_token_string_t cmd_showport_port =
7734 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7735 cmdline_parse_token_string_t cmd_showport_what =
7736 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7737 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7738 cmdline_parse_token_num_t cmd_showport_portnum =
7739 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7741 cmdline_parse_inst_t cmd_showport = {
7742 .f = cmd_showport_parsed,
7744 .help_str = "show|clear port "
7745 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7748 (void *)&cmd_showport_show,
7749 (void *)&cmd_showport_port,
7750 (void *)&cmd_showport_what,
7751 (void *)&cmd_showport_portnum,
7756 /* *** SHOW DEVICE INFO *** */
7757 struct cmd_showdevice_result {
7758 cmdline_fixed_string_t show;
7759 cmdline_fixed_string_t device;
7760 cmdline_fixed_string_t what;
7761 cmdline_fixed_string_t identifier;
7764 static void cmd_showdevice_parsed(void *parsed_result,
7765 __rte_unused struct cmdline *cl,
7766 __rte_unused void *data)
7768 struct cmd_showdevice_result *res = parsed_result;
7769 if (!strcmp(res->what, "info")) {
7770 if (!strcmp(res->identifier, "all"))
7771 device_infos_display(NULL);
7773 device_infos_display(res->identifier);
7777 cmdline_parse_token_string_t cmd_showdevice_show =
7778 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7780 cmdline_parse_token_string_t cmd_showdevice_device =
7781 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7782 cmdline_parse_token_string_t cmd_showdevice_what =
7783 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7785 cmdline_parse_token_string_t cmd_showdevice_identifier =
7786 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7789 cmdline_parse_inst_t cmd_showdevice = {
7790 .f = cmd_showdevice_parsed,
7792 .help_str = "show device info <identifier>|all",
7794 (void *)&cmd_showdevice_show,
7795 (void *)&cmd_showdevice_device,
7796 (void *)&cmd_showdevice_what,
7797 (void *)&cmd_showdevice_identifier,
7802 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7803 struct cmd_showeeprom_result {
7804 cmdline_fixed_string_t show;
7805 cmdline_fixed_string_t port;
7807 cmdline_fixed_string_t type;
7810 static void cmd_showeeprom_parsed(void *parsed_result,
7811 __rte_unused struct cmdline *cl,
7812 __rte_unused void *data)
7814 struct cmd_showeeprom_result *res = parsed_result;
7816 if (!strcmp(res->type, "eeprom"))
7817 port_eeprom_display(res->portnum);
7818 else if (!strcmp(res->type, "module_eeprom"))
7819 port_module_eeprom_display(res->portnum);
7821 printf("Unknown argument\n");
7824 cmdline_parse_token_string_t cmd_showeeprom_show =
7825 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7826 cmdline_parse_token_string_t cmd_showeeprom_port =
7827 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7828 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7829 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7830 cmdline_parse_token_string_t cmd_showeeprom_type =
7831 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7833 cmdline_parse_inst_t cmd_showeeprom = {
7834 .f = cmd_showeeprom_parsed,
7836 .help_str = "show port <port_id> module_eeprom|eeprom",
7838 (void *)&cmd_showeeprom_show,
7839 (void *)&cmd_showeeprom_port,
7840 (void *)&cmd_showeeprom_portnum,
7841 (void *)&cmd_showeeprom_type,
7846 /* *** SHOW QUEUE INFO *** */
7847 struct cmd_showqueue_result {
7848 cmdline_fixed_string_t show;
7849 cmdline_fixed_string_t type;
7850 cmdline_fixed_string_t what;
7856 cmd_showqueue_parsed(void *parsed_result,
7857 __rte_unused struct cmdline *cl,
7858 __rte_unused void *data)
7860 struct cmd_showqueue_result *res = parsed_result;
7862 if (!strcmp(res->type, "rxq"))
7863 rx_queue_infos_display(res->portnum, res->queuenum);
7864 else if (!strcmp(res->type, "txq"))
7865 tx_queue_infos_display(res->portnum, res->queuenum);
7868 cmdline_parse_token_string_t cmd_showqueue_show =
7869 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7870 cmdline_parse_token_string_t cmd_showqueue_type =
7871 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7872 cmdline_parse_token_string_t cmd_showqueue_what =
7873 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7874 cmdline_parse_token_num_t cmd_showqueue_portnum =
7875 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7876 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7877 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7879 cmdline_parse_inst_t cmd_showqueue = {
7880 .f = cmd_showqueue_parsed,
7882 .help_str = "show rxq|txq info <port_id> <queue_id>",
7884 (void *)&cmd_showqueue_show,
7885 (void *)&cmd_showqueue_type,
7886 (void *)&cmd_showqueue_what,
7887 (void *)&cmd_showqueue_portnum,
7888 (void *)&cmd_showqueue_queuenum,
7893 /* show/clear fwd engine statistics */
7895 cmdline_fixed_string_t action;
7896 cmdline_fixed_string_t fwd;
7897 cmdline_fixed_string_t stats;
7898 cmdline_fixed_string_t all;
7901 cmdline_parse_token_string_t cmd_fwd_action =
7902 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7903 cmdline_parse_token_string_t cmd_fwd_fwd =
7904 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7905 cmdline_parse_token_string_t cmd_fwd_stats =
7906 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7907 cmdline_parse_token_string_t cmd_fwd_all =
7908 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7911 cmd_showfwdall_parsed(void *parsed_result,
7912 __rte_unused struct cmdline *cl,
7913 __rte_unused void *data)
7915 struct fwd_result *res = parsed_result;
7917 if (!strcmp(res->action, "show"))
7918 fwd_stats_display();
7923 static cmdline_parse_inst_t cmd_showfwdall = {
7924 .f = cmd_showfwdall_parsed,
7926 .help_str = "show|clear fwd stats all",
7928 (void *)&cmd_fwd_action,
7929 (void *)&cmd_fwd_fwd,
7930 (void *)&cmd_fwd_stats,
7931 (void *)&cmd_fwd_all,
7936 /* *** READ PORT REGISTER *** */
7937 struct cmd_read_reg_result {
7938 cmdline_fixed_string_t read;
7939 cmdline_fixed_string_t reg;
7945 cmd_read_reg_parsed(void *parsed_result,
7946 __rte_unused struct cmdline *cl,
7947 __rte_unused void *data)
7949 struct cmd_read_reg_result *res = parsed_result;
7950 port_reg_display(res->port_id, res->reg_off);
7953 cmdline_parse_token_string_t cmd_read_reg_read =
7954 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7955 cmdline_parse_token_string_t cmd_read_reg_reg =
7956 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7957 cmdline_parse_token_num_t cmd_read_reg_port_id =
7958 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7959 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7960 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7962 cmdline_parse_inst_t cmd_read_reg = {
7963 .f = cmd_read_reg_parsed,
7965 .help_str = "read reg <port_id> <reg_off>",
7967 (void *)&cmd_read_reg_read,
7968 (void *)&cmd_read_reg_reg,
7969 (void *)&cmd_read_reg_port_id,
7970 (void *)&cmd_read_reg_reg_off,
7975 /* *** READ PORT REGISTER BIT FIELD *** */
7976 struct cmd_read_reg_bit_field_result {
7977 cmdline_fixed_string_t read;
7978 cmdline_fixed_string_t regfield;
7986 cmd_read_reg_bit_field_parsed(void *parsed_result,
7987 __rte_unused struct cmdline *cl,
7988 __rte_unused void *data)
7990 struct cmd_read_reg_bit_field_result *res = parsed_result;
7991 port_reg_bit_field_display(res->port_id, res->reg_off,
7992 res->bit1_pos, res->bit2_pos);
7995 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7996 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7998 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7999 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8000 regfield, "regfield");
8001 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8002 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8004 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8005 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8007 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8008 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8010 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8011 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8014 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8015 .f = cmd_read_reg_bit_field_parsed,
8017 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8018 "Read register bit field between bit_x and bit_y included",
8020 (void *)&cmd_read_reg_bit_field_read,
8021 (void *)&cmd_read_reg_bit_field_regfield,
8022 (void *)&cmd_read_reg_bit_field_port_id,
8023 (void *)&cmd_read_reg_bit_field_reg_off,
8024 (void *)&cmd_read_reg_bit_field_bit1_pos,
8025 (void *)&cmd_read_reg_bit_field_bit2_pos,
8030 /* *** READ PORT REGISTER BIT *** */
8031 struct cmd_read_reg_bit_result {
8032 cmdline_fixed_string_t read;
8033 cmdline_fixed_string_t regbit;
8040 cmd_read_reg_bit_parsed(void *parsed_result,
8041 __rte_unused struct cmdline *cl,
8042 __rte_unused void *data)
8044 struct cmd_read_reg_bit_result *res = parsed_result;
8045 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8048 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8049 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8050 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8051 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8053 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8054 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
8055 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8056 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
8057 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8058 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
8060 cmdline_parse_inst_t cmd_read_reg_bit = {
8061 .f = cmd_read_reg_bit_parsed,
8063 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8065 (void *)&cmd_read_reg_bit_read,
8066 (void *)&cmd_read_reg_bit_regbit,
8067 (void *)&cmd_read_reg_bit_port_id,
8068 (void *)&cmd_read_reg_bit_reg_off,
8069 (void *)&cmd_read_reg_bit_bit_pos,
8074 /* *** WRITE PORT REGISTER *** */
8075 struct cmd_write_reg_result {
8076 cmdline_fixed_string_t write;
8077 cmdline_fixed_string_t reg;
8084 cmd_write_reg_parsed(void *parsed_result,
8085 __rte_unused struct cmdline *cl,
8086 __rte_unused void *data)
8088 struct cmd_write_reg_result *res = parsed_result;
8089 port_reg_set(res->port_id, res->reg_off, res->value);
8092 cmdline_parse_token_string_t cmd_write_reg_write =
8093 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8094 cmdline_parse_token_string_t cmd_write_reg_reg =
8095 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8096 cmdline_parse_token_num_t cmd_write_reg_port_id =
8097 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8098 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8099 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8100 cmdline_parse_token_num_t cmd_write_reg_value =
8101 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8103 cmdline_parse_inst_t cmd_write_reg = {
8104 .f = cmd_write_reg_parsed,
8106 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8108 (void *)&cmd_write_reg_write,
8109 (void *)&cmd_write_reg_reg,
8110 (void *)&cmd_write_reg_port_id,
8111 (void *)&cmd_write_reg_reg_off,
8112 (void *)&cmd_write_reg_value,
8117 /* *** WRITE PORT REGISTER BIT FIELD *** */
8118 struct cmd_write_reg_bit_field_result {
8119 cmdline_fixed_string_t write;
8120 cmdline_fixed_string_t regfield;
8129 cmd_write_reg_bit_field_parsed(void *parsed_result,
8130 __rte_unused struct cmdline *cl,
8131 __rte_unused void *data)
8133 struct cmd_write_reg_bit_field_result *res = parsed_result;
8134 port_reg_bit_field_set(res->port_id, res->reg_off,
8135 res->bit1_pos, res->bit2_pos, res->value);
8138 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8139 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8141 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8142 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8143 regfield, "regfield");
8144 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8145 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8147 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8148 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8150 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8151 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8153 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8154 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8156 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8157 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8160 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8161 .f = cmd_write_reg_bit_field_parsed,
8163 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8165 "Set register bit field between bit_x and bit_y included",
8167 (void *)&cmd_write_reg_bit_field_write,
8168 (void *)&cmd_write_reg_bit_field_regfield,
8169 (void *)&cmd_write_reg_bit_field_port_id,
8170 (void *)&cmd_write_reg_bit_field_reg_off,
8171 (void *)&cmd_write_reg_bit_field_bit1_pos,
8172 (void *)&cmd_write_reg_bit_field_bit2_pos,
8173 (void *)&cmd_write_reg_bit_field_value,
8178 /* *** WRITE PORT REGISTER BIT *** */
8179 struct cmd_write_reg_bit_result {
8180 cmdline_fixed_string_t write;
8181 cmdline_fixed_string_t regbit;
8189 cmd_write_reg_bit_parsed(void *parsed_result,
8190 __rte_unused struct cmdline *cl,
8191 __rte_unused void *data)
8193 struct cmd_write_reg_bit_result *res = parsed_result;
8194 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8197 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8198 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8200 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8201 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8203 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8204 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8205 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8206 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8207 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8208 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8209 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8210 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8212 cmdline_parse_inst_t cmd_write_reg_bit = {
8213 .f = cmd_write_reg_bit_parsed,
8215 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8218 (void *)&cmd_write_reg_bit_write,
8219 (void *)&cmd_write_reg_bit_regbit,
8220 (void *)&cmd_write_reg_bit_port_id,
8221 (void *)&cmd_write_reg_bit_reg_off,
8222 (void *)&cmd_write_reg_bit_bit_pos,
8223 (void *)&cmd_write_reg_bit_value,
8228 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8229 struct cmd_read_rxd_txd_result {
8230 cmdline_fixed_string_t read;
8231 cmdline_fixed_string_t rxd_txd;
8238 cmd_read_rxd_txd_parsed(void *parsed_result,
8239 __rte_unused struct cmdline *cl,
8240 __rte_unused void *data)
8242 struct cmd_read_rxd_txd_result *res = parsed_result;
8244 if (!strcmp(res->rxd_txd, "rxd"))
8245 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8246 else if (!strcmp(res->rxd_txd, "txd"))
8247 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8250 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8251 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8252 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8253 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8255 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8256 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8257 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8258 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8259 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8260 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8262 cmdline_parse_inst_t cmd_read_rxd_txd = {
8263 .f = cmd_read_rxd_txd_parsed,
8265 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8267 (void *)&cmd_read_rxd_txd_read,
8268 (void *)&cmd_read_rxd_txd_rxd_txd,
8269 (void *)&cmd_read_rxd_txd_port_id,
8270 (void *)&cmd_read_rxd_txd_queue_id,
8271 (void *)&cmd_read_rxd_txd_desc_id,
8277 struct cmd_quit_result {
8278 cmdline_fixed_string_t quit;
8281 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8283 __rte_unused void *data)
8288 cmdline_parse_token_string_t cmd_quit_quit =
8289 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8291 cmdline_parse_inst_t cmd_quit = {
8292 .f = cmd_quit_parsed,
8294 .help_str = "quit: Exit application",
8296 (void *)&cmd_quit_quit,
8301 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8302 struct cmd_mac_addr_result {
8303 cmdline_fixed_string_t mac_addr_cmd;
8304 cmdline_fixed_string_t what;
8306 struct rte_ether_addr address;
8309 static void cmd_mac_addr_parsed(void *parsed_result,
8310 __rte_unused struct cmdline *cl,
8311 __rte_unused void *data)
8313 struct cmd_mac_addr_result *res = parsed_result;
8316 if (strcmp(res->what, "add") == 0)
8317 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8318 else if (strcmp(res->what, "set") == 0)
8319 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8322 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8324 /* check the return value and print it if is < 0 */
8326 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8330 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8331 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8333 cmdline_parse_token_string_t cmd_mac_addr_what =
8334 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8336 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8337 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8339 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8340 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8342 cmdline_parse_inst_t cmd_mac_addr = {
8343 .f = cmd_mac_addr_parsed,
8345 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8346 "Add/Remove/Set MAC address on port_id",
8348 (void *)&cmd_mac_addr_cmd,
8349 (void *)&cmd_mac_addr_what,
8350 (void *)&cmd_mac_addr_portnum,
8351 (void *)&cmd_mac_addr_addr,
8356 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8357 struct cmd_eth_peer_result {
8358 cmdline_fixed_string_t set;
8359 cmdline_fixed_string_t eth_peer;
8361 cmdline_fixed_string_t peer_addr;
8364 static void cmd_set_eth_peer_parsed(void *parsed_result,
8365 __rte_unused struct cmdline *cl,
8366 __rte_unused void *data)
8368 struct cmd_eth_peer_result *res = parsed_result;
8370 if (test_done == 0) {
8371 printf("Please stop forwarding first\n");
8374 if (!strcmp(res->eth_peer, "eth-peer")) {
8375 set_fwd_eth_peer(res->port_id, res->peer_addr);
8379 cmdline_parse_token_string_t cmd_eth_peer_set =
8380 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8381 cmdline_parse_token_string_t cmd_eth_peer =
8382 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8383 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8384 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8385 cmdline_parse_token_string_t cmd_eth_peer_addr =
8386 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8388 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8389 .f = cmd_set_eth_peer_parsed,
8391 .help_str = "set eth-peer <port_id> <peer_mac>",
8393 (void *)&cmd_eth_peer_set,
8394 (void *)&cmd_eth_peer,
8395 (void *)&cmd_eth_peer_port_id,
8396 (void *)&cmd_eth_peer_addr,
8401 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8402 struct cmd_set_qmap_result {
8403 cmdline_fixed_string_t set;
8404 cmdline_fixed_string_t qmap;
8405 cmdline_fixed_string_t what;
8412 cmd_set_qmap_parsed(void *parsed_result,
8413 __rte_unused struct cmdline *cl,
8414 __rte_unused void *data)
8416 struct cmd_set_qmap_result *res = parsed_result;
8417 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8419 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8422 cmdline_parse_token_string_t cmd_setqmap_set =
8423 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8425 cmdline_parse_token_string_t cmd_setqmap_qmap =
8426 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8428 cmdline_parse_token_string_t cmd_setqmap_what =
8429 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8431 cmdline_parse_token_num_t cmd_setqmap_portid =
8432 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8434 cmdline_parse_token_num_t cmd_setqmap_queueid =
8435 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8437 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8438 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8441 cmdline_parse_inst_t cmd_set_qmap = {
8442 .f = cmd_set_qmap_parsed,
8444 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8445 "Set statistics mapping value on tx|rx queue_id of port_id",
8447 (void *)&cmd_setqmap_set,
8448 (void *)&cmd_setqmap_qmap,
8449 (void *)&cmd_setqmap_what,
8450 (void *)&cmd_setqmap_portid,
8451 (void *)&cmd_setqmap_queueid,
8452 (void *)&cmd_setqmap_mapvalue,
8457 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8458 struct cmd_set_xstats_hide_zero_result {
8459 cmdline_fixed_string_t keyword;
8460 cmdline_fixed_string_t name;
8461 cmdline_fixed_string_t on_off;
8465 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8466 __rte_unused struct cmdline *cl,
8467 __rte_unused void *data)
8469 struct cmd_set_xstats_hide_zero_result *res;
8470 uint16_t on_off = 0;
8472 res = parsed_result;
8473 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8474 set_xstats_hide_zero(on_off);
8477 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8478 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8480 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8481 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8482 name, "xstats-hide-zero");
8483 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8484 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8487 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8488 .f = cmd_set_xstats_hide_zero_parsed,
8490 .help_str = "set xstats-hide-zero on|off",
8492 (void *)&cmd_set_xstats_hide_zero_keyword,
8493 (void *)&cmd_set_xstats_hide_zero_name,
8494 (void *)&cmd_set_xstats_hide_zero_on_off,
8499 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8500 struct cmd_set_record_core_cycles_result {
8501 cmdline_fixed_string_t keyword;
8502 cmdline_fixed_string_t name;
8503 cmdline_fixed_string_t on_off;
8507 cmd_set_record_core_cycles_parsed(void *parsed_result,
8508 __rte_unused struct cmdline *cl,
8509 __rte_unused void *data)
8511 struct cmd_set_record_core_cycles_result *res;
8512 uint16_t on_off = 0;
8514 res = parsed_result;
8515 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8516 set_record_core_cycles(on_off);
8519 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8520 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8522 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8523 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8524 name, "record-core-cycles");
8525 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8526 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8529 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8530 .f = cmd_set_record_core_cycles_parsed,
8532 .help_str = "set record-core-cycles on|off",
8534 (void *)&cmd_set_record_core_cycles_keyword,
8535 (void *)&cmd_set_record_core_cycles_name,
8536 (void *)&cmd_set_record_core_cycles_on_off,
8541 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8542 struct cmd_set_record_burst_stats_result {
8543 cmdline_fixed_string_t keyword;
8544 cmdline_fixed_string_t name;
8545 cmdline_fixed_string_t on_off;
8549 cmd_set_record_burst_stats_parsed(void *parsed_result,
8550 __rte_unused struct cmdline *cl,
8551 __rte_unused void *data)
8553 struct cmd_set_record_burst_stats_result *res;
8554 uint16_t on_off = 0;
8556 res = parsed_result;
8557 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8558 set_record_burst_stats(on_off);
8561 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8562 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8564 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8565 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8566 name, "record-burst-stats");
8567 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8568 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8571 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8572 .f = cmd_set_record_burst_stats_parsed,
8574 .help_str = "set record-burst-stats on|off",
8576 (void *)&cmd_set_record_burst_stats_keyword,
8577 (void *)&cmd_set_record_burst_stats_name,
8578 (void *)&cmd_set_record_burst_stats_on_off,
8583 /* *** CONFIGURE UNICAST HASH TABLE *** */
8584 struct cmd_set_uc_hash_table {
8585 cmdline_fixed_string_t set;
8586 cmdline_fixed_string_t port;
8588 cmdline_fixed_string_t what;
8589 struct rte_ether_addr address;
8590 cmdline_fixed_string_t mode;
8594 cmd_set_uc_hash_parsed(void *parsed_result,
8595 __rte_unused struct cmdline *cl,
8596 __rte_unused void *data)
8599 struct cmd_set_uc_hash_table *res = parsed_result;
8601 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8603 if (strcmp(res->what, "uta") == 0)
8604 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8605 &res->address,(uint8_t)is_on);
8607 printf("bad unicast hash table parameter, return code = %d \n", ret);
8611 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8612 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8614 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8615 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8617 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8618 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8620 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8621 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8623 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8624 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8626 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8627 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8630 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8631 .f = cmd_set_uc_hash_parsed,
8633 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8635 (void *)&cmd_set_uc_hash_set,
8636 (void *)&cmd_set_uc_hash_port,
8637 (void *)&cmd_set_uc_hash_portid,
8638 (void *)&cmd_set_uc_hash_what,
8639 (void *)&cmd_set_uc_hash_mac,
8640 (void *)&cmd_set_uc_hash_mode,
8645 struct cmd_set_uc_all_hash_table {
8646 cmdline_fixed_string_t set;
8647 cmdline_fixed_string_t port;
8649 cmdline_fixed_string_t what;
8650 cmdline_fixed_string_t value;
8651 cmdline_fixed_string_t mode;
8655 cmd_set_uc_all_hash_parsed(void *parsed_result,
8656 __rte_unused struct cmdline *cl,
8657 __rte_unused void *data)
8660 struct cmd_set_uc_all_hash_table *res = parsed_result;
8662 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8664 if ((strcmp(res->what, "uta") == 0) &&
8665 (strcmp(res->value, "all") == 0))
8666 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8668 printf("bad unicast hash table parameter,"
8669 "return code = %d \n", ret);
8672 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8673 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8675 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8676 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8678 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8679 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8681 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8682 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8684 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8685 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8687 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8688 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8691 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8692 .f = cmd_set_uc_all_hash_parsed,
8694 .help_str = "set port <port_id> uta all on|off",
8696 (void *)&cmd_set_uc_all_hash_set,
8697 (void *)&cmd_set_uc_all_hash_port,
8698 (void *)&cmd_set_uc_all_hash_portid,
8699 (void *)&cmd_set_uc_all_hash_what,
8700 (void *)&cmd_set_uc_all_hash_value,
8701 (void *)&cmd_set_uc_all_hash_mode,
8706 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8707 struct cmd_set_vf_macvlan_filter {
8708 cmdline_fixed_string_t set;
8709 cmdline_fixed_string_t port;
8711 cmdline_fixed_string_t vf;
8713 struct rte_ether_addr address;
8714 cmdline_fixed_string_t filter_type;
8715 cmdline_fixed_string_t mode;
8719 cmd_set_vf_macvlan_parsed(void *parsed_result,
8720 __rte_unused struct cmdline *cl,
8721 __rte_unused void *data)
8724 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8725 struct rte_eth_mac_filter filter;
8727 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8729 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8731 /* set VF MAC filter */
8735 filter.dst_id = res->vf_id;
8737 if (!strcmp(res->filter_type, "exact-mac"))
8738 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8739 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8740 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8741 else if (!strcmp(res->filter_type, "hashmac"))
8742 filter.filter_type = RTE_MAC_HASH_MATCH;
8743 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8744 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8746 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8749 ret = rte_eth_dev_filter_ctrl(res->port_id,
8750 RTE_ETH_FILTER_MACVLAN,
8754 ret = rte_eth_dev_filter_ctrl(res->port_id,
8755 RTE_ETH_FILTER_MACVLAN,
8756 RTE_ETH_FILTER_DELETE,
8760 printf("bad set MAC hash parameter, return code = %d\n", ret);
8764 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8765 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8767 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8768 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8770 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8771 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8773 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8774 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8776 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8777 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8779 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8780 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8782 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8783 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8784 filter_type, "exact-mac#exact-mac-vlan"
8785 "#hashmac#hashmac-vlan");
8786 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8787 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8790 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8791 .f = cmd_set_vf_macvlan_parsed,
8793 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8794 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8795 "Exact match rule: exact match of MAC or MAC and VLAN; "
8796 "hash match rule: hash match of MAC and exact match of VLAN",
8798 (void *)&cmd_set_vf_macvlan_set,
8799 (void *)&cmd_set_vf_macvlan_port,
8800 (void *)&cmd_set_vf_macvlan_portid,
8801 (void *)&cmd_set_vf_macvlan_vf,
8802 (void *)&cmd_set_vf_macvlan_vf_id,
8803 (void *)&cmd_set_vf_macvlan_mac,
8804 (void *)&cmd_set_vf_macvlan_filter_type,
8805 (void *)&cmd_set_vf_macvlan_mode,
8810 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8811 struct cmd_set_vf_traffic {
8812 cmdline_fixed_string_t set;
8813 cmdline_fixed_string_t port;
8815 cmdline_fixed_string_t vf;
8817 cmdline_fixed_string_t what;
8818 cmdline_fixed_string_t mode;
8822 cmd_set_vf_traffic_parsed(void *parsed_result,
8823 __rte_unused struct cmdline *cl,
8824 __rte_unused void *data)
8826 struct cmd_set_vf_traffic *res = parsed_result;
8827 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8828 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8830 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8833 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8834 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8836 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8837 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8839 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8840 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8842 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8843 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8845 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8846 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8848 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8849 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8851 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8852 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8855 cmdline_parse_inst_t cmd_set_vf_traffic = {
8856 .f = cmd_set_vf_traffic_parsed,
8858 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8860 (void *)&cmd_setvf_traffic_set,
8861 (void *)&cmd_setvf_traffic_port,
8862 (void *)&cmd_setvf_traffic_portid,
8863 (void *)&cmd_setvf_traffic_vf,
8864 (void *)&cmd_setvf_traffic_vfid,
8865 (void *)&cmd_setvf_traffic_what,
8866 (void *)&cmd_setvf_traffic_mode,
8871 /* *** CONFIGURE VF RECEIVE MODE *** */
8872 struct cmd_set_vf_rxmode {
8873 cmdline_fixed_string_t set;
8874 cmdline_fixed_string_t port;
8876 cmdline_fixed_string_t vf;
8878 cmdline_fixed_string_t what;
8879 cmdline_fixed_string_t mode;
8880 cmdline_fixed_string_t on;
8884 cmd_set_vf_rxmode_parsed(void *parsed_result,
8885 __rte_unused struct cmdline *cl,
8886 __rte_unused void *data)
8889 uint16_t vf_rxmode = 0;
8890 struct cmd_set_vf_rxmode *res = parsed_result;
8892 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8893 if (!strcmp(res->what,"rxmode")) {
8894 if (!strcmp(res->mode, "AUPE"))
8895 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8896 else if (!strcmp(res->mode, "ROPE"))
8897 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8898 else if (!strcmp(res->mode, "BAM"))
8899 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8900 else if (!strncmp(res->mode, "MPE",3))
8901 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8904 RTE_SET_USED(is_on);
8906 #ifdef RTE_LIBRTE_IXGBE_PMD
8907 if (ret == -ENOTSUP)
8908 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8909 vf_rxmode, (uint8_t)is_on);
8911 #ifdef RTE_LIBRTE_BNXT_PMD
8912 if (ret == -ENOTSUP)
8913 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8914 vf_rxmode, (uint8_t)is_on);
8917 printf("bad VF receive mode parameter, return code = %d \n",
8921 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8922 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8924 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8925 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8927 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8928 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8930 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8931 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8933 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8934 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8936 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8937 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8939 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8940 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8941 mode, "AUPE#ROPE#BAM#MPE");
8942 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8943 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8946 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8947 .f = cmd_set_vf_rxmode_parsed,
8949 .help_str = "set port <port_id> vf <vf_id> rxmode "
8950 "AUPE|ROPE|BAM|MPE on|off",
8952 (void *)&cmd_set_vf_rxmode_set,
8953 (void *)&cmd_set_vf_rxmode_port,
8954 (void *)&cmd_set_vf_rxmode_portid,
8955 (void *)&cmd_set_vf_rxmode_vf,
8956 (void *)&cmd_set_vf_rxmode_vfid,
8957 (void *)&cmd_set_vf_rxmode_what,
8958 (void *)&cmd_set_vf_rxmode_mode,
8959 (void *)&cmd_set_vf_rxmode_on,
8964 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8965 struct cmd_vf_mac_addr_result {
8966 cmdline_fixed_string_t mac_addr_cmd;
8967 cmdline_fixed_string_t what;
8968 cmdline_fixed_string_t port;
8970 cmdline_fixed_string_t vf;
8972 struct rte_ether_addr address;
8975 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8976 __rte_unused struct cmdline *cl,
8977 __rte_unused void *data)
8979 struct cmd_vf_mac_addr_result *res = parsed_result;
8982 if (strcmp(res->what, "add") != 0)
8985 #ifdef RTE_LIBRTE_I40E_PMD
8986 if (ret == -ENOTSUP)
8987 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8990 #ifdef RTE_LIBRTE_BNXT_PMD
8991 if (ret == -ENOTSUP)
8992 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8997 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9001 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9002 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9003 mac_addr_cmd,"mac_addr");
9004 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9005 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9007 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9008 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9010 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9011 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9013 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9014 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9016 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9017 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9019 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9020 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9023 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9024 .f = cmd_vf_mac_addr_parsed,
9026 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9027 "Add MAC address filtering for a VF on port_id",
9029 (void *)&cmd_vf_mac_addr_cmd,
9030 (void *)&cmd_vf_mac_addr_what,
9031 (void *)&cmd_vf_mac_addr_port,
9032 (void *)&cmd_vf_mac_addr_portnum,
9033 (void *)&cmd_vf_mac_addr_vf,
9034 (void *)&cmd_vf_mac_addr_vfnum,
9035 (void *)&cmd_vf_mac_addr_addr,
9040 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9041 struct cmd_vf_rx_vlan_filter {
9042 cmdline_fixed_string_t rx_vlan;
9043 cmdline_fixed_string_t what;
9045 cmdline_fixed_string_t port;
9047 cmdline_fixed_string_t vf;
9052 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9053 __rte_unused struct cmdline *cl,
9054 __rte_unused void *data)
9056 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9059 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9061 #ifdef RTE_LIBRTE_IXGBE_PMD
9062 if (ret == -ENOTSUP)
9063 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9064 res->vlan_id, res->vf_mask, is_add);
9066 #ifdef RTE_LIBRTE_I40E_PMD
9067 if (ret == -ENOTSUP)
9068 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9069 res->vlan_id, res->vf_mask, is_add);
9071 #ifdef RTE_LIBRTE_BNXT_PMD
9072 if (ret == -ENOTSUP)
9073 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9074 res->vlan_id, res->vf_mask, is_add);
9081 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9082 res->vlan_id, res->vf_mask);
9085 printf("invalid port_id %d\n", res->port_id);
9088 printf("function not implemented or supported\n");
9091 printf("programming error: (%s)\n", strerror(-ret));
9095 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9096 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9097 rx_vlan, "rx_vlan");
9098 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9099 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9101 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9102 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9104 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9105 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9107 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9108 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9110 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9111 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9113 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9114 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9117 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9118 .f = cmd_vf_rx_vlan_filter_parsed,
9120 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9121 "(vf_mask = hexadecimal VF mask)",
9123 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9124 (void *)&cmd_vf_rx_vlan_filter_what,
9125 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9126 (void *)&cmd_vf_rx_vlan_filter_port,
9127 (void *)&cmd_vf_rx_vlan_filter_portid,
9128 (void *)&cmd_vf_rx_vlan_filter_vf,
9129 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9134 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9135 struct cmd_queue_rate_limit_result {
9136 cmdline_fixed_string_t set;
9137 cmdline_fixed_string_t port;
9139 cmdline_fixed_string_t queue;
9141 cmdline_fixed_string_t rate;
9145 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9146 __rte_unused struct cmdline *cl,
9147 __rte_unused void *data)
9149 struct cmd_queue_rate_limit_result *res = parsed_result;
9152 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9153 && (strcmp(res->queue, "queue") == 0)
9154 && (strcmp(res->rate, "rate") == 0))
9155 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9158 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9162 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9163 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9165 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9166 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9168 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9169 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9171 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9172 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9174 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9175 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9177 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9178 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9180 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9181 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9184 cmdline_parse_inst_t cmd_queue_rate_limit = {
9185 .f = cmd_queue_rate_limit_parsed,
9187 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9188 "Set rate limit for a queue on port_id",
9190 (void *)&cmd_queue_rate_limit_set,
9191 (void *)&cmd_queue_rate_limit_port,
9192 (void *)&cmd_queue_rate_limit_portnum,
9193 (void *)&cmd_queue_rate_limit_queue,
9194 (void *)&cmd_queue_rate_limit_queuenum,
9195 (void *)&cmd_queue_rate_limit_rate,
9196 (void *)&cmd_queue_rate_limit_ratenum,
9201 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9202 struct cmd_vf_rate_limit_result {
9203 cmdline_fixed_string_t set;
9204 cmdline_fixed_string_t port;
9206 cmdline_fixed_string_t vf;
9208 cmdline_fixed_string_t rate;
9210 cmdline_fixed_string_t q_msk;
9214 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9215 __rte_unused struct cmdline *cl,
9216 __rte_unused void *data)
9218 struct cmd_vf_rate_limit_result *res = parsed_result;
9221 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9222 && (strcmp(res->vf, "vf") == 0)
9223 && (strcmp(res->rate, "rate") == 0)
9224 && (strcmp(res->q_msk, "queue_mask") == 0))
9225 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9226 res->rate_num, res->q_msk_val);
9228 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9232 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9233 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9235 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9236 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9238 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9239 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9241 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9242 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9244 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9245 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9247 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9248 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9250 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9251 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9253 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9254 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9255 q_msk, "queue_mask");
9256 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9257 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9260 cmdline_parse_inst_t cmd_vf_rate_limit = {
9261 .f = cmd_vf_rate_limit_parsed,
9263 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9264 "queue_mask <queue_mask_value>: "
9265 "Set rate limit for queues of VF on port_id",
9267 (void *)&cmd_vf_rate_limit_set,
9268 (void *)&cmd_vf_rate_limit_port,
9269 (void *)&cmd_vf_rate_limit_portnum,
9270 (void *)&cmd_vf_rate_limit_vf,
9271 (void *)&cmd_vf_rate_limit_vfnum,
9272 (void *)&cmd_vf_rate_limit_rate,
9273 (void *)&cmd_vf_rate_limit_ratenum,
9274 (void *)&cmd_vf_rate_limit_q_msk,
9275 (void *)&cmd_vf_rate_limit_q_msk_val,
9280 /* *** ADD TUNNEL FILTER OF A PORT *** */
9281 struct cmd_tunnel_filter_result {
9282 cmdline_fixed_string_t cmd;
9283 cmdline_fixed_string_t what;
9285 struct rte_ether_addr outer_mac;
9286 struct rte_ether_addr inner_mac;
9287 cmdline_ipaddr_t ip_value;
9288 uint16_t inner_vlan;
9289 cmdline_fixed_string_t tunnel_type;
9290 cmdline_fixed_string_t filter_type;
9296 cmd_tunnel_filter_parsed(void *parsed_result,
9297 __rte_unused struct cmdline *cl,
9298 __rte_unused void *data)
9300 struct cmd_tunnel_filter_result *res = parsed_result;
9301 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9304 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9306 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9307 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9308 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9310 if (res->ip_value.family == AF_INET) {
9311 tunnel_filter_conf.ip_addr.ipv4_addr =
9312 res->ip_value.addr.ipv4.s_addr;
9313 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9315 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9316 &(res->ip_value.addr.ipv6),
9317 sizeof(struct in6_addr));
9318 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9321 if (!strcmp(res->filter_type, "imac-ivlan"))
9322 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9323 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9324 tunnel_filter_conf.filter_type =
9325 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9326 else if (!strcmp(res->filter_type, "imac-tenid"))
9327 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9328 else if (!strcmp(res->filter_type, "imac"))
9329 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9330 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9331 tunnel_filter_conf.filter_type =
9332 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9333 else if (!strcmp(res->filter_type, "oip"))
9334 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9335 else if (!strcmp(res->filter_type, "iip"))
9336 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9338 printf("The filter type is not supported");
9342 if (!strcmp(res->tunnel_type, "vxlan"))
9343 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9344 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9345 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9346 else if (!strcmp(res->tunnel_type, "nvgre"))
9347 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9348 else if (!strcmp(res->tunnel_type, "ipingre"))
9349 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9351 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9355 tunnel_filter_conf.tenant_id = res->tenant_id;
9356 tunnel_filter_conf.queue_id = res->queue_num;
9357 if (!strcmp(res->what, "add"))
9358 ret = rte_eth_dev_filter_ctrl(res->port_id,
9359 RTE_ETH_FILTER_TUNNEL,
9361 &tunnel_filter_conf);
9363 ret = rte_eth_dev_filter_ctrl(res->port_id,
9364 RTE_ETH_FILTER_TUNNEL,
9365 RTE_ETH_FILTER_DELETE,
9366 &tunnel_filter_conf);
9368 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9372 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9373 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9374 cmd, "tunnel_filter");
9375 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9376 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9378 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9379 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9381 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9382 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9384 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9385 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9387 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9388 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9389 inner_vlan, UINT16);
9390 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9391 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9393 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9394 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9395 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9397 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9398 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9399 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9400 "imac#omac-imac-tenid");
9401 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9402 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9404 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9405 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9408 cmdline_parse_inst_t cmd_tunnel_filter = {
9409 .f = cmd_tunnel_filter_parsed,
9411 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9412 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9413 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9414 "<queue_id>: Add/Rm tunnel filter of a port",
9416 (void *)&cmd_tunnel_filter_cmd,
9417 (void *)&cmd_tunnel_filter_what,
9418 (void *)&cmd_tunnel_filter_port_id,
9419 (void *)&cmd_tunnel_filter_outer_mac,
9420 (void *)&cmd_tunnel_filter_inner_mac,
9421 (void *)&cmd_tunnel_filter_ip_value,
9422 (void *)&cmd_tunnel_filter_innner_vlan,
9423 (void *)&cmd_tunnel_filter_tunnel_type,
9424 (void *)&cmd_tunnel_filter_filter_type,
9425 (void *)&cmd_tunnel_filter_tenant_id,
9426 (void *)&cmd_tunnel_filter_queue_num,
9431 /* *** CONFIGURE TUNNEL UDP PORT *** */
9432 struct cmd_tunnel_udp_config {
9433 cmdline_fixed_string_t cmd;
9434 cmdline_fixed_string_t what;
9440 cmd_tunnel_udp_config_parsed(void *parsed_result,
9441 __rte_unused struct cmdline *cl,
9442 __rte_unused void *data)
9444 struct cmd_tunnel_udp_config *res = parsed_result;
9445 struct rte_eth_udp_tunnel tunnel_udp;
9448 tunnel_udp.udp_port = res->udp_port;
9450 if (!strcmp(res->cmd, "rx_vxlan_port"))
9451 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9453 if (!strcmp(res->what, "add"))
9454 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9457 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9461 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9464 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9465 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9466 cmd, "rx_vxlan_port");
9467 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9468 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9470 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9471 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9473 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9474 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9477 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9478 .f = cmd_tunnel_udp_config_parsed,
9480 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9481 "Add/Remove a tunneling UDP port filter",
9483 (void *)&cmd_tunnel_udp_config_cmd,
9484 (void *)&cmd_tunnel_udp_config_what,
9485 (void *)&cmd_tunnel_udp_config_udp_port,
9486 (void *)&cmd_tunnel_udp_config_port_id,
9491 struct cmd_config_tunnel_udp_port {
9492 cmdline_fixed_string_t port;
9493 cmdline_fixed_string_t config;
9495 cmdline_fixed_string_t udp_tunnel_port;
9496 cmdline_fixed_string_t action;
9497 cmdline_fixed_string_t tunnel_type;
9502 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9503 __rte_unused struct cmdline *cl,
9504 __rte_unused void *data)
9506 struct cmd_config_tunnel_udp_port *res = parsed_result;
9507 struct rte_eth_udp_tunnel tunnel_udp;
9510 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9513 tunnel_udp.udp_port = res->udp_port;
9515 if (!strcmp(res->tunnel_type, "vxlan")) {
9516 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9517 } else if (!strcmp(res->tunnel_type, "geneve")) {
9518 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9519 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9520 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9522 printf("Invalid tunnel type\n");
9526 if (!strcmp(res->action, "add"))
9527 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9530 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9534 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9537 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9538 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9540 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9541 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9543 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9544 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9546 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9547 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9550 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9551 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9553 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9554 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9555 "vxlan#geneve#vxlan-gpe");
9556 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9557 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9560 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9561 .f = cmd_cfg_tunnel_udp_port_parsed,
9563 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9565 (void *)&cmd_config_tunnel_udp_port_port,
9566 (void *)&cmd_config_tunnel_udp_port_config,
9567 (void *)&cmd_config_tunnel_udp_port_port_id,
9568 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9569 (void *)&cmd_config_tunnel_udp_port_action,
9570 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9571 (void *)&cmd_config_tunnel_udp_port_value,
9576 /* *** GLOBAL CONFIG *** */
9577 struct cmd_global_config_result {
9578 cmdline_fixed_string_t cmd;
9580 cmdline_fixed_string_t cfg_type;
9585 cmd_global_config_parsed(void *parsed_result,
9586 __rte_unused struct cmdline *cl,
9587 __rte_unused void *data)
9589 struct cmd_global_config_result *res = parsed_result;
9590 struct rte_eth_global_cfg conf;
9593 memset(&conf, 0, sizeof(conf));
9594 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9595 conf.cfg.gre_key_len = res->len;
9596 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9597 RTE_ETH_FILTER_SET, &conf);
9598 #ifdef RTE_LIBRTE_I40E_PMD
9599 if (ret == -ENOTSUP)
9600 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9603 printf("Global config error\n");
9606 cmdline_parse_token_string_t cmd_global_config_cmd =
9607 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9609 cmdline_parse_token_num_t cmd_global_config_port_id =
9610 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9612 cmdline_parse_token_string_t cmd_global_config_type =
9613 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9614 cfg_type, "gre-key-len");
9615 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9616 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9619 cmdline_parse_inst_t cmd_global_config = {
9620 .f = cmd_global_config_parsed,
9621 .data = (void *)NULL,
9622 .help_str = "global_config <port_id> gre-key-len <key_len>",
9624 (void *)&cmd_global_config_cmd,
9625 (void *)&cmd_global_config_port_id,
9626 (void *)&cmd_global_config_type,
9627 (void *)&cmd_global_config_gre_key_len,
9632 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9633 struct cmd_set_mirror_mask_result {
9634 cmdline_fixed_string_t set;
9635 cmdline_fixed_string_t port;
9637 cmdline_fixed_string_t mirror;
9639 cmdline_fixed_string_t what;
9640 cmdline_fixed_string_t value;
9641 cmdline_fixed_string_t dstpool;
9643 cmdline_fixed_string_t on;
9646 cmdline_parse_token_string_t cmd_mirror_mask_set =
9647 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9649 cmdline_parse_token_string_t cmd_mirror_mask_port =
9650 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9652 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9653 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9655 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9656 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9657 mirror, "mirror-rule");
9658 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9659 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9661 cmdline_parse_token_string_t cmd_mirror_mask_what =
9662 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9663 what, "pool-mirror-up#pool-mirror-down"
9665 cmdline_parse_token_string_t cmd_mirror_mask_value =
9666 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9668 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9669 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9670 dstpool, "dst-pool");
9671 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9672 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9674 cmdline_parse_token_string_t cmd_mirror_mask_on =
9675 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9679 cmd_set_mirror_mask_parsed(void *parsed_result,
9680 __rte_unused struct cmdline *cl,
9681 __rte_unused void *data)
9684 struct cmd_set_mirror_mask_result *res = parsed_result;
9685 struct rte_eth_mirror_conf mr_conf;
9687 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9689 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9691 mr_conf.dst_pool = res->dstpool_id;
9693 if (!strcmp(res->what, "pool-mirror-up")) {
9694 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9695 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9696 } else if (!strcmp(res->what, "pool-mirror-down")) {
9697 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9698 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9699 } else if (!strcmp(res->what, "vlan-mirror")) {
9700 mr_conf.rule_type = ETH_MIRROR_VLAN;
9701 nb_item = parse_item_list(res->value, "vlan",
9702 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9706 for (i = 0; i < nb_item; i++) {
9707 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9708 printf("Invalid vlan_id: must be < 4096\n");
9712 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9713 mr_conf.vlan.vlan_mask |= 1ULL << i;
9717 if (!strcmp(res->on, "on"))
9718 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9721 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9724 printf("mirror rule add error: (%s)\n", strerror(-ret));
9727 cmdline_parse_inst_t cmd_set_mirror_mask = {
9728 .f = cmd_set_mirror_mask_parsed,
9730 .help_str = "set port <port_id> mirror-rule <rule_id> "
9731 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9732 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9734 (void *)&cmd_mirror_mask_set,
9735 (void *)&cmd_mirror_mask_port,
9736 (void *)&cmd_mirror_mask_portid,
9737 (void *)&cmd_mirror_mask_mirror,
9738 (void *)&cmd_mirror_mask_ruleid,
9739 (void *)&cmd_mirror_mask_what,
9740 (void *)&cmd_mirror_mask_value,
9741 (void *)&cmd_mirror_mask_dstpool,
9742 (void *)&cmd_mirror_mask_poolid,
9743 (void *)&cmd_mirror_mask_on,
9748 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9749 struct cmd_set_mirror_link_result {
9750 cmdline_fixed_string_t set;
9751 cmdline_fixed_string_t port;
9753 cmdline_fixed_string_t mirror;
9755 cmdline_fixed_string_t what;
9756 cmdline_fixed_string_t dstpool;
9758 cmdline_fixed_string_t on;
9761 cmdline_parse_token_string_t cmd_mirror_link_set =
9762 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9764 cmdline_parse_token_string_t cmd_mirror_link_port =
9765 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9767 cmdline_parse_token_num_t cmd_mirror_link_portid =
9768 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9770 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9771 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9772 mirror, "mirror-rule");
9773 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9774 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9776 cmdline_parse_token_string_t cmd_mirror_link_what =
9777 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9778 what, "uplink-mirror#downlink-mirror");
9779 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9780 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9781 dstpool, "dst-pool");
9782 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9783 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9785 cmdline_parse_token_string_t cmd_mirror_link_on =
9786 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9790 cmd_set_mirror_link_parsed(void *parsed_result,
9791 __rte_unused struct cmdline *cl,
9792 __rte_unused void *data)
9795 struct cmd_set_mirror_link_result *res = parsed_result;
9796 struct rte_eth_mirror_conf mr_conf;
9798 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9799 if (!strcmp(res->what, "uplink-mirror"))
9800 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9802 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9804 mr_conf.dst_pool = res->dstpool_id;
9806 if (!strcmp(res->on, "on"))
9807 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9810 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9813 /* check the return value and print it if is < 0 */
9815 printf("mirror rule add error: (%s)\n", strerror(-ret));
9819 cmdline_parse_inst_t cmd_set_mirror_link = {
9820 .f = cmd_set_mirror_link_parsed,
9822 .help_str = "set port <port_id> mirror-rule <rule_id> "
9823 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9825 (void *)&cmd_mirror_link_set,
9826 (void *)&cmd_mirror_link_port,
9827 (void *)&cmd_mirror_link_portid,
9828 (void *)&cmd_mirror_link_mirror,
9829 (void *)&cmd_mirror_link_ruleid,
9830 (void *)&cmd_mirror_link_what,
9831 (void *)&cmd_mirror_link_dstpool,
9832 (void *)&cmd_mirror_link_poolid,
9833 (void *)&cmd_mirror_link_on,
9838 /* *** RESET VM MIRROR RULE *** */
9839 struct cmd_rm_mirror_rule_result {
9840 cmdline_fixed_string_t reset;
9841 cmdline_fixed_string_t port;
9843 cmdline_fixed_string_t mirror;
9847 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9848 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9850 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9851 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9853 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9854 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9856 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9857 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9858 mirror, "mirror-rule");
9859 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9860 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9864 cmd_reset_mirror_rule_parsed(void *parsed_result,
9865 __rte_unused struct cmdline *cl,
9866 __rte_unused void *data)
9869 struct cmd_set_mirror_link_result *res = parsed_result;
9871 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9873 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9876 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9877 .f = cmd_reset_mirror_rule_parsed,
9879 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9881 (void *)&cmd_rm_mirror_rule_reset,
9882 (void *)&cmd_rm_mirror_rule_port,
9883 (void *)&cmd_rm_mirror_rule_portid,
9884 (void *)&cmd_rm_mirror_rule_mirror,
9885 (void *)&cmd_rm_mirror_rule_ruleid,
9890 /* ******************************************************************************** */
9892 struct cmd_dump_result {
9893 cmdline_fixed_string_t dump;
9897 dump_struct_sizes(void)
9899 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9900 DUMP_SIZE(struct rte_mbuf);
9901 DUMP_SIZE(struct rte_mempool);
9902 DUMP_SIZE(struct rte_ring);
9907 /* Dump the socket memory statistics on console */
9909 dump_socket_mem(FILE *f)
9911 struct rte_malloc_socket_stats socket_stats;
9916 unsigned int n_alloc = 0;
9917 unsigned int n_free = 0;
9918 static size_t last_allocs;
9919 static size_t last_total;
9922 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9923 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9924 !socket_stats.heap_totalsz_bytes)
9926 total += socket_stats.heap_totalsz_bytes;
9927 alloc += socket_stats.heap_allocsz_bytes;
9928 free += socket_stats.heap_freesz_bytes;
9929 n_alloc += socket_stats.alloc_count;
9930 n_free += socket_stats.free_count;
9932 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9934 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9935 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9936 (double)socket_stats.heap_allocsz_bytes * 100 /
9937 (double)socket_stats.heap_totalsz_bytes,
9938 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9939 socket_stats.alloc_count,
9940 socket_stats.free_count);
9943 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9944 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9945 (double)alloc * 100 / (double)total,
9946 (double)free / (1024 * 1024),
9949 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9950 ((double)total - (double)last_total) / (1024 * 1024),
9951 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9952 last_allocs = alloc;
9956 static void cmd_dump_parsed(void *parsed_result,
9957 __rte_unused struct cmdline *cl,
9958 __rte_unused void *data)
9960 struct cmd_dump_result *res = parsed_result;
9962 if (!strcmp(res->dump, "dump_physmem"))
9963 rte_dump_physmem_layout(stdout);
9964 else if (!strcmp(res->dump, "dump_socket_mem"))
9965 dump_socket_mem(stdout);
9966 else if (!strcmp(res->dump, "dump_memzone"))
9967 rte_memzone_dump(stdout);
9968 else if (!strcmp(res->dump, "dump_struct_sizes"))
9969 dump_struct_sizes();
9970 else if (!strcmp(res->dump, "dump_ring"))
9971 rte_ring_list_dump(stdout);
9972 else if (!strcmp(res->dump, "dump_mempool"))
9973 rte_mempool_list_dump(stdout);
9974 else if (!strcmp(res->dump, "dump_devargs"))
9975 rte_devargs_dump(stdout);
9976 else if (!strcmp(res->dump, "dump_log_types"))
9977 rte_log_dump(stdout);
9980 cmdline_parse_token_string_t cmd_dump_dump =
9981 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9985 "dump_struct_sizes#"
9991 cmdline_parse_inst_t cmd_dump = {
9992 .f = cmd_dump_parsed, /* function to call */
9993 .data = NULL, /* 2nd arg of func */
9994 .help_str = "Dump status",
9995 .tokens = { /* token list, NULL terminated */
9996 (void *)&cmd_dump_dump,
10001 /* ******************************************************************************** */
10003 struct cmd_dump_one_result {
10004 cmdline_fixed_string_t dump;
10005 cmdline_fixed_string_t name;
10008 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
10009 __rte_unused void *data)
10011 struct cmd_dump_one_result *res = parsed_result;
10013 if (!strcmp(res->dump, "dump_ring")) {
10014 struct rte_ring *r;
10015 r = rte_ring_lookup(res->name);
10017 cmdline_printf(cl, "Cannot find ring\n");
10020 rte_ring_dump(stdout, r);
10021 } else if (!strcmp(res->dump, "dump_mempool")) {
10022 struct rte_mempool *mp;
10023 mp = rte_mempool_lookup(res->name);
10025 cmdline_printf(cl, "Cannot find mempool\n");
10028 rte_mempool_dump(stdout, mp);
10032 cmdline_parse_token_string_t cmd_dump_one_dump =
10033 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
10034 "dump_ring#dump_mempool");
10036 cmdline_parse_token_string_t cmd_dump_one_name =
10037 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
10039 cmdline_parse_inst_t cmd_dump_one = {
10040 .f = cmd_dump_one_parsed, /* function to call */
10041 .data = NULL, /* 2nd arg of func */
10042 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
10043 .tokens = { /* token list, NULL terminated */
10044 (void *)&cmd_dump_one_dump,
10045 (void *)&cmd_dump_one_name,
10050 /* *** Add/Del syn filter *** */
10051 struct cmd_syn_filter_result {
10052 cmdline_fixed_string_t filter;
10054 cmdline_fixed_string_t ops;
10055 cmdline_fixed_string_t priority;
10056 cmdline_fixed_string_t high;
10057 cmdline_fixed_string_t queue;
10062 cmd_syn_filter_parsed(void *parsed_result,
10063 __rte_unused struct cmdline *cl,
10064 __rte_unused void *data)
10066 struct cmd_syn_filter_result *res = parsed_result;
10067 struct rte_eth_syn_filter syn_filter;
10070 ret = rte_eth_dev_filter_supported(res->port_id,
10071 RTE_ETH_FILTER_SYN);
10073 printf("syn filter is not supported on port %u.\n",
10078 memset(&syn_filter, 0, sizeof(syn_filter));
10080 if (!strcmp(res->ops, "add")) {
10081 if (!strcmp(res->high, "high"))
10082 syn_filter.hig_pri = 1;
10084 syn_filter.hig_pri = 0;
10086 syn_filter.queue = res->queue_id;
10087 ret = rte_eth_dev_filter_ctrl(res->port_id,
10088 RTE_ETH_FILTER_SYN,
10089 RTE_ETH_FILTER_ADD,
10092 ret = rte_eth_dev_filter_ctrl(res->port_id,
10093 RTE_ETH_FILTER_SYN,
10094 RTE_ETH_FILTER_DELETE,
10098 printf("syn filter programming error: (%s)\n",
10102 cmdline_parse_token_string_t cmd_syn_filter_filter =
10103 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10104 filter, "syn_filter");
10105 cmdline_parse_token_num_t cmd_syn_filter_port_id =
10106 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10108 cmdline_parse_token_string_t cmd_syn_filter_ops =
10109 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10111 cmdline_parse_token_string_t cmd_syn_filter_priority =
10112 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10113 priority, "priority");
10114 cmdline_parse_token_string_t cmd_syn_filter_high =
10115 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10117 cmdline_parse_token_string_t cmd_syn_filter_queue =
10118 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10120 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
10121 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10124 cmdline_parse_inst_t cmd_syn_filter = {
10125 .f = cmd_syn_filter_parsed,
10127 .help_str = "syn_filter <port_id> add|del priority high|low queue "
10128 "<queue_id>: Add/Delete syn filter",
10130 (void *)&cmd_syn_filter_filter,
10131 (void *)&cmd_syn_filter_port_id,
10132 (void *)&cmd_syn_filter_ops,
10133 (void *)&cmd_syn_filter_priority,
10134 (void *)&cmd_syn_filter_high,
10135 (void *)&cmd_syn_filter_queue,
10136 (void *)&cmd_syn_filter_queue_id,
10141 /* *** queue region set *** */
10142 struct cmd_queue_region_result {
10143 cmdline_fixed_string_t set;
10144 cmdline_fixed_string_t port;
10146 cmdline_fixed_string_t cmd;
10147 cmdline_fixed_string_t region;
10149 cmdline_fixed_string_t queue_start_index;
10151 cmdline_fixed_string_t queue_num;
10152 uint8_t queue_num_value;
10156 cmd_queue_region_parsed(void *parsed_result,
10157 __rte_unused struct cmdline *cl,
10158 __rte_unused void *data)
10160 struct cmd_queue_region_result *res = parsed_result;
10161 int ret = -ENOTSUP;
10162 #ifdef RTE_LIBRTE_I40E_PMD
10163 struct rte_pmd_i40e_queue_region_conf region_conf;
10164 enum rte_pmd_i40e_queue_region_op op_type;
10167 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10170 #ifdef RTE_LIBRTE_I40E_PMD
10171 memset(®ion_conf, 0, sizeof(region_conf));
10172 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10173 region_conf.region_id = res->region_id;
10174 region_conf.queue_num = res->queue_num_value;
10175 region_conf.queue_start_index = res->queue_id;
10177 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10178 op_type, ®ion_conf);
10185 printf("function not implemented or supported\n");
10188 printf("queue region config error: (%s)\n", strerror(-ret));
10192 cmdline_parse_token_string_t cmd_queue_region_set =
10193 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10195 cmdline_parse_token_string_t cmd_queue_region_port =
10196 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10197 cmdline_parse_token_num_t cmd_queue_region_port_id =
10198 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10200 cmdline_parse_token_string_t cmd_queue_region_cmd =
10201 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10202 cmd, "queue-region");
10203 cmdline_parse_token_string_t cmd_queue_region_id =
10204 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10205 region, "region_id");
10206 cmdline_parse_token_num_t cmd_queue_region_index =
10207 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10209 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10210 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10211 queue_start_index, "queue_start_index");
10212 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10213 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10215 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10216 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10217 queue_num, "queue_num");
10218 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10219 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10220 queue_num_value, UINT8);
10222 cmdline_parse_inst_t cmd_queue_region = {
10223 .f = cmd_queue_region_parsed,
10225 .help_str = "set port <port_id> queue-region region_id <value> "
10226 "queue_start_index <value> queue_num <value>: Set a queue region",
10228 (void *)&cmd_queue_region_set,
10229 (void *)&cmd_queue_region_port,
10230 (void *)&cmd_queue_region_port_id,
10231 (void *)&cmd_queue_region_cmd,
10232 (void *)&cmd_queue_region_id,
10233 (void *)&cmd_queue_region_index,
10234 (void *)&cmd_queue_region_queue_start_index,
10235 (void *)&cmd_queue_region_queue_id,
10236 (void *)&cmd_queue_region_queue_num,
10237 (void *)&cmd_queue_region_queue_num_value,
10242 /* *** queue region and flowtype set *** */
10243 struct cmd_region_flowtype_result {
10244 cmdline_fixed_string_t set;
10245 cmdline_fixed_string_t port;
10247 cmdline_fixed_string_t cmd;
10248 cmdline_fixed_string_t region;
10250 cmdline_fixed_string_t flowtype;
10251 uint8_t flowtype_id;
10255 cmd_region_flowtype_parsed(void *parsed_result,
10256 __rte_unused struct cmdline *cl,
10257 __rte_unused void *data)
10259 struct cmd_region_flowtype_result *res = parsed_result;
10260 int ret = -ENOTSUP;
10261 #ifdef RTE_LIBRTE_I40E_PMD
10262 struct rte_pmd_i40e_queue_region_conf region_conf;
10263 enum rte_pmd_i40e_queue_region_op op_type;
10266 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10269 #ifdef RTE_LIBRTE_I40E_PMD
10270 memset(®ion_conf, 0, sizeof(region_conf));
10272 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10273 region_conf.region_id = res->region_id;
10274 region_conf.hw_flowtype = res->flowtype_id;
10276 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10277 op_type, ®ion_conf);
10284 printf("function not implemented or supported\n");
10287 printf("region flowtype config error: (%s)\n", strerror(-ret));
10291 cmdline_parse_token_string_t cmd_region_flowtype_set =
10292 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10294 cmdline_parse_token_string_t cmd_region_flowtype_port =
10295 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10297 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10298 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10300 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10301 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10302 cmd, "queue-region");
10303 cmdline_parse_token_string_t cmd_region_flowtype_index =
10304 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10305 region, "region_id");
10306 cmdline_parse_token_num_t cmd_region_flowtype_id =
10307 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10309 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10310 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10311 flowtype, "flowtype");
10312 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10313 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10314 flowtype_id, UINT8);
10315 cmdline_parse_inst_t cmd_region_flowtype = {
10316 .f = cmd_region_flowtype_parsed,
10318 .help_str = "set port <port_id> queue-region region_id <value> "
10319 "flowtype <value>: Set a flowtype region index",
10321 (void *)&cmd_region_flowtype_set,
10322 (void *)&cmd_region_flowtype_port,
10323 (void *)&cmd_region_flowtype_port_index,
10324 (void *)&cmd_region_flowtype_cmd,
10325 (void *)&cmd_region_flowtype_index,
10326 (void *)&cmd_region_flowtype_id,
10327 (void *)&cmd_region_flowtype_flow_index,
10328 (void *)&cmd_region_flowtype_flow_id,
10333 /* *** User Priority (UP) to queue region (region_id) set *** */
10334 struct cmd_user_priority_region_result {
10335 cmdline_fixed_string_t set;
10336 cmdline_fixed_string_t port;
10338 cmdline_fixed_string_t cmd;
10339 cmdline_fixed_string_t user_priority;
10340 uint8_t user_priority_id;
10341 cmdline_fixed_string_t region;
10346 cmd_user_priority_region_parsed(void *parsed_result,
10347 __rte_unused struct cmdline *cl,
10348 __rte_unused void *data)
10350 struct cmd_user_priority_region_result *res = parsed_result;
10351 int ret = -ENOTSUP;
10352 #ifdef RTE_LIBRTE_I40E_PMD
10353 struct rte_pmd_i40e_queue_region_conf region_conf;
10354 enum rte_pmd_i40e_queue_region_op op_type;
10357 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10360 #ifdef RTE_LIBRTE_I40E_PMD
10361 memset(®ion_conf, 0, sizeof(region_conf));
10362 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10363 region_conf.user_priority = res->user_priority_id;
10364 region_conf.region_id = res->region_id;
10366 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10367 op_type, ®ion_conf);
10374 printf("function not implemented or supported\n");
10377 printf("user_priority region config error: (%s)\n",
10382 cmdline_parse_token_string_t cmd_user_priority_region_set =
10383 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10385 cmdline_parse_token_string_t cmd_user_priority_region_port =
10386 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10388 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10389 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10391 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10392 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10393 cmd, "queue-region");
10394 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10395 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10396 user_priority, "UP");
10397 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10398 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10399 user_priority_id, UINT8);
10400 cmdline_parse_token_string_t cmd_user_priority_region_region =
10401 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10402 region, "region_id");
10403 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10404 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10407 cmdline_parse_inst_t cmd_user_priority_region = {
10408 .f = cmd_user_priority_region_parsed,
10410 .help_str = "set port <port_id> queue-region UP <value> "
10411 "region_id <value>: Set the mapping of User Priority (UP) "
10412 "to queue region (region_id) ",
10414 (void *)&cmd_user_priority_region_set,
10415 (void *)&cmd_user_priority_region_port,
10416 (void *)&cmd_user_priority_region_port_index,
10417 (void *)&cmd_user_priority_region_cmd,
10418 (void *)&cmd_user_priority_region_UP,
10419 (void *)&cmd_user_priority_region_UP_id,
10420 (void *)&cmd_user_priority_region_region,
10421 (void *)&cmd_user_priority_region_region_id,
10426 /* *** flush all queue region related configuration *** */
10427 struct cmd_flush_queue_region_result {
10428 cmdline_fixed_string_t set;
10429 cmdline_fixed_string_t port;
10431 cmdline_fixed_string_t cmd;
10432 cmdline_fixed_string_t flush;
10433 cmdline_fixed_string_t what;
10437 cmd_flush_queue_region_parsed(void *parsed_result,
10438 __rte_unused struct cmdline *cl,
10439 __rte_unused void *data)
10441 struct cmd_flush_queue_region_result *res = parsed_result;
10442 int ret = -ENOTSUP;
10443 #ifdef RTE_LIBRTE_I40E_PMD
10444 struct rte_pmd_i40e_queue_region_conf region_conf;
10445 enum rte_pmd_i40e_queue_region_op op_type;
10448 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10451 #ifdef RTE_LIBRTE_I40E_PMD
10452 memset(®ion_conf, 0, sizeof(region_conf));
10454 if (strcmp(res->what, "on") == 0)
10455 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10457 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10459 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10460 op_type, ®ion_conf);
10467 printf("function not implemented or supported\n");
10470 printf("queue region config flush error: (%s)\n",
10475 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10476 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10478 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10479 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10481 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10482 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10484 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10485 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10486 cmd, "queue-region");
10487 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10488 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10490 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10491 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10494 cmdline_parse_inst_t cmd_flush_queue_region = {
10495 .f = cmd_flush_queue_region_parsed,
10497 .help_str = "set port <port_id> queue-region flush on|off"
10498 ": flush all queue region related configuration",
10500 (void *)&cmd_flush_queue_region_set,
10501 (void *)&cmd_flush_queue_region_port,
10502 (void *)&cmd_flush_queue_region_port_index,
10503 (void *)&cmd_flush_queue_region_cmd,
10504 (void *)&cmd_flush_queue_region_flush,
10505 (void *)&cmd_flush_queue_region_what,
10510 /* *** get all queue region related configuration info *** */
10511 struct cmd_show_queue_region_info {
10512 cmdline_fixed_string_t show;
10513 cmdline_fixed_string_t port;
10515 cmdline_fixed_string_t cmd;
10519 cmd_show_queue_region_info_parsed(void *parsed_result,
10520 __rte_unused struct cmdline *cl,
10521 __rte_unused void *data)
10523 struct cmd_show_queue_region_info *res = parsed_result;
10524 int ret = -ENOTSUP;
10525 #ifdef RTE_LIBRTE_I40E_PMD
10526 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10527 enum rte_pmd_i40e_queue_region_op op_type;
10530 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10533 #ifdef RTE_LIBRTE_I40E_PMD
10534 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10536 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10538 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10539 op_type, &rte_pmd_regions);
10541 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10548 printf("function not implemented or supported\n");
10551 printf("queue region config info show error: (%s)\n",
10556 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10557 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10559 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10560 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10562 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10563 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10565 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10566 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10567 cmd, "queue-region");
10569 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10570 .f = cmd_show_queue_region_info_parsed,
10572 .help_str = "show port <port_id> queue-region"
10573 ": show all queue region related configuration info",
10575 (void *)&cmd_show_queue_region_info_get,
10576 (void *)&cmd_show_queue_region_info_port,
10577 (void *)&cmd_show_queue_region_info_port_index,
10578 (void *)&cmd_show_queue_region_info_cmd,
10583 /* *** ADD/REMOVE A 2tuple FILTER *** */
10584 struct cmd_2tuple_filter_result {
10585 cmdline_fixed_string_t filter;
10587 cmdline_fixed_string_t ops;
10588 cmdline_fixed_string_t dst_port;
10589 uint16_t dst_port_value;
10590 cmdline_fixed_string_t protocol;
10591 uint8_t protocol_value;
10592 cmdline_fixed_string_t mask;
10593 uint8_t mask_value;
10594 cmdline_fixed_string_t tcp_flags;
10595 uint8_t tcp_flags_value;
10596 cmdline_fixed_string_t priority;
10597 uint8_t priority_value;
10598 cmdline_fixed_string_t queue;
10603 cmd_2tuple_filter_parsed(void *parsed_result,
10604 __rte_unused struct cmdline *cl,
10605 __rte_unused void *data)
10607 struct rte_eth_ntuple_filter filter;
10608 struct cmd_2tuple_filter_result *res = parsed_result;
10611 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10613 printf("ntuple filter is not supported on port %u.\n",
10618 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10620 filter.flags = RTE_2TUPLE_FLAGS;
10621 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10622 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10623 filter.proto = res->protocol_value;
10624 filter.priority = res->priority_value;
10625 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10626 printf("nonzero tcp_flags is only meaningful"
10627 " when protocol is TCP.\n");
10630 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10631 printf("invalid TCP flags.\n");
10635 if (res->tcp_flags_value != 0) {
10636 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10637 filter.tcp_flags = res->tcp_flags_value;
10640 /* need convert to big endian. */
10641 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10642 filter.queue = res->queue_id;
10644 if (!strcmp(res->ops, "add"))
10645 ret = rte_eth_dev_filter_ctrl(res->port_id,
10646 RTE_ETH_FILTER_NTUPLE,
10647 RTE_ETH_FILTER_ADD,
10650 ret = rte_eth_dev_filter_ctrl(res->port_id,
10651 RTE_ETH_FILTER_NTUPLE,
10652 RTE_ETH_FILTER_DELETE,
10655 printf("2tuple filter programming error: (%s)\n",
10660 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10661 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10662 filter, "2tuple_filter");
10663 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10664 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10666 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10667 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10669 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10670 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10671 dst_port, "dst_port");
10672 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10673 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10674 dst_port_value, UINT16);
10675 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10676 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10677 protocol, "protocol");
10678 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10679 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10680 protocol_value, UINT8);
10681 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10682 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10684 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10685 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10687 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10688 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10689 tcp_flags, "tcp_flags");
10690 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10691 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10692 tcp_flags_value, UINT8);
10693 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10694 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10695 priority, "priority");
10696 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10697 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10698 priority_value, UINT8);
10699 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10700 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10702 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10703 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10706 cmdline_parse_inst_t cmd_2tuple_filter = {
10707 .f = cmd_2tuple_filter_parsed,
10709 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10710 "<value> mask <value> tcp_flags <value> priority <value> queue "
10711 "<queue_id>: Add a 2tuple filter",
10713 (void *)&cmd_2tuple_filter_filter,
10714 (void *)&cmd_2tuple_filter_port_id,
10715 (void *)&cmd_2tuple_filter_ops,
10716 (void *)&cmd_2tuple_filter_dst_port,
10717 (void *)&cmd_2tuple_filter_dst_port_value,
10718 (void *)&cmd_2tuple_filter_protocol,
10719 (void *)&cmd_2tuple_filter_protocol_value,
10720 (void *)&cmd_2tuple_filter_mask,
10721 (void *)&cmd_2tuple_filter_mask_value,
10722 (void *)&cmd_2tuple_filter_tcp_flags,
10723 (void *)&cmd_2tuple_filter_tcp_flags_value,
10724 (void *)&cmd_2tuple_filter_priority,
10725 (void *)&cmd_2tuple_filter_priority_value,
10726 (void *)&cmd_2tuple_filter_queue,
10727 (void *)&cmd_2tuple_filter_queue_id,
10732 /* *** ADD/REMOVE A 5tuple FILTER *** */
10733 struct cmd_5tuple_filter_result {
10734 cmdline_fixed_string_t filter;
10736 cmdline_fixed_string_t ops;
10737 cmdline_fixed_string_t dst_ip;
10738 cmdline_ipaddr_t dst_ip_value;
10739 cmdline_fixed_string_t src_ip;
10740 cmdline_ipaddr_t src_ip_value;
10741 cmdline_fixed_string_t dst_port;
10742 uint16_t dst_port_value;
10743 cmdline_fixed_string_t src_port;
10744 uint16_t src_port_value;
10745 cmdline_fixed_string_t protocol;
10746 uint8_t protocol_value;
10747 cmdline_fixed_string_t mask;
10748 uint8_t mask_value;
10749 cmdline_fixed_string_t tcp_flags;
10750 uint8_t tcp_flags_value;
10751 cmdline_fixed_string_t priority;
10752 uint8_t priority_value;
10753 cmdline_fixed_string_t queue;
10758 cmd_5tuple_filter_parsed(void *parsed_result,
10759 __rte_unused struct cmdline *cl,
10760 __rte_unused void *data)
10762 struct rte_eth_ntuple_filter filter;
10763 struct cmd_5tuple_filter_result *res = parsed_result;
10766 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10768 printf("ntuple filter is not supported on port %u.\n",
10773 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10775 filter.flags = RTE_5TUPLE_FLAGS;
10776 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10777 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10778 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10779 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10780 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10781 filter.proto = res->protocol_value;
10782 filter.priority = res->priority_value;
10783 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10784 printf("nonzero tcp_flags is only meaningful"
10785 " when protocol is TCP.\n");
10788 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10789 printf("invalid TCP flags.\n");
10793 if (res->tcp_flags_value != 0) {
10794 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10795 filter.tcp_flags = res->tcp_flags_value;
10798 if (res->dst_ip_value.family == AF_INET)
10799 /* no need to convert, already big endian. */
10800 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10802 if (filter.dst_ip_mask == 0) {
10803 printf("can not support ipv6 involved compare.\n");
10809 if (res->src_ip_value.family == AF_INET)
10810 /* no need to convert, already big endian. */
10811 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10813 if (filter.src_ip_mask == 0) {
10814 printf("can not support ipv6 involved compare.\n");
10819 /* need convert to big endian. */
10820 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10821 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10822 filter.queue = res->queue_id;
10824 if (!strcmp(res->ops, "add"))
10825 ret = rte_eth_dev_filter_ctrl(res->port_id,
10826 RTE_ETH_FILTER_NTUPLE,
10827 RTE_ETH_FILTER_ADD,
10830 ret = rte_eth_dev_filter_ctrl(res->port_id,
10831 RTE_ETH_FILTER_NTUPLE,
10832 RTE_ETH_FILTER_DELETE,
10835 printf("5tuple filter programming error: (%s)\n",
10839 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10840 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10841 filter, "5tuple_filter");
10842 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10843 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10845 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10846 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10848 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10849 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10851 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10852 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10854 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10855 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10857 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10858 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10860 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10861 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10862 dst_port, "dst_port");
10863 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10864 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10865 dst_port_value, UINT16);
10866 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10867 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10868 src_port, "src_port");
10869 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10870 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10871 src_port_value, UINT16);
10872 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10873 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10874 protocol, "protocol");
10875 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10876 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10877 protocol_value, UINT8);
10878 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10879 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10881 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10882 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10884 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10885 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10886 tcp_flags, "tcp_flags");
10887 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10888 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10889 tcp_flags_value, UINT8);
10890 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10891 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10892 priority, "priority");
10893 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10894 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10895 priority_value, UINT8);
10896 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10897 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10899 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10900 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10903 cmdline_parse_inst_t cmd_5tuple_filter = {
10904 .f = cmd_5tuple_filter_parsed,
10906 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10907 "src_ip <value> dst_port <value> src_port <value> "
10908 "protocol <value> mask <value> tcp_flags <value> "
10909 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10911 (void *)&cmd_5tuple_filter_filter,
10912 (void *)&cmd_5tuple_filter_port_id,
10913 (void *)&cmd_5tuple_filter_ops,
10914 (void *)&cmd_5tuple_filter_dst_ip,
10915 (void *)&cmd_5tuple_filter_dst_ip_value,
10916 (void *)&cmd_5tuple_filter_src_ip,
10917 (void *)&cmd_5tuple_filter_src_ip_value,
10918 (void *)&cmd_5tuple_filter_dst_port,
10919 (void *)&cmd_5tuple_filter_dst_port_value,
10920 (void *)&cmd_5tuple_filter_src_port,
10921 (void *)&cmd_5tuple_filter_src_port_value,
10922 (void *)&cmd_5tuple_filter_protocol,
10923 (void *)&cmd_5tuple_filter_protocol_value,
10924 (void *)&cmd_5tuple_filter_mask,
10925 (void *)&cmd_5tuple_filter_mask_value,
10926 (void *)&cmd_5tuple_filter_tcp_flags,
10927 (void *)&cmd_5tuple_filter_tcp_flags_value,
10928 (void *)&cmd_5tuple_filter_priority,
10929 (void *)&cmd_5tuple_filter_priority_value,
10930 (void *)&cmd_5tuple_filter_queue,
10931 (void *)&cmd_5tuple_filter_queue_id,
10936 /* *** ADD/REMOVE A flex FILTER *** */
10937 struct cmd_flex_filter_result {
10938 cmdline_fixed_string_t filter;
10939 cmdline_fixed_string_t ops;
10941 cmdline_fixed_string_t len;
10943 cmdline_fixed_string_t bytes;
10944 cmdline_fixed_string_t bytes_value;
10945 cmdline_fixed_string_t mask;
10946 cmdline_fixed_string_t mask_value;
10947 cmdline_fixed_string_t priority;
10948 uint8_t priority_value;
10949 cmdline_fixed_string_t queue;
10953 static int xdigit2val(unsigned char c)
10958 else if (isupper(c))
10959 val = c - 'A' + 10;
10961 val = c - 'a' + 10;
10966 cmd_flex_filter_parsed(void *parsed_result,
10967 __rte_unused struct cmdline *cl,
10968 __rte_unused void *data)
10971 struct rte_eth_flex_filter filter;
10972 struct cmd_flex_filter_result *res = parsed_result;
10973 char *bytes_ptr, *mask_ptr;
10974 uint16_t len, i, j = 0;
10979 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10980 printf("the len exceed the max length 128\n");
10983 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10984 filter.len = res->len_value;
10985 filter.priority = res->priority_value;
10986 filter.queue = res->queue_id;
10987 bytes_ptr = res->bytes_value;
10988 mask_ptr = res->mask_value;
10990 /* translate bytes string to array. */
10991 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10992 (bytes_ptr[1] == 'X')))
10994 len = strnlen(bytes_ptr, res->len_value * 2);
10995 if (len == 0 || (len % 8 != 0)) {
10996 printf("please check len and bytes input\n");
10999 for (i = 0; i < len; i++) {
11001 if (isxdigit(c) == 0) {
11002 /* invalid characters. */
11003 printf("invalid input\n");
11006 val = xdigit2val(c);
11009 filter.bytes[j] = byte;
11010 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
11017 /* translate mask string to uint8_t array. */
11018 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
11019 (mask_ptr[1] == 'X')))
11021 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
11023 printf("invalid input\n");
11028 for (i = 0; i < len; i++) {
11030 if (isxdigit(c) == 0) {
11031 /* invalid characters. */
11032 printf("invalid input\n");
11035 val = xdigit2val(c);
11038 filter.mask[j] = byte;
11039 printf("mask[%d]:%02x ", j, filter.mask[j]);
11047 if (!strcmp(res->ops, "add"))
11048 ret = rte_eth_dev_filter_ctrl(res->port_id,
11049 RTE_ETH_FILTER_FLEXIBLE,
11050 RTE_ETH_FILTER_ADD,
11053 ret = rte_eth_dev_filter_ctrl(res->port_id,
11054 RTE_ETH_FILTER_FLEXIBLE,
11055 RTE_ETH_FILTER_DELETE,
11059 printf("flex filter setting error: (%s)\n", strerror(-ret));
11062 cmdline_parse_token_string_t cmd_flex_filter_filter =
11063 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11064 filter, "flex_filter");
11065 cmdline_parse_token_num_t cmd_flex_filter_port_id =
11066 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11068 cmdline_parse_token_string_t cmd_flex_filter_ops =
11069 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11071 cmdline_parse_token_string_t cmd_flex_filter_len =
11072 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11074 cmdline_parse_token_num_t cmd_flex_filter_len_value =
11075 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11077 cmdline_parse_token_string_t cmd_flex_filter_bytes =
11078 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11080 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
11081 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11082 bytes_value, NULL);
11083 cmdline_parse_token_string_t cmd_flex_filter_mask =
11084 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11086 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
11087 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11089 cmdline_parse_token_string_t cmd_flex_filter_priority =
11090 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11091 priority, "priority");
11092 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
11093 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11094 priority_value, UINT8);
11095 cmdline_parse_token_string_t cmd_flex_filter_queue =
11096 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11098 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
11099 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11101 cmdline_parse_inst_t cmd_flex_filter = {
11102 .f = cmd_flex_filter_parsed,
11104 .help_str = "flex_filter <port_id> add|del len <value> bytes "
11105 "<value> mask <value> priority <value> queue <queue_id>: "
11106 "Add/Del a flex filter",
11108 (void *)&cmd_flex_filter_filter,
11109 (void *)&cmd_flex_filter_port_id,
11110 (void *)&cmd_flex_filter_ops,
11111 (void *)&cmd_flex_filter_len,
11112 (void *)&cmd_flex_filter_len_value,
11113 (void *)&cmd_flex_filter_bytes,
11114 (void *)&cmd_flex_filter_bytes_value,
11115 (void *)&cmd_flex_filter_mask,
11116 (void *)&cmd_flex_filter_mask_value,
11117 (void *)&cmd_flex_filter_priority,
11118 (void *)&cmd_flex_filter_priority_value,
11119 (void *)&cmd_flex_filter_queue,
11120 (void *)&cmd_flex_filter_queue_id,
11125 /* *** Filters Control *** */
11127 /* *** deal with ethertype filter *** */
11128 struct cmd_ethertype_filter_result {
11129 cmdline_fixed_string_t filter;
11131 cmdline_fixed_string_t ops;
11132 cmdline_fixed_string_t mac;
11133 struct rte_ether_addr mac_addr;
11134 cmdline_fixed_string_t ethertype;
11135 uint16_t ethertype_value;
11136 cmdline_fixed_string_t drop;
11137 cmdline_fixed_string_t queue;
11141 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
11142 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11143 filter, "ethertype_filter");
11144 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
11145 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11147 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
11148 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11150 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
11151 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11152 mac, "mac_addr#mac_ignr");
11153 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
11154 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
11156 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
11157 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11158 ethertype, "ethertype");
11159 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
11160 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11161 ethertype_value, UINT16);
11162 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
11163 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11165 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
11166 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11168 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
11169 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11173 cmd_ethertype_filter_parsed(void *parsed_result,
11174 __rte_unused struct cmdline *cl,
11175 __rte_unused void *data)
11177 struct cmd_ethertype_filter_result *res = parsed_result;
11178 struct rte_eth_ethertype_filter filter;
11181 ret = rte_eth_dev_filter_supported(res->port_id,
11182 RTE_ETH_FILTER_ETHERTYPE);
11184 printf("ethertype filter is not supported on port %u.\n",
11189 memset(&filter, 0, sizeof(filter));
11190 if (!strcmp(res->mac, "mac_addr")) {
11191 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
11192 rte_memcpy(&filter.mac_addr, &res->mac_addr,
11193 sizeof(struct rte_ether_addr));
11195 if (!strcmp(res->drop, "drop"))
11196 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
11197 filter.ether_type = res->ethertype_value;
11198 filter.queue = res->queue_id;
11200 if (!strcmp(res->ops, "add"))
11201 ret = rte_eth_dev_filter_ctrl(res->port_id,
11202 RTE_ETH_FILTER_ETHERTYPE,
11203 RTE_ETH_FILTER_ADD,
11206 ret = rte_eth_dev_filter_ctrl(res->port_id,
11207 RTE_ETH_FILTER_ETHERTYPE,
11208 RTE_ETH_FILTER_DELETE,
11211 printf("ethertype filter programming error: (%s)\n",
11215 cmdline_parse_inst_t cmd_ethertype_filter = {
11216 .f = cmd_ethertype_filter_parsed,
11218 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
11219 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
11220 "Add or delete an ethertype filter entry",
11222 (void *)&cmd_ethertype_filter_filter,
11223 (void *)&cmd_ethertype_filter_port_id,
11224 (void *)&cmd_ethertype_filter_ops,
11225 (void *)&cmd_ethertype_filter_mac,
11226 (void *)&cmd_ethertype_filter_mac_addr,
11227 (void *)&cmd_ethertype_filter_ethertype,
11228 (void *)&cmd_ethertype_filter_ethertype_value,
11229 (void *)&cmd_ethertype_filter_drop,
11230 (void *)&cmd_ethertype_filter_queue,
11231 (void *)&cmd_ethertype_filter_queue_id,
11236 /* *** deal with flow director filter *** */
11237 struct cmd_flow_director_result {
11238 cmdline_fixed_string_t flow_director_filter;
11240 cmdline_fixed_string_t mode;
11241 cmdline_fixed_string_t mode_value;
11242 cmdline_fixed_string_t ops;
11243 cmdline_fixed_string_t flow;
11244 cmdline_fixed_string_t flow_type;
11245 cmdline_fixed_string_t ether;
11246 uint16_t ether_type;
11247 cmdline_fixed_string_t src;
11248 cmdline_ipaddr_t ip_src;
11250 cmdline_fixed_string_t dst;
11251 cmdline_ipaddr_t ip_dst;
11253 cmdline_fixed_string_t verify_tag;
11254 uint32_t verify_tag_value;
11255 cmdline_fixed_string_t tos;
11257 cmdline_fixed_string_t proto;
11258 uint8_t proto_value;
11259 cmdline_fixed_string_t ttl;
11261 cmdline_fixed_string_t vlan;
11262 uint16_t vlan_value;
11263 cmdline_fixed_string_t flexbytes;
11264 cmdline_fixed_string_t flexbytes_value;
11265 cmdline_fixed_string_t pf_vf;
11266 cmdline_fixed_string_t drop;
11267 cmdline_fixed_string_t queue;
11269 cmdline_fixed_string_t fd_id;
11270 uint32_t fd_id_value;
11271 cmdline_fixed_string_t mac;
11272 struct rte_ether_addr mac_addr;
11273 cmdline_fixed_string_t tunnel;
11274 cmdline_fixed_string_t tunnel_type;
11275 cmdline_fixed_string_t tunnel_id;
11276 uint32_t tunnel_id_value;
11277 cmdline_fixed_string_t packet;
11282 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
11285 const char *p, *p0 = q_arg;
11287 unsigned long int_fld;
11288 char *str_fld[max_num];
11293 p = strchr(p0, '(');
11297 p0 = strchr(p, ')');
11302 if (size >= sizeof(s))
11305 snprintf(s, sizeof(s), "%.*s", size, p);
11306 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11307 if (ret < 0 || ret > max_num)
11309 for (i = 0; i < ret; i++) {
11311 int_fld = strtoul(str_fld[i], &end, 0);
11312 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11314 flexbytes[i] = (uint8_t)int_fld;
11320 str2flowtype(char *string)
11323 static const struct {
11326 } flowtype_str[] = {
11327 {"raw", RTE_ETH_FLOW_RAW},
11328 {"ipv4", RTE_ETH_FLOW_IPV4},
11329 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11330 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11331 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11332 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11333 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11334 {"ipv6", RTE_ETH_FLOW_IPV6},
11335 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11336 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11337 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11338 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11339 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11340 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11343 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11344 if (!strcmp(flowtype_str[i].str, string))
11345 return flowtype_str[i].type;
11348 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11349 return (uint16_t)atoi(string);
11351 return RTE_ETH_FLOW_UNKNOWN;
11354 static enum rte_eth_fdir_tunnel_type
11355 str2fdir_tunneltype(char *string)
11359 static const struct {
11361 enum rte_eth_fdir_tunnel_type type;
11362 } tunneltype_str[] = {
11363 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11364 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11367 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11368 if (!strcmp(tunneltype_str[i].str, string))
11369 return tunneltype_str[i].type;
11371 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11374 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11376 if ((ip_addr).family == AF_INET) \
11377 (ip) = (ip_addr).addr.ipv4.s_addr; \
11379 printf("invalid parameter.\n"); \
11384 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11386 if ((ip_addr).family == AF_INET6) \
11387 rte_memcpy(&(ip), \
11388 &((ip_addr).addr.ipv6), \
11389 sizeof(struct in6_addr)); \
11391 printf("invalid parameter.\n"); \
11397 cmd_flow_director_filter_parsed(void *parsed_result,
11398 __rte_unused struct cmdline *cl,
11399 __rte_unused void *data)
11401 struct cmd_flow_director_result *res = parsed_result;
11402 struct rte_eth_fdir_filter entry;
11403 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11405 unsigned long vf_id;
11408 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11410 printf("flow director is not supported on port %u.\n",
11414 memset(flexbytes, 0, sizeof(flexbytes));
11415 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11417 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11418 if (strcmp(res->mode_value, "MAC-VLAN")) {
11419 printf("Please set mode to MAC-VLAN.\n");
11422 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11423 if (strcmp(res->mode_value, "Tunnel")) {
11424 printf("Please set mode to Tunnel.\n");
11428 if (!strcmp(res->mode_value, "raw")) {
11429 #ifdef RTE_LIBRTE_I40E_PMD
11430 struct rte_pmd_i40e_flow_type_mapping
11431 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11432 struct rte_pmd_i40e_pkt_template_conf conf;
11433 uint16_t flow_type = str2flowtype(res->flow_type);
11434 uint16_t i, port = res->port_id;
11437 memset(&conf, 0, sizeof(conf));
11439 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11440 printf("Invalid flow type specified.\n");
11443 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11447 if (mapping[flow_type].pctype == 0ULL) {
11448 printf("Invalid flow type specified.\n");
11451 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11452 if (mapping[flow_type].pctype & (1ULL << i)) {
11453 conf.input.pctype = i;
11458 conf.input.packet = open_file(res->filepath,
11459 &conf.input.length);
11460 if (!conf.input.packet)
11462 if (!strcmp(res->drop, "drop"))
11463 conf.action.behavior =
11464 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11466 conf.action.behavior =
11467 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11468 conf.action.report_status =
11469 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11470 conf.action.rx_queue = res->queue_id;
11471 conf.soft_id = res->fd_id_value;
11472 add = strcmp(res->ops, "del") ? 1 : 0;
11473 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11477 printf("flow director config error: (%s)\n",
11479 close_file(conf.input.packet);
11482 } else if (strcmp(res->mode_value, "IP")) {
11483 printf("Please set mode to IP or raw.\n");
11486 entry.input.flow_type = str2flowtype(res->flow_type);
11489 ret = parse_flexbytes(res->flexbytes_value,
11491 RTE_ETH_FDIR_MAX_FLEXLEN);
11493 printf("error: Cannot parse flexbytes input.\n");
11497 switch (entry.input.flow_type) {
11498 case RTE_ETH_FLOW_FRAG_IPV4:
11499 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11500 entry.input.flow.ip4_flow.proto = res->proto_value;
11502 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11503 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11504 IPV4_ADDR_TO_UINT(res->ip_dst,
11505 entry.input.flow.ip4_flow.dst_ip);
11506 IPV4_ADDR_TO_UINT(res->ip_src,
11507 entry.input.flow.ip4_flow.src_ip);
11508 entry.input.flow.ip4_flow.tos = res->tos_value;
11509 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11510 /* need convert to big endian. */
11511 entry.input.flow.udp4_flow.dst_port =
11512 rte_cpu_to_be_16(res->port_dst);
11513 entry.input.flow.udp4_flow.src_port =
11514 rte_cpu_to_be_16(res->port_src);
11516 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11517 IPV4_ADDR_TO_UINT(res->ip_dst,
11518 entry.input.flow.sctp4_flow.ip.dst_ip);
11519 IPV4_ADDR_TO_UINT(res->ip_src,
11520 entry.input.flow.sctp4_flow.ip.src_ip);
11521 entry.input.flow.ip4_flow.tos = res->tos_value;
11522 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11523 /* need convert to big endian. */
11524 entry.input.flow.sctp4_flow.dst_port =
11525 rte_cpu_to_be_16(res->port_dst);
11526 entry.input.flow.sctp4_flow.src_port =
11527 rte_cpu_to_be_16(res->port_src);
11528 entry.input.flow.sctp4_flow.verify_tag =
11529 rte_cpu_to_be_32(res->verify_tag_value);
11531 case RTE_ETH_FLOW_FRAG_IPV6:
11532 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11533 entry.input.flow.ipv6_flow.proto = res->proto_value;
11535 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11536 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11537 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11538 entry.input.flow.ipv6_flow.dst_ip);
11539 IPV6_ADDR_TO_ARRAY(res->ip_src,
11540 entry.input.flow.ipv6_flow.src_ip);
11541 entry.input.flow.ipv6_flow.tc = res->tos_value;
11542 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11543 /* need convert to big endian. */
11544 entry.input.flow.udp6_flow.dst_port =
11545 rte_cpu_to_be_16(res->port_dst);
11546 entry.input.flow.udp6_flow.src_port =
11547 rte_cpu_to_be_16(res->port_src);
11549 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11550 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11551 entry.input.flow.sctp6_flow.ip.dst_ip);
11552 IPV6_ADDR_TO_ARRAY(res->ip_src,
11553 entry.input.flow.sctp6_flow.ip.src_ip);
11554 entry.input.flow.ipv6_flow.tc = res->tos_value;
11555 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11556 /* need convert to big endian. */
11557 entry.input.flow.sctp6_flow.dst_port =
11558 rte_cpu_to_be_16(res->port_dst);
11559 entry.input.flow.sctp6_flow.src_port =
11560 rte_cpu_to_be_16(res->port_src);
11561 entry.input.flow.sctp6_flow.verify_tag =
11562 rte_cpu_to_be_32(res->verify_tag_value);
11564 case RTE_ETH_FLOW_L2_PAYLOAD:
11565 entry.input.flow.l2_flow.ether_type =
11566 rte_cpu_to_be_16(res->ether_type);
11572 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11573 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11575 sizeof(struct rte_ether_addr));
11577 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11578 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11580 sizeof(struct rte_ether_addr));
11581 entry.input.flow.tunnel_flow.tunnel_type =
11582 str2fdir_tunneltype(res->tunnel_type);
11583 entry.input.flow.tunnel_flow.tunnel_id =
11584 rte_cpu_to_be_32(res->tunnel_id_value);
11587 rte_memcpy(entry.input.flow_ext.flexbytes,
11589 RTE_ETH_FDIR_MAX_FLEXLEN);
11591 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11593 entry.action.flex_off = 0; /*use 0 by default */
11594 if (!strcmp(res->drop, "drop"))
11595 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11597 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11599 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11600 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11601 if (!strcmp(res->pf_vf, "pf"))
11602 entry.input.flow_ext.is_vf = 0;
11603 else if (!strncmp(res->pf_vf, "vf", 2)) {
11604 struct rte_eth_dev_info dev_info;
11606 ret = eth_dev_info_get_print_err(res->port_id,
11612 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11613 if (errno != 0 || *end != '\0' ||
11614 vf_id >= dev_info.max_vfs) {
11615 printf("invalid parameter %s.\n", res->pf_vf);
11618 entry.input.flow_ext.is_vf = 1;
11619 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11621 printf("invalid parameter %s.\n", res->pf_vf);
11626 /* set to report FD ID by default */
11627 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11628 entry.action.rx_queue = res->queue_id;
11629 entry.soft_id = res->fd_id_value;
11630 if (!strcmp(res->ops, "add"))
11631 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11632 RTE_ETH_FILTER_ADD, &entry);
11633 else if (!strcmp(res->ops, "del"))
11634 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11635 RTE_ETH_FILTER_DELETE, &entry);
11637 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11638 RTE_ETH_FILTER_UPDATE, &entry);
11640 printf("flow director programming error: (%s)\n",
11644 cmdline_parse_token_string_t cmd_flow_director_filter =
11645 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11646 flow_director_filter, "flow_director_filter");
11647 cmdline_parse_token_num_t cmd_flow_director_port_id =
11648 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11650 cmdline_parse_token_string_t cmd_flow_director_ops =
11651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11652 ops, "add#del#update");
11653 cmdline_parse_token_string_t cmd_flow_director_flow =
11654 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11656 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11657 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11659 cmdline_parse_token_string_t cmd_flow_director_ether =
11660 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11662 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11663 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11664 ether_type, UINT16);
11665 cmdline_parse_token_string_t cmd_flow_director_src =
11666 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11668 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11669 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11671 cmdline_parse_token_num_t cmd_flow_director_port_src =
11672 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11674 cmdline_parse_token_string_t cmd_flow_director_dst =
11675 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11677 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11678 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11680 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11681 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11683 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11685 verify_tag, "verify_tag");
11686 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11687 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11688 verify_tag_value, UINT32);
11689 cmdline_parse_token_string_t cmd_flow_director_tos =
11690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11692 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11693 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11695 cmdline_parse_token_string_t cmd_flow_director_proto =
11696 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11698 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11699 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11700 proto_value, UINT8);
11701 cmdline_parse_token_string_t cmd_flow_director_ttl =
11702 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11704 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11705 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11707 cmdline_parse_token_string_t cmd_flow_director_vlan =
11708 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11710 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11711 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11712 vlan_value, UINT16);
11713 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11714 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11715 flexbytes, "flexbytes");
11716 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11718 flexbytes_value, NULL);
11719 cmdline_parse_token_string_t cmd_flow_director_drop =
11720 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11722 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11723 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11725 cmdline_parse_token_string_t cmd_flow_director_queue =
11726 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11728 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11729 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11731 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11732 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11734 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11735 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11736 fd_id_value, UINT32);
11738 cmdline_parse_token_string_t cmd_flow_director_mode =
11739 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11741 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11744 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11745 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11746 mode_value, "MAC-VLAN");
11747 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11749 mode_value, "Tunnel");
11750 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11751 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11752 mode_value, "raw");
11753 cmdline_parse_token_string_t cmd_flow_director_mac =
11754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11756 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11757 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11759 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11762 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11763 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11764 tunnel_type, "NVGRE#VxLAN");
11765 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11767 tunnel_id, "tunnel-id");
11768 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11769 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11770 tunnel_id_value, UINT32);
11771 cmdline_parse_token_string_t cmd_flow_director_packet =
11772 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11774 cmdline_parse_token_string_t cmd_flow_director_filepath =
11775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11778 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11779 .f = cmd_flow_director_filter_parsed,
11781 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11782 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11783 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11784 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11785 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11786 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11787 "fd_id <fd_id_value>: "
11788 "Add or delete an ip flow director entry on NIC",
11790 (void *)&cmd_flow_director_filter,
11791 (void *)&cmd_flow_director_port_id,
11792 (void *)&cmd_flow_director_mode,
11793 (void *)&cmd_flow_director_mode_ip,
11794 (void *)&cmd_flow_director_ops,
11795 (void *)&cmd_flow_director_flow,
11796 (void *)&cmd_flow_director_flow_type,
11797 (void *)&cmd_flow_director_src,
11798 (void *)&cmd_flow_director_ip_src,
11799 (void *)&cmd_flow_director_dst,
11800 (void *)&cmd_flow_director_ip_dst,
11801 (void *)&cmd_flow_director_tos,
11802 (void *)&cmd_flow_director_tos_value,
11803 (void *)&cmd_flow_director_proto,
11804 (void *)&cmd_flow_director_proto_value,
11805 (void *)&cmd_flow_director_ttl,
11806 (void *)&cmd_flow_director_ttl_value,
11807 (void *)&cmd_flow_director_vlan,
11808 (void *)&cmd_flow_director_vlan_value,
11809 (void *)&cmd_flow_director_flexbytes,
11810 (void *)&cmd_flow_director_flexbytes_value,
11811 (void *)&cmd_flow_director_drop,
11812 (void *)&cmd_flow_director_pf_vf,
11813 (void *)&cmd_flow_director_queue,
11814 (void *)&cmd_flow_director_queue_id,
11815 (void *)&cmd_flow_director_fd_id,
11816 (void *)&cmd_flow_director_fd_id_value,
11821 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11822 .f = cmd_flow_director_filter_parsed,
11824 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11825 "director entry on NIC",
11827 (void *)&cmd_flow_director_filter,
11828 (void *)&cmd_flow_director_port_id,
11829 (void *)&cmd_flow_director_mode,
11830 (void *)&cmd_flow_director_mode_ip,
11831 (void *)&cmd_flow_director_ops,
11832 (void *)&cmd_flow_director_flow,
11833 (void *)&cmd_flow_director_flow_type,
11834 (void *)&cmd_flow_director_src,
11835 (void *)&cmd_flow_director_ip_src,
11836 (void *)&cmd_flow_director_port_src,
11837 (void *)&cmd_flow_director_dst,
11838 (void *)&cmd_flow_director_ip_dst,
11839 (void *)&cmd_flow_director_port_dst,
11840 (void *)&cmd_flow_director_tos,
11841 (void *)&cmd_flow_director_tos_value,
11842 (void *)&cmd_flow_director_ttl,
11843 (void *)&cmd_flow_director_ttl_value,
11844 (void *)&cmd_flow_director_vlan,
11845 (void *)&cmd_flow_director_vlan_value,
11846 (void *)&cmd_flow_director_flexbytes,
11847 (void *)&cmd_flow_director_flexbytes_value,
11848 (void *)&cmd_flow_director_drop,
11849 (void *)&cmd_flow_director_pf_vf,
11850 (void *)&cmd_flow_director_queue,
11851 (void *)&cmd_flow_director_queue_id,
11852 (void *)&cmd_flow_director_fd_id,
11853 (void *)&cmd_flow_director_fd_id_value,
11858 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11859 .f = cmd_flow_director_filter_parsed,
11861 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11862 "director entry on NIC",
11864 (void *)&cmd_flow_director_filter,
11865 (void *)&cmd_flow_director_port_id,
11866 (void *)&cmd_flow_director_mode,
11867 (void *)&cmd_flow_director_mode_ip,
11868 (void *)&cmd_flow_director_ops,
11869 (void *)&cmd_flow_director_flow,
11870 (void *)&cmd_flow_director_flow_type,
11871 (void *)&cmd_flow_director_src,
11872 (void *)&cmd_flow_director_ip_src,
11873 (void *)&cmd_flow_director_port_src,
11874 (void *)&cmd_flow_director_dst,
11875 (void *)&cmd_flow_director_ip_dst,
11876 (void *)&cmd_flow_director_port_dst,
11877 (void *)&cmd_flow_director_verify_tag,
11878 (void *)&cmd_flow_director_verify_tag_value,
11879 (void *)&cmd_flow_director_tos,
11880 (void *)&cmd_flow_director_tos_value,
11881 (void *)&cmd_flow_director_ttl,
11882 (void *)&cmd_flow_director_ttl_value,
11883 (void *)&cmd_flow_director_vlan,
11884 (void *)&cmd_flow_director_vlan_value,
11885 (void *)&cmd_flow_director_flexbytes,
11886 (void *)&cmd_flow_director_flexbytes_value,
11887 (void *)&cmd_flow_director_drop,
11888 (void *)&cmd_flow_director_pf_vf,
11889 (void *)&cmd_flow_director_queue,
11890 (void *)&cmd_flow_director_queue_id,
11891 (void *)&cmd_flow_director_fd_id,
11892 (void *)&cmd_flow_director_fd_id_value,
11897 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11898 .f = cmd_flow_director_filter_parsed,
11900 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11901 "director entry on NIC",
11903 (void *)&cmd_flow_director_filter,
11904 (void *)&cmd_flow_director_port_id,
11905 (void *)&cmd_flow_director_mode,
11906 (void *)&cmd_flow_director_mode_ip,
11907 (void *)&cmd_flow_director_ops,
11908 (void *)&cmd_flow_director_flow,
11909 (void *)&cmd_flow_director_flow_type,
11910 (void *)&cmd_flow_director_ether,
11911 (void *)&cmd_flow_director_ether_type,
11912 (void *)&cmd_flow_director_flexbytes,
11913 (void *)&cmd_flow_director_flexbytes_value,
11914 (void *)&cmd_flow_director_drop,
11915 (void *)&cmd_flow_director_pf_vf,
11916 (void *)&cmd_flow_director_queue,
11917 (void *)&cmd_flow_director_queue_id,
11918 (void *)&cmd_flow_director_fd_id,
11919 (void *)&cmd_flow_director_fd_id_value,
11924 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11925 .f = cmd_flow_director_filter_parsed,
11927 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11928 "director entry on NIC",
11930 (void *)&cmd_flow_director_filter,
11931 (void *)&cmd_flow_director_port_id,
11932 (void *)&cmd_flow_director_mode,
11933 (void *)&cmd_flow_director_mode_mac_vlan,
11934 (void *)&cmd_flow_director_ops,
11935 (void *)&cmd_flow_director_mac,
11936 (void *)&cmd_flow_director_mac_addr,
11937 (void *)&cmd_flow_director_vlan,
11938 (void *)&cmd_flow_director_vlan_value,
11939 (void *)&cmd_flow_director_flexbytes,
11940 (void *)&cmd_flow_director_flexbytes_value,
11941 (void *)&cmd_flow_director_drop,
11942 (void *)&cmd_flow_director_queue,
11943 (void *)&cmd_flow_director_queue_id,
11944 (void *)&cmd_flow_director_fd_id,
11945 (void *)&cmd_flow_director_fd_id_value,
11950 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11951 .f = cmd_flow_director_filter_parsed,
11953 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11954 "director entry on NIC",
11956 (void *)&cmd_flow_director_filter,
11957 (void *)&cmd_flow_director_port_id,
11958 (void *)&cmd_flow_director_mode,
11959 (void *)&cmd_flow_director_mode_tunnel,
11960 (void *)&cmd_flow_director_ops,
11961 (void *)&cmd_flow_director_mac,
11962 (void *)&cmd_flow_director_mac_addr,
11963 (void *)&cmd_flow_director_vlan,
11964 (void *)&cmd_flow_director_vlan_value,
11965 (void *)&cmd_flow_director_tunnel,
11966 (void *)&cmd_flow_director_tunnel_type,
11967 (void *)&cmd_flow_director_tunnel_id,
11968 (void *)&cmd_flow_director_tunnel_id_value,
11969 (void *)&cmd_flow_director_flexbytes,
11970 (void *)&cmd_flow_director_flexbytes_value,
11971 (void *)&cmd_flow_director_drop,
11972 (void *)&cmd_flow_director_queue,
11973 (void *)&cmd_flow_director_queue_id,
11974 (void *)&cmd_flow_director_fd_id,
11975 (void *)&cmd_flow_director_fd_id_value,
11980 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11981 .f = cmd_flow_director_filter_parsed,
11983 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11984 "director entry on NIC",
11986 (void *)&cmd_flow_director_filter,
11987 (void *)&cmd_flow_director_port_id,
11988 (void *)&cmd_flow_director_mode,
11989 (void *)&cmd_flow_director_mode_raw,
11990 (void *)&cmd_flow_director_ops,
11991 (void *)&cmd_flow_director_flow,
11992 (void *)&cmd_flow_director_flow_type,
11993 (void *)&cmd_flow_director_drop,
11994 (void *)&cmd_flow_director_queue,
11995 (void *)&cmd_flow_director_queue_id,
11996 (void *)&cmd_flow_director_fd_id,
11997 (void *)&cmd_flow_director_fd_id_value,
11998 (void *)&cmd_flow_director_packet,
11999 (void *)&cmd_flow_director_filepath,
12004 struct cmd_flush_flow_director_result {
12005 cmdline_fixed_string_t flush_flow_director;
12009 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
12010 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
12011 flush_flow_director, "flush_flow_director");
12012 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
12013 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
12017 cmd_flush_flow_director_parsed(void *parsed_result,
12018 __rte_unused struct cmdline *cl,
12019 __rte_unused void *data)
12021 struct cmd_flow_director_result *res = parsed_result;
12024 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
12026 printf("flow director is not supported on port %u.\n",
12031 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12032 RTE_ETH_FILTER_FLUSH, NULL);
12034 printf("flow director table flushing error: (%s)\n",
12038 cmdline_parse_inst_t cmd_flush_flow_director = {
12039 .f = cmd_flush_flow_director_parsed,
12041 .help_str = "flush_flow_director <port_id>: "
12042 "Flush all flow director entries of a device on NIC",
12044 (void *)&cmd_flush_flow_director_flush,
12045 (void *)&cmd_flush_flow_director_port_id,
12050 /* *** deal with flow director mask *** */
12051 struct cmd_flow_director_mask_result {
12052 cmdline_fixed_string_t flow_director_mask;
12054 cmdline_fixed_string_t mode;
12055 cmdline_fixed_string_t mode_value;
12056 cmdline_fixed_string_t vlan;
12057 uint16_t vlan_mask;
12058 cmdline_fixed_string_t src_mask;
12059 cmdline_ipaddr_t ipv4_src;
12060 cmdline_ipaddr_t ipv6_src;
12062 cmdline_fixed_string_t dst_mask;
12063 cmdline_ipaddr_t ipv4_dst;
12064 cmdline_ipaddr_t ipv6_dst;
12066 cmdline_fixed_string_t mac;
12067 uint8_t mac_addr_byte_mask;
12068 cmdline_fixed_string_t tunnel_id;
12069 uint32_t tunnel_id_mask;
12070 cmdline_fixed_string_t tunnel_type;
12071 uint8_t tunnel_type_mask;
12075 cmd_flow_director_mask_parsed(void *parsed_result,
12076 __rte_unused struct cmdline *cl,
12077 __rte_unused void *data)
12079 struct cmd_flow_director_mask_result *res = parsed_result;
12080 struct rte_eth_fdir_masks *mask;
12081 struct rte_port *port;
12083 port = &ports[res->port_id];
12084 /** Check if the port is not started **/
12085 if (port->port_status != RTE_PORT_STOPPED) {
12086 printf("Please stop port %d first\n", res->port_id);
12090 mask = &port->dev_conf.fdir_conf.mask;
12092 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
12093 if (strcmp(res->mode_value, "MAC-VLAN")) {
12094 printf("Please set mode to MAC-VLAN.\n");
12098 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12099 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
12100 if (strcmp(res->mode_value, "Tunnel")) {
12101 printf("Please set mode to Tunnel.\n");
12105 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12106 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
12107 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
12108 mask->tunnel_type_mask = res->tunnel_type_mask;
12110 if (strcmp(res->mode_value, "IP")) {
12111 printf("Please set mode to IP.\n");
12115 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12116 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
12117 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
12118 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
12119 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
12120 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
12121 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
12124 cmd_reconfig_device_queue(res->port_id, 1, 1);
12127 cmdline_parse_token_string_t cmd_flow_director_mask =
12128 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12129 flow_director_mask, "flow_director_mask");
12130 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
12131 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12133 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
12134 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12136 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
12137 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12138 vlan_mask, UINT16);
12139 cmdline_parse_token_string_t cmd_flow_director_mask_src =
12140 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12141 src_mask, "src_mask");
12142 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
12143 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12145 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
12146 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12148 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
12149 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12151 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
12152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12153 dst_mask, "dst_mask");
12154 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
12155 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12157 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
12158 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12160 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
12161 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12164 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
12165 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12167 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
12168 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12170 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
12171 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12172 mode_value, "MAC-VLAN");
12173 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
12174 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12175 mode_value, "Tunnel");
12176 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
12177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12179 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
12180 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12181 mac_addr_byte_mask, UINT8);
12182 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
12183 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12184 tunnel_type, "tunnel-type");
12185 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
12186 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12187 tunnel_type_mask, UINT8);
12188 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
12189 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12190 tunnel_id, "tunnel-id");
12191 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
12192 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12193 tunnel_id_mask, UINT32);
12195 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
12196 .f = cmd_flow_director_mask_parsed,
12198 .help_str = "flow_director_mask ... : "
12199 "Set IP mode flow director's mask on NIC",
12201 (void *)&cmd_flow_director_mask,
12202 (void *)&cmd_flow_director_mask_port_id,
12203 (void *)&cmd_flow_director_mask_mode,
12204 (void *)&cmd_flow_director_mask_mode_ip,
12205 (void *)&cmd_flow_director_mask_vlan,
12206 (void *)&cmd_flow_director_mask_vlan_value,
12207 (void *)&cmd_flow_director_mask_src,
12208 (void *)&cmd_flow_director_mask_ipv4_src,
12209 (void *)&cmd_flow_director_mask_ipv6_src,
12210 (void *)&cmd_flow_director_mask_port_src,
12211 (void *)&cmd_flow_director_mask_dst,
12212 (void *)&cmd_flow_director_mask_ipv4_dst,
12213 (void *)&cmd_flow_director_mask_ipv6_dst,
12214 (void *)&cmd_flow_director_mask_port_dst,
12219 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
12220 .f = cmd_flow_director_mask_parsed,
12222 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
12223 "flow director's mask on NIC",
12225 (void *)&cmd_flow_director_mask,
12226 (void *)&cmd_flow_director_mask_port_id,
12227 (void *)&cmd_flow_director_mask_mode,
12228 (void *)&cmd_flow_director_mask_mode_mac_vlan,
12229 (void *)&cmd_flow_director_mask_vlan,
12230 (void *)&cmd_flow_director_mask_vlan_value,
12235 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
12236 .f = cmd_flow_director_mask_parsed,
12238 .help_str = "flow_director_mask ... : Set tunnel mode "
12239 "flow director's mask on NIC",
12241 (void *)&cmd_flow_director_mask,
12242 (void *)&cmd_flow_director_mask_port_id,
12243 (void *)&cmd_flow_director_mask_mode,
12244 (void *)&cmd_flow_director_mask_mode_tunnel,
12245 (void *)&cmd_flow_director_mask_vlan,
12246 (void *)&cmd_flow_director_mask_vlan_value,
12247 (void *)&cmd_flow_director_mask_mac,
12248 (void *)&cmd_flow_director_mask_mac_value,
12249 (void *)&cmd_flow_director_mask_tunnel_type,
12250 (void *)&cmd_flow_director_mask_tunnel_type_value,
12251 (void *)&cmd_flow_director_mask_tunnel_id,
12252 (void *)&cmd_flow_director_mask_tunnel_id_value,
12257 /* *** deal with flow director mask on flexible payload *** */
12258 struct cmd_flow_director_flex_mask_result {
12259 cmdline_fixed_string_t flow_director_flexmask;
12261 cmdline_fixed_string_t flow;
12262 cmdline_fixed_string_t flow_type;
12263 cmdline_fixed_string_t mask;
12267 cmd_flow_director_flex_mask_parsed(void *parsed_result,
12268 __rte_unused struct cmdline *cl,
12269 __rte_unused void *data)
12271 struct cmd_flow_director_flex_mask_result *res = parsed_result;
12272 struct rte_eth_fdir_info fdir_info;
12273 struct rte_eth_fdir_flex_mask flex_mask;
12274 struct rte_port *port;
12275 uint64_t flow_type_mask;
12279 port = &ports[res->port_id];
12280 /** Check if the port is not started **/
12281 if (port->port_status != RTE_PORT_STOPPED) {
12282 printf("Please stop port %d first\n", res->port_id);
12286 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
12287 ret = parse_flexbytes(res->mask,
12289 RTE_ETH_FDIR_MAX_FLEXLEN);
12291 printf("error: Cannot parse mask input.\n");
12295 memset(&fdir_info, 0, sizeof(fdir_info));
12296 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12297 RTE_ETH_FILTER_INFO, &fdir_info);
12299 printf("Cannot get FDir filter info\n");
12303 if (!strcmp(res->flow_type, "none")) {
12304 /* means don't specify the flow type */
12305 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12306 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12307 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12308 0, sizeof(struct rte_eth_fdir_flex_mask));
12309 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12310 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12312 sizeof(struct rte_eth_fdir_flex_mask));
12313 cmd_reconfig_device_queue(res->port_id, 1, 1);
12316 flow_type_mask = fdir_info.flow_types_mask[0];
12317 if (!strcmp(res->flow_type, "all")) {
12318 if (!flow_type_mask) {
12319 printf("No flow type supported\n");
12322 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12323 if (flow_type_mask & (1ULL << i)) {
12324 flex_mask.flow_type = i;
12325 fdir_set_flex_mask(res->port_id, &flex_mask);
12328 cmd_reconfig_device_queue(res->port_id, 1, 1);
12331 flex_mask.flow_type = str2flowtype(res->flow_type);
12332 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12333 printf("Flow type %s not supported on port %d\n",
12334 res->flow_type, res->port_id);
12337 fdir_set_flex_mask(res->port_id, &flex_mask);
12338 cmd_reconfig_device_queue(res->port_id, 1, 1);
12341 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12343 flow_director_flexmask,
12344 "flow_director_flex_mask");
12345 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12346 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12348 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12349 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12351 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12353 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12354 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12355 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12359 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12360 .f = cmd_flow_director_flex_mask_parsed,
12362 .help_str = "flow_director_flex_mask ... : "
12363 "Set flow director's flex mask on NIC",
12365 (void *)&cmd_flow_director_flexmask,
12366 (void *)&cmd_flow_director_flexmask_port_id,
12367 (void *)&cmd_flow_director_flexmask_flow,
12368 (void *)&cmd_flow_director_flexmask_flow_type,
12369 (void *)&cmd_flow_director_flexmask_mask,
12374 /* *** deal with flow director flexible payload configuration *** */
12375 struct cmd_flow_director_flexpayload_result {
12376 cmdline_fixed_string_t flow_director_flexpayload;
12378 cmdline_fixed_string_t payload_layer;
12379 cmdline_fixed_string_t payload_cfg;
12383 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12386 const char *p, *p0 = q_arg;
12388 unsigned long int_fld;
12389 char *str_fld[max_num];
12394 p = strchr(p0, '(');
12398 p0 = strchr(p, ')');
12403 if (size >= sizeof(s))
12406 snprintf(s, sizeof(s), "%.*s", size, p);
12407 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12408 if (ret < 0 || ret > max_num)
12410 for (i = 0; i < ret; i++) {
12412 int_fld = strtoul(str_fld[i], &end, 0);
12413 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12415 offsets[i] = (uint16_t)int_fld;
12421 cmd_flow_director_flxpld_parsed(void *parsed_result,
12422 __rte_unused struct cmdline *cl,
12423 __rte_unused void *data)
12425 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12426 struct rte_eth_flex_payload_cfg flex_cfg;
12427 struct rte_port *port;
12430 port = &ports[res->port_id];
12431 /** Check if the port is not started **/
12432 if (port->port_status != RTE_PORT_STOPPED) {
12433 printf("Please stop port %d first\n", res->port_id);
12437 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12439 if (!strcmp(res->payload_layer, "raw"))
12440 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12441 else if (!strcmp(res->payload_layer, "l2"))
12442 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12443 else if (!strcmp(res->payload_layer, "l3"))
12444 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12445 else if (!strcmp(res->payload_layer, "l4"))
12446 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12448 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12449 RTE_ETH_FDIR_MAX_FLEXLEN);
12451 printf("error: Cannot parse flex payload input.\n");
12455 fdir_set_flex_payload(res->port_id, &flex_cfg);
12456 cmd_reconfig_device_queue(res->port_id, 1, 1);
12459 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12460 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12461 flow_director_flexpayload,
12462 "flow_director_flex_payload");
12463 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12464 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12466 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12467 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12468 payload_layer, "raw#l2#l3#l4");
12469 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12471 payload_cfg, NULL);
12473 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12474 .f = cmd_flow_director_flxpld_parsed,
12476 .help_str = "flow_director_flexpayload ... : "
12477 "Set flow director's flex payload on NIC",
12479 (void *)&cmd_flow_director_flexpayload,
12480 (void *)&cmd_flow_director_flexpayload_port_id,
12481 (void *)&cmd_flow_director_flexpayload_payload_layer,
12482 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12487 /* Generic flow interface command. */
12488 extern cmdline_parse_inst_t cmd_flow;
12490 /* *** Classification Filters Control *** */
12491 /* *** Get symmetric hash enable per port *** */
12492 struct cmd_get_sym_hash_ena_per_port_result {
12493 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12498 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12499 __rte_unused struct cmdline *cl,
12500 __rte_unused void *data)
12502 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12503 struct rte_eth_hash_filter_info info;
12506 if (rte_eth_dev_filter_supported(res->port_id,
12507 RTE_ETH_FILTER_HASH) < 0) {
12508 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12513 memset(&info, 0, sizeof(info));
12514 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12515 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12516 RTE_ETH_FILTER_GET, &info);
12519 printf("Cannot get symmetric hash enable per port "
12520 "on port %u\n", res->port_id);
12524 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12525 "enabled" : "disabled", res->port_id);
12528 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12529 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12530 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12531 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12532 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12535 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12536 .f = cmd_get_sym_hash_per_port_parsed,
12538 .help_str = "get_sym_hash_ena_per_port <port_id>",
12540 (void *)&cmd_get_sym_hash_ena_per_port_all,
12541 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12546 /* *** Set symmetric hash enable per port *** */
12547 struct cmd_set_sym_hash_ena_per_port_result {
12548 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12549 cmdline_fixed_string_t enable;
12554 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12555 __rte_unused struct cmdline *cl,
12556 __rte_unused void *data)
12558 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12559 struct rte_eth_hash_filter_info info;
12562 if (rte_eth_dev_filter_supported(res->port_id,
12563 RTE_ETH_FILTER_HASH) < 0) {
12564 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12569 memset(&info, 0, sizeof(info));
12570 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12571 if (!strcmp(res->enable, "enable"))
12572 info.info.enable = 1;
12573 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12574 RTE_ETH_FILTER_SET, &info);
12576 printf("Cannot set symmetric hash enable per port on "
12577 "port %u\n", res->port_id);
12580 printf("Symmetric hash has been set to %s on port %u\n",
12581 res->enable, res->port_id);
12584 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12585 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12586 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12587 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12588 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12590 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12591 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12592 enable, "enable#disable");
12594 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12595 .f = cmd_set_sym_hash_per_port_parsed,
12597 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12599 (void *)&cmd_set_sym_hash_ena_per_port_all,
12600 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12601 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12606 /* Get global config of hash function */
12607 struct cmd_get_hash_global_config_result {
12608 cmdline_fixed_string_t get_hash_global_config;
12613 flowtype_to_str(uint16_t ftype)
12619 } ftype_table[] = {
12620 {"ipv4", RTE_ETH_FLOW_IPV4},
12621 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12622 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12623 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12624 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12625 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12626 {"ipv6", RTE_ETH_FLOW_IPV6},
12627 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12628 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12629 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12630 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12631 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12632 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12633 {"port", RTE_ETH_FLOW_PORT},
12634 {"vxlan", RTE_ETH_FLOW_VXLAN},
12635 {"geneve", RTE_ETH_FLOW_GENEVE},
12636 {"nvgre", RTE_ETH_FLOW_NVGRE},
12637 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12640 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12641 if (ftype_table[i].ftype == ftype)
12642 return ftype_table[i].str;
12649 cmd_get_hash_global_config_parsed(void *parsed_result,
12650 __rte_unused struct cmdline *cl,
12651 __rte_unused void *data)
12653 struct cmd_get_hash_global_config_result *res = parsed_result;
12654 struct rte_eth_hash_filter_info info;
12655 uint32_t idx, offset;
12660 if (rte_eth_dev_filter_supported(res->port_id,
12661 RTE_ETH_FILTER_HASH) < 0) {
12662 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12667 memset(&info, 0, sizeof(info));
12668 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12669 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12670 RTE_ETH_FILTER_GET, &info);
12672 printf("Cannot get hash global configurations by port %d\n",
12677 switch (info.info.global_conf.hash_func) {
12678 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12679 printf("Hash function is Toeplitz\n");
12681 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12682 printf("Hash function is Simple XOR\n");
12684 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12685 printf("Hash function is Symmetric Toeplitz\n");
12688 printf("Unknown hash function\n");
12692 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12693 idx = i / UINT64_BIT;
12694 offset = i % UINT64_BIT;
12695 if (!(info.info.global_conf.valid_bit_mask[idx] &
12698 str = flowtype_to_str(i);
12701 printf("Symmetric hash is %s globally for flow type %s "
12703 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12704 (1ULL << offset)) ? "enabled" : "disabled"), str,
12709 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12710 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12711 get_hash_global_config, "get_hash_global_config");
12712 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12713 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12716 cmdline_parse_inst_t cmd_get_hash_global_config = {
12717 .f = cmd_get_hash_global_config_parsed,
12719 .help_str = "get_hash_global_config <port_id>",
12721 (void *)&cmd_get_hash_global_config_all,
12722 (void *)&cmd_get_hash_global_config_port_id,
12727 /* Set global config of hash function */
12728 struct cmd_set_hash_global_config_result {
12729 cmdline_fixed_string_t set_hash_global_config;
12731 cmdline_fixed_string_t hash_func;
12732 cmdline_fixed_string_t flow_type;
12733 cmdline_fixed_string_t enable;
12737 cmd_set_hash_global_config_parsed(void *parsed_result,
12738 __rte_unused struct cmdline *cl,
12739 __rte_unused void *data)
12741 struct cmd_set_hash_global_config_result *res = parsed_result;
12742 struct rte_eth_hash_filter_info info;
12743 uint32_t ftype, idx, offset;
12746 if (rte_eth_dev_filter_supported(res->port_id,
12747 RTE_ETH_FILTER_HASH) < 0) {
12748 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12752 memset(&info, 0, sizeof(info));
12753 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12754 if (!strcmp(res->hash_func, "toeplitz"))
12755 info.info.global_conf.hash_func =
12756 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12757 else if (!strcmp(res->hash_func, "simple_xor"))
12758 info.info.global_conf.hash_func =
12759 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12760 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12761 info.info.global_conf.hash_func =
12762 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12763 else if (!strcmp(res->hash_func, "default"))
12764 info.info.global_conf.hash_func =
12765 RTE_ETH_HASH_FUNCTION_DEFAULT;
12767 ftype = str2flowtype(res->flow_type);
12768 idx = ftype / UINT64_BIT;
12769 offset = ftype % UINT64_BIT;
12770 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12771 if (!strcmp(res->enable, "enable"))
12772 info.info.global_conf.sym_hash_enable_mask[idx] |=
12774 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12775 RTE_ETH_FILTER_SET, &info);
12777 printf("Cannot set global hash configurations by port %d\n",
12780 printf("Global hash configurations have been set "
12781 "successfully by port %d\n", res->port_id);
12784 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12785 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12786 set_hash_global_config, "set_hash_global_config");
12787 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12788 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12790 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12791 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12792 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12793 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12794 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12796 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12797 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12798 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12799 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12800 enable, "enable#disable");
12802 cmdline_parse_inst_t cmd_set_hash_global_config = {
12803 .f = cmd_set_hash_global_config_parsed,
12805 .help_str = "set_hash_global_config <port_id> "
12806 "toeplitz|simple_xor|symmetric_toeplitz|default "
12807 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12808 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12809 "l2_payload enable|disable",
12811 (void *)&cmd_set_hash_global_config_all,
12812 (void *)&cmd_set_hash_global_config_port_id,
12813 (void *)&cmd_set_hash_global_config_hash_func,
12814 (void *)&cmd_set_hash_global_config_flow_type,
12815 (void *)&cmd_set_hash_global_config_enable,
12820 /* Set hash input set */
12821 struct cmd_set_hash_input_set_result {
12822 cmdline_fixed_string_t set_hash_input_set;
12824 cmdline_fixed_string_t flow_type;
12825 cmdline_fixed_string_t inset_field;
12826 cmdline_fixed_string_t select;
12829 static enum rte_eth_input_set_field
12830 str2inset(char *string)
12834 static const struct {
12836 enum rte_eth_input_set_field inset;
12837 } inset_table[] = {
12838 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12839 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12840 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12841 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12842 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12843 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12844 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12845 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12846 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12847 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12848 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12849 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12850 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12851 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12852 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12853 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12854 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12855 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12856 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12857 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12858 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12859 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12860 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12861 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12862 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12863 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12864 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12865 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12866 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12867 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12868 {"none", RTE_ETH_INPUT_SET_NONE},
12871 for (i = 0; i < RTE_DIM(inset_table); i++) {
12872 if (!strcmp(string, inset_table[i].str))
12873 return inset_table[i].inset;
12876 return RTE_ETH_INPUT_SET_UNKNOWN;
12880 cmd_set_hash_input_set_parsed(void *parsed_result,
12881 __rte_unused struct cmdline *cl,
12882 __rte_unused void *data)
12884 struct cmd_set_hash_input_set_result *res = parsed_result;
12885 struct rte_eth_hash_filter_info info;
12887 memset(&info, 0, sizeof(info));
12888 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12889 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12890 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12891 info.info.input_set_conf.inset_size = 1;
12892 if (!strcmp(res->select, "select"))
12893 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12894 else if (!strcmp(res->select, "add"))
12895 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12896 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12897 RTE_ETH_FILTER_SET, &info);
12900 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12901 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12902 set_hash_input_set, "set_hash_input_set");
12903 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12904 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12906 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12907 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12909 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12910 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12912 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12913 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12914 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12915 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12916 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12918 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12919 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12920 select, "select#add");
12922 cmdline_parse_inst_t cmd_set_hash_input_set = {
12923 .f = cmd_set_hash_input_set_parsed,
12925 .help_str = "set_hash_input_set <port_id> "
12926 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12927 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12928 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12929 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12930 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12931 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12932 "fld-7th|fld-8th|none select|add",
12934 (void *)&cmd_set_hash_input_set_cmd,
12935 (void *)&cmd_set_hash_input_set_port_id,
12936 (void *)&cmd_set_hash_input_set_flow_type,
12937 (void *)&cmd_set_hash_input_set_field,
12938 (void *)&cmd_set_hash_input_set_select,
12943 /* Set flow director input set */
12944 struct cmd_set_fdir_input_set_result {
12945 cmdline_fixed_string_t set_fdir_input_set;
12947 cmdline_fixed_string_t flow_type;
12948 cmdline_fixed_string_t inset_field;
12949 cmdline_fixed_string_t select;
12953 cmd_set_fdir_input_set_parsed(void *parsed_result,
12954 __rte_unused struct cmdline *cl,
12955 __rte_unused void *data)
12957 struct cmd_set_fdir_input_set_result *res = parsed_result;
12958 struct rte_eth_fdir_filter_info info;
12960 memset(&info, 0, sizeof(info));
12961 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12962 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12963 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12964 info.info.input_set_conf.inset_size = 1;
12965 if (!strcmp(res->select, "select"))
12966 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12967 else if (!strcmp(res->select, "add"))
12968 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12969 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12970 RTE_ETH_FILTER_SET, &info);
12973 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12974 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12975 set_fdir_input_set, "set_fdir_input_set");
12976 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12977 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12979 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12980 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12982 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12983 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12984 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12985 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12987 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12988 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12989 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12990 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12991 "sctp-veri-tag#none");
12992 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12993 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12994 select, "select#add");
12996 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12997 .f = cmd_set_fdir_input_set_parsed,
12999 .help_str = "set_fdir_input_set <port_id> "
13000 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
13001 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
13002 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
13003 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
13004 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
13005 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
13006 "sctp-veri-tag|none select|add",
13008 (void *)&cmd_set_fdir_input_set_cmd,
13009 (void *)&cmd_set_fdir_input_set_port_id,
13010 (void *)&cmd_set_fdir_input_set_flow_type,
13011 (void *)&cmd_set_fdir_input_set_field,
13012 (void *)&cmd_set_fdir_input_set_select,
13017 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
13018 struct cmd_mcast_addr_result {
13019 cmdline_fixed_string_t mcast_addr_cmd;
13020 cmdline_fixed_string_t what;
13022 struct rte_ether_addr mc_addr;
13025 static void cmd_mcast_addr_parsed(void *parsed_result,
13026 __rte_unused struct cmdline *cl,
13027 __rte_unused void *data)
13029 struct cmd_mcast_addr_result *res = parsed_result;
13031 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
13032 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
13033 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
13034 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
13035 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
13038 if (strcmp(res->what, "add") == 0)
13039 mcast_addr_add(res->port_num, &res->mc_addr);
13041 mcast_addr_remove(res->port_num, &res->mc_addr);
13044 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
13045 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
13046 mcast_addr_cmd, "mcast_addr");
13047 cmdline_parse_token_string_t cmd_mcast_addr_what =
13048 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
13050 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
13051 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
13052 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
13053 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
13055 cmdline_parse_inst_t cmd_mcast_addr = {
13056 .f = cmd_mcast_addr_parsed,
13058 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
13059 "Add/Remove multicast MAC address on port_id",
13061 (void *)&cmd_mcast_addr_cmd,
13062 (void *)&cmd_mcast_addr_what,
13063 (void *)&cmd_mcast_addr_portnum,
13064 (void *)&cmd_mcast_addr_addr,
13069 /* l2 tunnel config
13070 * only support E-tag now.
13073 /* Ether type config */
13074 struct cmd_config_l2_tunnel_eth_type_result {
13075 cmdline_fixed_string_t port;
13076 cmdline_fixed_string_t config;
13077 cmdline_fixed_string_t all;
13079 cmdline_fixed_string_t l2_tunnel;
13080 cmdline_fixed_string_t l2_tunnel_type;
13081 cmdline_fixed_string_t eth_type;
13082 uint16_t eth_type_val;
13085 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
13086 TOKEN_STRING_INITIALIZER
13087 (struct cmd_config_l2_tunnel_eth_type_result,
13089 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
13090 TOKEN_STRING_INITIALIZER
13091 (struct cmd_config_l2_tunnel_eth_type_result,
13093 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
13094 TOKEN_STRING_INITIALIZER
13095 (struct cmd_config_l2_tunnel_eth_type_result,
13097 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
13098 TOKEN_NUM_INITIALIZER
13099 (struct cmd_config_l2_tunnel_eth_type_result,
13101 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
13102 TOKEN_STRING_INITIALIZER
13103 (struct cmd_config_l2_tunnel_eth_type_result,
13104 l2_tunnel, "l2-tunnel");
13105 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
13106 TOKEN_STRING_INITIALIZER
13107 (struct cmd_config_l2_tunnel_eth_type_result,
13108 l2_tunnel_type, "E-tag");
13109 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
13110 TOKEN_STRING_INITIALIZER
13111 (struct cmd_config_l2_tunnel_eth_type_result,
13112 eth_type, "ether-type");
13113 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
13114 TOKEN_NUM_INITIALIZER
13115 (struct cmd_config_l2_tunnel_eth_type_result,
13116 eth_type_val, UINT16);
13118 static enum rte_eth_tunnel_type
13119 str2fdir_l2_tunnel_type(char *string)
13123 static const struct {
13125 enum rte_eth_tunnel_type type;
13126 } l2_tunnel_type_str[] = {
13127 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
13130 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
13131 if (!strcmp(l2_tunnel_type_str[i].str, string))
13132 return l2_tunnel_type_str[i].type;
13134 return RTE_TUNNEL_TYPE_NONE;
13137 /* ether type config for all ports */
13139 cmd_config_l2_tunnel_eth_type_all_parsed
13140 (void *parsed_result,
13141 __rte_unused struct cmdline *cl,
13142 __rte_unused void *data)
13144 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
13145 struct rte_eth_l2_tunnel_conf entry;
13148 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13149 entry.ether_type = res->eth_type_val;
13151 RTE_ETH_FOREACH_DEV(pid) {
13152 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
13156 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
13157 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
13159 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
13161 (void *)&cmd_config_l2_tunnel_eth_type_port,
13162 (void *)&cmd_config_l2_tunnel_eth_type_config,
13163 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
13164 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13165 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13166 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13167 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13172 /* ether type config for a specific port */
13174 cmd_config_l2_tunnel_eth_type_specific_parsed(
13175 void *parsed_result,
13176 __rte_unused struct cmdline *cl,
13177 __rte_unused void *data)
13179 struct cmd_config_l2_tunnel_eth_type_result *res =
13181 struct rte_eth_l2_tunnel_conf entry;
13183 if (port_id_is_invalid(res->id, ENABLED_WARN))
13186 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13187 entry.ether_type = res->eth_type_val;
13189 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
13192 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
13193 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
13195 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
13197 (void *)&cmd_config_l2_tunnel_eth_type_port,
13198 (void *)&cmd_config_l2_tunnel_eth_type_config,
13199 (void *)&cmd_config_l2_tunnel_eth_type_id,
13200 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13201 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13202 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13203 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13208 /* Enable/disable l2 tunnel */
13209 struct cmd_config_l2_tunnel_en_dis_result {
13210 cmdline_fixed_string_t port;
13211 cmdline_fixed_string_t config;
13212 cmdline_fixed_string_t all;
13214 cmdline_fixed_string_t l2_tunnel;
13215 cmdline_fixed_string_t l2_tunnel_type;
13216 cmdline_fixed_string_t en_dis;
13219 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
13220 TOKEN_STRING_INITIALIZER
13221 (struct cmd_config_l2_tunnel_en_dis_result,
13223 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
13224 TOKEN_STRING_INITIALIZER
13225 (struct cmd_config_l2_tunnel_en_dis_result,
13227 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
13228 TOKEN_STRING_INITIALIZER
13229 (struct cmd_config_l2_tunnel_en_dis_result,
13231 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
13232 TOKEN_NUM_INITIALIZER
13233 (struct cmd_config_l2_tunnel_en_dis_result,
13235 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
13236 TOKEN_STRING_INITIALIZER
13237 (struct cmd_config_l2_tunnel_en_dis_result,
13238 l2_tunnel, "l2-tunnel");
13239 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
13240 TOKEN_STRING_INITIALIZER
13241 (struct cmd_config_l2_tunnel_en_dis_result,
13242 l2_tunnel_type, "E-tag");
13243 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
13244 TOKEN_STRING_INITIALIZER
13245 (struct cmd_config_l2_tunnel_en_dis_result,
13246 en_dis, "enable#disable");
13248 /* enable/disable l2 tunnel for all ports */
13250 cmd_config_l2_tunnel_en_dis_all_parsed(
13251 void *parsed_result,
13252 __rte_unused struct cmdline *cl,
13253 __rte_unused void *data)
13255 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
13256 struct rte_eth_l2_tunnel_conf entry;
13260 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13262 if (!strcmp("enable", res->en_dis))
13267 RTE_ETH_FOREACH_DEV(pid) {
13268 rte_eth_dev_l2_tunnel_offload_set(pid,
13270 ETH_L2_TUNNEL_ENABLE_MASK,
13275 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
13276 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
13278 .help_str = "port config all l2-tunnel E-tag enable|disable",
13280 (void *)&cmd_config_l2_tunnel_en_dis_port,
13281 (void *)&cmd_config_l2_tunnel_en_dis_config,
13282 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
13283 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13284 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13285 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13290 /* enable/disable l2 tunnel for a port */
13292 cmd_config_l2_tunnel_en_dis_specific_parsed(
13293 void *parsed_result,
13294 __rte_unused struct cmdline *cl,
13295 __rte_unused void *data)
13297 struct cmd_config_l2_tunnel_en_dis_result *res =
13299 struct rte_eth_l2_tunnel_conf entry;
13301 if (port_id_is_invalid(res->id, ENABLED_WARN))
13304 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13306 if (!strcmp("enable", res->en_dis))
13307 rte_eth_dev_l2_tunnel_offload_set(res->id,
13309 ETH_L2_TUNNEL_ENABLE_MASK,
13312 rte_eth_dev_l2_tunnel_offload_set(res->id,
13314 ETH_L2_TUNNEL_ENABLE_MASK,
13318 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13319 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13321 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13323 (void *)&cmd_config_l2_tunnel_en_dis_port,
13324 (void *)&cmd_config_l2_tunnel_en_dis_config,
13325 (void *)&cmd_config_l2_tunnel_en_dis_id,
13326 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13327 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13328 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13333 /* E-tag configuration */
13335 /* Common result structure for all E-tag configuration */
13336 struct cmd_config_e_tag_result {
13337 cmdline_fixed_string_t e_tag;
13338 cmdline_fixed_string_t set;
13339 cmdline_fixed_string_t insertion;
13340 cmdline_fixed_string_t stripping;
13341 cmdline_fixed_string_t forwarding;
13342 cmdline_fixed_string_t filter;
13343 cmdline_fixed_string_t add;
13344 cmdline_fixed_string_t del;
13345 cmdline_fixed_string_t on;
13346 cmdline_fixed_string_t off;
13347 cmdline_fixed_string_t on_off;
13348 cmdline_fixed_string_t port_tag_id;
13349 uint32_t port_tag_id_val;
13350 cmdline_fixed_string_t e_tag_id;
13351 uint16_t e_tag_id_val;
13352 cmdline_fixed_string_t dst_pool;
13353 uint8_t dst_pool_val;
13354 cmdline_fixed_string_t port;
13356 cmdline_fixed_string_t vf;
13360 /* Common CLI fields for all E-tag configuration */
13361 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13362 TOKEN_STRING_INITIALIZER
13363 (struct cmd_config_e_tag_result,
13365 cmdline_parse_token_string_t cmd_config_e_tag_set =
13366 TOKEN_STRING_INITIALIZER
13367 (struct cmd_config_e_tag_result,
13369 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13370 TOKEN_STRING_INITIALIZER
13371 (struct cmd_config_e_tag_result,
13372 insertion, "insertion");
13373 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13374 TOKEN_STRING_INITIALIZER
13375 (struct cmd_config_e_tag_result,
13376 stripping, "stripping");
13377 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13378 TOKEN_STRING_INITIALIZER
13379 (struct cmd_config_e_tag_result,
13380 forwarding, "forwarding");
13381 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13382 TOKEN_STRING_INITIALIZER
13383 (struct cmd_config_e_tag_result,
13385 cmdline_parse_token_string_t cmd_config_e_tag_add =
13386 TOKEN_STRING_INITIALIZER
13387 (struct cmd_config_e_tag_result,
13389 cmdline_parse_token_string_t cmd_config_e_tag_del =
13390 TOKEN_STRING_INITIALIZER
13391 (struct cmd_config_e_tag_result,
13393 cmdline_parse_token_string_t cmd_config_e_tag_on =
13394 TOKEN_STRING_INITIALIZER
13395 (struct cmd_config_e_tag_result,
13397 cmdline_parse_token_string_t cmd_config_e_tag_off =
13398 TOKEN_STRING_INITIALIZER
13399 (struct cmd_config_e_tag_result,
13401 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13402 TOKEN_STRING_INITIALIZER
13403 (struct cmd_config_e_tag_result,
13405 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13406 TOKEN_STRING_INITIALIZER
13407 (struct cmd_config_e_tag_result,
13408 port_tag_id, "port-tag-id");
13409 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13410 TOKEN_NUM_INITIALIZER
13411 (struct cmd_config_e_tag_result,
13412 port_tag_id_val, UINT32);
13413 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13414 TOKEN_STRING_INITIALIZER
13415 (struct cmd_config_e_tag_result,
13416 e_tag_id, "e-tag-id");
13417 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13418 TOKEN_NUM_INITIALIZER
13419 (struct cmd_config_e_tag_result,
13420 e_tag_id_val, UINT16);
13421 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13422 TOKEN_STRING_INITIALIZER
13423 (struct cmd_config_e_tag_result,
13424 dst_pool, "dst-pool");
13425 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13426 TOKEN_NUM_INITIALIZER
13427 (struct cmd_config_e_tag_result,
13428 dst_pool_val, UINT8);
13429 cmdline_parse_token_string_t cmd_config_e_tag_port =
13430 TOKEN_STRING_INITIALIZER
13431 (struct cmd_config_e_tag_result,
13433 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13434 TOKEN_NUM_INITIALIZER
13435 (struct cmd_config_e_tag_result,
13437 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13438 TOKEN_STRING_INITIALIZER
13439 (struct cmd_config_e_tag_result,
13441 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13442 TOKEN_NUM_INITIALIZER
13443 (struct cmd_config_e_tag_result,
13446 /* E-tag insertion configuration */
13448 cmd_config_e_tag_insertion_en_parsed(
13449 void *parsed_result,
13450 __rte_unused struct cmdline *cl,
13451 __rte_unused void *data)
13453 struct cmd_config_e_tag_result *res =
13455 struct rte_eth_l2_tunnel_conf entry;
13457 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13460 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13461 entry.tunnel_id = res->port_tag_id_val;
13462 entry.vf_id = res->vf_id;
13463 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13465 ETH_L2_TUNNEL_INSERTION_MASK,
13470 cmd_config_e_tag_insertion_dis_parsed(
13471 void *parsed_result,
13472 __rte_unused struct cmdline *cl,
13473 __rte_unused void *data)
13475 struct cmd_config_e_tag_result *res =
13477 struct rte_eth_l2_tunnel_conf entry;
13479 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13482 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13483 entry.vf_id = res->vf_id;
13485 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13487 ETH_L2_TUNNEL_INSERTION_MASK,
13491 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13492 .f = cmd_config_e_tag_insertion_en_parsed,
13494 .help_str = "E-tag ... : E-tag insertion enable",
13496 (void *)&cmd_config_e_tag_e_tag,
13497 (void *)&cmd_config_e_tag_set,
13498 (void *)&cmd_config_e_tag_insertion,
13499 (void *)&cmd_config_e_tag_on,
13500 (void *)&cmd_config_e_tag_port_tag_id,
13501 (void *)&cmd_config_e_tag_port_tag_id_val,
13502 (void *)&cmd_config_e_tag_port,
13503 (void *)&cmd_config_e_tag_port_id,
13504 (void *)&cmd_config_e_tag_vf,
13505 (void *)&cmd_config_e_tag_vf_id,
13510 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13511 .f = cmd_config_e_tag_insertion_dis_parsed,
13513 .help_str = "E-tag ... : E-tag insertion disable",
13515 (void *)&cmd_config_e_tag_e_tag,
13516 (void *)&cmd_config_e_tag_set,
13517 (void *)&cmd_config_e_tag_insertion,
13518 (void *)&cmd_config_e_tag_off,
13519 (void *)&cmd_config_e_tag_port,
13520 (void *)&cmd_config_e_tag_port_id,
13521 (void *)&cmd_config_e_tag_vf,
13522 (void *)&cmd_config_e_tag_vf_id,
13527 /* E-tag stripping configuration */
13529 cmd_config_e_tag_stripping_parsed(
13530 void *parsed_result,
13531 __rte_unused struct cmdline *cl,
13532 __rte_unused void *data)
13534 struct cmd_config_e_tag_result *res =
13536 struct rte_eth_l2_tunnel_conf entry;
13538 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13541 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13543 if (!strcmp(res->on_off, "on"))
13544 rte_eth_dev_l2_tunnel_offload_set
13547 ETH_L2_TUNNEL_STRIPPING_MASK,
13550 rte_eth_dev_l2_tunnel_offload_set
13553 ETH_L2_TUNNEL_STRIPPING_MASK,
13557 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13558 .f = cmd_config_e_tag_stripping_parsed,
13560 .help_str = "E-tag ... : E-tag stripping enable/disable",
13562 (void *)&cmd_config_e_tag_e_tag,
13563 (void *)&cmd_config_e_tag_set,
13564 (void *)&cmd_config_e_tag_stripping,
13565 (void *)&cmd_config_e_tag_on_off,
13566 (void *)&cmd_config_e_tag_port,
13567 (void *)&cmd_config_e_tag_port_id,
13572 /* E-tag forwarding configuration */
13574 cmd_config_e_tag_forwarding_parsed(
13575 void *parsed_result,
13576 __rte_unused struct cmdline *cl,
13577 __rte_unused void *data)
13579 struct cmd_config_e_tag_result *res = parsed_result;
13580 struct rte_eth_l2_tunnel_conf entry;
13582 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13585 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13587 if (!strcmp(res->on_off, "on"))
13588 rte_eth_dev_l2_tunnel_offload_set
13591 ETH_L2_TUNNEL_FORWARDING_MASK,
13594 rte_eth_dev_l2_tunnel_offload_set
13597 ETH_L2_TUNNEL_FORWARDING_MASK,
13601 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13602 .f = cmd_config_e_tag_forwarding_parsed,
13604 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13606 (void *)&cmd_config_e_tag_e_tag,
13607 (void *)&cmd_config_e_tag_set,
13608 (void *)&cmd_config_e_tag_forwarding,
13609 (void *)&cmd_config_e_tag_on_off,
13610 (void *)&cmd_config_e_tag_port,
13611 (void *)&cmd_config_e_tag_port_id,
13616 /* E-tag filter configuration */
13618 cmd_config_e_tag_filter_add_parsed(
13619 void *parsed_result,
13620 __rte_unused struct cmdline *cl,
13621 __rte_unused void *data)
13623 struct cmd_config_e_tag_result *res = parsed_result;
13624 struct rte_eth_l2_tunnel_conf entry;
13627 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13630 if (res->e_tag_id_val > 0x3fff) {
13631 printf("e-tag-id must be equal or less than 0x3fff.\n");
13635 ret = rte_eth_dev_filter_supported(res->port_id,
13636 RTE_ETH_FILTER_L2_TUNNEL);
13638 printf("E-tag filter is not supported on port %u.\n",
13643 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13644 entry.tunnel_id = res->e_tag_id_val;
13645 entry.pool = res->dst_pool_val;
13647 ret = rte_eth_dev_filter_ctrl(res->port_id,
13648 RTE_ETH_FILTER_L2_TUNNEL,
13649 RTE_ETH_FILTER_ADD,
13652 printf("E-tag filter programming error: (%s)\n",
13656 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13657 .f = cmd_config_e_tag_filter_add_parsed,
13659 .help_str = "E-tag ... : E-tag filter add",
13661 (void *)&cmd_config_e_tag_e_tag,
13662 (void *)&cmd_config_e_tag_set,
13663 (void *)&cmd_config_e_tag_filter,
13664 (void *)&cmd_config_e_tag_add,
13665 (void *)&cmd_config_e_tag_e_tag_id,
13666 (void *)&cmd_config_e_tag_e_tag_id_val,
13667 (void *)&cmd_config_e_tag_dst_pool,
13668 (void *)&cmd_config_e_tag_dst_pool_val,
13669 (void *)&cmd_config_e_tag_port,
13670 (void *)&cmd_config_e_tag_port_id,
13676 cmd_config_e_tag_filter_del_parsed(
13677 void *parsed_result,
13678 __rte_unused struct cmdline *cl,
13679 __rte_unused void *data)
13681 struct cmd_config_e_tag_result *res = parsed_result;
13682 struct rte_eth_l2_tunnel_conf entry;
13685 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13688 if (res->e_tag_id_val > 0x3fff) {
13689 printf("e-tag-id must be less than 0x3fff.\n");
13693 ret = rte_eth_dev_filter_supported(res->port_id,
13694 RTE_ETH_FILTER_L2_TUNNEL);
13696 printf("E-tag filter is not supported on port %u.\n",
13701 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13702 entry.tunnel_id = res->e_tag_id_val;
13704 ret = rte_eth_dev_filter_ctrl(res->port_id,
13705 RTE_ETH_FILTER_L2_TUNNEL,
13706 RTE_ETH_FILTER_DELETE,
13709 printf("E-tag filter programming error: (%s)\n",
13713 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13714 .f = cmd_config_e_tag_filter_del_parsed,
13716 .help_str = "E-tag ... : E-tag filter delete",
13718 (void *)&cmd_config_e_tag_e_tag,
13719 (void *)&cmd_config_e_tag_set,
13720 (void *)&cmd_config_e_tag_filter,
13721 (void *)&cmd_config_e_tag_del,
13722 (void *)&cmd_config_e_tag_e_tag_id,
13723 (void *)&cmd_config_e_tag_e_tag_id_val,
13724 (void *)&cmd_config_e_tag_port,
13725 (void *)&cmd_config_e_tag_port_id,
13730 /* vf vlan anti spoof configuration */
13732 /* Common result structure for vf vlan anti spoof */
13733 struct cmd_vf_vlan_anti_spoof_result {
13734 cmdline_fixed_string_t set;
13735 cmdline_fixed_string_t vf;
13736 cmdline_fixed_string_t vlan;
13737 cmdline_fixed_string_t antispoof;
13740 cmdline_fixed_string_t on_off;
13743 /* Common CLI fields for vf vlan anti spoof enable disable */
13744 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13745 TOKEN_STRING_INITIALIZER
13746 (struct cmd_vf_vlan_anti_spoof_result,
13748 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13749 TOKEN_STRING_INITIALIZER
13750 (struct cmd_vf_vlan_anti_spoof_result,
13752 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13753 TOKEN_STRING_INITIALIZER
13754 (struct cmd_vf_vlan_anti_spoof_result,
13756 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13757 TOKEN_STRING_INITIALIZER
13758 (struct cmd_vf_vlan_anti_spoof_result,
13759 antispoof, "antispoof");
13760 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13761 TOKEN_NUM_INITIALIZER
13762 (struct cmd_vf_vlan_anti_spoof_result,
13764 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13765 TOKEN_NUM_INITIALIZER
13766 (struct cmd_vf_vlan_anti_spoof_result,
13768 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13769 TOKEN_STRING_INITIALIZER
13770 (struct cmd_vf_vlan_anti_spoof_result,
13774 cmd_set_vf_vlan_anti_spoof_parsed(
13775 void *parsed_result,
13776 __rte_unused struct cmdline *cl,
13777 __rte_unused void *data)
13779 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13780 int ret = -ENOTSUP;
13782 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13784 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13787 #ifdef RTE_LIBRTE_IXGBE_PMD
13788 if (ret == -ENOTSUP)
13789 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13790 res->vf_id, is_on);
13792 #ifdef RTE_LIBRTE_I40E_PMD
13793 if (ret == -ENOTSUP)
13794 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13795 res->vf_id, is_on);
13797 #ifdef RTE_LIBRTE_BNXT_PMD
13798 if (ret == -ENOTSUP)
13799 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13800 res->vf_id, is_on);
13807 printf("invalid vf_id %d\n", res->vf_id);
13810 printf("invalid port_id %d\n", res->port_id);
13813 printf("function not implemented\n");
13816 printf("programming error: (%s)\n", strerror(-ret));
13820 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13821 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13823 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13825 (void *)&cmd_vf_vlan_anti_spoof_set,
13826 (void *)&cmd_vf_vlan_anti_spoof_vf,
13827 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13828 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13829 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13830 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13831 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13836 /* vf mac anti spoof configuration */
13838 /* Common result structure for vf mac anti spoof */
13839 struct cmd_vf_mac_anti_spoof_result {
13840 cmdline_fixed_string_t set;
13841 cmdline_fixed_string_t vf;
13842 cmdline_fixed_string_t mac;
13843 cmdline_fixed_string_t antispoof;
13846 cmdline_fixed_string_t on_off;
13849 /* Common CLI fields for vf mac anti spoof enable disable */
13850 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13851 TOKEN_STRING_INITIALIZER
13852 (struct cmd_vf_mac_anti_spoof_result,
13854 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13855 TOKEN_STRING_INITIALIZER
13856 (struct cmd_vf_mac_anti_spoof_result,
13858 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13859 TOKEN_STRING_INITIALIZER
13860 (struct cmd_vf_mac_anti_spoof_result,
13862 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13863 TOKEN_STRING_INITIALIZER
13864 (struct cmd_vf_mac_anti_spoof_result,
13865 antispoof, "antispoof");
13866 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13867 TOKEN_NUM_INITIALIZER
13868 (struct cmd_vf_mac_anti_spoof_result,
13870 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13871 TOKEN_NUM_INITIALIZER
13872 (struct cmd_vf_mac_anti_spoof_result,
13874 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13875 TOKEN_STRING_INITIALIZER
13876 (struct cmd_vf_mac_anti_spoof_result,
13880 cmd_set_vf_mac_anti_spoof_parsed(
13881 void *parsed_result,
13882 __rte_unused struct cmdline *cl,
13883 __rte_unused void *data)
13885 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13886 int ret = -ENOTSUP;
13888 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13890 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13893 #ifdef RTE_LIBRTE_IXGBE_PMD
13894 if (ret == -ENOTSUP)
13895 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13896 res->vf_id, is_on);
13898 #ifdef RTE_LIBRTE_I40E_PMD
13899 if (ret == -ENOTSUP)
13900 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13901 res->vf_id, is_on);
13903 #ifdef RTE_LIBRTE_BNXT_PMD
13904 if (ret == -ENOTSUP)
13905 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13906 res->vf_id, is_on);
13913 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13916 printf("invalid port_id %d\n", res->port_id);
13919 printf("function not implemented\n");
13922 printf("programming error: (%s)\n", strerror(-ret));
13926 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13927 .f = cmd_set_vf_mac_anti_spoof_parsed,
13929 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13931 (void *)&cmd_vf_mac_anti_spoof_set,
13932 (void *)&cmd_vf_mac_anti_spoof_vf,
13933 (void *)&cmd_vf_mac_anti_spoof_mac,
13934 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13935 (void *)&cmd_vf_mac_anti_spoof_port_id,
13936 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13937 (void *)&cmd_vf_mac_anti_spoof_on_off,
13942 /* vf vlan strip queue configuration */
13944 /* Common result structure for vf mac anti spoof */
13945 struct cmd_vf_vlan_stripq_result {
13946 cmdline_fixed_string_t set;
13947 cmdline_fixed_string_t vf;
13948 cmdline_fixed_string_t vlan;
13949 cmdline_fixed_string_t stripq;
13952 cmdline_fixed_string_t on_off;
13955 /* Common CLI fields for vf vlan strip enable disable */
13956 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13957 TOKEN_STRING_INITIALIZER
13958 (struct cmd_vf_vlan_stripq_result,
13960 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13961 TOKEN_STRING_INITIALIZER
13962 (struct cmd_vf_vlan_stripq_result,
13964 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13965 TOKEN_STRING_INITIALIZER
13966 (struct cmd_vf_vlan_stripq_result,
13968 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13969 TOKEN_STRING_INITIALIZER
13970 (struct cmd_vf_vlan_stripq_result,
13972 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13973 TOKEN_NUM_INITIALIZER
13974 (struct cmd_vf_vlan_stripq_result,
13976 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13977 TOKEN_NUM_INITIALIZER
13978 (struct cmd_vf_vlan_stripq_result,
13980 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13981 TOKEN_STRING_INITIALIZER
13982 (struct cmd_vf_vlan_stripq_result,
13986 cmd_set_vf_vlan_stripq_parsed(
13987 void *parsed_result,
13988 __rte_unused struct cmdline *cl,
13989 __rte_unused void *data)
13991 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13992 int ret = -ENOTSUP;
13994 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13996 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13999 #ifdef RTE_LIBRTE_IXGBE_PMD
14000 if (ret == -ENOTSUP)
14001 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
14002 res->vf_id, is_on);
14004 #ifdef RTE_LIBRTE_I40E_PMD
14005 if (ret == -ENOTSUP)
14006 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
14007 res->vf_id, is_on);
14009 #ifdef RTE_LIBRTE_BNXT_PMD
14010 if (ret == -ENOTSUP)
14011 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
14012 res->vf_id, is_on);
14019 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14022 printf("invalid port_id %d\n", res->port_id);
14025 printf("function not implemented\n");
14028 printf("programming error: (%s)\n", strerror(-ret));
14032 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
14033 .f = cmd_set_vf_vlan_stripq_parsed,
14035 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
14037 (void *)&cmd_vf_vlan_stripq_set,
14038 (void *)&cmd_vf_vlan_stripq_vf,
14039 (void *)&cmd_vf_vlan_stripq_vlan,
14040 (void *)&cmd_vf_vlan_stripq_stripq,
14041 (void *)&cmd_vf_vlan_stripq_port_id,
14042 (void *)&cmd_vf_vlan_stripq_vf_id,
14043 (void *)&cmd_vf_vlan_stripq_on_off,
14048 /* vf vlan insert configuration */
14050 /* Common result structure for vf vlan insert */
14051 struct cmd_vf_vlan_insert_result {
14052 cmdline_fixed_string_t set;
14053 cmdline_fixed_string_t vf;
14054 cmdline_fixed_string_t vlan;
14055 cmdline_fixed_string_t insert;
14061 /* Common CLI fields for vf vlan insert enable disable */
14062 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
14063 TOKEN_STRING_INITIALIZER
14064 (struct cmd_vf_vlan_insert_result,
14066 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
14067 TOKEN_STRING_INITIALIZER
14068 (struct cmd_vf_vlan_insert_result,
14070 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
14071 TOKEN_STRING_INITIALIZER
14072 (struct cmd_vf_vlan_insert_result,
14074 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
14075 TOKEN_STRING_INITIALIZER
14076 (struct cmd_vf_vlan_insert_result,
14078 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
14079 TOKEN_NUM_INITIALIZER
14080 (struct cmd_vf_vlan_insert_result,
14082 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
14083 TOKEN_NUM_INITIALIZER
14084 (struct cmd_vf_vlan_insert_result,
14086 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
14087 TOKEN_NUM_INITIALIZER
14088 (struct cmd_vf_vlan_insert_result,
14092 cmd_set_vf_vlan_insert_parsed(
14093 void *parsed_result,
14094 __rte_unused struct cmdline *cl,
14095 __rte_unused void *data)
14097 struct cmd_vf_vlan_insert_result *res = parsed_result;
14098 int ret = -ENOTSUP;
14100 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14103 #ifdef RTE_LIBRTE_IXGBE_PMD
14104 if (ret == -ENOTSUP)
14105 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
14108 #ifdef RTE_LIBRTE_I40E_PMD
14109 if (ret == -ENOTSUP)
14110 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
14113 #ifdef RTE_LIBRTE_BNXT_PMD
14114 if (ret == -ENOTSUP)
14115 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
14123 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
14126 printf("invalid port_id %d\n", res->port_id);
14129 printf("function not implemented\n");
14132 printf("programming error: (%s)\n", strerror(-ret));
14136 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
14137 .f = cmd_set_vf_vlan_insert_parsed,
14139 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
14141 (void *)&cmd_vf_vlan_insert_set,
14142 (void *)&cmd_vf_vlan_insert_vf,
14143 (void *)&cmd_vf_vlan_insert_vlan,
14144 (void *)&cmd_vf_vlan_insert_insert,
14145 (void *)&cmd_vf_vlan_insert_port_id,
14146 (void *)&cmd_vf_vlan_insert_vf_id,
14147 (void *)&cmd_vf_vlan_insert_vlan_id,
14152 /* tx loopback configuration */
14154 /* Common result structure for tx loopback */
14155 struct cmd_tx_loopback_result {
14156 cmdline_fixed_string_t set;
14157 cmdline_fixed_string_t tx;
14158 cmdline_fixed_string_t loopback;
14160 cmdline_fixed_string_t on_off;
14163 /* Common CLI fields for tx loopback enable disable */
14164 cmdline_parse_token_string_t cmd_tx_loopback_set =
14165 TOKEN_STRING_INITIALIZER
14166 (struct cmd_tx_loopback_result,
14168 cmdline_parse_token_string_t cmd_tx_loopback_tx =
14169 TOKEN_STRING_INITIALIZER
14170 (struct cmd_tx_loopback_result,
14172 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
14173 TOKEN_STRING_INITIALIZER
14174 (struct cmd_tx_loopback_result,
14175 loopback, "loopback");
14176 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
14177 TOKEN_NUM_INITIALIZER
14178 (struct cmd_tx_loopback_result,
14180 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
14181 TOKEN_STRING_INITIALIZER
14182 (struct cmd_tx_loopback_result,
14186 cmd_set_tx_loopback_parsed(
14187 void *parsed_result,
14188 __rte_unused struct cmdline *cl,
14189 __rte_unused void *data)
14191 struct cmd_tx_loopback_result *res = parsed_result;
14192 int ret = -ENOTSUP;
14194 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14196 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14199 #ifdef RTE_LIBRTE_IXGBE_PMD
14200 if (ret == -ENOTSUP)
14201 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
14203 #ifdef RTE_LIBRTE_I40E_PMD
14204 if (ret == -ENOTSUP)
14205 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
14207 #ifdef RTE_LIBRTE_BNXT_PMD
14208 if (ret == -ENOTSUP)
14209 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
14211 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
14212 if (ret == -ENOTSUP)
14213 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
14220 printf("invalid is_on %d\n", is_on);
14223 printf("invalid port_id %d\n", res->port_id);
14226 printf("function not implemented\n");
14229 printf("programming error: (%s)\n", strerror(-ret));
14233 cmdline_parse_inst_t cmd_set_tx_loopback = {
14234 .f = cmd_set_tx_loopback_parsed,
14236 .help_str = "set tx loopback <port_id> on|off",
14238 (void *)&cmd_tx_loopback_set,
14239 (void *)&cmd_tx_loopback_tx,
14240 (void *)&cmd_tx_loopback_loopback,
14241 (void *)&cmd_tx_loopback_port_id,
14242 (void *)&cmd_tx_loopback_on_off,
14247 /* all queues drop enable configuration */
14249 /* Common result structure for all queues drop enable */
14250 struct cmd_all_queues_drop_en_result {
14251 cmdline_fixed_string_t set;
14252 cmdline_fixed_string_t all;
14253 cmdline_fixed_string_t queues;
14254 cmdline_fixed_string_t drop;
14256 cmdline_fixed_string_t on_off;
14259 /* Common CLI fields for tx loopback enable disable */
14260 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
14261 TOKEN_STRING_INITIALIZER
14262 (struct cmd_all_queues_drop_en_result,
14264 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
14265 TOKEN_STRING_INITIALIZER
14266 (struct cmd_all_queues_drop_en_result,
14268 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
14269 TOKEN_STRING_INITIALIZER
14270 (struct cmd_all_queues_drop_en_result,
14272 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
14273 TOKEN_STRING_INITIALIZER
14274 (struct cmd_all_queues_drop_en_result,
14276 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
14277 TOKEN_NUM_INITIALIZER
14278 (struct cmd_all_queues_drop_en_result,
14280 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
14281 TOKEN_STRING_INITIALIZER
14282 (struct cmd_all_queues_drop_en_result,
14286 cmd_set_all_queues_drop_en_parsed(
14287 void *parsed_result,
14288 __rte_unused struct cmdline *cl,
14289 __rte_unused void *data)
14291 struct cmd_all_queues_drop_en_result *res = parsed_result;
14292 int ret = -ENOTSUP;
14293 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14295 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14298 #ifdef RTE_LIBRTE_IXGBE_PMD
14299 if (ret == -ENOTSUP)
14300 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14302 #ifdef RTE_LIBRTE_BNXT_PMD
14303 if (ret == -ENOTSUP)
14304 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14310 printf("invalid is_on %d\n", is_on);
14313 printf("invalid port_id %d\n", res->port_id);
14316 printf("function not implemented\n");
14319 printf("programming error: (%s)\n", strerror(-ret));
14323 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14324 .f = cmd_set_all_queues_drop_en_parsed,
14326 .help_str = "set all queues drop <port_id> on|off",
14328 (void *)&cmd_all_queues_drop_en_set,
14329 (void *)&cmd_all_queues_drop_en_all,
14330 (void *)&cmd_all_queues_drop_en_queues,
14331 (void *)&cmd_all_queues_drop_en_drop,
14332 (void *)&cmd_all_queues_drop_en_port_id,
14333 (void *)&cmd_all_queues_drop_en_on_off,
14338 /* vf split drop enable configuration */
14340 /* Common result structure for vf split drop enable */
14341 struct cmd_vf_split_drop_en_result {
14342 cmdline_fixed_string_t set;
14343 cmdline_fixed_string_t vf;
14344 cmdline_fixed_string_t split;
14345 cmdline_fixed_string_t drop;
14348 cmdline_fixed_string_t on_off;
14351 /* Common CLI fields for vf split drop enable disable */
14352 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14353 TOKEN_STRING_INITIALIZER
14354 (struct cmd_vf_split_drop_en_result,
14356 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14357 TOKEN_STRING_INITIALIZER
14358 (struct cmd_vf_split_drop_en_result,
14360 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14361 TOKEN_STRING_INITIALIZER
14362 (struct cmd_vf_split_drop_en_result,
14364 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14365 TOKEN_STRING_INITIALIZER
14366 (struct cmd_vf_split_drop_en_result,
14368 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14369 TOKEN_NUM_INITIALIZER
14370 (struct cmd_vf_split_drop_en_result,
14372 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14373 TOKEN_NUM_INITIALIZER
14374 (struct cmd_vf_split_drop_en_result,
14376 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14377 TOKEN_STRING_INITIALIZER
14378 (struct cmd_vf_split_drop_en_result,
14382 cmd_set_vf_split_drop_en_parsed(
14383 void *parsed_result,
14384 __rte_unused struct cmdline *cl,
14385 __rte_unused void *data)
14387 struct cmd_vf_split_drop_en_result *res = parsed_result;
14388 int ret = -ENOTSUP;
14389 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14391 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14394 #ifdef RTE_LIBRTE_IXGBE_PMD
14395 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14402 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14405 printf("invalid port_id %d\n", res->port_id);
14408 printf("not supported on port %d\n", res->port_id);
14411 printf("programming error: (%s)\n", strerror(-ret));
14415 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14416 .f = cmd_set_vf_split_drop_en_parsed,
14418 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14420 (void *)&cmd_vf_split_drop_en_set,
14421 (void *)&cmd_vf_split_drop_en_vf,
14422 (void *)&cmd_vf_split_drop_en_split,
14423 (void *)&cmd_vf_split_drop_en_drop,
14424 (void *)&cmd_vf_split_drop_en_port_id,
14425 (void *)&cmd_vf_split_drop_en_vf_id,
14426 (void *)&cmd_vf_split_drop_en_on_off,
14431 /* vf mac address configuration */
14433 /* Common result structure for vf mac address */
14434 struct cmd_set_vf_mac_addr_result {
14435 cmdline_fixed_string_t set;
14436 cmdline_fixed_string_t vf;
14437 cmdline_fixed_string_t mac;
14438 cmdline_fixed_string_t addr;
14441 struct rte_ether_addr mac_addr;
14445 /* Common CLI fields for vf split drop enable disable */
14446 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14447 TOKEN_STRING_INITIALIZER
14448 (struct cmd_set_vf_mac_addr_result,
14450 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14451 TOKEN_STRING_INITIALIZER
14452 (struct cmd_set_vf_mac_addr_result,
14454 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14455 TOKEN_STRING_INITIALIZER
14456 (struct cmd_set_vf_mac_addr_result,
14458 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14459 TOKEN_STRING_INITIALIZER
14460 (struct cmd_set_vf_mac_addr_result,
14462 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14463 TOKEN_NUM_INITIALIZER
14464 (struct cmd_set_vf_mac_addr_result,
14466 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14467 TOKEN_NUM_INITIALIZER
14468 (struct cmd_set_vf_mac_addr_result,
14470 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14471 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14475 cmd_set_vf_mac_addr_parsed(
14476 void *parsed_result,
14477 __rte_unused struct cmdline *cl,
14478 __rte_unused void *data)
14480 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14481 int ret = -ENOTSUP;
14483 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14486 #ifdef RTE_LIBRTE_IXGBE_PMD
14487 if (ret == -ENOTSUP)
14488 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14491 #ifdef RTE_LIBRTE_I40E_PMD
14492 if (ret == -ENOTSUP)
14493 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14496 #ifdef RTE_LIBRTE_BNXT_PMD
14497 if (ret == -ENOTSUP)
14498 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14506 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14509 printf("invalid port_id %d\n", res->port_id);
14512 printf("function not implemented\n");
14515 printf("programming error: (%s)\n", strerror(-ret));
14519 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14520 .f = cmd_set_vf_mac_addr_parsed,
14522 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14524 (void *)&cmd_set_vf_mac_addr_set,
14525 (void *)&cmd_set_vf_mac_addr_vf,
14526 (void *)&cmd_set_vf_mac_addr_mac,
14527 (void *)&cmd_set_vf_mac_addr_addr,
14528 (void *)&cmd_set_vf_mac_addr_port_id,
14529 (void *)&cmd_set_vf_mac_addr_vf_id,
14530 (void *)&cmd_set_vf_mac_addr_mac_addr,
14535 /* MACsec configuration */
14537 /* Common result structure for MACsec offload enable */
14538 struct cmd_macsec_offload_on_result {
14539 cmdline_fixed_string_t set;
14540 cmdline_fixed_string_t macsec;
14541 cmdline_fixed_string_t offload;
14543 cmdline_fixed_string_t on;
14544 cmdline_fixed_string_t encrypt;
14545 cmdline_fixed_string_t en_on_off;
14546 cmdline_fixed_string_t replay_protect;
14547 cmdline_fixed_string_t rp_on_off;
14550 /* Common CLI fields for MACsec offload disable */
14551 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14552 TOKEN_STRING_INITIALIZER
14553 (struct cmd_macsec_offload_on_result,
14555 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14556 TOKEN_STRING_INITIALIZER
14557 (struct cmd_macsec_offload_on_result,
14559 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14560 TOKEN_STRING_INITIALIZER
14561 (struct cmd_macsec_offload_on_result,
14562 offload, "offload");
14563 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14564 TOKEN_NUM_INITIALIZER
14565 (struct cmd_macsec_offload_on_result,
14567 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14568 TOKEN_STRING_INITIALIZER
14569 (struct cmd_macsec_offload_on_result,
14571 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14572 TOKEN_STRING_INITIALIZER
14573 (struct cmd_macsec_offload_on_result,
14574 encrypt, "encrypt");
14575 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14576 TOKEN_STRING_INITIALIZER
14577 (struct cmd_macsec_offload_on_result,
14578 en_on_off, "on#off");
14579 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14580 TOKEN_STRING_INITIALIZER
14581 (struct cmd_macsec_offload_on_result,
14582 replay_protect, "replay-protect");
14583 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14584 TOKEN_STRING_INITIALIZER
14585 (struct cmd_macsec_offload_on_result,
14586 rp_on_off, "on#off");
14589 cmd_set_macsec_offload_on_parsed(
14590 void *parsed_result,
14591 __rte_unused struct cmdline *cl,
14592 __rte_unused void *data)
14594 struct cmd_macsec_offload_on_result *res = parsed_result;
14595 int ret = -ENOTSUP;
14596 portid_t port_id = res->port_id;
14597 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14598 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14599 struct rte_eth_dev_info dev_info;
14601 if (port_id_is_invalid(port_id, ENABLED_WARN))
14603 if (!port_is_stopped(port_id)) {
14604 printf("Please stop port %d first\n", port_id);
14608 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14612 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14613 #ifdef RTE_LIBRTE_IXGBE_PMD
14614 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14622 ports[port_id].dev_conf.txmode.offloads |=
14623 DEV_TX_OFFLOAD_MACSEC_INSERT;
14624 cmd_reconfig_device_queue(port_id, 1, 1);
14627 printf("invalid port_id %d\n", port_id);
14630 printf("not supported on port %d\n", port_id);
14633 printf("programming error: (%s)\n", strerror(-ret));
14637 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14638 .f = cmd_set_macsec_offload_on_parsed,
14640 .help_str = "set macsec offload <port_id> on "
14641 "encrypt on|off replay-protect on|off",
14643 (void *)&cmd_macsec_offload_on_set,
14644 (void *)&cmd_macsec_offload_on_macsec,
14645 (void *)&cmd_macsec_offload_on_offload,
14646 (void *)&cmd_macsec_offload_on_port_id,
14647 (void *)&cmd_macsec_offload_on_on,
14648 (void *)&cmd_macsec_offload_on_encrypt,
14649 (void *)&cmd_macsec_offload_on_en_on_off,
14650 (void *)&cmd_macsec_offload_on_replay_protect,
14651 (void *)&cmd_macsec_offload_on_rp_on_off,
14656 /* Common result structure for MACsec offload disable */
14657 struct cmd_macsec_offload_off_result {
14658 cmdline_fixed_string_t set;
14659 cmdline_fixed_string_t macsec;
14660 cmdline_fixed_string_t offload;
14662 cmdline_fixed_string_t off;
14665 /* Common CLI fields for MACsec offload disable */
14666 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14667 TOKEN_STRING_INITIALIZER
14668 (struct cmd_macsec_offload_off_result,
14670 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14671 TOKEN_STRING_INITIALIZER
14672 (struct cmd_macsec_offload_off_result,
14674 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14675 TOKEN_STRING_INITIALIZER
14676 (struct cmd_macsec_offload_off_result,
14677 offload, "offload");
14678 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14679 TOKEN_NUM_INITIALIZER
14680 (struct cmd_macsec_offload_off_result,
14682 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14683 TOKEN_STRING_INITIALIZER
14684 (struct cmd_macsec_offload_off_result,
14688 cmd_set_macsec_offload_off_parsed(
14689 void *parsed_result,
14690 __rte_unused struct cmdline *cl,
14691 __rte_unused void *data)
14693 struct cmd_macsec_offload_off_result *res = parsed_result;
14694 int ret = -ENOTSUP;
14695 struct rte_eth_dev_info dev_info;
14696 portid_t port_id = res->port_id;
14698 if (port_id_is_invalid(port_id, ENABLED_WARN))
14700 if (!port_is_stopped(port_id)) {
14701 printf("Please stop port %d first\n", port_id);
14705 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14709 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14710 #ifdef RTE_LIBRTE_IXGBE_PMD
14711 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14716 ports[port_id].dev_conf.txmode.offloads &=
14717 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14718 cmd_reconfig_device_queue(port_id, 1, 1);
14721 printf("invalid port_id %d\n", port_id);
14724 printf("not supported on port %d\n", port_id);
14727 printf("programming error: (%s)\n", strerror(-ret));
14731 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14732 .f = cmd_set_macsec_offload_off_parsed,
14734 .help_str = "set macsec offload <port_id> off",
14736 (void *)&cmd_macsec_offload_off_set,
14737 (void *)&cmd_macsec_offload_off_macsec,
14738 (void *)&cmd_macsec_offload_off_offload,
14739 (void *)&cmd_macsec_offload_off_port_id,
14740 (void *)&cmd_macsec_offload_off_off,
14745 /* Common result structure for MACsec secure connection configure */
14746 struct cmd_macsec_sc_result {
14747 cmdline_fixed_string_t set;
14748 cmdline_fixed_string_t macsec;
14749 cmdline_fixed_string_t sc;
14750 cmdline_fixed_string_t tx_rx;
14752 struct rte_ether_addr mac;
14756 /* Common CLI fields for MACsec secure connection configure */
14757 cmdline_parse_token_string_t cmd_macsec_sc_set =
14758 TOKEN_STRING_INITIALIZER
14759 (struct cmd_macsec_sc_result,
14761 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14762 TOKEN_STRING_INITIALIZER
14763 (struct cmd_macsec_sc_result,
14765 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14766 TOKEN_STRING_INITIALIZER
14767 (struct cmd_macsec_sc_result,
14769 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14770 TOKEN_STRING_INITIALIZER
14771 (struct cmd_macsec_sc_result,
14773 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14774 TOKEN_NUM_INITIALIZER
14775 (struct cmd_macsec_sc_result,
14777 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14778 TOKEN_ETHERADDR_INITIALIZER
14779 (struct cmd_macsec_sc_result,
14781 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14782 TOKEN_NUM_INITIALIZER
14783 (struct cmd_macsec_sc_result,
14787 cmd_set_macsec_sc_parsed(
14788 void *parsed_result,
14789 __rte_unused struct cmdline *cl,
14790 __rte_unused void *data)
14792 struct cmd_macsec_sc_result *res = parsed_result;
14793 int ret = -ENOTSUP;
14794 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14796 #ifdef RTE_LIBRTE_IXGBE_PMD
14798 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14799 res->mac.addr_bytes) :
14800 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14801 res->mac.addr_bytes, res->pi);
14803 RTE_SET_USED(is_tx);
14809 printf("invalid port_id %d\n", res->port_id);
14812 printf("not supported on port %d\n", res->port_id);
14815 printf("programming error: (%s)\n", strerror(-ret));
14819 cmdline_parse_inst_t cmd_set_macsec_sc = {
14820 .f = cmd_set_macsec_sc_parsed,
14822 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14824 (void *)&cmd_macsec_sc_set,
14825 (void *)&cmd_macsec_sc_macsec,
14826 (void *)&cmd_macsec_sc_sc,
14827 (void *)&cmd_macsec_sc_tx_rx,
14828 (void *)&cmd_macsec_sc_port_id,
14829 (void *)&cmd_macsec_sc_mac,
14830 (void *)&cmd_macsec_sc_pi,
14835 /* Common result structure for MACsec secure connection configure */
14836 struct cmd_macsec_sa_result {
14837 cmdline_fixed_string_t set;
14838 cmdline_fixed_string_t macsec;
14839 cmdline_fixed_string_t sa;
14840 cmdline_fixed_string_t tx_rx;
14845 cmdline_fixed_string_t key;
14848 /* Common CLI fields for MACsec secure connection configure */
14849 cmdline_parse_token_string_t cmd_macsec_sa_set =
14850 TOKEN_STRING_INITIALIZER
14851 (struct cmd_macsec_sa_result,
14853 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14854 TOKEN_STRING_INITIALIZER
14855 (struct cmd_macsec_sa_result,
14857 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14858 TOKEN_STRING_INITIALIZER
14859 (struct cmd_macsec_sa_result,
14861 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14862 TOKEN_STRING_INITIALIZER
14863 (struct cmd_macsec_sa_result,
14865 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14866 TOKEN_NUM_INITIALIZER
14867 (struct cmd_macsec_sa_result,
14869 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14870 TOKEN_NUM_INITIALIZER
14871 (struct cmd_macsec_sa_result,
14873 cmdline_parse_token_num_t cmd_macsec_sa_an =
14874 TOKEN_NUM_INITIALIZER
14875 (struct cmd_macsec_sa_result,
14877 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14878 TOKEN_NUM_INITIALIZER
14879 (struct cmd_macsec_sa_result,
14881 cmdline_parse_token_string_t cmd_macsec_sa_key =
14882 TOKEN_STRING_INITIALIZER
14883 (struct cmd_macsec_sa_result,
14887 cmd_set_macsec_sa_parsed(
14888 void *parsed_result,
14889 __rte_unused struct cmdline *cl,
14890 __rte_unused void *data)
14892 struct cmd_macsec_sa_result *res = parsed_result;
14893 int ret = -ENOTSUP;
14894 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14895 uint8_t key[16] = { 0 };
14901 key_len = strlen(res->key) / 2;
14905 for (i = 0; i < key_len; i++) {
14906 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14909 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14912 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14915 #ifdef RTE_LIBRTE_IXGBE_PMD
14917 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14918 res->idx, res->an, res->pn, key) :
14919 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14920 res->idx, res->an, res->pn, key);
14922 RTE_SET_USED(is_tx);
14929 printf("invalid idx %d or an %d\n", res->idx, res->an);
14932 printf("invalid port_id %d\n", res->port_id);
14935 printf("not supported on port %d\n", res->port_id);
14938 printf("programming error: (%s)\n", strerror(-ret));
14942 cmdline_parse_inst_t cmd_set_macsec_sa = {
14943 .f = cmd_set_macsec_sa_parsed,
14945 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14947 (void *)&cmd_macsec_sa_set,
14948 (void *)&cmd_macsec_sa_macsec,
14949 (void *)&cmd_macsec_sa_sa,
14950 (void *)&cmd_macsec_sa_tx_rx,
14951 (void *)&cmd_macsec_sa_port_id,
14952 (void *)&cmd_macsec_sa_idx,
14953 (void *)&cmd_macsec_sa_an,
14954 (void *)&cmd_macsec_sa_pn,
14955 (void *)&cmd_macsec_sa_key,
14960 /* VF unicast promiscuous mode configuration */
14962 /* Common result structure for VF unicast promiscuous mode */
14963 struct cmd_vf_promisc_result {
14964 cmdline_fixed_string_t set;
14965 cmdline_fixed_string_t vf;
14966 cmdline_fixed_string_t promisc;
14969 cmdline_fixed_string_t on_off;
14972 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14973 cmdline_parse_token_string_t cmd_vf_promisc_set =
14974 TOKEN_STRING_INITIALIZER
14975 (struct cmd_vf_promisc_result,
14977 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14978 TOKEN_STRING_INITIALIZER
14979 (struct cmd_vf_promisc_result,
14981 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14982 TOKEN_STRING_INITIALIZER
14983 (struct cmd_vf_promisc_result,
14984 promisc, "promisc");
14985 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14986 TOKEN_NUM_INITIALIZER
14987 (struct cmd_vf_promisc_result,
14989 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14990 TOKEN_NUM_INITIALIZER
14991 (struct cmd_vf_promisc_result,
14993 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14994 TOKEN_STRING_INITIALIZER
14995 (struct cmd_vf_promisc_result,
14999 cmd_set_vf_promisc_parsed(
15000 void *parsed_result,
15001 __rte_unused struct cmdline *cl,
15002 __rte_unused void *data)
15004 struct cmd_vf_promisc_result *res = parsed_result;
15005 int ret = -ENOTSUP;
15007 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15009 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15012 #ifdef RTE_LIBRTE_I40E_PMD
15013 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
15014 res->vf_id, is_on);
15021 printf("invalid vf_id %d\n", res->vf_id);
15024 printf("invalid port_id %d\n", res->port_id);
15027 printf("function not implemented\n");
15030 printf("programming error: (%s)\n", strerror(-ret));
15034 cmdline_parse_inst_t cmd_set_vf_promisc = {
15035 .f = cmd_set_vf_promisc_parsed,
15037 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
15038 "Set unicast promiscuous mode for a VF from the PF",
15040 (void *)&cmd_vf_promisc_set,
15041 (void *)&cmd_vf_promisc_vf,
15042 (void *)&cmd_vf_promisc_promisc,
15043 (void *)&cmd_vf_promisc_port_id,
15044 (void *)&cmd_vf_promisc_vf_id,
15045 (void *)&cmd_vf_promisc_on_off,
15050 /* VF multicast promiscuous mode configuration */
15052 /* Common result structure for VF multicast promiscuous mode */
15053 struct cmd_vf_allmulti_result {
15054 cmdline_fixed_string_t set;
15055 cmdline_fixed_string_t vf;
15056 cmdline_fixed_string_t allmulti;
15059 cmdline_fixed_string_t on_off;
15062 /* Common CLI fields for VF multicast promiscuous mode enable disable */
15063 cmdline_parse_token_string_t cmd_vf_allmulti_set =
15064 TOKEN_STRING_INITIALIZER
15065 (struct cmd_vf_allmulti_result,
15067 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
15068 TOKEN_STRING_INITIALIZER
15069 (struct cmd_vf_allmulti_result,
15071 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
15072 TOKEN_STRING_INITIALIZER
15073 (struct cmd_vf_allmulti_result,
15074 allmulti, "allmulti");
15075 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
15076 TOKEN_NUM_INITIALIZER
15077 (struct cmd_vf_allmulti_result,
15079 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
15080 TOKEN_NUM_INITIALIZER
15081 (struct cmd_vf_allmulti_result,
15083 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
15084 TOKEN_STRING_INITIALIZER
15085 (struct cmd_vf_allmulti_result,
15089 cmd_set_vf_allmulti_parsed(
15090 void *parsed_result,
15091 __rte_unused struct cmdline *cl,
15092 __rte_unused void *data)
15094 struct cmd_vf_allmulti_result *res = parsed_result;
15095 int ret = -ENOTSUP;
15097 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15099 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15102 #ifdef RTE_LIBRTE_I40E_PMD
15103 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
15104 res->vf_id, is_on);
15111 printf("invalid vf_id %d\n", res->vf_id);
15114 printf("invalid port_id %d\n", res->port_id);
15117 printf("function not implemented\n");
15120 printf("programming error: (%s)\n", strerror(-ret));
15124 cmdline_parse_inst_t cmd_set_vf_allmulti = {
15125 .f = cmd_set_vf_allmulti_parsed,
15127 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
15128 "Set multicast promiscuous mode for a VF from the PF",
15130 (void *)&cmd_vf_allmulti_set,
15131 (void *)&cmd_vf_allmulti_vf,
15132 (void *)&cmd_vf_allmulti_allmulti,
15133 (void *)&cmd_vf_allmulti_port_id,
15134 (void *)&cmd_vf_allmulti_vf_id,
15135 (void *)&cmd_vf_allmulti_on_off,
15140 /* vf broadcast mode configuration */
15142 /* Common result structure for vf broadcast */
15143 struct cmd_set_vf_broadcast_result {
15144 cmdline_fixed_string_t set;
15145 cmdline_fixed_string_t vf;
15146 cmdline_fixed_string_t broadcast;
15149 cmdline_fixed_string_t on_off;
15152 /* Common CLI fields for vf broadcast enable disable */
15153 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
15154 TOKEN_STRING_INITIALIZER
15155 (struct cmd_set_vf_broadcast_result,
15157 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
15158 TOKEN_STRING_INITIALIZER
15159 (struct cmd_set_vf_broadcast_result,
15161 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
15162 TOKEN_STRING_INITIALIZER
15163 (struct cmd_set_vf_broadcast_result,
15164 broadcast, "broadcast");
15165 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
15166 TOKEN_NUM_INITIALIZER
15167 (struct cmd_set_vf_broadcast_result,
15169 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
15170 TOKEN_NUM_INITIALIZER
15171 (struct cmd_set_vf_broadcast_result,
15173 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
15174 TOKEN_STRING_INITIALIZER
15175 (struct cmd_set_vf_broadcast_result,
15179 cmd_set_vf_broadcast_parsed(
15180 void *parsed_result,
15181 __rte_unused struct cmdline *cl,
15182 __rte_unused void *data)
15184 struct cmd_set_vf_broadcast_result *res = parsed_result;
15185 int ret = -ENOTSUP;
15187 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15189 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15192 #ifdef RTE_LIBRTE_I40E_PMD
15193 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
15194 res->vf_id, is_on);
15201 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15204 printf("invalid port_id %d\n", res->port_id);
15207 printf("function not implemented\n");
15210 printf("programming error: (%s)\n", strerror(-ret));
15214 cmdline_parse_inst_t cmd_set_vf_broadcast = {
15215 .f = cmd_set_vf_broadcast_parsed,
15217 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
15219 (void *)&cmd_set_vf_broadcast_set,
15220 (void *)&cmd_set_vf_broadcast_vf,
15221 (void *)&cmd_set_vf_broadcast_broadcast,
15222 (void *)&cmd_set_vf_broadcast_port_id,
15223 (void *)&cmd_set_vf_broadcast_vf_id,
15224 (void *)&cmd_set_vf_broadcast_on_off,
15229 /* vf vlan tag configuration */
15231 /* Common result structure for vf vlan tag */
15232 struct cmd_set_vf_vlan_tag_result {
15233 cmdline_fixed_string_t set;
15234 cmdline_fixed_string_t vf;
15235 cmdline_fixed_string_t vlan;
15236 cmdline_fixed_string_t tag;
15239 cmdline_fixed_string_t on_off;
15242 /* Common CLI fields for vf vlan tag enable disable */
15243 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
15244 TOKEN_STRING_INITIALIZER
15245 (struct cmd_set_vf_vlan_tag_result,
15247 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
15248 TOKEN_STRING_INITIALIZER
15249 (struct cmd_set_vf_vlan_tag_result,
15251 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
15252 TOKEN_STRING_INITIALIZER
15253 (struct cmd_set_vf_vlan_tag_result,
15255 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
15256 TOKEN_STRING_INITIALIZER
15257 (struct cmd_set_vf_vlan_tag_result,
15259 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
15260 TOKEN_NUM_INITIALIZER
15261 (struct cmd_set_vf_vlan_tag_result,
15263 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
15264 TOKEN_NUM_INITIALIZER
15265 (struct cmd_set_vf_vlan_tag_result,
15267 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
15268 TOKEN_STRING_INITIALIZER
15269 (struct cmd_set_vf_vlan_tag_result,
15273 cmd_set_vf_vlan_tag_parsed(
15274 void *parsed_result,
15275 __rte_unused struct cmdline *cl,
15276 __rte_unused void *data)
15278 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
15279 int ret = -ENOTSUP;
15281 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15283 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15286 #ifdef RTE_LIBRTE_I40E_PMD
15287 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
15288 res->vf_id, is_on);
15295 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15298 printf("invalid port_id %d\n", res->port_id);
15301 printf("function not implemented\n");
15304 printf("programming error: (%s)\n", strerror(-ret));
15308 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15309 .f = cmd_set_vf_vlan_tag_parsed,
15311 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15313 (void *)&cmd_set_vf_vlan_tag_set,
15314 (void *)&cmd_set_vf_vlan_tag_vf,
15315 (void *)&cmd_set_vf_vlan_tag_vlan,
15316 (void *)&cmd_set_vf_vlan_tag_tag,
15317 (void *)&cmd_set_vf_vlan_tag_port_id,
15318 (void *)&cmd_set_vf_vlan_tag_vf_id,
15319 (void *)&cmd_set_vf_vlan_tag_on_off,
15324 /* Common definition of VF and TC TX bandwidth configuration */
15325 struct cmd_vf_tc_bw_result {
15326 cmdline_fixed_string_t set;
15327 cmdline_fixed_string_t vf;
15328 cmdline_fixed_string_t tc;
15329 cmdline_fixed_string_t tx;
15330 cmdline_fixed_string_t min_bw;
15331 cmdline_fixed_string_t max_bw;
15332 cmdline_fixed_string_t strict_link_prio;
15337 cmdline_fixed_string_t bw_list;
15341 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15342 TOKEN_STRING_INITIALIZER
15343 (struct cmd_vf_tc_bw_result,
15345 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15346 TOKEN_STRING_INITIALIZER
15347 (struct cmd_vf_tc_bw_result,
15349 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15350 TOKEN_STRING_INITIALIZER
15351 (struct cmd_vf_tc_bw_result,
15353 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15354 TOKEN_STRING_INITIALIZER
15355 (struct cmd_vf_tc_bw_result,
15357 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15358 TOKEN_STRING_INITIALIZER
15359 (struct cmd_vf_tc_bw_result,
15360 strict_link_prio, "strict-link-priority");
15361 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15362 TOKEN_STRING_INITIALIZER
15363 (struct cmd_vf_tc_bw_result,
15364 min_bw, "min-bandwidth");
15365 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15366 TOKEN_STRING_INITIALIZER
15367 (struct cmd_vf_tc_bw_result,
15368 max_bw, "max-bandwidth");
15369 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15370 TOKEN_NUM_INITIALIZER
15371 (struct cmd_vf_tc_bw_result,
15373 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15374 TOKEN_NUM_INITIALIZER
15375 (struct cmd_vf_tc_bw_result,
15377 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15378 TOKEN_NUM_INITIALIZER
15379 (struct cmd_vf_tc_bw_result,
15381 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15382 TOKEN_NUM_INITIALIZER
15383 (struct cmd_vf_tc_bw_result,
15385 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15386 TOKEN_STRING_INITIALIZER
15387 (struct cmd_vf_tc_bw_result,
15389 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15390 TOKEN_NUM_INITIALIZER
15391 (struct cmd_vf_tc_bw_result,
15394 /* VF max bandwidth setting */
15396 cmd_vf_max_bw_parsed(
15397 void *parsed_result,
15398 __rte_unused struct cmdline *cl,
15399 __rte_unused void *data)
15401 struct cmd_vf_tc_bw_result *res = parsed_result;
15402 int ret = -ENOTSUP;
15404 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15407 #ifdef RTE_LIBRTE_I40E_PMD
15408 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15409 res->vf_id, res->bw);
15416 printf("invalid vf_id %d or bandwidth %d\n",
15417 res->vf_id, res->bw);
15420 printf("invalid port_id %d\n", res->port_id);
15423 printf("function not implemented\n");
15426 printf("programming error: (%s)\n", strerror(-ret));
15430 cmdline_parse_inst_t cmd_vf_max_bw = {
15431 .f = cmd_vf_max_bw_parsed,
15433 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15435 (void *)&cmd_vf_tc_bw_set,
15436 (void *)&cmd_vf_tc_bw_vf,
15437 (void *)&cmd_vf_tc_bw_tx,
15438 (void *)&cmd_vf_tc_bw_max_bw,
15439 (void *)&cmd_vf_tc_bw_port_id,
15440 (void *)&cmd_vf_tc_bw_vf_id,
15441 (void *)&cmd_vf_tc_bw_bw,
15447 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15452 const char *p, *p0 = str;
15459 p = strchr(p0, '(');
15461 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15465 p0 = strchr(p, ')');
15467 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15471 if (size >= sizeof(s)) {
15472 printf("The string size exceeds the internal buffer size\n");
15475 snprintf(s, sizeof(s), "%.*s", size, p);
15476 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15478 printf("Failed to get the bandwidth list. ");
15482 for (i = 0; i < ret; i++)
15483 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15488 /* TC min bandwidth setting */
15490 cmd_vf_tc_min_bw_parsed(
15491 void *parsed_result,
15492 __rte_unused struct cmdline *cl,
15493 __rte_unused void *data)
15495 struct cmd_vf_tc_bw_result *res = parsed_result;
15498 int ret = -ENOTSUP;
15500 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15503 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15507 #ifdef RTE_LIBRTE_I40E_PMD
15508 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15516 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15519 printf("invalid port_id %d\n", res->port_id);
15522 printf("function not implemented\n");
15525 printf("programming error: (%s)\n", strerror(-ret));
15529 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15530 .f = cmd_vf_tc_min_bw_parsed,
15532 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15533 " <bw1, bw2, ...>",
15535 (void *)&cmd_vf_tc_bw_set,
15536 (void *)&cmd_vf_tc_bw_vf,
15537 (void *)&cmd_vf_tc_bw_tc,
15538 (void *)&cmd_vf_tc_bw_tx,
15539 (void *)&cmd_vf_tc_bw_min_bw,
15540 (void *)&cmd_vf_tc_bw_port_id,
15541 (void *)&cmd_vf_tc_bw_vf_id,
15542 (void *)&cmd_vf_tc_bw_bw_list,
15548 cmd_tc_min_bw_parsed(
15549 void *parsed_result,
15550 __rte_unused struct cmdline *cl,
15551 __rte_unused void *data)
15553 struct cmd_vf_tc_bw_result *res = parsed_result;
15554 struct rte_port *port;
15557 int ret = -ENOTSUP;
15559 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15562 port = &ports[res->port_id];
15563 /** Check if the port is not started **/
15564 if (port->port_status != RTE_PORT_STOPPED) {
15565 printf("Please stop port %d first\n", res->port_id);
15569 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15573 #ifdef RTE_LIBRTE_IXGBE_PMD
15574 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15581 printf("invalid bandwidth\n");
15584 printf("invalid port_id %d\n", res->port_id);
15587 printf("function not implemented\n");
15590 printf("programming error: (%s)\n", strerror(-ret));
15594 cmdline_parse_inst_t cmd_tc_min_bw = {
15595 .f = cmd_tc_min_bw_parsed,
15597 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15599 (void *)&cmd_vf_tc_bw_set,
15600 (void *)&cmd_vf_tc_bw_tc,
15601 (void *)&cmd_vf_tc_bw_tx,
15602 (void *)&cmd_vf_tc_bw_min_bw,
15603 (void *)&cmd_vf_tc_bw_port_id,
15604 (void *)&cmd_vf_tc_bw_bw_list,
15609 /* TC max bandwidth setting */
15611 cmd_vf_tc_max_bw_parsed(
15612 void *parsed_result,
15613 __rte_unused struct cmdline *cl,
15614 __rte_unused void *data)
15616 struct cmd_vf_tc_bw_result *res = parsed_result;
15617 int ret = -ENOTSUP;
15619 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15622 #ifdef RTE_LIBRTE_I40E_PMD
15623 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15624 res->tc_no, res->bw);
15631 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15632 res->vf_id, res->tc_no, res->bw);
15635 printf("invalid port_id %d\n", res->port_id);
15638 printf("function not implemented\n");
15641 printf("programming error: (%s)\n", strerror(-ret));
15645 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15646 .f = cmd_vf_tc_max_bw_parsed,
15648 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15651 (void *)&cmd_vf_tc_bw_set,
15652 (void *)&cmd_vf_tc_bw_vf,
15653 (void *)&cmd_vf_tc_bw_tc,
15654 (void *)&cmd_vf_tc_bw_tx,
15655 (void *)&cmd_vf_tc_bw_max_bw,
15656 (void *)&cmd_vf_tc_bw_port_id,
15657 (void *)&cmd_vf_tc_bw_vf_id,
15658 (void *)&cmd_vf_tc_bw_tc_no,
15659 (void *)&cmd_vf_tc_bw_bw,
15664 /** Set VXLAN encapsulation details */
15665 struct cmd_set_vxlan_result {
15666 cmdline_fixed_string_t set;
15667 cmdline_fixed_string_t vxlan;
15668 cmdline_fixed_string_t pos_token;
15669 cmdline_fixed_string_t ip_version;
15670 uint32_t vlan_present:1;
15674 cmdline_ipaddr_t ip_src;
15675 cmdline_ipaddr_t ip_dst;
15679 struct rte_ether_addr eth_src;
15680 struct rte_ether_addr eth_dst;
15683 cmdline_parse_token_string_t cmd_set_vxlan_set =
15684 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15685 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15686 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15687 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15688 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15690 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15691 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15692 "vxlan-with-vlan");
15693 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15694 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15696 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15697 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15699 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15700 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15702 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15703 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15704 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15705 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15707 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15708 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15709 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15710 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15712 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15713 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15714 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15715 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15717 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15718 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15719 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15720 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15722 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15723 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15724 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15725 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15727 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15728 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15729 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15730 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15732 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15733 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15734 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15735 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15737 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15738 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15739 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15740 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15742 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15743 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15744 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15745 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15747 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15748 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15750 static void cmd_set_vxlan_parsed(void *parsed_result,
15751 __rte_unused struct cmdline *cl,
15752 __rte_unused void *data)
15754 struct cmd_set_vxlan_result *res = parsed_result;
15759 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15762 vxlan_encap_conf.select_tos_ttl = 0;
15763 if (strcmp(res->vxlan, "vxlan") == 0)
15764 vxlan_encap_conf.select_vlan = 0;
15765 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15766 vxlan_encap_conf.select_vlan = 1;
15767 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15768 vxlan_encap_conf.select_vlan = 0;
15769 vxlan_encap_conf.select_tos_ttl = 1;
15771 if (strcmp(res->ip_version, "ipv4") == 0)
15772 vxlan_encap_conf.select_ipv4 = 1;
15773 else if (strcmp(res->ip_version, "ipv6") == 0)
15774 vxlan_encap_conf.select_ipv4 = 0;
15777 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15778 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15779 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15780 vxlan_encap_conf.ip_tos = res->tos;
15781 vxlan_encap_conf.ip_ttl = res->ttl;
15782 if (vxlan_encap_conf.select_ipv4) {
15783 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15784 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15786 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15787 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15789 if (vxlan_encap_conf.select_vlan)
15790 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15791 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15792 RTE_ETHER_ADDR_LEN);
15793 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15794 RTE_ETHER_ADDR_LEN);
15797 cmdline_parse_inst_t cmd_set_vxlan = {
15798 .f = cmd_set_vxlan_parsed,
15800 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15801 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15802 " eth-src <eth-src> eth-dst <eth-dst>",
15804 (void *)&cmd_set_vxlan_set,
15805 (void *)&cmd_set_vxlan_vxlan,
15806 (void *)&cmd_set_vxlan_ip_version,
15807 (void *)&cmd_set_vxlan_ip_version_value,
15808 (void *)&cmd_set_vxlan_vni,
15809 (void *)&cmd_set_vxlan_vni_value,
15810 (void *)&cmd_set_vxlan_udp_src,
15811 (void *)&cmd_set_vxlan_udp_src_value,
15812 (void *)&cmd_set_vxlan_udp_dst,
15813 (void *)&cmd_set_vxlan_udp_dst_value,
15814 (void *)&cmd_set_vxlan_ip_src,
15815 (void *)&cmd_set_vxlan_ip_src_value,
15816 (void *)&cmd_set_vxlan_ip_dst,
15817 (void *)&cmd_set_vxlan_ip_dst_value,
15818 (void *)&cmd_set_vxlan_eth_src,
15819 (void *)&cmd_set_vxlan_eth_src_value,
15820 (void *)&cmd_set_vxlan_eth_dst,
15821 (void *)&cmd_set_vxlan_eth_dst_value,
15826 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15827 .f = cmd_set_vxlan_parsed,
15829 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15830 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15831 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15832 " eth-dst <eth-dst>",
15834 (void *)&cmd_set_vxlan_set,
15835 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15836 (void *)&cmd_set_vxlan_ip_version,
15837 (void *)&cmd_set_vxlan_ip_version_value,
15838 (void *)&cmd_set_vxlan_vni,
15839 (void *)&cmd_set_vxlan_vni_value,
15840 (void *)&cmd_set_vxlan_udp_src,
15841 (void *)&cmd_set_vxlan_udp_src_value,
15842 (void *)&cmd_set_vxlan_udp_dst,
15843 (void *)&cmd_set_vxlan_udp_dst_value,
15844 (void *)&cmd_set_vxlan_ip_tos,
15845 (void *)&cmd_set_vxlan_ip_tos_value,
15846 (void *)&cmd_set_vxlan_ip_ttl,
15847 (void *)&cmd_set_vxlan_ip_ttl_value,
15848 (void *)&cmd_set_vxlan_ip_src,
15849 (void *)&cmd_set_vxlan_ip_src_value,
15850 (void *)&cmd_set_vxlan_ip_dst,
15851 (void *)&cmd_set_vxlan_ip_dst_value,
15852 (void *)&cmd_set_vxlan_eth_src,
15853 (void *)&cmd_set_vxlan_eth_src_value,
15854 (void *)&cmd_set_vxlan_eth_dst,
15855 (void *)&cmd_set_vxlan_eth_dst_value,
15860 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15861 .f = cmd_set_vxlan_parsed,
15863 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15864 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15865 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15868 (void *)&cmd_set_vxlan_set,
15869 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15870 (void *)&cmd_set_vxlan_ip_version,
15871 (void *)&cmd_set_vxlan_ip_version_value,
15872 (void *)&cmd_set_vxlan_vni,
15873 (void *)&cmd_set_vxlan_vni_value,
15874 (void *)&cmd_set_vxlan_udp_src,
15875 (void *)&cmd_set_vxlan_udp_src_value,
15876 (void *)&cmd_set_vxlan_udp_dst,
15877 (void *)&cmd_set_vxlan_udp_dst_value,
15878 (void *)&cmd_set_vxlan_ip_src,
15879 (void *)&cmd_set_vxlan_ip_src_value,
15880 (void *)&cmd_set_vxlan_ip_dst,
15881 (void *)&cmd_set_vxlan_ip_dst_value,
15882 (void *)&cmd_set_vxlan_vlan,
15883 (void *)&cmd_set_vxlan_vlan_value,
15884 (void *)&cmd_set_vxlan_eth_src,
15885 (void *)&cmd_set_vxlan_eth_src_value,
15886 (void *)&cmd_set_vxlan_eth_dst,
15887 (void *)&cmd_set_vxlan_eth_dst_value,
15892 /** Set NVGRE encapsulation details */
15893 struct cmd_set_nvgre_result {
15894 cmdline_fixed_string_t set;
15895 cmdline_fixed_string_t nvgre;
15896 cmdline_fixed_string_t pos_token;
15897 cmdline_fixed_string_t ip_version;
15899 cmdline_ipaddr_t ip_src;
15900 cmdline_ipaddr_t ip_dst;
15902 struct rte_ether_addr eth_src;
15903 struct rte_ether_addr eth_dst;
15906 cmdline_parse_token_string_t cmd_set_nvgre_set =
15907 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15908 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15909 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15910 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15911 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15912 "nvgre-with-vlan");
15913 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15914 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15916 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15917 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15919 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15920 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15922 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15923 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15924 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15925 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15927 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15928 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15929 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15930 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15932 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15933 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15934 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15935 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15937 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15938 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15939 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15940 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15942 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15943 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15944 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15945 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15947 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15948 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15950 static void cmd_set_nvgre_parsed(void *parsed_result,
15951 __rte_unused struct cmdline *cl,
15952 __rte_unused void *data)
15954 struct cmd_set_nvgre_result *res = parsed_result;
15956 uint32_t nvgre_tni;
15959 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15962 if (strcmp(res->nvgre, "nvgre") == 0)
15963 nvgre_encap_conf.select_vlan = 0;
15964 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15965 nvgre_encap_conf.select_vlan = 1;
15966 if (strcmp(res->ip_version, "ipv4") == 0)
15967 nvgre_encap_conf.select_ipv4 = 1;
15968 else if (strcmp(res->ip_version, "ipv6") == 0)
15969 nvgre_encap_conf.select_ipv4 = 0;
15972 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15973 if (nvgre_encap_conf.select_ipv4) {
15974 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15975 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15977 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15978 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15980 if (nvgre_encap_conf.select_vlan)
15981 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15982 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15983 RTE_ETHER_ADDR_LEN);
15984 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15985 RTE_ETHER_ADDR_LEN);
15988 cmdline_parse_inst_t cmd_set_nvgre = {
15989 .f = cmd_set_nvgre_parsed,
15991 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15992 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15993 " eth-dst <eth-dst>",
15995 (void *)&cmd_set_nvgre_set,
15996 (void *)&cmd_set_nvgre_nvgre,
15997 (void *)&cmd_set_nvgre_ip_version,
15998 (void *)&cmd_set_nvgre_ip_version_value,
15999 (void *)&cmd_set_nvgre_tni,
16000 (void *)&cmd_set_nvgre_tni_value,
16001 (void *)&cmd_set_nvgre_ip_src,
16002 (void *)&cmd_set_nvgre_ip_src_value,
16003 (void *)&cmd_set_nvgre_ip_dst,
16004 (void *)&cmd_set_nvgre_ip_dst_value,
16005 (void *)&cmd_set_nvgre_eth_src,
16006 (void *)&cmd_set_nvgre_eth_src_value,
16007 (void *)&cmd_set_nvgre_eth_dst,
16008 (void *)&cmd_set_nvgre_eth_dst_value,
16013 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
16014 .f = cmd_set_nvgre_parsed,
16016 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
16017 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16018 " eth-src <eth-src> eth-dst <eth-dst>",
16020 (void *)&cmd_set_nvgre_set,
16021 (void *)&cmd_set_nvgre_nvgre_with_vlan,
16022 (void *)&cmd_set_nvgre_ip_version,
16023 (void *)&cmd_set_nvgre_ip_version_value,
16024 (void *)&cmd_set_nvgre_tni,
16025 (void *)&cmd_set_nvgre_tni_value,
16026 (void *)&cmd_set_nvgre_ip_src,
16027 (void *)&cmd_set_nvgre_ip_src_value,
16028 (void *)&cmd_set_nvgre_ip_dst,
16029 (void *)&cmd_set_nvgre_ip_dst_value,
16030 (void *)&cmd_set_nvgre_vlan,
16031 (void *)&cmd_set_nvgre_vlan_value,
16032 (void *)&cmd_set_nvgre_eth_src,
16033 (void *)&cmd_set_nvgre_eth_src_value,
16034 (void *)&cmd_set_nvgre_eth_dst,
16035 (void *)&cmd_set_nvgre_eth_dst_value,
16040 /** Set L2 encapsulation details */
16041 struct cmd_set_l2_encap_result {
16042 cmdline_fixed_string_t set;
16043 cmdline_fixed_string_t l2_encap;
16044 cmdline_fixed_string_t pos_token;
16045 cmdline_fixed_string_t ip_version;
16046 uint32_t vlan_present:1;
16048 struct rte_ether_addr eth_src;
16049 struct rte_ether_addr eth_dst;
16052 cmdline_parse_token_string_t cmd_set_l2_encap_set =
16053 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
16054 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
16055 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
16056 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
16057 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
16058 "l2_encap-with-vlan");
16059 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
16060 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16062 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
16063 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
16065 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
16066 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16068 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
16069 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
16070 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
16071 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16073 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
16074 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
16075 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
16076 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16078 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
16079 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
16081 static void cmd_set_l2_encap_parsed(void *parsed_result,
16082 __rte_unused struct cmdline *cl,
16083 __rte_unused void *data)
16085 struct cmd_set_l2_encap_result *res = parsed_result;
16087 if (strcmp(res->l2_encap, "l2_encap") == 0)
16088 l2_encap_conf.select_vlan = 0;
16089 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
16090 l2_encap_conf.select_vlan = 1;
16091 if (strcmp(res->ip_version, "ipv4") == 0)
16092 l2_encap_conf.select_ipv4 = 1;
16093 else if (strcmp(res->ip_version, "ipv6") == 0)
16094 l2_encap_conf.select_ipv4 = 0;
16097 if (l2_encap_conf.select_vlan)
16098 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16099 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
16100 RTE_ETHER_ADDR_LEN);
16101 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16102 RTE_ETHER_ADDR_LEN);
16105 cmdline_parse_inst_t cmd_set_l2_encap = {
16106 .f = cmd_set_l2_encap_parsed,
16108 .help_str = "set l2_encap ip-version ipv4|ipv6"
16109 " eth-src <eth-src> eth-dst <eth-dst>",
16111 (void *)&cmd_set_l2_encap_set,
16112 (void *)&cmd_set_l2_encap_l2_encap,
16113 (void *)&cmd_set_l2_encap_ip_version,
16114 (void *)&cmd_set_l2_encap_ip_version_value,
16115 (void *)&cmd_set_l2_encap_eth_src,
16116 (void *)&cmd_set_l2_encap_eth_src_value,
16117 (void *)&cmd_set_l2_encap_eth_dst,
16118 (void *)&cmd_set_l2_encap_eth_dst_value,
16123 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
16124 .f = cmd_set_l2_encap_parsed,
16126 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
16127 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16129 (void *)&cmd_set_l2_encap_set,
16130 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
16131 (void *)&cmd_set_l2_encap_ip_version,
16132 (void *)&cmd_set_l2_encap_ip_version_value,
16133 (void *)&cmd_set_l2_encap_vlan,
16134 (void *)&cmd_set_l2_encap_vlan_value,
16135 (void *)&cmd_set_l2_encap_eth_src,
16136 (void *)&cmd_set_l2_encap_eth_src_value,
16137 (void *)&cmd_set_l2_encap_eth_dst,
16138 (void *)&cmd_set_l2_encap_eth_dst_value,
16143 /** Set L2 decapsulation details */
16144 struct cmd_set_l2_decap_result {
16145 cmdline_fixed_string_t set;
16146 cmdline_fixed_string_t l2_decap;
16147 cmdline_fixed_string_t pos_token;
16148 uint32_t vlan_present:1;
16151 cmdline_parse_token_string_t cmd_set_l2_decap_set =
16152 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
16153 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
16154 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16156 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
16157 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16158 "l2_decap-with-vlan");
16160 static void cmd_set_l2_decap_parsed(void *parsed_result,
16161 __rte_unused struct cmdline *cl,
16162 __rte_unused void *data)
16164 struct cmd_set_l2_decap_result *res = parsed_result;
16166 if (strcmp(res->l2_decap, "l2_decap") == 0)
16167 l2_decap_conf.select_vlan = 0;
16168 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
16169 l2_decap_conf.select_vlan = 1;
16172 cmdline_parse_inst_t cmd_set_l2_decap = {
16173 .f = cmd_set_l2_decap_parsed,
16175 .help_str = "set l2_decap",
16177 (void *)&cmd_set_l2_decap_set,
16178 (void *)&cmd_set_l2_decap_l2_decap,
16183 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
16184 .f = cmd_set_l2_decap_parsed,
16186 .help_str = "set l2_decap-with-vlan",
16188 (void *)&cmd_set_l2_decap_set,
16189 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
16194 /** Set MPLSoGRE encapsulation details */
16195 struct cmd_set_mplsogre_encap_result {
16196 cmdline_fixed_string_t set;
16197 cmdline_fixed_string_t mplsogre;
16198 cmdline_fixed_string_t pos_token;
16199 cmdline_fixed_string_t ip_version;
16200 uint32_t vlan_present:1;
16202 cmdline_ipaddr_t ip_src;
16203 cmdline_ipaddr_t ip_dst;
16205 struct rte_ether_addr eth_src;
16206 struct rte_ether_addr eth_dst;
16209 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
16210 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
16212 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
16213 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
16215 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
16216 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16217 mplsogre, "mplsogre_encap-with-vlan");
16218 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
16219 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16220 pos_token, "ip-version");
16221 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
16222 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16223 ip_version, "ipv4#ipv6");
16224 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
16225 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16226 pos_token, "label");
16227 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
16228 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
16230 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
16231 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16232 pos_token, "ip-src");
16233 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16234 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16235 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16236 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16237 pos_token, "ip-dst");
16238 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16239 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16240 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16241 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16242 pos_token, "vlan-tci");
16243 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16244 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16246 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16247 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16248 pos_token, "eth-src");
16249 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16250 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16252 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16253 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16254 pos_token, "eth-dst");
16255 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16256 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16259 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16260 __rte_unused struct cmdline *cl,
16261 __rte_unused void *data)
16263 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16265 uint32_t mplsogre_label;
16268 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16271 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16272 mplsogre_encap_conf.select_vlan = 0;
16273 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16274 mplsogre_encap_conf.select_vlan = 1;
16275 if (strcmp(res->ip_version, "ipv4") == 0)
16276 mplsogre_encap_conf.select_ipv4 = 1;
16277 else if (strcmp(res->ip_version, "ipv6") == 0)
16278 mplsogre_encap_conf.select_ipv4 = 0;
16281 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16282 if (mplsogre_encap_conf.select_ipv4) {
16283 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16284 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16286 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16287 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16289 if (mplsogre_encap_conf.select_vlan)
16290 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16291 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16292 RTE_ETHER_ADDR_LEN);
16293 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16294 RTE_ETHER_ADDR_LEN);
16297 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16298 .f = cmd_set_mplsogre_encap_parsed,
16300 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16301 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16302 " eth-dst <eth-dst>",
16304 (void *)&cmd_set_mplsogre_encap_set,
16305 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16306 (void *)&cmd_set_mplsogre_encap_ip_version,
16307 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16308 (void *)&cmd_set_mplsogre_encap_label,
16309 (void *)&cmd_set_mplsogre_encap_label_value,
16310 (void *)&cmd_set_mplsogre_encap_ip_src,
16311 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16312 (void *)&cmd_set_mplsogre_encap_ip_dst,
16313 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16314 (void *)&cmd_set_mplsogre_encap_eth_src,
16315 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16316 (void *)&cmd_set_mplsogre_encap_eth_dst,
16317 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16322 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16323 .f = cmd_set_mplsogre_encap_parsed,
16325 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16326 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16327 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16329 (void *)&cmd_set_mplsogre_encap_set,
16330 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16331 (void *)&cmd_set_mplsogre_encap_ip_version,
16332 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16333 (void *)&cmd_set_mplsogre_encap_label,
16334 (void *)&cmd_set_mplsogre_encap_label_value,
16335 (void *)&cmd_set_mplsogre_encap_ip_src,
16336 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16337 (void *)&cmd_set_mplsogre_encap_ip_dst,
16338 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16339 (void *)&cmd_set_mplsogre_encap_vlan,
16340 (void *)&cmd_set_mplsogre_encap_vlan_value,
16341 (void *)&cmd_set_mplsogre_encap_eth_src,
16342 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16343 (void *)&cmd_set_mplsogre_encap_eth_dst,
16344 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16349 /** Set MPLSoGRE decapsulation details */
16350 struct cmd_set_mplsogre_decap_result {
16351 cmdline_fixed_string_t set;
16352 cmdline_fixed_string_t mplsogre;
16353 cmdline_fixed_string_t pos_token;
16354 cmdline_fixed_string_t ip_version;
16355 uint32_t vlan_present:1;
16358 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16359 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16361 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16362 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16364 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16365 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16366 mplsogre, "mplsogre_decap-with-vlan");
16367 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16368 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16369 pos_token, "ip-version");
16370 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16371 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16372 ip_version, "ipv4#ipv6");
16374 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16375 __rte_unused struct cmdline *cl,
16376 __rte_unused void *data)
16378 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16380 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16381 mplsogre_decap_conf.select_vlan = 0;
16382 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16383 mplsogre_decap_conf.select_vlan = 1;
16384 if (strcmp(res->ip_version, "ipv4") == 0)
16385 mplsogre_decap_conf.select_ipv4 = 1;
16386 else if (strcmp(res->ip_version, "ipv6") == 0)
16387 mplsogre_decap_conf.select_ipv4 = 0;
16390 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16391 .f = cmd_set_mplsogre_decap_parsed,
16393 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16395 (void *)&cmd_set_mplsogre_decap_set,
16396 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16397 (void *)&cmd_set_mplsogre_decap_ip_version,
16398 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16403 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16404 .f = cmd_set_mplsogre_decap_parsed,
16406 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16408 (void *)&cmd_set_mplsogre_decap_set,
16409 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16410 (void *)&cmd_set_mplsogre_decap_ip_version,
16411 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16416 /** Set MPLSoUDP encapsulation details */
16417 struct cmd_set_mplsoudp_encap_result {
16418 cmdline_fixed_string_t set;
16419 cmdline_fixed_string_t mplsoudp;
16420 cmdline_fixed_string_t pos_token;
16421 cmdline_fixed_string_t ip_version;
16422 uint32_t vlan_present:1;
16426 cmdline_ipaddr_t ip_src;
16427 cmdline_ipaddr_t ip_dst;
16429 struct rte_ether_addr eth_src;
16430 struct rte_ether_addr eth_dst;
16433 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16434 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16436 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16437 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16439 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16440 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16441 mplsoudp, "mplsoudp_encap-with-vlan");
16442 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16443 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16444 pos_token, "ip-version");
16445 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16446 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16447 ip_version, "ipv4#ipv6");
16448 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16449 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16450 pos_token, "label");
16451 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16452 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16454 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16455 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16456 pos_token, "udp-src");
16457 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16458 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16460 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16461 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16462 pos_token, "udp-dst");
16463 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16464 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16466 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16467 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16468 pos_token, "ip-src");
16469 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16470 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16471 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16472 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16473 pos_token, "ip-dst");
16474 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16475 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16476 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16477 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16478 pos_token, "vlan-tci");
16479 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16480 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16482 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16483 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16484 pos_token, "eth-src");
16485 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16486 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16488 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16489 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16490 pos_token, "eth-dst");
16491 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16492 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16495 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16496 __rte_unused struct cmdline *cl,
16497 __rte_unused void *data)
16499 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16501 uint32_t mplsoudp_label;
16504 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16507 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16508 mplsoudp_encap_conf.select_vlan = 0;
16509 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16510 mplsoudp_encap_conf.select_vlan = 1;
16511 if (strcmp(res->ip_version, "ipv4") == 0)
16512 mplsoudp_encap_conf.select_ipv4 = 1;
16513 else if (strcmp(res->ip_version, "ipv6") == 0)
16514 mplsoudp_encap_conf.select_ipv4 = 0;
16517 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16518 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16519 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16520 if (mplsoudp_encap_conf.select_ipv4) {
16521 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16522 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16524 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16525 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16527 if (mplsoudp_encap_conf.select_vlan)
16528 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16529 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16530 RTE_ETHER_ADDR_LEN);
16531 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16532 RTE_ETHER_ADDR_LEN);
16535 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16536 .f = cmd_set_mplsoudp_encap_parsed,
16538 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16539 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16540 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16542 (void *)&cmd_set_mplsoudp_encap_set,
16543 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16544 (void *)&cmd_set_mplsoudp_encap_ip_version,
16545 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16546 (void *)&cmd_set_mplsoudp_encap_label,
16547 (void *)&cmd_set_mplsoudp_encap_label_value,
16548 (void *)&cmd_set_mplsoudp_encap_udp_src,
16549 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16550 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16551 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16552 (void *)&cmd_set_mplsoudp_encap_ip_src,
16553 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16554 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16555 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16556 (void *)&cmd_set_mplsoudp_encap_eth_src,
16557 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16558 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16559 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16564 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16565 .f = cmd_set_mplsoudp_encap_parsed,
16567 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16568 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16569 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16570 " eth-src <eth-src> eth-dst <eth-dst>",
16572 (void *)&cmd_set_mplsoudp_encap_set,
16573 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16574 (void *)&cmd_set_mplsoudp_encap_ip_version,
16575 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16576 (void *)&cmd_set_mplsoudp_encap_label,
16577 (void *)&cmd_set_mplsoudp_encap_label_value,
16578 (void *)&cmd_set_mplsoudp_encap_udp_src,
16579 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16580 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16581 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16582 (void *)&cmd_set_mplsoudp_encap_ip_src,
16583 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16584 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16585 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16586 (void *)&cmd_set_mplsoudp_encap_vlan,
16587 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16588 (void *)&cmd_set_mplsoudp_encap_eth_src,
16589 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16590 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16591 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16596 /** Set MPLSoUDP decapsulation details */
16597 struct cmd_set_mplsoudp_decap_result {
16598 cmdline_fixed_string_t set;
16599 cmdline_fixed_string_t mplsoudp;
16600 cmdline_fixed_string_t pos_token;
16601 cmdline_fixed_string_t ip_version;
16602 uint32_t vlan_present:1;
16605 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16606 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16608 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16609 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16611 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16612 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16613 mplsoudp, "mplsoudp_decap-with-vlan");
16614 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16615 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16616 pos_token, "ip-version");
16617 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16618 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16619 ip_version, "ipv4#ipv6");
16621 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16622 __rte_unused struct cmdline *cl,
16623 __rte_unused void *data)
16625 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16627 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16628 mplsoudp_decap_conf.select_vlan = 0;
16629 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16630 mplsoudp_decap_conf.select_vlan = 1;
16631 if (strcmp(res->ip_version, "ipv4") == 0)
16632 mplsoudp_decap_conf.select_ipv4 = 1;
16633 else if (strcmp(res->ip_version, "ipv6") == 0)
16634 mplsoudp_decap_conf.select_ipv4 = 0;
16637 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16638 .f = cmd_set_mplsoudp_decap_parsed,
16640 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16642 (void *)&cmd_set_mplsoudp_decap_set,
16643 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16644 (void *)&cmd_set_mplsoudp_decap_ip_version,
16645 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16650 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16651 .f = cmd_set_mplsoudp_decap_parsed,
16653 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16655 (void *)&cmd_set_mplsoudp_decap_set,
16656 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16657 (void *)&cmd_set_mplsoudp_decap_ip_version,
16658 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16663 /* Strict link priority scheduling mode setting */
16665 cmd_strict_link_prio_parsed(
16666 void *parsed_result,
16667 __rte_unused struct cmdline *cl,
16668 __rte_unused void *data)
16670 struct cmd_vf_tc_bw_result *res = parsed_result;
16671 int ret = -ENOTSUP;
16673 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16676 #ifdef RTE_LIBRTE_I40E_PMD
16677 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16684 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16687 printf("invalid port_id %d\n", res->port_id);
16690 printf("function not implemented\n");
16693 printf("programming error: (%s)\n", strerror(-ret));
16697 cmdline_parse_inst_t cmd_strict_link_prio = {
16698 .f = cmd_strict_link_prio_parsed,
16700 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16702 (void *)&cmd_vf_tc_bw_set,
16703 (void *)&cmd_vf_tc_bw_tx,
16704 (void *)&cmd_vf_tc_bw_strict_link_prio,
16705 (void *)&cmd_vf_tc_bw_port_id,
16706 (void *)&cmd_vf_tc_bw_tc_map,
16711 /* Load dynamic device personalization*/
16712 struct cmd_ddp_add_result {
16713 cmdline_fixed_string_t ddp;
16714 cmdline_fixed_string_t add;
16719 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16720 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16721 cmdline_parse_token_string_t cmd_ddp_add_add =
16722 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16723 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16724 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16725 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16726 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16729 cmd_ddp_add_parsed(
16730 void *parsed_result,
16731 __rte_unused struct cmdline *cl,
16732 __rte_unused void *data)
16734 struct cmd_ddp_add_result *res = parsed_result;
16740 int ret = -ENOTSUP;
16742 if (!all_ports_stopped()) {
16743 printf("Please stop all ports first\n");
16747 filepath = strdup(res->filepath);
16748 if (filepath == NULL) {
16749 printf("Failed to allocate memory\n");
16752 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16754 buff = open_file(file_fld[0], &size);
16756 free((void *)filepath);
16760 #ifdef RTE_LIBRTE_I40E_PMD
16761 if (ret == -ENOTSUP)
16762 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16764 RTE_PMD_I40E_PKG_OP_WR_ADD);
16767 if (ret == -EEXIST)
16768 printf("Profile has already existed.\n");
16770 printf("Failed to load profile.\n");
16771 else if (file_num == 2)
16772 save_file(file_fld[1], buff, size);
16775 free((void *)filepath);
16778 cmdline_parse_inst_t cmd_ddp_add = {
16779 .f = cmd_ddp_add_parsed,
16781 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16783 (void *)&cmd_ddp_add_ddp,
16784 (void *)&cmd_ddp_add_add,
16785 (void *)&cmd_ddp_add_port_id,
16786 (void *)&cmd_ddp_add_filepath,
16791 /* Delete dynamic device personalization*/
16792 struct cmd_ddp_del_result {
16793 cmdline_fixed_string_t ddp;
16794 cmdline_fixed_string_t del;
16799 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16800 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16801 cmdline_parse_token_string_t cmd_ddp_del_del =
16802 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16803 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16804 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16805 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16806 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16809 cmd_ddp_del_parsed(
16810 void *parsed_result,
16811 __rte_unused struct cmdline *cl,
16812 __rte_unused void *data)
16814 struct cmd_ddp_del_result *res = parsed_result;
16817 int ret = -ENOTSUP;
16819 if (!all_ports_stopped()) {
16820 printf("Please stop all ports first\n");
16824 buff = open_file(res->filepath, &size);
16828 #ifdef RTE_LIBRTE_I40E_PMD
16829 if (ret == -ENOTSUP)
16830 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16832 RTE_PMD_I40E_PKG_OP_WR_DEL);
16835 if (ret == -EACCES)
16836 printf("Profile does not exist.\n");
16838 printf("Failed to delete profile.\n");
16843 cmdline_parse_inst_t cmd_ddp_del = {
16844 .f = cmd_ddp_del_parsed,
16846 .help_str = "ddp del <port_id> <backup_profile_path>",
16848 (void *)&cmd_ddp_del_ddp,
16849 (void *)&cmd_ddp_del_del,
16850 (void *)&cmd_ddp_del_port_id,
16851 (void *)&cmd_ddp_del_filepath,
16856 /* Get dynamic device personalization profile info */
16857 struct cmd_ddp_info_result {
16858 cmdline_fixed_string_t ddp;
16859 cmdline_fixed_string_t get;
16860 cmdline_fixed_string_t info;
16864 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16865 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16866 cmdline_parse_token_string_t cmd_ddp_info_get =
16867 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16868 cmdline_parse_token_string_t cmd_ddp_info_info =
16869 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16870 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16871 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16874 cmd_ddp_info_parsed(
16875 void *parsed_result,
16876 __rte_unused struct cmdline *cl,
16877 __rte_unused void *data)
16879 struct cmd_ddp_info_result *res = parsed_result;
16882 int ret = -ENOTSUP;
16883 #ifdef RTE_LIBRTE_I40E_PMD
16886 uint32_t buff_size = 0;
16887 struct rte_pmd_i40e_profile_info info;
16888 uint32_t dev_num = 0;
16889 struct rte_pmd_i40e_ddp_device_id *devs;
16890 uint32_t proto_num = 0;
16891 struct rte_pmd_i40e_proto_info *proto = NULL;
16892 uint32_t pctype_num = 0;
16893 struct rte_pmd_i40e_ptype_info *pctype;
16894 uint32_t ptype_num = 0;
16895 struct rte_pmd_i40e_ptype_info *ptype;
16900 pkg = open_file(res->filepath, &pkg_size);
16904 #ifdef RTE_LIBRTE_I40E_PMD
16905 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16906 (uint8_t *)&info, sizeof(info),
16907 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16909 printf("Global Track id: 0x%x\n", info.track_id);
16910 printf("Global Version: %d.%d.%d.%d\n",
16911 info.version.major,
16912 info.version.minor,
16913 info.version.update,
16914 info.version.draft);
16915 printf("Global Package name: %s\n\n", info.name);
16918 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16919 (uint8_t *)&info, sizeof(info),
16920 RTE_PMD_I40E_PKG_INFO_HEADER);
16922 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16923 printf("i40e Profile Version: %d.%d.%d.%d\n",
16924 info.version.major,
16925 info.version.minor,
16926 info.version.update,
16927 info.version.draft);
16928 printf("i40e Profile name: %s\n\n", info.name);
16931 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16932 (uint8_t *)&buff_size, sizeof(buff_size),
16933 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16934 if (!ret && buff_size) {
16935 buff = (uint8_t *)malloc(buff_size);
16937 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16939 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16941 printf("Package Notes:\n%s\n\n", buff);
16946 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16947 (uint8_t *)&dev_num, sizeof(dev_num),
16948 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16949 if (!ret && dev_num) {
16950 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16951 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16953 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16954 (uint8_t *)devs, buff_size,
16955 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16957 printf("List of supported devices:\n");
16958 for (i = 0; i < dev_num; i++) {
16959 printf(" %04X:%04X %04X:%04X\n",
16960 devs[i].vendor_dev_id >> 16,
16961 devs[i].vendor_dev_id & 0xFFFF,
16962 devs[i].sub_vendor_dev_id >> 16,
16963 devs[i].sub_vendor_dev_id & 0xFFFF);
16971 /* get information about protocols and packet types */
16972 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16973 (uint8_t *)&proto_num, sizeof(proto_num),
16974 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16975 if (ret || !proto_num)
16976 goto no_print_return;
16978 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16979 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16981 goto no_print_return;
16983 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16985 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16987 printf("List of used protocols:\n");
16988 for (i = 0; i < proto_num; i++)
16989 printf(" %2u: %s\n", proto[i].proto_id,
16993 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16994 (uint8_t *)&pctype_num, sizeof(pctype_num),
16995 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16996 if (ret || !pctype_num)
16997 goto no_print_pctypes;
16999 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
17000 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
17002 goto no_print_pctypes;
17004 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
17006 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
17009 goto no_print_pctypes;
17012 printf("List of defined packet classification types:\n");
17013 for (i = 0; i < pctype_num; i++) {
17014 printf(" %2u:", pctype[i].ptype_id);
17015 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
17016 proto_id = pctype[i].protocols[j];
17017 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
17018 for (n = 0; n < proto_num; n++) {
17019 if (proto[n].proto_id == proto_id) {
17020 printf(" %s", proto[n].name);
17033 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
17035 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
17036 if (ret || !ptype_num)
17037 goto no_print_return;
17039 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
17040 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
17042 goto no_print_return;
17044 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
17046 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
17049 goto no_print_return;
17051 printf("List of defined packet types:\n");
17052 for (i = 0; i < ptype_num; i++) {
17053 printf(" %2u:", ptype[i].ptype_id);
17054 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
17055 proto_id = ptype[i].protocols[j];
17056 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
17057 for (n = 0; n < proto_num; n++) {
17058 if (proto[n].proto_id == proto_id) {
17059 printf(" %s", proto[n].name);
17075 if (ret == -ENOTSUP)
17076 printf("Function not supported in PMD driver\n");
17080 cmdline_parse_inst_t cmd_ddp_get_info = {
17081 .f = cmd_ddp_info_parsed,
17083 .help_str = "ddp get info <profile_path>",
17085 (void *)&cmd_ddp_info_ddp,
17086 (void *)&cmd_ddp_info_get,
17087 (void *)&cmd_ddp_info_info,
17088 (void *)&cmd_ddp_info_filepath,
17093 /* Get dynamic device personalization profile info list*/
17094 #define PROFILE_INFO_SIZE 48
17095 #define MAX_PROFILE_NUM 16
17097 struct cmd_ddp_get_list_result {
17098 cmdline_fixed_string_t ddp;
17099 cmdline_fixed_string_t get;
17100 cmdline_fixed_string_t list;
17104 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
17105 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
17106 cmdline_parse_token_string_t cmd_ddp_get_list_get =
17107 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
17108 cmdline_parse_token_string_t cmd_ddp_get_list_list =
17109 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
17110 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
17111 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
17114 cmd_ddp_get_list_parsed(
17115 __rte_unused void *parsed_result,
17116 __rte_unused struct cmdline *cl,
17117 __rte_unused void *data)
17119 #ifdef RTE_LIBRTE_I40E_PMD
17120 struct cmd_ddp_get_list_result *res = parsed_result;
17121 struct rte_pmd_i40e_profile_list *p_list;
17122 struct rte_pmd_i40e_profile_info *p_info;
17127 int ret = -ENOTSUP;
17129 #ifdef RTE_LIBRTE_I40E_PMD
17130 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
17131 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
17133 printf("%s: Failed to malloc buffer\n", __func__);
17137 if (ret == -ENOTSUP)
17138 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
17139 (uint8_t *)p_list, size);
17142 p_num = p_list->p_count;
17143 printf("Profile number is: %d\n\n", p_num);
17145 for (i = 0; i < p_num; i++) {
17146 p_info = &p_list->p_info[i];
17147 printf("Profile %d:\n", i);
17148 printf("Track id: 0x%x\n", p_info->track_id);
17149 printf("Version: %d.%d.%d.%d\n",
17150 p_info->version.major,
17151 p_info->version.minor,
17152 p_info->version.update,
17153 p_info->version.draft);
17154 printf("Profile name: %s\n\n", p_info->name);
17162 printf("Failed to get ddp list\n");
17165 cmdline_parse_inst_t cmd_ddp_get_list = {
17166 .f = cmd_ddp_get_list_parsed,
17168 .help_str = "ddp get list <port_id>",
17170 (void *)&cmd_ddp_get_list_ddp,
17171 (void *)&cmd_ddp_get_list_get,
17172 (void *)&cmd_ddp_get_list_list,
17173 (void *)&cmd_ddp_get_list_port_id,
17178 /* Configure input set */
17179 struct cmd_cfg_input_set_result {
17180 cmdline_fixed_string_t port;
17181 cmdline_fixed_string_t cfg;
17183 cmdline_fixed_string_t pctype;
17185 cmdline_fixed_string_t inset_type;
17186 cmdline_fixed_string_t opt;
17187 cmdline_fixed_string_t field;
17192 cmd_cfg_input_set_parsed(
17193 __rte_unused void *parsed_result,
17194 __rte_unused struct cmdline *cl,
17195 __rte_unused void *data)
17197 #ifdef RTE_LIBRTE_I40E_PMD
17198 struct cmd_cfg_input_set_result *res = parsed_result;
17199 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17200 struct rte_pmd_i40e_inset inset;
17202 int ret = -ENOTSUP;
17204 if (!all_ports_stopped()) {
17205 printf("Please stop all ports first\n");
17209 #ifdef RTE_LIBRTE_I40E_PMD
17210 if (!strcmp(res->inset_type, "hash_inset"))
17211 inset_type = INSET_HASH;
17212 else if (!strcmp(res->inset_type, "fdir_inset"))
17213 inset_type = INSET_FDIR;
17214 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17215 inset_type = INSET_FDIR_FLX;
17216 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
17217 &inset, inset_type);
17219 printf("Failed to get input set.\n");
17223 if (!strcmp(res->opt, "get")) {
17224 ret = rte_pmd_i40e_inset_field_get(inset.inset,
17227 printf("Field index %d is enabled.\n", res->field_idx);
17229 printf("Field index %d is disabled.\n", res->field_idx);
17231 } else if (!strcmp(res->opt, "set"))
17232 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17234 else if (!strcmp(res->opt, "clear"))
17235 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17238 printf("Failed to configure input set field.\n");
17242 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17243 &inset, inset_type);
17245 printf("Failed to set input set.\n");
17250 if (ret == -ENOTSUP)
17251 printf("Function not supported\n");
17254 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17255 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17257 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17258 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17260 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17261 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17263 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17264 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17266 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17267 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17269 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17270 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17272 "hash_inset#fdir_inset#fdir_flx_inset");
17273 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17274 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17275 opt, "get#set#clear");
17276 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17277 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17279 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17280 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17283 cmdline_parse_inst_t cmd_cfg_input_set = {
17284 .f = cmd_cfg_input_set_parsed,
17286 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17287 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17289 (void *)&cmd_cfg_input_set_port,
17290 (void *)&cmd_cfg_input_set_cfg,
17291 (void *)&cmd_cfg_input_set_port_id,
17292 (void *)&cmd_cfg_input_set_pctype,
17293 (void *)&cmd_cfg_input_set_pctype_id,
17294 (void *)&cmd_cfg_input_set_inset_type,
17295 (void *)&cmd_cfg_input_set_opt,
17296 (void *)&cmd_cfg_input_set_field,
17297 (void *)&cmd_cfg_input_set_field_idx,
17302 /* Clear input set */
17303 struct cmd_clear_input_set_result {
17304 cmdline_fixed_string_t port;
17305 cmdline_fixed_string_t cfg;
17307 cmdline_fixed_string_t pctype;
17309 cmdline_fixed_string_t inset_type;
17310 cmdline_fixed_string_t clear;
17311 cmdline_fixed_string_t all;
17315 cmd_clear_input_set_parsed(
17316 __rte_unused void *parsed_result,
17317 __rte_unused struct cmdline *cl,
17318 __rte_unused void *data)
17320 #ifdef RTE_LIBRTE_I40E_PMD
17321 struct cmd_clear_input_set_result *res = parsed_result;
17322 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17323 struct rte_pmd_i40e_inset inset;
17325 int ret = -ENOTSUP;
17327 if (!all_ports_stopped()) {
17328 printf("Please stop all ports first\n");
17332 #ifdef RTE_LIBRTE_I40E_PMD
17333 if (!strcmp(res->inset_type, "hash_inset"))
17334 inset_type = INSET_HASH;
17335 else if (!strcmp(res->inset_type, "fdir_inset"))
17336 inset_type = INSET_FDIR;
17337 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17338 inset_type = INSET_FDIR_FLX;
17340 memset(&inset, 0, sizeof(inset));
17342 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17343 &inset, inset_type);
17345 printf("Failed to clear input set.\n");
17351 if (ret == -ENOTSUP)
17352 printf("Function not supported\n");
17355 cmdline_parse_token_string_t cmd_clear_input_set_port =
17356 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17358 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17359 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17361 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17362 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17364 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17365 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17367 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17368 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17370 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17371 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17373 "hash_inset#fdir_inset#fdir_flx_inset");
17374 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17375 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17377 cmdline_parse_token_string_t cmd_clear_input_set_all =
17378 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17381 cmdline_parse_inst_t cmd_clear_input_set = {
17382 .f = cmd_clear_input_set_parsed,
17384 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17385 "fdir_inset|fdir_flx_inset clear all",
17387 (void *)&cmd_clear_input_set_port,
17388 (void *)&cmd_clear_input_set_cfg,
17389 (void *)&cmd_clear_input_set_port_id,
17390 (void *)&cmd_clear_input_set_pctype,
17391 (void *)&cmd_clear_input_set_pctype_id,
17392 (void *)&cmd_clear_input_set_inset_type,
17393 (void *)&cmd_clear_input_set_clear,
17394 (void *)&cmd_clear_input_set_all,
17399 /* show vf stats */
17401 /* Common result structure for show vf stats */
17402 struct cmd_show_vf_stats_result {
17403 cmdline_fixed_string_t show;
17404 cmdline_fixed_string_t vf;
17405 cmdline_fixed_string_t stats;
17410 /* Common CLI fields show vf stats*/
17411 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17412 TOKEN_STRING_INITIALIZER
17413 (struct cmd_show_vf_stats_result,
17415 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17416 TOKEN_STRING_INITIALIZER
17417 (struct cmd_show_vf_stats_result,
17419 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17420 TOKEN_STRING_INITIALIZER
17421 (struct cmd_show_vf_stats_result,
17423 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17424 TOKEN_NUM_INITIALIZER
17425 (struct cmd_show_vf_stats_result,
17427 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17428 TOKEN_NUM_INITIALIZER
17429 (struct cmd_show_vf_stats_result,
17433 cmd_show_vf_stats_parsed(
17434 void *parsed_result,
17435 __rte_unused struct cmdline *cl,
17436 __rte_unused void *data)
17438 struct cmd_show_vf_stats_result *res = parsed_result;
17439 struct rte_eth_stats stats;
17440 int ret = -ENOTSUP;
17441 static const char *nic_stats_border = "########################";
17443 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17446 memset(&stats, 0, sizeof(stats));
17448 #ifdef RTE_LIBRTE_I40E_PMD
17449 if (ret == -ENOTSUP)
17450 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17454 #ifdef RTE_LIBRTE_BNXT_PMD
17455 if (ret == -ENOTSUP)
17456 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17465 printf("invalid vf_id %d\n", res->vf_id);
17468 printf("invalid port_id %d\n", res->port_id);
17471 printf("function not implemented\n");
17474 printf("programming error: (%s)\n", strerror(-ret));
17477 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17478 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17480 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17482 stats.ipackets, stats.imissed, stats.ibytes);
17483 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17484 printf(" RX-nombuf: %-10"PRIu64"\n",
17486 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17488 stats.opackets, stats.oerrors, stats.obytes);
17490 printf(" %s############################%s\n",
17491 nic_stats_border, nic_stats_border);
17494 cmdline_parse_inst_t cmd_show_vf_stats = {
17495 .f = cmd_show_vf_stats_parsed,
17497 .help_str = "show vf stats <port_id> <vf_id>",
17499 (void *)&cmd_show_vf_stats_show,
17500 (void *)&cmd_show_vf_stats_vf,
17501 (void *)&cmd_show_vf_stats_stats,
17502 (void *)&cmd_show_vf_stats_port_id,
17503 (void *)&cmd_show_vf_stats_vf_id,
17508 /* clear vf stats */
17510 /* Common result structure for clear vf stats */
17511 struct cmd_clear_vf_stats_result {
17512 cmdline_fixed_string_t clear;
17513 cmdline_fixed_string_t vf;
17514 cmdline_fixed_string_t stats;
17519 /* Common CLI fields clear vf stats*/
17520 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17521 TOKEN_STRING_INITIALIZER
17522 (struct cmd_clear_vf_stats_result,
17524 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17525 TOKEN_STRING_INITIALIZER
17526 (struct cmd_clear_vf_stats_result,
17528 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17529 TOKEN_STRING_INITIALIZER
17530 (struct cmd_clear_vf_stats_result,
17532 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17533 TOKEN_NUM_INITIALIZER
17534 (struct cmd_clear_vf_stats_result,
17536 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17537 TOKEN_NUM_INITIALIZER
17538 (struct cmd_clear_vf_stats_result,
17542 cmd_clear_vf_stats_parsed(
17543 void *parsed_result,
17544 __rte_unused struct cmdline *cl,
17545 __rte_unused void *data)
17547 struct cmd_clear_vf_stats_result *res = parsed_result;
17548 int ret = -ENOTSUP;
17550 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17553 #ifdef RTE_LIBRTE_I40E_PMD
17554 if (ret == -ENOTSUP)
17555 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17558 #ifdef RTE_LIBRTE_BNXT_PMD
17559 if (ret == -ENOTSUP)
17560 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17568 printf("invalid vf_id %d\n", res->vf_id);
17571 printf("invalid port_id %d\n", res->port_id);
17574 printf("function not implemented\n");
17577 printf("programming error: (%s)\n", strerror(-ret));
17581 cmdline_parse_inst_t cmd_clear_vf_stats = {
17582 .f = cmd_clear_vf_stats_parsed,
17584 .help_str = "clear vf stats <port_id> <vf_id>",
17586 (void *)&cmd_clear_vf_stats_clear,
17587 (void *)&cmd_clear_vf_stats_vf,
17588 (void *)&cmd_clear_vf_stats_stats,
17589 (void *)&cmd_clear_vf_stats_port_id,
17590 (void *)&cmd_clear_vf_stats_vf_id,
17595 /* port config pctype mapping reset */
17597 /* Common result structure for port config pctype mapping reset */
17598 struct cmd_pctype_mapping_reset_result {
17599 cmdline_fixed_string_t port;
17600 cmdline_fixed_string_t config;
17602 cmdline_fixed_string_t pctype;
17603 cmdline_fixed_string_t mapping;
17604 cmdline_fixed_string_t reset;
17607 /* Common CLI fields for port config pctype mapping reset*/
17608 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17609 TOKEN_STRING_INITIALIZER
17610 (struct cmd_pctype_mapping_reset_result,
17612 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17613 TOKEN_STRING_INITIALIZER
17614 (struct cmd_pctype_mapping_reset_result,
17616 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17617 TOKEN_NUM_INITIALIZER
17618 (struct cmd_pctype_mapping_reset_result,
17620 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17621 TOKEN_STRING_INITIALIZER
17622 (struct cmd_pctype_mapping_reset_result,
17624 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17625 TOKEN_STRING_INITIALIZER
17626 (struct cmd_pctype_mapping_reset_result,
17627 mapping, "mapping");
17628 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17629 TOKEN_STRING_INITIALIZER
17630 (struct cmd_pctype_mapping_reset_result,
17634 cmd_pctype_mapping_reset_parsed(
17635 void *parsed_result,
17636 __rte_unused struct cmdline *cl,
17637 __rte_unused void *data)
17639 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17640 int ret = -ENOTSUP;
17642 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17645 #ifdef RTE_LIBRTE_I40E_PMD
17646 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17653 printf("invalid port_id %d\n", res->port_id);
17656 printf("function not implemented\n");
17659 printf("programming error: (%s)\n", strerror(-ret));
17663 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17664 .f = cmd_pctype_mapping_reset_parsed,
17666 .help_str = "port config <port_id> pctype mapping reset",
17668 (void *)&cmd_pctype_mapping_reset_port,
17669 (void *)&cmd_pctype_mapping_reset_config,
17670 (void *)&cmd_pctype_mapping_reset_port_id,
17671 (void *)&cmd_pctype_mapping_reset_pctype,
17672 (void *)&cmd_pctype_mapping_reset_mapping,
17673 (void *)&cmd_pctype_mapping_reset_reset,
17678 /* show port pctype mapping */
17680 /* Common result structure for show port pctype mapping */
17681 struct cmd_pctype_mapping_get_result {
17682 cmdline_fixed_string_t show;
17683 cmdline_fixed_string_t port;
17685 cmdline_fixed_string_t pctype;
17686 cmdline_fixed_string_t mapping;
17689 /* Common CLI fields for pctype mapping get */
17690 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17691 TOKEN_STRING_INITIALIZER
17692 (struct cmd_pctype_mapping_get_result,
17694 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17695 TOKEN_STRING_INITIALIZER
17696 (struct cmd_pctype_mapping_get_result,
17698 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17699 TOKEN_NUM_INITIALIZER
17700 (struct cmd_pctype_mapping_get_result,
17702 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17703 TOKEN_STRING_INITIALIZER
17704 (struct cmd_pctype_mapping_get_result,
17706 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17707 TOKEN_STRING_INITIALIZER
17708 (struct cmd_pctype_mapping_get_result,
17709 mapping, "mapping");
17712 cmd_pctype_mapping_get_parsed(
17713 void *parsed_result,
17714 __rte_unused struct cmdline *cl,
17715 __rte_unused void *data)
17717 struct cmd_pctype_mapping_get_result *res = parsed_result;
17718 int ret = -ENOTSUP;
17719 #ifdef RTE_LIBRTE_I40E_PMD
17720 struct rte_pmd_i40e_flow_type_mapping
17721 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17722 int i, j, first_pctype;
17725 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17728 #ifdef RTE_LIBRTE_I40E_PMD
17729 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17736 printf("invalid port_id %d\n", res->port_id);
17739 printf("function not implemented\n");
17742 printf("programming error: (%s)\n", strerror(-ret));
17746 #ifdef RTE_LIBRTE_I40E_PMD
17747 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17748 if (mapping[i].pctype != 0ULL) {
17751 printf("pctype: ");
17752 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17753 if (mapping[i].pctype & (1ULL << j)) {
17754 printf(first_pctype ?
17755 "%02d" : ",%02d", j);
17759 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17765 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17766 .f = cmd_pctype_mapping_get_parsed,
17768 .help_str = "show port <port_id> pctype mapping",
17770 (void *)&cmd_pctype_mapping_get_show,
17771 (void *)&cmd_pctype_mapping_get_port,
17772 (void *)&cmd_pctype_mapping_get_port_id,
17773 (void *)&cmd_pctype_mapping_get_pctype,
17774 (void *)&cmd_pctype_mapping_get_mapping,
17779 /* port config pctype mapping update */
17781 /* Common result structure for port config pctype mapping update */
17782 struct cmd_pctype_mapping_update_result {
17783 cmdline_fixed_string_t port;
17784 cmdline_fixed_string_t config;
17786 cmdline_fixed_string_t pctype;
17787 cmdline_fixed_string_t mapping;
17788 cmdline_fixed_string_t update;
17789 cmdline_fixed_string_t pctype_list;
17790 uint16_t flow_type;
17793 /* Common CLI fields for pctype mapping update*/
17794 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17795 TOKEN_STRING_INITIALIZER
17796 (struct cmd_pctype_mapping_update_result,
17798 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17799 TOKEN_STRING_INITIALIZER
17800 (struct cmd_pctype_mapping_update_result,
17802 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17803 TOKEN_NUM_INITIALIZER
17804 (struct cmd_pctype_mapping_update_result,
17806 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17807 TOKEN_STRING_INITIALIZER
17808 (struct cmd_pctype_mapping_update_result,
17810 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17811 TOKEN_STRING_INITIALIZER
17812 (struct cmd_pctype_mapping_update_result,
17813 mapping, "mapping");
17814 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17815 TOKEN_STRING_INITIALIZER
17816 (struct cmd_pctype_mapping_update_result,
17818 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17819 TOKEN_STRING_INITIALIZER
17820 (struct cmd_pctype_mapping_update_result,
17821 pctype_list, NULL);
17822 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17823 TOKEN_NUM_INITIALIZER
17824 (struct cmd_pctype_mapping_update_result,
17825 flow_type, UINT16);
17828 cmd_pctype_mapping_update_parsed(
17829 void *parsed_result,
17830 __rte_unused struct cmdline *cl,
17831 __rte_unused void *data)
17833 struct cmd_pctype_mapping_update_result *res = parsed_result;
17834 int ret = -ENOTSUP;
17835 #ifdef RTE_LIBRTE_I40E_PMD
17836 struct rte_pmd_i40e_flow_type_mapping mapping;
17838 unsigned int nb_item;
17839 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17842 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17845 #ifdef RTE_LIBRTE_I40E_PMD
17846 nb_item = parse_item_list(res->pctype_list, "pctypes",
17847 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17848 mapping.flow_type = res->flow_type;
17849 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17850 mapping.pctype |= (1ULL << pctype_list[i]);
17851 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17861 printf("invalid pctype or flow type\n");
17864 printf("invalid port_id %d\n", res->port_id);
17867 printf("function not implemented\n");
17870 printf("programming error: (%s)\n", strerror(-ret));
17874 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17875 .f = cmd_pctype_mapping_update_parsed,
17877 .help_str = "port config <port_id> pctype mapping update"
17878 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17880 (void *)&cmd_pctype_mapping_update_port,
17881 (void *)&cmd_pctype_mapping_update_config,
17882 (void *)&cmd_pctype_mapping_update_port_id,
17883 (void *)&cmd_pctype_mapping_update_pctype,
17884 (void *)&cmd_pctype_mapping_update_mapping,
17885 (void *)&cmd_pctype_mapping_update_update,
17886 (void *)&cmd_pctype_mapping_update_pc_type,
17887 (void *)&cmd_pctype_mapping_update_flow_type,
17892 /* ptype mapping get */
17894 /* Common result structure for ptype mapping get */
17895 struct cmd_ptype_mapping_get_result {
17896 cmdline_fixed_string_t ptype;
17897 cmdline_fixed_string_t mapping;
17898 cmdline_fixed_string_t get;
17900 uint8_t valid_only;
17903 /* Common CLI fields for ptype mapping get */
17904 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17905 TOKEN_STRING_INITIALIZER
17906 (struct cmd_ptype_mapping_get_result,
17908 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17909 TOKEN_STRING_INITIALIZER
17910 (struct cmd_ptype_mapping_get_result,
17911 mapping, "mapping");
17912 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17913 TOKEN_STRING_INITIALIZER
17914 (struct cmd_ptype_mapping_get_result,
17916 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17917 TOKEN_NUM_INITIALIZER
17918 (struct cmd_ptype_mapping_get_result,
17920 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17921 TOKEN_NUM_INITIALIZER
17922 (struct cmd_ptype_mapping_get_result,
17923 valid_only, UINT8);
17926 cmd_ptype_mapping_get_parsed(
17927 void *parsed_result,
17928 __rte_unused struct cmdline *cl,
17929 __rte_unused void *data)
17931 struct cmd_ptype_mapping_get_result *res = parsed_result;
17932 int ret = -ENOTSUP;
17933 #ifdef RTE_LIBRTE_I40E_PMD
17934 int max_ptype_num = 256;
17935 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17940 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17943 #ifdef RTE_LIBRTE_I40E_PMD
17944 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17955 printf("invalid port_id %d\n", res->port_id);
17958 printf("function not implemented\n");
17961 printf("programming error: (%s)\n", strerror(-ret));
17964 #ifdef RTE_LIBRTE_I40E_PMD
17966 for (i = 0; i < count; i++)
17967 printf("%3d\t0x%08x\n",
17968 mapping[i].hw_ptype, mapping[i].sw_ptype);
17973 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17974 .f = cmd_ptype_mapping_get_parsed,
17976 .help_str = "ptype mapping get <port_id> <valid_only>",
17978 (void *)&cmd_ptype_mapping_get_ptype,
17979 (void *)&cmd_ptype_mapping_get_mapping,
17980 (void *)&cmd_ptype_mapping_get_get,
17981 (void *)&cmd_ptype_mapping_get_port_id,
17982 (void *)&cmd_ptype_mapping_get_valid_only,
17987 /* ptype mapping replace */
17989 /* Common result structure for ptype mapping replace */
17990 struct cmd_ptype_mapping_replace_result {
17991 cmdline_fixed_string_t ptype;
17992 cmdline_fixed_string_t mapping;
17993 cmdline_fixed_string_t replace;
18000 /* Common CLI fields for ptype mapping replace */
18001 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
18002 TOKEN_STRING_INITIALIZER
18003 (struct cmd_ptype_mapping_replace_result,
18005 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
18006 TOKEN_STRING_INITIALIZER
18007 (struct cmd_ptype_mapping_replace_result,
18008 mapping, "mapping");
18009 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
18010 TOKEN_STRING_INITIALIZER
18011 (struct cmd_ptype_mapping_replace_result,
18012 replace, "replace");
18013 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
18014 TOKEN_NUM_INITIALIZER
18015 (struct cmd_ptype_mapping_replace_result,
18017 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
18018 TOKEN_NUM_INITIALIZER
18019 (struct cmd_ptype_mapping_replace_result,
18021 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
18022 TOKEN_NUM_INITIALIZER
18023 (struct cmd_ptype_mapping_replace_result,
18025 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
18026 TOKEN_NUM_INITIALIZER
18027 (struct cmd_ptype_mapping_replace_result,
18031 cmd_ptype_mapping_replace_parsed(
18032 void *parsed_result,
18033 __rte_unused struct cmdline *cl,
18034 __rte_unused void *data)
18036 struct cmd_ptype_mapping_replace_result *res = parsed_result;
18037 int ret = -ENOTSUP;
18039 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18042 #ifdef RTE_LIBRTE_I40E_PMD
18043 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
18053 printf("invalid ptype 0x%8x or 0x%8x\n",
18054 res->target, res->pkt_type);
18057 printf("invalid port_id %d\n", res->port_id);
18060 printf("function not implemented\n");
18063 printf("programming error: (%s)\n", strerror(-ret));
18067 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
18068 .f = cmd_ptype_mapping_replace_parsed,
18071 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
18073 (void *)&cmd_ptype_mapping_replace_ptype,
18074 (void *)&cmd_ptype_mapping_replace_mapping,
18075 (void *)&cmd_ptype_mapping_replace_replace,
18076 (void *)&cmd_ptype_mapping_replace_port_id,
18077 (void *)&cmd_ptype_mapping_replace_target,
18078 (void *)&cmd_ptype_mapping_replace_mask,
18079 (void *)&cmd_ptype_mapping_replace_pkt_type,
18084 /* ptype mapping reset */
18086 /* Common result structure for ptype mapping reset */
18087 struct cmd_ptype_mapping_reset_result {
18088 cmdline_fixed_string_t ptype;
18089 cmdline_fixed_string_t mapping;
18090 cmdline_fixed_string_t reset;
18094 /* Common CLI fields for ptype mapping reset*/
18095 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
18096 TOKEN_STRING_INITIALIZER
18097 (struct cmd_ptype_mapping_reset_result,
18099 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
18100 TOKEN_STRING_INITIALIZER
18101 (struct cmd_ptype_mapping_reset_result,
18102 mapping, "mapping");
18103 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
18104 TOKEN_STRING_INITIALIZER
18105 (struct cmd_ptype_mapping_reset_result,
18107 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
18108 TOKEN_NUM_INITIALIZER
18109 (struct cmd_ptype_mapping_reset_result,
18113 cmd_ptype_mapping_reset_parsed(
18114 void *parsed_result,
18115 __rte_unused struct cmdline *cl,
18116 __rte_unused void *data)
18118 struct cmd_ptype_mapping_reset_result *res = parsed_result;
18119 int ret = -ENOTSUP;
18121 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18124 #ifdef RTE_LIBRTE_I40E_PMD
18125 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
18132 printf("invalid port_id %d\n", res->port_id);
18135 printf("function not implemented\n");
18138 printf("programming error: (%s)\n", strerror(-ret));
18142 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
18143 .f = cmd_ptype_mapping_reset_parsed,
18145 .help_str = "ptype mapping reset <port_id>",
18147 (void *)&cmd_ptype_mapping_reset_ptype,
18148 (void *)&cmd_ptype_mapping_reset_mapping,
18149 (void *)&cmd_ptype_mapping_reset_reset,
18150 (void *)&cmd_ptype_mapping_reset_port_id,
18155 /* ptype mapping update */
18157 /* Common result structure for ptype mapping update */
18158 struct cmd_ptype_mapping_update_result {
18159 cmdline_fixed_string_t ptype;
18160 cmdline_fixed_string_t mapping;
18161 cmdline_fixed_string_t reset;
18167 /* Common CLI fields for ptype mapping update*/
18168 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
18169 TOKEN_STRING_INITIALIZER
18170 (struct cmd_ptype_mapping_update_result,
18172 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
18173 TOKEN_STRING_INITIALIZER
18174 (struct cmd_ptype_mapping_update_result,
18175 mapping, "mapping");
18176 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
18177 TOKEN_STRING_INITIALIZER
18178 (struct cmd_ptype_mapping_update_result,
18180 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
18181 TOKEN_NUM_INITIALIZER
18182 (struct cmd_ptype_mapping_update_result,
18184 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
18185 TOKEN_NUM_INITIALIZER
18186 (struct cmd_ptype_mapping_update_result,
18188 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
18189 TOKEN_NUM_INITIALIZER
18190 (struct cmd_ptype_mapping_update_result,
18194 cmd_ptype_mapping_update_parsed(
18195 void *parsed_result,
18196 __rte_unused struct cmdline *cl,
18197 __rte_unused void *data)
18199 struct cmd_ptype_mapping_update_result *res = parsed_result;
18200 int ret = -ENOTSUP;
18201 #ifdef RTE_LIBRTE_I40E_PMD
18202 struct rte_pmd_i40e_ptype_mapping mapping;
18204 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18207 #ifdef RTE_LIBRTE_I40E_PMD
18208 mapping.hw_ptype = res->hw_ptype;
18209 mapping.sw_ptype = res->sw_ptype;
18210 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
18220 printf("invalid ptype 0x%8x\n", res->sw_ptype);
18223 printf("invalid port_id %d\n", res->port_id);
18226 printf("function not implemented\n");
18229 printf("programming error: (%s)\n", strerror(-ret));
18233 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18234 .f = cmd_ptype_mapping_update_parsed,
18236 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18238 (void *)&cmd_ptype_mapping_update_ptype,
18239 (void *)&cmd_ptype_mapping_update_mapping,
18240 (void *)&cmd_ptype_mapping_update_update,
18241 (void *)&cmd_ptype_mapping_update_port_id,
18242 (void *)&cmd_ptype_mapping_update_hw_ptype,
18243 (void *)&cmd_ptype_mapping_update_sw_ptype,
18248 /* Common result structure for file commands */
18249 struct cmd_cmdfile_result {
18250 cmdline_fixed_string_t load;
18251 cmdline_fixed_string_t filename;
18254 /* Common CLI fields for file commands */
18255 cmdline_parse_token_string_t cmd_load_cmdfile =
18256 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18257 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18258 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18261 cmd_load_from_file_parsed(
18262 void *parsed_result,
18263 __rte_unused struct cmdline *cl,
18264 __rte_unused void *data)
18266 struct cmd_cmdfile_result *res = parsed_result;
18268 cmdline_read_from_file(res->filename);
18271 cmdline_parse_inst_t cmd_load_from_file = {
18272 .f = cmd_load_from_file_parsed,
18274 .help_str = "load <filename>",
18276 (void *)&cmd_load_cmdfile,
18277 (void *)&cmd_load_cmdfile_filename,
18282 /* Get Rx offloads capabilities */
18283 struct cmd_rx_offload_get_capa_result {
18284 cmdline_fixed_string_t show;
18285 cmdline_fixed_string_t port;
18287 cmdline_fixed_string_t rx_offload;
18288 cmdline_fixed_string_t capabilities;
18291 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18292 TOKEN_STRING_INITIALIZER
18293 (struct cmd_rx_offload_get_capa_result,
18295 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18296 TOKEN_STRING_INITIALIZER
18297 (struct cmd_rx_offload_get_capa_result,
18299 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18300 TOKEN_NUM_INITIALIZER
18301 (struct cmd_rx_offload_get_capa_result,
18303 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18304 TOKEN_STRING_INITIALIZER
18305 (struct cmd_rx_offload_get_capa_result,
18306 rx_offload, "rx_offload");
18307 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18308 TOKEN_STRING_INITIALIZER
18309 (struct cmd_rx_offload_get_capa_result,
18310 capabilities, "capabilities");
18313 print_rx_offloads(uint64_t offloads)
18315 uint64_t single_offload;
18323 begin = __builtin_ctzll(offloads);
18324 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18326 single_offload = 1ULL << begin;
18327 for (bit = begin; bit < end; bit++) {
18328 if (offloads & single_offload)
18330 rte_eth_dev_rx_offload_name(single_offload));
18331 single_offload <<= 1;
18336 cmd_rx_offload_get_capa_parsed(
18337 void *parsed_result,
18338 __rte_unused struct cmdline *cl,
18339 __rte_unused void *data)
18341 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18342 struct rte_eth_dev_info dev_info;
18343 portid_t port_id = res->port_id;
18344 uint64_t queue_offloads;
18345 uint64_t port_offloads;
18348 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18352 queue_offloads = dev_info.rx_queue_offload_capa;
18353 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18355 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18356 printf(" Per Queue :");
18357 print_rx_offloads(queue_offloads);
18360 printf(" Per Port :");
18361 print_rx_offloads(port_offloads);
18365 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18366 .f = cmd_rx_offload_get_capa_parsed,
18368 .help_str = "show port <port_id> rx_offload capabilities",
18370 (void *)&cmd_rx_offload_get_capa_show,
18371 (void *)&cmd_rx_offload_get_capa_port,
18372 (void *)&cmd_rx_offload_get_capa_port_id,
18373 (void *)&cmd_rx_offload_get_capa_rx_offload,
18374 (void *)&cmd_rx_offload_get_capa_capabilities,
18379 /* Get Rx offloads configuration */
18380 struct cmd_rx_offload_get_configuration_result {
18381 cmdline_fixed_string_t show;
18382 cmdline_fixed_string_t port;
18384 cmdline_fixed_string_t rx_offload;
18385 cmdline_fixed_string_t configuration;
18388 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18389 TOKEN_STRING_INITIALIZER
18390 (struct cmd_rx_offload_get_configuration_result,
18392 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18393 TOKEN_STRING_INITIALIZER
18394 (struct cmd_rx_offload_get_configuration_result,
18396 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18397 TOKEN_NUM_INITIALIZER
18398 (struct cmd_rx_offload_get_configuration_result,
18400 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18401 TOKEN_STRING_INITIALIZER
18402 (struct cmd_rx_offload_get_configuration_result,
18403 rx_offload, "rx_offload");
18404 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18405 TOKEN_STRING_INITIALIZER
18406 (struct cmd_rx_offload_get_configuration_result,
18407 configuration, "configuration");
18410 cmd_rx_offload_get_configuration_parsed(
18411 void *parsed_result,
18412 __rte_unused struct cmdline *cl,
18413 __rte_unused void *data)
18415 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18416 struct rte_eth_dev_info dev_info;
18417 portid_t port_id = res->port_id;
18418 struct rte_port *port = &ports[port_id];
18419 uint64_t port_offloads;
18420 uint64_t queue_offloads;
18421 uint16_t nb_rx_queues;
18425 printf("Rx Offloading Configuration of port %d :\n", port_id);
18427 port_offloads = port->dev_conf.rxmode.offloads;
18429 print_rx_offloads(port_offloads);
18432 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18436 nb_rx_queues = dev_info.nb_rx_queues;
18437 for (q = 0; q < nb_rx_queues; q++) {
18438 queue_offloads = port->rx_conf[q].offloads;
18439 printf(" Queue[%2d] :", q);
18440 print_rx_offloads(queue_offloads);
18446 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18447 .f = cmd_rx_offload_get_configuration_parsed,
18449 .help_str = "show port <port_id> rx_offload configuration",
18451 (void *)&cmd_rx_offload_get_configuration_show,
18452 (void *)&cmd_rx_offload_get_configuration_port,
18453 (void *)&cmd_rx_offload_get_configuration_port_id,
18454 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18455 (void *)&cmd_rx_offload_get_configuration_configuration,
18460 /* Enable/Disable a per port offloading */
18461 struct cmd_config_per_port_rx_offload_result {
18462 cmdline_fixed_string_t port;
18463 cmdline_fixed_string_t config;
18465 cmdline_fixed_string_t rx_offload;
18466 cmdline_fixed_string_t offload;
18467 cmdline_fixed_string_t on_off;
18470 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18471 TOKEN_STRING_INITIALIZER
18472 (struct cmd_config_per_port_rx_offload_result,
18474 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18475 TOKEN_STRING_INITIALIZER
18476 (struct cmd_config_per_port_rx_offload_result,
18478 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18479 TOKEN_NUM_INITIALIZER
18480 (struct cmd_config_per_port_rx_offload_result,
18482 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18483 TOKEN_STRING_INITIALIZER
18484 (struct cmd_config_per_port_rx_offload_result,
18485 rx_offload, "rx_offload");
18486 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18487 TOKEN_STRING_INITIALIZER
18488 (struct cmd_config_per_port_rx_offload_result,
18489 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18490 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18491 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18492 "scatter#buffer_split#timestamp#security#"
18493 "keep_crc#rss_hash");
18494 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18495 TOKEN_STRING_INITIALIZER
18496 (struct cmd_config_per_port_rx_offload_result,
18500 search_rx_offload(const char *name)
18502 uint64_t single_offload;
18503 const char *single_name;
18507 single_offload = 1;
18508 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18509 single_name = rte_eth_dev_rx_offload_name(single_offload);
18510 if (!strcasecmp(single_name, name)) {
18514 single_offload <<= 1;
18518 return single_offload;
18524 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18525 __rte_unused struct cmdline *cl,
18526 __rte_unused void *data)
18528 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18529 portid_t port_id = res->port_id;
18530 struct rte_eth_dev_info dev_info;
18531 struct rte_port *port = &ports[port_id];
18532 uint64_t single_offload;
18533 uint16_t nb_rx_queues;
18537 if (port->port_status != RTE_PORT_STOPPED) {
18538 printf("Error: Can't config offload when Port %d "
18539 "is not stopped\n", port_id);
18543 single_offload = search_rx_offload(res->offload);
18544 if (single_offload == 0) {
18545 printf("Unknown offload name: %s\n", res->offload);
18549 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18553 nb_rx_queues = dev_info.nb_rx_queues;
18554 if (!strcmp(res->on_off, "on")) {
18555 port->dev_conf.rxmode.offloads |= single_offload;
18556 for (q = 0; q < nb_rx_queues; q++)
18557 port->rx_conf[q].offloads |= single_offload;
18559 port->dev_conf.rxmode.offloads &= ~single_offload;
18560 for (q = 0; q < nb_rx_queues; q++)
18561 port->rx_conf[q].offloads &= ~single_offload;
18564 cmd_reconfig_device_queue(port_id, 1, 1);
18567 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18568 .f = cmd_config_per_port_rx_offload_parsed,
18570 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18571 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18572 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18573 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18574 "keep_crc|rss_hash on|off",
18576 (void *)&cmd_config_per_port_rx_offload_result_port,
18577 (void *)&cmd_config_per_port_rx_offload_result_config,
18578 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18579 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18580 (void *)&cmd_config_per_port_rx_offload_result_offload,
18581 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18586 /* Enable/Disable a per queue offloading */
18587 struct cmd_config_per_queue_rx_offload_result {
18588 cmdline_fixed_string_t port;
18590 cmdline_fixed_string_t rxq;
18592 cmdline_fixed_string_t rx_offload;
18593 cmdline_fixed_string_t offload;
18594 cmdline_fixed_string_t on_off;
18597 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18598 TOKEN_STRING_INITIALIZER
18599 (struct cmd_config_per_queue_rx_offload_result,
18601 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18602 TOKEN_NUM_INITIALIZER
18603 (struct cmd_config_per_queue_rx_offload_result,
18605 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18606 TOKEN_STRING_INITIALIZER
18607 (struct cmd_config_per_queue_rx_offload_result,
18609 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18610 TOKEN_NUM_INITIALIZER
18611 (struct cmd_config_per_queue_rx_offload_result,
18613 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18614 TOKEN_STRING_INITIALIZER
18615 (struct cmd_config_per_queue_rx_offload_result,
18616 rx_offload, "rx_offload");
18617 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18618 TOKEN_STRING_INITIALIZER
18619 (struct cmd_config_per_queue_rx_offload_result,
18620 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18621 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18622 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18623 "scatter#buffer_split#timestamp#security#keep_crc");
18624 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18625 TOKEN_STRING_INITIALIZER
18626 (struct cmd_config_per_queue_rx_offload_result,
18630 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18631 __rte_unused struct cmdline *cl,
18632 __rte_unused void *data)
18634 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18635 struct rte_eth_dev_info dev_info;
18636 portid_t port_id = res->port_id;
18637 uint16_t queue_id = res->queue_id;
18638 struct rte_port *port = &ports[port_id];
18639 uint64_t single_offload;
18642 if (port->port_status != RTE_PORT_STOPPED) {
18643 printf("Error: Can't config offload when Port %d "
18644 "is not stopped\n", port_id);
18648 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18652 if (queue_id >= dev_info.nb_rx_queues) {
18653 printf("Error: input queue_id should be 0 ... "
18654 "%d\n", dev_info.nb_rx_queues - 1);
18658 single_offload = search_rx_offload(res->offload);
18659 if (single_offload == 0) {
18660 printf("Unknown offload name: %s\n", res->offload);
18664 if (!strcmp(res->on_off, "on"))
18665 port->rx_conf[queue_id].offloads |= single_offload;
18667 port->rx_conf[queue_id].offloads &= ~single_offload;
18669 cmd_reconfig_device_queue(port_id, 1, 1);
18672 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18673 .f = cmd_config_per_queue_rx_offload_parsed,
18675 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18676 "vlan_strip|ipv4_cksum|"
18677 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18678 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18679 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18682 (void *)&cmd_config_per_queue_rx_offload_result_port,
18683 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18684 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18685 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18686 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18687 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18688 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18693 /* Get Tx offloads capabilities */
18694 struct cmd_tx_offload_get_capa_result {
18695 cmdline_fixed_string_t show;
18696 cmdline_fixed_string_t port;
18698 cmdline_fixed_string_t tx_offload;
18699 cmdline_fixed_string_t capabilities;
18702 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18703 TOKEN_STRING_INITIALIZER
18704 (struct cmd_tx_offload_get_capa_result,
18706 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18707 TOKEN_STRING_INITIALIZER
18708 (struct cmd_tx_offload_get_capa_result,
18710 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18711 TOKEN_NUM_INITIALIZER
18712 (struct cmd_tx_offload_get_capa_result,
18714 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18715 TOKEN_STRING_INITIALIZER
18716 (struct cmd_tx_offload_get_capa_result,
18717 tx_offload, "tx_offload");
18718 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18719 TOKEN_STRING_INITIALIZER
18720 (struct cmd_tx_offload_get_capa_result,
18721 capabilities, "capabilities");
18724 print_tx_offloads(uint64_t offloads)
18726 uint64_t single_offload;
18734 begin = __builtin_ctzll(offloads);
18735 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18737 single_offload = 1ULL << begin;
18738 for (bit = begin; bit < end; bit++) {
18739 if (offloads & single_offload)
18741 rte_eth_dev_tx_offload_name(single_offload));
18742 single_offload <<= 1;
18747 cmd_tx_offload_get_capa_parsed(
18748 void *parsed_result,
18749 __rte_unused struct cmdline *cl,
18750 __rte_unused void *data)
18752 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18753 struct rte_eth_dev_info dev_info;
18754 portid_t port_id = res->port_id;
18755 uint64_t queue_offloads;
18756 uint64_t port_offloads;
18759 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18763 queue_offloads = dev_info.tx_queue_offload_capa;
18764 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18766 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18767 printf(" Per Queue :");
18768 print_tx_offloads(queue_offloads);
18771 printf(" Per Port :");
18772 print_tx_offloads(port_offloads);
18776 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18777 .f = cmd_tx_offload_get_capa_parsed,
18779 .help_str = "show port <port_id> tx_offload capabilities",
18781 (void *)&cmd_tx_offload_get_capa_show,
18782 (void *)&cmd_tx_offload_get_capa_port,
18783 (void *)&cmd_tx_offload_get_capa_port_id,
18784 (void *)&cmd_tx_offload_get_capa_tx_offload,
18785 (void *)&cmd_tx_offload_get_capa_capabilities,
18790 /* Get Tx offloads configuration */
18791 struct cmd_tx_offload_get_configuration_result {
18792 cmdline_fixed_string_t show;
18793 cmdline_fixed_string_t port;
18795 cmdline_fixed_string_t tx_offload;
18796 cmdline_fixed_string_t configuration;
18799 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18800 TOKEN_STRING_INITIALIZER
18801 (struct cmd_tx_offload_get_configuration_result,
18803 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18804 TOKEN_STRING_INITIALIZER
18805 (struct cmd_tx_offload_get_configuration_result,
18807 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18808 TOKEN_NUM_INITIALIZER
18809 (struct cmd_tx_offload_get_configuration_result,
18811 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18812 TOKEN_STRING_INITIALIZER
18813 (struct cmd_tx_offload_get_configuration_result,
18814 tx_offload, "tx_offload");
18815 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18816 TOKEN_STRING_INITIALIZER
18817 (struct cmd_tx_offload_get_configuration_result,
18818 configuration, "configuration");
18821 cmd_tx_offload_get_configuration_parsed(
18822 void *parsed_result,
18823 __rte_unused struct cmdline *cl,
18824 __rte_unused void *data)
18826 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18827 struct rte_eth_dev_info dev_info;
18828 portid_t port_id = res->port_id;
18829 struct rte_port *port = &ports[port_id];
18830 uint64_t port_offloads;
18831 uint64_t queue_offloads;
18832 uint16_t nb_tx_queues;
18836 printf("Tx Offloading Configuration of port %d :\n", port_id);
18838 port_offloads = port->dev_conf.txmode.offloads;
18840 print_tx_offloads(port_offloads);
18843 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18847 nb_tx_queues = dev_info.nb_tx_queues;
18848 for (q = 0; q < nb_tx_queues; q++) {
18849 queue_offloads = port->tx_conf[q].offloads;
18850 printf(" Queue[%2d] :", q);
18851 print_tx_offloads(queue_offloads);
18857 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18858 .f = cmd_tx_offload_get_configuration_parsed,
18860 .help_str = "show port <port_id> tx_offload configuration",
18862 (void *)&cmd_tx_offload_get_configuration_show,
18863 (void *)&cmd_tx_offload_get_configuration_port,
18864 (void *)&cmd_tx_offload_get_configuration_port_id,
18865 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18866 (void *)&cmd_tx_offload_get_configuration_configuration,
18871 /* Enable/Disable a per port offloading */
18872 struct cmd_config_per_port_tx_offload_result {
18873 cmdline_fixed_string_t port;
18874 cmdline_fixed_string_t config;
18876 cmdline_fixed_string_t tx_offload;
18877 cmdline_fixed_string_t offload;
18878 cmdline_fixed_string_t on_off;
18881 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18882 TOKEN_STRING_INITIALIZER
18883 (struct cmd_config_per_port_tx_offload_result,
18885 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18886 TOKEN_STRING_INITIALIZER
18887 (struct cmd_config_per_port_tx_offload_result,
18889 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18890 TOKEN_NUM_INITIALIZER
18891 (struct cmd_config_per_port_tx_offload_result,
18893 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18894 TOKEN_STRING_INITIALIZER
18895 (struct cmd_config_per_port_tx_offload_result,
18896 tx_offload, "tx_offload");
18897 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18898 TOKEN_STRING_INITIALIZER
18899 (struct cmd_config_per_port_tx_offload_result,
18900 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18901 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18902 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18903 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18904 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18905 "send_on_timestamp");
18906 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18907 TOKEN_STRING_INITIALIZER
18908 (struct cmd_config_per_port_tx_offload_result,
18912 search_tx_offload(const char *name)
18914 uint64_t single_offload;
18915 const char *single_name;
18919 single_offload = 1;
18920 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18921 single_name = rte_eth_dev_tx_offload_name(single_offload);
18922 if (single_name == NULL)
18924 if (!strcasecmp(single_name, name)) {
18927 } else if (!strcasecmp(single_name, "UNKNOWN"))
18929 single_offload <<= 1;
18933 return single_offload;
18939 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18940 __rte_unused struct cmdline *cl,
18941 __rte_unused void *data)
18943 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18944 portid_t port_id = res->port_id;
18945 struct rte_eth_dev_info dev_info;
18946 struct rte_port *port = &ports[port_id];
18947 uint64_t single_offload;
18948 uint16_t nb_tx_queues;
18952 if (port->port_status != RTE_PORT_STOPPED) {
18953 printf("Error: Can't config offload when Port %d "
18954 "is not stopped\n", port_id);
18958 single_offload = search_tx_offload(res->offload);
18959 if (single_offload == 0) {
18960 printf("Unknown offload name: %s\n", res->offload);
18964 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18968 nb_tx_queues = dev_info.nb_tx_queues;
18969 if (!strcmp(res->on_off, "on")) {
18970 port->dev_conf.txmode.offloads |= single_offload;
18971 for (q = 0; q < nb_tx_queues; q++)
18972 port->tx_conf[q].offloads |= single_offload;
18974 port->dev_conf.txmode.offloads &= ~single_offload;
18975 for (q = 0; q < nb_tx_queues; q++)
18976 port->tx_conf[q].offloads &= ~single_offload;
18979 cmd_reconfig_device_queue(port_id, 1, 1);
18982 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18983 .f = cmd_config_per_port_tx_offload_parsed,
18985 .help_str = "port config <port_id> tx_offload "
18986 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18987 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18988 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18989 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18990 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18991 "send_on_timestamp on|off",
18993 (void *)&cmd_config_per_port_tx_offload_result_port,
18994 (void *)&cmd_config_per_port_tx_offload_result_config,
18995 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18996 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18997 (void *)&cmd_config_per_port_tx_offload_result_offload,
18998 (void *)&cmd_config_per_port_tx_offload_result_on_off,
19003 /* Enable/Disable a per queue offloading */
19004 struct cmd_config_per_queue_tx_offload_result {
19005 cmdline_fixed_string_t port;
19007 cmdline_fixed_string_t txq;
19009 cmdline_fixed_string_t tx_offload;
19010 cmdline_fixed_string_t offload;
19011 cmdline_fixed_string_t on_off;
19014 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
19015 TOKEN_STRING_INITIALIZER
19016 (struct cmd_config_per_queue_tx_offload_result,
19018 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
19019 TOKEN_NUM_INITIALIZER
19020 (struct cmd_config_per_queue_tx_offload_result,
19022 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
19023 TOKEN_STRING_INITIALIZER
19024 (struct cmd_config_per_queue_tx_offload_result,
19026 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
19027 TOKEN_NUM_INITIALIZER
19028 (struct cmd_config_per_queue_tx_offload_result,
19030 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
19031 TOKEN_STRING_INITIALIZER
19032 (struct cmd_config_per_queue_tx_offload_result,
19033 tx_offload, "tx_offload");
19034 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
19035 TOKEN_STRING_INITIALIZER
19036 (struct cmd_config_per_queue_tx_offload_result,
19037 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
19038 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
19039 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
19040 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
19041 "mt_lockfree#multi_segs#mbuf_fast_free#security");
19042 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
19043 TOKEN_STRING_INITIALIZER
19044 (struct cmd_config_per_queue_tx_offload_result,
19048 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
19049 __rte_unused struct cmdline *cl,
19050 __rte_unused void *data)
19052 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
19053 struct rte_eth_dev_info dev_info;
19054 portid_t port_id = res->port_id;
19055 uint16_t queue_id = res->queue_id;
19056 struct rte_port *port = &ports[port_id];
19057 uint64_t single_offload;
19060 if (port->port_status != RTE_PORT_STOPPED) {
19061 printf("Error: Can't config offload when Port %d "
19062 "is not stopped\n", port_id);
19066 ret = eth_dev_info_get_print_err(port_id, &dev_info);
19070 if (queue_id >= dev_info.nb_tx_queues) {
19071 printf("Error: input queue_id should be 0 ... "
19072 "%d\n", dev_info.nb_tx_queues - 1);
19076 single_offload = search_tx_offload(res->offload);
19077 if (single_offload == 0) {
19078 printf("Unknown offload name: %s\n", res->offload);
19082 if (!strcmp(res->on_off, "on"))
19083 port->tx_conf[queue_id].offloads |= single_offload;
19085 port->tx_conf[queue_id].offloads &= ~single_offload;
19087 cmd_reconfig_device_queue(port_id, 1, 1);
19090 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
19091 .f = cmd_config_per_queue_tx_offload_parsed,
19093 .help_str = "port <port_id> txq <queue_id> tx_offload "
19094 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
19095 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
19096 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
19097 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
19098 "mt_lockfree|multi_segs|mbuf_fast_free|security "
19101 (void *)&cmd_config_per_queue_tx_offload_result_port,
19102 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
19103 (void *)&cmd_config_per_queue_tx_offload_result_txq,
19104 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
19105 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
19106 (void *)&cmd_config_per_queue_tx_offload_result_offload,
19107 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
19112 /* *** configure tx_metadata for specific port *** */
19113 struct cmd_config_tx_metadata_specific_result {
19114 cmdline_fixed_string_t port;
19115 cmdline_fixed_string_t keyword;
19117 cmdline_fixed_string_t item;
19122 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
19123 __rte_unused struct cmdline *cl,
19124 __rte_unused void *data)
19126 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
19128 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19130 ports[res->port_id].tx_metadata = res->value;
19131 /* Add/remove callback to insert valid metadata in every Tx packet. */
19132 if (ports[res->port_id].tx_metadata)
19133 add_tx_md_callback(res->port_id);
19135 remove_tx_md_callback(res->port_id);
19136 rte_flow_dynf_metadata_register();
19139 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
19140 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19142 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
19143 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19144 keyword, "config");
19145 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
19146 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19148 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
19149 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19150 item, "tx_metadata");
19151 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
19152 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19155 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
19156 .f = cmd_config_tx_metadata_specific_parsed,
19158 .help_str = "port config <port_id> tx_metadata <value>",
19160 (void *)&cmd_config_tx_metadata_specific_port,
19161 (void *)&cmd_config_tx_metadata_specific_keyword,
19162 (void *)&cmd_config_tx_metadata_specific_id,
19163 (void *)&cmd_config_tx_metadata_specific_item,
19164 (void *)&cmd_config_tx_metadata_specific_value,
19169 /* *** set dynf *** */
19170 struct cmd_config_tx_dynf_specific_result {
19171 cmdline_fixed_string_t port;
19172 cmdline_fixed_string_t keyword;
19174 cmdline_fixed_string_t item;
19175 cmdline_fixed_string_t name;
19176 cmdline_fixed_string_t value;
19180 cmd_config_dynf_specific_parsed(void *parsed_result,
19181 __rte_unused struct cmdline *cl,
19182 __rte_unused void *data)
19184 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
19185 struct rte_mbuf_dynflag desc_flag;
19187 uint64_t old_port_flags;
19189 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19191 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
19193 if (strlcpy(desc_flag.name, res->name,
19194 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
19195 printf("Flag name too long\n");
19198 desc_flag.flags = 0;
19199 flag = rte_mbuf_dynflag_register(&desc_flag);
19201 printf("Can't register flag\n");
19204 strcpy(dynf_names[flag], desc_flag.name);
19206 old_port_flags = ports[res->port_id].mbuf_dynf;
19207 if (!strcmp(res->value, "set")) {
19208 ports[res->port_id].mbuf_dynf |= 1UL << flag;
19209 if (old_port_flags == 0)
19210 add_tx_dynf_callback(res->port_id);
19212 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
19213 if (ports[res->port_id].mbuf_dynf == 0)
19214 remove_tx_dynf_callback(res->port_id);
19218 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
19219 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19221 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
19222 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19223 keyword, "config");
19224 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
19225 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19227 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
19228 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19230 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
19231 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19233 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
19234 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19235 value, "set#clear");
19237 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19238 .f = cmd_config_dynf_specific_parsed,
19240 .help_str = "port config <port id> dynf <name> set|clear",
19242 (void *)&cmd_config_tx_dynf_specific_port,
19243 (void *)&cmd_config_tx_dynf_specific_keyword,
19244 (void *)&cmd_config_tx_dynf_specific_port_id,
19245 (void *)&cmd_config_tx_dynf_specific_item,
19246 (void *)&cmd_config_tx_dynf_specific_name,
19247 (void *)&cmd_config_tx_dynf_specific_value,
19252 /* *** display tx_metadata per port configuration *** */
19253 struct cmd_show_tx_metadata_result {
19254 cmdline_fixed_string_t cmd_show;
19255 cmdline_fixed_string_t cmd_port;
19256 cmdline_fixed_string_t cmd_keyword;
19261 cmd_show_tx_metadata_parsed(void *parsed_result,
19262 __rte_unused struct cmdline *cl,
19263 __rte_unused void *data)
19265 struct cmd_show_tx_metadata_result *res = parsed_result;
19267 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19268 printf("invalid port id %u\n", res->cmd_pid);
19271 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19272 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19273 ports[res->cmd_pid].tx_metadata);
19277 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19278 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19280 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19281 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19283 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19284 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19286 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19287 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19288 cmd_keyword, "tx_metadata");
19290 cmdline_parse_inst_t cmd_show_tx_metadata = {
19291 .f = cmd_show_tx_metadata_parsed,
19293 .help_str = "show port <port_id> tx_metadata",
19295 (void *)&cmd_show_tx_metadata_show,
19296 (void *)&cmd_show_tx_metadata_port,
19297 (void *)&cmd_show_tx_metadata_pid,
19298 (void *)&cmd_show_tx_metadata_keyword,
19303 /* *** show fec capability per port configuration *** */
19304 struct cmd_show_fec_capability_result {
19305 cmdline_fixed_string_t cmd_show;
19306 cmdline_fixed_string_t cmd_port;
19307 cmdline_fixed_string_t cmd_fec;
19308 cmdline_fixed_string_t cmd_keyword;
19313 cmd_show_fec_capability_parsed(void *parsed_result,
19314 __rte_unused struct cmdline *cl,
19315 __rte_unused void *data)
19317 #define FEC_CAP_NUM 2
19318 struct cmd_show_fec_capability_result *res = parsed_result;
19319 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
19320 unsigned int num = FEC_CAP_NUM;
19321 unsigned int ret_num;
19324 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19325 printf("Invalid port id %u\n", res->cmd_pid);
19329 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
19330 if (ret == -ENOTSUP) {
19331 printf("Function not implemented\n");
19333 } else if (ret < 0) {
19334 printf("Get FEC capability failed\n");
19338 ret_num = (unsigned int)ret;
19339 show_fec_capability(ret_num, speed_fec_capa);
19342 cmdline_parse_token_string_t cmd_show_fec_capability_show =
19343 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19345 cmdline_parse_token_string_t cmd_show_fec_capability_port =
19346 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19348 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
19349 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
19351 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
19352 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19354 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
19355 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19356 cmd_keyword, "capabilities");
19358 cmdline_parse_inst_t cmd_show_capability = {
19359 .f = cmd_show_fec_capability_parsed,
19361 .help_str = "show port <port_id> fec capabilities",
19363 (void *)&cmd_show_fec_capability_show,
19364 (void *)&cmd_show_fec_capability_port,
19365 (void *)&cmd_show_fec_capability_pid,
19366 (void *)&cmd_show_fec_capability_fec,
19367 (void *)&cmd_show_fec_capability_keyword,
19372 /* *** show fec mode per port configuration *** */
19373 struct cmd_show_fec_metadata_result {
19374 cmdline_fixed_string_t cmd_show;
19375 cmdline_fixed_string_t cmd_port;
19376 cmdline_fixed_string_t cmd_keyword;
19381 cmd_show_fec_mode_parsed(void *parsed_result,
19382 __rte_unused struct cmdline *cl,
19383 __rte_unused void *data)
19385 #define FEC_NAME_SIZE 16
19386 struct cmd_show_fec_metadata_result *res = parsed_result;
19388 char buf[FEC_NAME_SIZE];
19391 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19392 printf("Invalid port id %u\n", res->cmd_pid);
19395 ret = rte_eth_fec_get(res->cmd_pid, &mode);
19396 if (ret == -ENOTSUP) {
19397 printf("Function not implemented\n");
19399 } else if (ret < 0) {
19400 printf("Get FEC mode failed\n");
19405 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
19406 strlcpy(buf, "off", sizeof(buf));
19408 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
19409 strlcpy(buf, "auto", sizeof(buf));
19411 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
19412 strlcpy(buf, "baser", sizeof(buf));
19414 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
19415 strlcpy(buf, "rs", sizeof(buf));
19421 printf("%s\n", buf);
19424 cmdline_parse_token_string_t cmd_show_fec_mode_show =
19425 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19427 cmdline_parse_token_string_t cmd_show_fec_mode_port =
19428 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19430 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
19431 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
19433 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
19434 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19435 cmd_keyword, "fec_mode");
19437 cmdline_parse_inst_t cmd_show_fec_mode = {
19438 .f = cmd_show_fec_mode_parsed,
19440 .help_str = "show port <port_id> fec_mode",
19442 (void *)&cmd_show_fec_mode_show,
19443 (void *)&cmd_show_fec_mode_port,
19444 (void *)&cmd_show_fec_mode_pid,
19445 (void *)&cmd_show_fec_mode_keyword,
19450 /* *** set fec mode per port configuration *** */
19451 struct cmd_set_port_fec_mode {
19452 cmdline_fixed_string_t set;
19453 cmdline_fixed_string_t port;
19455 cmdline_fixed_string_t fec_mode;
19456 cmdline_fixed_string_t fec_value;
19459 /* Common CLI fields for set fec mode */
19460 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
19461 TOKEN_STRING_INITIALIZER
19462 (struct cmd_set_port_fec_mode,
19464 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
19465 TOKEN_STRING_INITIALIZER
19466 (struct cmd_set_port_fec_mode,
19468 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
19469 TOKEN_NUM_INITIALIZER
19470 (struct cmd_set_port_fec_mode,
19472 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
19473 TOKEN_STRING_INITIALIZER
19474 (struct cmd_set_port_fec_mode,
19475 fec_mode, "fec_mode");
19476 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
19477 TOKEN_STRING_INITIALIZER
19478 (struct cmd_set_port_fec_mode,
19482 cmd_set_port_fec_mode_parsed(
19483 void *parsed_result,
19484 __rte_unused struct cmdline *cl,
19485 __rte_unused void *data)
19487 struct cmd_set_port_fec_mode *res = parsed_result;
19488 uint16_t port_id = res->port_id;
19492 ret = parse_fec_mode(res->fec_value, &mode);
19494 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
19499 ret = rte_eth_fec_set(port_id, mode);
19500 if (ret == -ENOTSUP) {
19501 printf("Function not implemented\n");
19503 } else if (ret < 0) {
19504 printf("Set FEC mode failed\n");
19509 cmdline_parse_inst_t cmd_set_fec_mode = {
19510 .f = cmd_set_port_fec_mode_parsed,
19512 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
19514 (void *)&cmd_set_port_fec_mode_set,
19515 (void *)&cmd_set_port_fec_mode_port,
19516 (void *)&cmd_set_port_fec_mode_port_id,
19517 (void *)&cmd_set_port_fec_mode_str,
19518 (void *)&cmd_set_port_fec_mode_value,
19523 /* show port supported ptypes */
19525 /* Common result structure for show port ptypes */
19526 struct cmd_show_port_supported_ptypes_result {
19527 cmdline_fixed_string_t show;
19528 cmdline_fixed_string_t port;
19530 cmdline_fixed_string_t ptypes;
19533 /* Common CLI fields for show port ptypes */
19534 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19535 TOKEN_STRING_INITIALIZER
19536 (struct cmd_show_port_supported_ptypes_result,
19538 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19539 TOKEN_STRING_INITIALIZER
19540 (struct cmd_show_port_supported_ptypes_result,
19542 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19543 TOKEN_NUM_INITIALIZER
19544 (struct cmd_show_port_supported_ptypes_result,
19546 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19547 TOKEN_STRING_INITIALIZER
19548 (struct cmd_show_port_supported_ptypes_result,
19552 cmd_show_port_supported_ptypes_parsed(
19553 void *parsed_result,
19554 __rte_unused struct cmdline *cl,
19555 __rte_unused void *data)
19557 #define RSVD_PTYPE_MASK 0xf0000000
19558 #define MAX_PTYPES_PER_LAYER 16
19559 #define LTYPE_NAMESIZE 32
19560 #define PTYPE_NAMESIZE 256
19561 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19562 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19563 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19564 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19565 uint16_t port_id = res->port_id;
19568 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19572 while (ptype_mask != RSVD_PTYPE_MASK) {
19574 switch (ptype_mask) {
19575 case RTE_PTYPE_L2_MASK:
19576 strlcpy(ltype, "L2", sizeof(ltype));
19578 case RTE_PTYPE_L3_MASK:
19579 strlcpy(ltype, "L3", sizeof(ltype));
19581 case RTE_PTYPE_L4_MASK:
19582 strlcpy(ltype, "L4", sizeof(ltype));
19584 case RTE_PTYPE_TUNNEL_MASK:
19585 strlcpy(ltype, "Tunnel", sizeof(ltype));
19587 case RTE_PTYPE_INNER_L2_MASK:
19588 strlcpy(ltype, "Inner L2", sizeof(ltype));
19590 case RTE_PTYPE_INNER_L3_MASK:
19591 strlcpy(ltype, "Inner L3", sizeof(ltype));
19593 case RTE_PTYPE_INNER_L4_MASK:
19594 strlcpy(ltype, "Inner L4", sizeof(ltype));
19600 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19601 ptype_mask, ptypes,
19602 MAX_PTYPES_PER_LAYER);
19605 printf("Supported %s ptypes:\n", ltype);
19607 printf("%s ptypes unsupported\n", ltype);
19609 for (i = 0; i < ret; ++i) {
19610 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19611 printf("%s\n", buf);
19618 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19619 .f = cmd_show_port_supported_ptypes_parsed,
19621 .help_str = "show port <port_id> ptypes",
19623 (void *)&cmd_show_port_supported_ptypes_show,
19624 (void *)&cmd_show_port_supported_ptypes_port,
19625 (void *)&cmd_show_port_supported_ptypes_port_id,
19626 (void *)&cmd_show_port_supported_ptypes_ptypes,
19631 /* *** display rx/tx descriptor status *** */
19632 struct cmd_show_rx_tx_desc_status_result {
19633 cmdline_fixed_string_t cmd_show;
19634 cmdline_fixed_string_t cmd_port;
19635 cmdline_fixed_string_t cmd_keyword;
19636 cmdline_fixed_string_t cmd_desc;
19637 cmdline_fixed_string_t cmd_status;
19644 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19645 __rte_unused struct cmdline *cl,
19646 __rte_unused void *data)
19648 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19651 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19652 printf("invalid port id %u\n", res->cmd_pid);
19656 if (!strcmp(res->cmd_keyword, "rxq")) {
19657 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19660 printf("Invalid queueid = %d\n", res->cmd_qid);
19663 if (rc == RTE_ETH_RX_DESC_AVAIL)
19664 printf("Desc status = AVAILABLE\n");
19665 else if (rc == RTE_ETH_RX_DESC_DONE)
19666 printf("Desc status = DONE\n");
19668 printf("Desc status = UNAVAILABLE\n");
19669 } else if (!strcmp(res->cmd_keyword, "txq")) {
19670 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19673 printf("Invalid queueid = %d\n", res->cmd_qid);
19676 if (rc == RTE_ETH_TX_DESC_FULL)
19677 printf("Desc status = FULL\n");
19678 else if (rc == RTE_ETH_TX_DESC_DONE)
19679 printf("Desc status = DONE\n");
19681 printf("Desc status = UNAVAILABLE\n");
19685 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19686 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19688 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19689 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19691 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19692 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19694 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19695 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19696 cmd_keyword, "rxq#txq");
19697 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19698 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19700 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19701 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19703 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19704 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19706 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19707 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19708 cmd_status, "status");
19709 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19710 .f = cmd_show_rx_tx_desc_status_parsed,
19712 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19715 (void *)&cmd_show_rx_tx_desc_status_show,
19716 (void *)&cmd_show_rx_tx_desc_status_port,
19717 (void *)&cmd_show_rx_tx_desc_status_pid,
19718 (void *)&cmd_show_rx_tx_desc_status_keyword,
19719 (void *)&cmd_show_rx_tx_desc_status_qid,
19720 (void *)&cmd_show_rx_tx_desc_status_desc,
19721 (void *)&cmd_show_rx_tx_desc_status_did,
19722 (void *)&cmd_show_rx_tx_desc_status_status,
19727 /* Common result structure for set port ptypes */
19728 struct cmd_set_port_ptypes_result {
19729 cmdline_fixed_string_t set;
19730 cmdline_fixed_string_t port;
19732 cmdline_fixed_string_t ptype_mask;
19736 /* Common CLI fields for set port ptypes */
19737 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19738 TOKEN_STRING_INITIALIZER
19739 (struct cmd_set_port_ptypes_result,
19741 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19742 TOKEN_STRING_INITIALIZER
19743 (struct cmd_set_port_ptypes_result,
19745 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19746 TOKEN_NUM_INITIALIZER
19747 (struct cmd_set_port_ptypes_result,
19749 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19750 TOKEN_STRING_INITIALIZER
19751 (struct cmd_set_port_ptypes_result,
19752 ptype_mask, "ptype_mask");
19753 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19754 TOKEN_NUM_INITIALIZER
19755 (struct cmd_set_port_ptypes_result,
19759 cmd_set_port_ptypes_parsed(
19760 void *parsed_result,
19761 __rte_unused struct cmdline *cl,
19762 __rte_unused void *data)
19764 struct cmd_set_port_ptypes_result *res = parsed_result;
19765 #define PTYPE_NAMESIZE 256
19766 char ptype_name[PTYPE_NAMESIZE];
19767 uint16_t port_id = res->port_id;
19768 uint32_t ptype_mask = res->mask;
19771 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19774 printf("Port %d doesn't support any ptypes.\n", port_id);
19778 uint32_t ptypes[ret];
19780 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19782 printf("Unable to set requested ptypes for Port %d\n", port_id);
19786 printf("Successfully set following ptypes for Port %d\n", port_id);
19787 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19788 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19789 printf("%s\n", ptype_name);
19792 clear_ptypes = false;
19795 cmdline_parse_inst_t cmd_set_port_ptypes = {
19796 .f = cmd_set_port_ptypes_parsed,
19798 .help_str = "set port <port_id> ptype_mask <mask>",
19800 (void *)&cmd_set_port_ptypes_set,
19801 (void *)&cmd_set_port_ptypes_port,
19802 (void *)&cmd_set_port_ptypes_port_id,
19803 (void *)&cmd_set_port_ptypes_mask_str,
19804 (void *)&cmd_set_port_ptypes_mask_u32,
19809 /* *** display mac addresses added to a port *** */
19810 struct cmd_showport_macs_result {
19811 cmdline_fixed_string_t cmd_show;
19812 cmdline_fixed_string_t cmd_port;
19813 cmdline_fixed_string_t cmd_keyword;
19818 cmd_showport_macs_parsed(void *parsed_result,
19819 __rte_unused struct cmdline *cl,
19820 __rte_unused void *data)
19822 struct cmd_showport_macs_result *res = parsed_result;
19824 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19827 if (!strcmp(res->cmd_keyword, "macs"))
19828 show_macs(res->cmd_pid);
19829 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19830 show_mcast_macs(res->cmd_pid);
19833 cmdline_parse_token_string_t cmd_showport_macs_show =
19834 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19836 cmdline_parse_token_string_t cmd_showport_macs_port =
19837 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19839 cmdline_parse_token_num_t cmd_showport_macs_pid =
19840 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19842 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19843 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19844 cmd_keyword, "macs#mcast_macs");
19846 cmdline_parse_inst_t cmd_showport_macs = {
19847 .f = cmd_showport_macs_parsed,
19849 .help_str = "show port <port_id> macs|mcast_macs",
19851 (void *)&cmd_showport_macs_show,
19852 (void *)&cmd_showport_macs_port,
19853 (void *)&cmd_showport_macs_pid,
19854 (void *)&cmd_showport_macs_keyword,
19859 /* ******************************************************************************** */
19861 /* list of instructions */
19862 cmdline_parse_ctx_t main_ctx[] = {
19863 (cmdline_parse_inst_t *)&cmd_help_brief,
19864 (cmdline_parse_inst_t *)&cmd_help_long,
19865 (cmdline_parse_inst_t *)&cmd_quit,
19866 (cmdline_parse_inst_t *)&cmd_load_from_file,
19867 (cmdline_parse_inst_t *)&cmd_showport,
19868 (cmdline_parse_inst_t *)&cmd_showqueue,
19869 (cmdline_parse_inst_t *)&cmd_showeeprom,
19870 (cmdline_parse_inst_t *)&cmd_showportall,
19871 (cmdline_parse_inst_t *)&cmd_showdevice,
19872 (cmdline_parse_inst_t *)&cmd_showcfg,
19873 (cmdline_parse_inst_t *)&cmd_showfwdall,
19874 (cmdline_parse_inst_t *)&cmd_start,
19875 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19876 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19877 (cmdline_parse_inst_t *)&cmd_set_link_up,
19878 (cmdline_parse_inst_t *)&cmd_set_link_down,
19879 (cmdline_parse_inst_t *)&cmd_reset,
19880 (cmdline_parse_inst_t *)&cmd_set_numbers,
19881 (cmdline_parse_inst_t *)&cmd_set_log,
19882 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
19883 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19884 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19885 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19886 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19887 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19888 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19889 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19890 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19891 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19892 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19893 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19894 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19895 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19896 (cmdline_parse_inst_t *)&cmd_set_link_check,
19897 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19898 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19899 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19900 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19901 #ifdef RTE_LIBRTE_PMD_BOND
19902 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19903 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19904 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19905 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19906 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19907 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19908 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19909 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19910 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19911 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19912 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19914 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19915 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19916 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19917 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19918 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19919 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19920 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19921 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19922 (cmdline_parse_inst_t *)&cmd_csum_set,
19923 (cmdline_parse_inst_t *)&cmd_csum_show,
19924 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19925 (cmdline_parse_inst_t *)&cmd_tso_set,
19926 (cmdline_parse_inst_t *)&cmd_tso_show,
19927 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19928 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19929 (cmdline_parse_inst_t *)&cmd_gro_enable,
19930 (cmdline_parse_inst_t *)&cmd_gro_flush,
19931 (cmdline_parse_inst_t *)&cmd_gro_show,
19932 (cmdline_parse_inst_t *)&cmd_gso_enable,
19933 (cmdline_parse_inst_t *)&cmd_gso_size,
19934 (cmdline_parse_inst_t *)&cmd_gso_show,
19935 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19936 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19937 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19938 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19939 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19940 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19941 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19942 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19943 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19944 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19945 (cmdline_parse_inst_t *)&cmd_config_dcb,
19946 (cmdline_parse_inst_t *)&cmd_read_reg,
19947 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19948 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19949 (cmdline_parse_inst_t *)&cmd_write_reg,
19950 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19951 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19952 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19953 (cmdline_parse_inst_t *)&cmd_stop,
19954 (cmdline_parse_inst_t *)&cmd_mac_addr,
19955 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19956 (cmdline_parse_inst_t *)&cmd_set_qmap,
19957 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19958 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
19959 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
19960 (cmdline_parse_inst_t *)&cmd_operate_port,
19961 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19962 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19963 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19964 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19965 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19966 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19967 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19968 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19969 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19970 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19971 (cmdline_parse_inst_t *)&cmd_config_mtu,
19972 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19973 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19974 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19975 (cmdline_parse_inst_t *)&cmd_config_rss,
19976 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19977 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19978 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19979 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19980 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19981 (cmdline_parse_inst_t *)&cmd_showport_reta,
19982 (cmdline_parse_inst_t *)&cmd_showport_macs,
19983 (cmdline_parse_inst_t *)&cmd_config_burst,
19984 (cmdline_parse_inst_t *)&cmd_config_thresh,
19985 (cmdline_parse_inst_t *)&cmd_config_threshold,
19986 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19987 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19988 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19989 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19990 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19991 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19992 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19993 (cmdline_parse_inst_t *)&cmd_global_config,
19994 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19995 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19996 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19997 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19998 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19999 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
20000 (cmdline_parse_inst_t *)&cmd_dump,
20001 (cmdline_parse_inst_t *)&cmd_dump_one,
20002 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
20003 (cmdline_parse_inst_t *)&cmd_syn_filter,
20004 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
20005 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
20006 (cmdline_parse_inst_t *)&cmd_flex_filter,
20007 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
20008 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
20009 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
20010 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
20011 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
20012 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
20013 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
20014 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
20015 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
20016 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
20017 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
20018 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
20019 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
20020 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
20021 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
20022 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
20023 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
20024 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
20025 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
20026 (cmdline_parse_inst_t *)&cmd_flow,
20027 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
20028 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
20029 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
20030 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
20031 (cmdline_parse_inst_t *)&cmd_create_port_meter,
20032 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
20033 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
20034 (cmdline_parse_inst_t *)&cmd_del_port_meter,
20035 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
20036 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
20037 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
20038 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
20039 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
20040 (cmdline_parse_inst_t *)&cmd_mcast_addr,
20041 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
20042 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
20043 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
20044 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
20045 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
20046 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
20047 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
20048 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
20049 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
20050 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
20051 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
20052 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
20053 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
20054 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
20055 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
20056 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
20057 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
20058 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
20059 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
20060 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
20061 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
20062 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
20063 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
20064 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
20065 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
20066 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
20067 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
20068 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
20069 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
20070 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
20071 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
20072 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
20073 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
20074 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
20075 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
20076 (cmdline_parse_inst_t *)&cmd_set_vxlan,
20077 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
20078 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
20079 (cmdline_parse_inst_t *)&cmd_set_nvgre,
20080 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
20081 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
20082 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
20083 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
20084 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
20085 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
20086 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
20087 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
20088 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
20089 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
20090 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
20091 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
20092 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
20093 (cmdline_parse_inst_t *)&cmd_ddp_add,
20094 (cmdline_parse_inst_t *)&cmd_ddp_del,
20095 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
20096 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
20097 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
20098 (cmdline_parse_inst_t *)&cmd_clear_input_set,
20099 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
20100 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
20101 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
20102 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
20103 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
20104 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
20105 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
20106 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
20108 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
20109 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
20110 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
20111 (cmdline_parse_inst_t *)&cmd_queue_region,
20112 (cmdline_parse_inst_t *)&cmd_region_flowtype,
20113 (cmdline_parse_inst_t *)&cmd_user_priority_region,
20114 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
20115 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
20116 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
20117 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
20118 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
20119 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
20120 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
20121 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
20122 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
20123 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
20124 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
20125 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
20126 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
20127 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
20128 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
20129 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
20130 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
20131 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
20132 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
20133 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
20134 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
20135 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
20136 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
20137 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
20138 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
20139 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
20140 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
20141 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
20142 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
20143 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
20144 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
20145 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
20146 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
20147 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
20148 #ifdef RTE_LIBRTE_BPF
20149 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
20150 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
20152 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
20153 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
20154 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
20155 (cmdline_parse_inst_t *)&cmd_set_raw,
20156 (cmdline_parse_inst_t *)&cmd_show_set_raw,
20157 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
20158 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
20159 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
20160 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
20161 (cmdline_parse_inst_t *)&cmd_show_capability,
20165 /* read cmdline commands from file */
20167 cmdline_read_from_file(const char *filename)
20169 struct cmdline *cl;
20171 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
20173 printf("Failed to create file based cmdline context: %s\n",
20178 cmdline_interact(cl);
20183 printf("Read CLI commands from %s\n", filename);
20186 /* prompt function, called from main on MASTER lcore */
20190 /* initialize non-constant commands */
20191 cmd_set_fwd_mode_init();
20192 cmd_set_fwd_retry_mode_init();
20194 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
20195 if (testpmd_cl == NULL)
20197 cmdline_interact(testpmd_cl);
20198 cmdline_stdin_exit(testpmd_cl);
20204 if (testpmd_cl != NULL)
20205 cmdline_quit(testpmd_cl);
20209 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
20211 if (id == (portid_t)RTE_PORT_ALL) {
20214 RTE_ETH_FOREACH_DEV(pid) {
20215 /* check if need_reconfig has been set to 1 */
20216 if (ports[pid].need_reconfig == 0)
20217 ports[pid].need_reconfig = dev;
20218 /* check if need_reconfig_queues has been set to 1 */
20219 if (ports[pid].need_reconfig_queues == 0)
20220 ports[pid].need_reconfig_queues = queue;
20222 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
20223 /* check if need_reconfig has been set to 1 */
20224 if (ports[id].need_reconfig == 0)
20225 ports[id].need_reconfig = dev;
20226 /* check if need_reconfig_queues has been set to 1 */
20227 if (ports[id].need_reconfig_queues == 0)
20228 ports[id].need_reconfig_queues = queue;